Add symlink absolute to relative conversion
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!