Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symlink absolute to relative conversion #1

Open
awakecoding opened this issue May 2, 2019 · 0 comments
Open

Add symlink absolute to relative conversion #1

awakecoding opened this issue May 2, 2019 · 0 comments

Comments

@awakecoding
Copy link

First, thanks for the awesome tool, I originally looked at undocked.py but the Go implementation looks more elaborate and can be installed with a single executable, which is nice.

I have a small feature request that would make a huge difference: I am working on using docker images to produce sysroots meant for cross-compilation outside of a docker container. The main issue I encounter when using the "raw" docker container contents are absolute symlinks that can point to invalid locations on the build host, while they really should be pointing inside the sysroot directory.

One instance of such a problem I encountered is with libgcc_s.so which can often be a symlink to the real .so, unfortunately often set with an absolute path:

$ file ./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so
./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so: broken symbolic link to /lib/i386-linux-gnu/libgcc_s.so.1
$ rm ./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so
$ ln -s ../../../../../lib/i386-linux-gnu/libgcc_s.so.1 ./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so
$ file ./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so
./usr/lib/gcc/i686-linux-gnu/5/libgcc_s.so: ELF 32-bit LSB shared object Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=50f0704a5c669c096642b2c5b08b4867bbc9303f, stripped

In the above example, the 32-bit ubuntu sysroot has a libgcc_s.so symlink to '/lib/i386-linux-gnu/libgcc_s.so.1', which obviously makes no sense when outside of the container. Replacing the symlink by '../../../../../lib/i386-linux-gnu/libgcc_s.so.1' (relative) fixes the symlink such that it can point to the right location again.

The Dockerfile I used for this example is simple, it's just an ubuntu environment with a few development packages:

FROM i386/ubuntu:16.04
LABEL maintainer "Devolutions Inc."

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y
RUN apt-get install -y \
    libx11-dev \
    libxtst-dev \
    libxcursor-dev \
    libxrandr-dev \
    libgtk-3-dev \
    libglib2.0-dev \
    libappindicator3-dev \
    libnotify-dev \
    libssl-dev

I then built and extracted its contents this way:

docker build . -t ubuntu-16.04-i386-sysroot
undocker extract ubuntu-16.04-i386-sysroot ./sysroot

Let me know if this could be done, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant