2017-08-10 01:23:37 +00:00
|
|
|
FROM frebib/debian-builder as builder
|
2017-05-10 20:55:40 +00:00
|
|
|
|
2017-05-11 21:15:10 +00:00
|
|
|
ARG ARCH=x86_64
|
2017-08-09 18:44:55 +00:00
|
|
|
ARG ARCH_ALT=i686
|
2017-05-10 20:55:40 +00:00
|
|
|
|
2017-08-02 21:02:14 +00:00
|
|
|
ARG GLIBC_VER=2.26
|
|
|
|
ARG BUSYB_VER=1.27.1
|
2017-05-12 00:30:49 +00:00
|
|
|
ARG SU_EXEC_VER=v0.2
|
2017-08-02 21:02:14 +00:00
|
|
|
ARG TINI_VER=v0.15.0
|
2017-05-12 00:30:49 +00:00
|
|
|
|
2017-05-22 16:06:05 +00:00
|
|
|
ARG PREFIX=/output
|
|
|
|
WORKDIR $PREFIX
|
2017-05-11 09:36:22 +00:00
|
|
|
|
2017-05-11 22:37:11 +00:00
|
|
|
#Set up our dependencies, configure the output filesystem a bit
|
2017-08-10 12:38:31 +00:00
|
|
|
RUN mkdir -p bin dev etc home lib proc root sbin tmp usr/bin usr/sbin usr/lib var && \
|
2017-05-22 16:27:07 +00:00
|
|
|
# This is probably only relevant on 64bit systems?
|
2017-08-09 20:16:39 +00:00
|
|
|
ln -sv usr/lib usr/lib64 && \
|
2017-05-22 16:05:55 +00:00
|
|
|
ln -sv lib lib64
|
2017-05-11 22:37:11 +00:00
|
|
|
|
2017-08-09 20:16:39 +00:00
|
|
|
# Pull tini and su-exec utilities
|
2017-08-09 20:39:40 +00:00
|
|
|
RUN curl -fL https://github.com/javabean/su-exec/releases/download/${SU_EXEC_VER}/su-exec.amd64 > sbin/su-exec && \
|
|
|
|
curl -fL https://github.com/krallin/tini/releases/download/${TINI_VER}/tini-amd64 > sbin/tini && \
|
2017-08-09 20:16:39 +00:00
|
|
|
chmod +x sbin/su-exec sbin/tini
|
2017-05-11 23:34:57 +00:00
|
|
|
|
2017-08-09 20:16:39 +00:00
|
|
|
WORKDIR /tmp/glibc
|
2017-05-10 20:55:40 +00:00
|
|
|
|
2017-05-12 10:50:24 +00:00
|
|
|
# Download and build glibc from source
|
2017-08-09 20:39:40 +00:00
|
|
|
RUN curl -fL https://ftp.gnu.org/gnu/glibc/glibc-${GLIBC_VER}.tar.xz | tar xJ && \
|
2017-05-12 10:50:24 +00:00
|
|
|
mkdir -p glibc-build && cd glibc-build && \
|
2017-08-09 20:29:31 +00:00
|
|
|
\
|
2017-05-12 10:50:24 +00:00
|
|
|
echo "slibdir=/lib" >> configparms && \
|
|
|
|
echo "rtlddir=/lib" >> configparms && \
|
|
|
|
echo "sbindir=/bin" >> configparms && \
|
|
|
|
echo "rootsbindir=/bin" >> configparms && \
|
2017-08-09 20:29:31 +00:00
|
|
|
\
|
2017-05-22 16:27:07 +00:00
|
|
|
# Fix debian lib path weirdness
|
2017-08-02 21:30:15 +00:00
|
|
|
rm -rf /usr/include/${ARCH}-linux-gnu/c++ && \
|
|
|
|
ln -s /usr/include/${ARCH}-linux-gnu/* /usr/include && \
|
2017-05-22 16:27:07 +00:00
|
|
|
\
|
2017-08-02 21:28:58 +00:00
|
|
|
../glibc-${GLIBC_VER}/configure \
|
2017-05-12 10:50:24 +00:00
|
|
|
--prefix="$(pwd)/root" \
|
|
|
|
--libdir="$(pwd)/root/lib" \
|
|
|
|
--libexecdir=/lib \
|
|
|
|
--with-headers=/usr/include \
|
|
|
|
--enable-add-ons \
|
|
|
|
--enable-obsolete-rpc \
|
|
|
|
--enable-kernel=3.10.0 \
|
|
|
|
--enable-bind-now \
|
|
|
|
--disable-profile \
|
|
|
|
--enable-stackguard-randomization \
|
|
|
|
--enable-stack-protector=strong \
|
|
|
|
--enable-lock-elision \
|
|
|
|
--enable-multi-arch \
|
|
|
|
--disable-werror && \
|
2017-08-09 20:42:08 +00:00
|
|
|
make -j "$(nproc)" && \
|
|
|
|
make install_root=$(pwd)/out install
|
2017-05-12 10:50:24 +00:00
|
|
|
|
|
|
|
# Copy glibc libs & generate ld cache
|
2017-08-02 21:28:58 +00:00
|
|
|
RUN cp -d glibc-build/out/lib/*.so "${PREFIX}/lib" && \
|
|
|
|
echo '/usr/lib' > "${PREFIX}/etc/ld.so.conf" && \
|
|
|
|
ldconfig -r "${PREFIX}"
|
2017-05-12 10:50:24 +00:00
|
|
|
|
2017-08-09 20:16:39 +00:00
|
|
|
WORKDIR /tmp/busybox
|
|
|
|
|
|
|
|
# Download and build busybox from source
|
2017-08-09 20:39:40 +00:00
|
|
|
RUN curl -fL https://busybox.net/downloads/busybox-${BUSYB_VER}.tar.bz2 \
|
2017-08-09 20:29:31 +00:00
|
|
|
| tar xj --strip-components=1 && \
|
|
|
|
# Use default configuration
|
|
|
|
make defconfig && \
|
2017-08-09 20:42:08 +00:00
|
|
|
make -j "$(nproc)" && \
|
2017-08-09 20:29:31 +00:00
|
|
|
cp busybox "${PREFIX}/bin" && \
|
2017-08-09 20:16:39 +00:00
|
|
|
# "Install" busybox, creating symlinks to all binaries it provides
|
2017-08-09 20:42:28 +00:00
|
|
|
./busybox --list-full | xargs -i ln -s /bin/busybox "${PREFIX}/{}"
|
2017-08-09 20:16:39 +00:00
|
|
|
|
2017-05-22 17:09:32 +00:00
|
|
|
WORKDIR $PREFIX
|
|
|
|
|
2017-08-09 13:06:52 +00:00
|
|
|
# Add default skeleton configuration files
|
|
|
|
RUN for f in passwd shadow group profile; do \
|
2017-08-09 20:39:40 +00:00
|
|
|
curl -fL -o "${PREFIX}/etc/$f" "https://git.busybox.net/buildroot/plain/system/skeleton/etc/$f"; \
|
2017-08-09 20:29:31 +00:00
|
|
|
done && \
|
|
|
|
\
|
|
|
|
# Copy UTC localtime to output
|
|
|
|
cp /usr/share/zoneinfo/Etc/UTC etc/
|
2017-05-22 17:09:32 +00:00
|
|
|
|
2017-05-11 21:15:10 +00:00
|
|
|
# =============
|
|
|
|
|
|
|
|
FROM scratch
|
2017-05-10 20:55:40 +00:00
|
|
|
WORKDIR /
|
2017-08-09 13:06:52 +00:00
|
|
|
|
2017-05-11 23:34:57 +00:00
|
|
|
COPY --from=builder /output/ /
|
2017-08-09 13:06:52 +00:00
|
|
|
RUN mkdir -p /tmp && \
|
2017-08-09 20:29:31 +00:00
|
|
|
chmod 1777 /tmp
|
2017-08-09 13:06:52 +00:00
|
|
|
|
2017-08-09 13:21:09 +00:00
|
|
|
CMD ["/bin/sh"]
|