heredocify stage2
This commit is contained in:
parent
8346d12f62
commit
b94c1e5253
|
@ -61,19 +61,22 @@ ADD --checksum=sha256:${MPC_HASH} ${MPC_SITE} .
|
|||
ADD --checksum=sha256:${ISL_HASH} ${ISL_SITE} .
|
||||
|
||||
FROM fetch as build
|
||||
COPY --from=stage2 . /
|
||||
RUN set -eux; \
|
||||
tar -xf ${LINUX_FILE}; \
|
||||
tar -xzf ${MUSL_FILE}; \
|
||||
tar -xf ${BINUTILS_FILE}; \
|
||||
tar -xf ${GCC_FILE}; \
|
||||
cd gcc-${GCC_VERSION}; \
|
||||
COPY --from=stage1 . /
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
tar -xf ${LINUX_FILE}
|
||||
tar -xzf ${MUSL_FILE}
|
||||
tar -xf ${BINUTILS_FILE}
|
||||
tar -xf ${GCC_FILE}
|
||||
cd gcc-${GCC_VERSION}
|
||||
mv ../*.tar.* .; \
|
||||
./contrib/download_prerequisites
|
||||
EOF
|
||||
|
||||
# Phase 1: Build cross binutils in build-binutils
|
||||
WORKDIR ${BINUTILS_DIR}
|
||||
RUN set -eux; \
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
../binutils-${BINUTILS_VERSION}/configure \
|
||||
--build=${BUILD} \
|
||||
--host=${HOST} \
|
||||
|
@ -88,20 +91,24 @@ RUN set -eux; \
|
|||
--enable-64-bit-bfd \
|
||||
--enable-ld=default \
|
||||
--enable-install-libiberty \
|
||||
--enable-deterministic-archives; \
|
||||
--enable-deterministic-archives
|
||||
make all
|
||||
EOF
|
||||
|
||||
# Phase 2: Prepare build sysroot
|
||||
WORKDIR ${SYSROOT_DIR}
|
||||
RUN set -eux; \
|
||||
mkdir -p include; \
|
||||
ln -sf . usr; \
|
||||
ln -sf lib lib32; \
|
||||
RUN <<-EOF
|
||||
set -eux
|
||||
mkdir -p include
|
||||
ln -sf . usr
|
||||
ln -sf lib lib32
|
||||
ln -sf lib lib64
|
||||
EOF
|
||||
|
||||
# Phase 3: Build gcc (without libgcc) in build-gcc
|
||||
WORKDIR ${GCC_DIR}
|
||||
RUN set -eux; \
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
../gcc-${GCC_VERSION}/configure \
|
||||
--build=${BUILD} \
|
||||
--host=${HOST} \
|
||||
|
@ -131,30 +138,35 @@ RUN set -eux; \
|
|||
OBJDUMP_FOR_TARGET=${BINUTILS_DIR}/binutils/objdump \
|
||||
RANLIB_FOR_TARGET=${BINUTILS_DIR}/binutils/ranlib \
|
||||
READELF_FOR_TARGET=${BINUTILS_DIR}/binutils/readelf \
|
||||
STRIP_FOR_TARGET=${BINUTILS_DIR}/binutils/strip-new; \
|
||||
STRIP_FOR_TARGET=${BINUTILS_DIR}/binutils/strip-new
|
||||
make all-gcc
|
||||
EOF
|
||||
|
||||
# Phase 4: Install musl libc headers to build-sysroot for use by libgcc
|
||||
WORKDIR ${MUSL_DIR}
|
||||
RUN set -eux; \
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
../musl-${MUSL_VERSION}/configure \
|
||||
CC="${GCC_DIR}/gcc/xgcc -B ${GCC_DIR}/gcc" \
|
||||
LIBCC="${GCC_DIR}/${TARGET}/libgcc/libgcc.a" \
|
||||
--prefix= \
|
||||
--host=${TARGET}; \
|
||||
--host=${TARGET}
|
||||
make DESTDIR=${SYSROOT_DIR} install-headers
|
||||
EOF
|
||||
|
||||
# Phase 5: Compile libgcc
|
||||
WORKDIR ${GCC_DIR}
|
||||
RUN make MAKE="make enable_shared=no" all-target-libgcc
|
||||
RUN --network=none make MAKE="make enable_shared=no" all-target-libgcc
|
||||
|
||||
# Phase 5: Compile musl libc and install to sysroot
|
||||
WORKDIR ${MUSL_DIR}
|
||||
RUN set -eux; \
|
||||
RUN --network=none <<-EOF
|
||||
set -eux
|
||||
make \
|
||||
AR=${BINUTILS_DIR}/binutils/ar \
|
||||
RANLIB=${BINUTILS_DIR}/binutils/ranlib; \
|
||||
RANLIB=${BINUTILS_DIR}/binutils/ranlib
|
||||
make DESTDIR=${SYSROOT_DIR} install
|
||||
EOF
|
||||
|
||||
# Phase 6: Compile remaining gcc targets
|
||||
WORKDIR ${GCC_DIR}
|
||||
|
@ -162,27 +174,30 @@ RUN make all
|
|||
|
||||
# Phase 7: Generate linux headers
|
||||
WORKDIR ${HOME}/linux-${LINUX_VERSION}
|
||||
RUN set -eux; \
|
||||
make ARCH=${TARGET_ARCH} headers; \
|
||||
find usr/include -name '.*' -delete; \
|
||||
rm usr/include/Makefile; \
|
||||
rm usr/include/headers_check.pl; \
|
||||
RUN --network=none
|
||||
set -eux
|
||||
make ARCH=${TARGET_ARCH} headers
|
||||
find usr/include -name '.*' -delete
|
||||
rm usr/include/Makefile
|
||||
rm usr/include/headers_check.pl
|
||||
cp -rv usr/include ${LINUX_DIR}
|
||||
EOF
|
||||
|
||||
FROM build as install
|
||||
WORKDIR ${HOME}
|
||||
USER 0:0
|
||||
COPY --from=stage1 . /rootfs/
|
||||
RUN set -eux; \
|
||||
rm /rootfs/lib; \
|
||||
env -C build-musl make DESTDIR=/rootfs/${TARGET} install; \
|
||||
env -C build-gcc make DESTDIR=/rootfs/ install; \
|
||||
env -C build-binutils make DESTDIR=/rootfs/ install; \
|
||||
cp -Rv ${LINUX_DIR}/* /rootfs/${TARGET}/include; \
|
||||
ln -s /usr/lib/ld-musl-${HOST_ARCH}.so.1 /rootfs/lib/libc.so; \
|
||||
ln -s /usr/lib/ld-musl-${HOST_ARCH}.so.1 /rootfs/lib/ld-musl-${HOST_ARCH}.so.1; \
|
||||
ln -s /${TARGET}/lib/ld-musl-${TARGET_ARCH}.so.1 /rootfs/lib/ld-musl-${TARGET_ARCH}.so.1; \
|
||||
RUN <<-EOF
|
||||
set -eux
|
||||
rm /rootfs/lib
|
||||
env -C build-musl make DESTDIR=/rootfs/${TARGET} install
|
||||
env -C build-gcc make DESTDIR=/rootfs/ install
|
||||
env -C build-binutils make DESTDIR=/rootfs/ install
|
||||
cp -Rv ${LINUX_DIR}/* /rootfs/${TARGET}/include
|
||||
ln -s /usr/lib/ld-musl-${HOST_ARCH}.so.1 /rootfs/lib/libc.so
|
||||
ln -s /usr/lib/ld-musl-${HOST_ARCH}.so.1 /rootfs/lib/ld-musl-${HOST_ARCH}.so.1
|
||||
ln -s /${TARGET}/lib/ld-musl-${TARGET_ARCH}.so.1 /rootfs/lib/ld-musl-${TARGET_ARCH}.so.1
|
||||
find /rootfs -exec touch -hcd "@0" "{}" +
|
||||
EOF
|
||||
|
||||
FROM base as package
|
||||
COPY --from=install /rootfs/ /
|
||||
|
|
Reference in New Issue