diff --git a/contrib/rootfs-builder/Makefile b/contrib/rootfs-builder/Makefile index ca8042a91..9af382ba1 100644 --- a/contrib/rootfs-builder/Makefile +++ b/contrib/rootfs-builder/Makefile @@ -6,27 +6,27 @@ rootfs-%.tar.gz: rootfs/%/bin/echo tar -czf $@ -C rootfs/$* . .PRECIOUS: rootfs/%/bin/busybox -rootfs/%/bin/busybox: downloads/stage3-%-current.tar.bz2 rootfs-files +rootfs/%/bin/busybox: downloads/stage3-%-current.tar rootfs-files gpg --verify $<.DIGESTS.asc (cd downloads && \ - grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.bz2.DIGESTS.asc | \ + grep -A1 '^# SHA512 HASH' stage3-$*-current.tar.DIGESTS.asc | \ grep -v '^--' | \ sha512sum -c) sudo rm -rf rootfs/$* sudo mkdir -p rootfs/$* - sudo tar -xvf downloads/stage3-$*-current.tar.bz2 -C rootfs/$* \ + sudo tar -xvf downloads/stage3-$*-current.tar -C rootfs/$* \ --no-recursion --wildcards $$(< rootfs-files) sudo touch $@ .PRECIOUS: rootfs/%/bin/echo rootfs/%/bin/echo: rootfs/%/bin/busybox - sudo sh -c 'COMMANDS=$$($< --list) || exit 1; for COMMAND in $${COMMANDS}; do \ + sudo sh -c 'COMMANDS=$$($< --list | grep -v "^busybox$$") || exit 1; for COMMAND in $${COMMANDS}; do \ test -L "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" || exit; \ done' -downloads/stage3-%-current.tar.bz2: get-stage3.sh +downloads/stage3-%-current.tar: get-stage3.sh STAGE3_ARCH=$* ./$< - touch downloads/stage3-$*-*.tar.bz2 + touch downloads/stage3-$*-*.tar clean: rm -f downloads/* diff --git a/contrib/rootfs-builder/get-stage3.sh b/contrib/rootfs-builder/get-stage3.sh index 6828f0171..e6f558d6e 100755 --- a/contrib/rootfs-builder/get-stage3.sh +++ b/contrib/rootfs-builder/get-stage3.sh @@ -2,7 +2,7 @@ # # Download the current Gentoo stage3 # -# Copyright (C) 2014-2015 W. Trevor King +# Copyright (C) 2014-2018 W. Trevor King # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,8 +16,36 @@ # See the License for the specific language governing permissions and # limitations under the License. +die() +{ + echo "$1" + exit 1 +} + MIRROR="${MIRROR:-http://distfiles.gentoo.org/}" -STAGE3_ARCH="${STAGE3_ARCH:-amd64}" +if test -n "${STAGE3}" +then + if test -n "${STAGE3_ARCH}" + then + die 'if you set STAGE3, you do not need to set STAGE3_ARCH' + fi + if test -n "${DATE}" + then + die 'if you set STAGE3, you do not need to set DATE' + fi + STAGE3_ARCH=$(echo "${STAGE3}" | sed -n 's/stage3-\([^-]*\)-.*/\1/p') + if test -z "${STAGE3_ARCH}" + then + die "could not calculate STAGE3_ARCH from ${STAGE3}" + fi + DATE=$(echo "${STAGE3}" | sed -n "s/stage3-${STAGE3_ARCH}-\([0-9TZ]*\)[.]tar[.].*/\1/p") + if test -z "${DATE}" + then + die "could not calculate DATE from ${STAGE3}" + fi +else + STAGE3_ARCH="${STAGE3_ARCH:-amd64}" +fi if test -z "${BASE_ARCH}" then @@ -38,19 +66,35 @@ then fi BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/${BASE_ARCH}/autobuilds/}" -LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt") -DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar[.]bz2.*||p") + +if test -z "${STAGE3}" +then + LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt") + if test -z "${DATE}" + then + DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9TZ]*[.]tar.*||p") + if test -z "${DATE}" + then + die "could not calculate DATE from ${BASE_ARCH_URL}latest-stage3.txt" + fi + fi + + STAGE3=$(echo "${LATEST}" | sed -n "s|${DATE}/\(stage3-${STAGE3_ARCH}-${DATE}[.]tar[.][^ ]*\) .*|\1|p") + if test -z "${STAGE3}" + then + die "could not calculate STAGE3 from ${BASE_ARCH_URL}latest-stage3.txt" + fi +fi + ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}" -STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}" STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}" STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}" -die() -{ - echo "$1" - exit 1 -} - +COMPRESSION=$(echo "${STAGE3}" | sed -n 's/^.*[.]\([^.]*\)$/\1/p') +if test -z "${COMPRESSION}" +then + die "could not calculate COMPRESSION from ${STAGE3}" +fi for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do if [ ! -f "downloads/${FILE}" ]; then wget -O "downloads/${FILE}" "${ARCH_URL}${FILE}" @@ -60,7 +104,11 @@ for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do fi fi - CURRENT=$(echo "${FILE}" | sed "s/${DATE}/current/") + FILE_NOCOMPRESSION=$(echo "${FILE}" | sed "s/[.]${COMPRESSION}//") + if [ "${FILE_NOCOMPRESSION}" = "${FILE}" ]; then + die "unable to remove .${COMPRESSION} from ${FILE}" + fi + CURRENT=$(echo "${FILE_NOCOMPRESSION}" | sed "s/${DATE}/current/") ( cd downloads && rm -f "${CURRENT}" && @@ -68,4 +116,3 @@ for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do die "failed to link ${CURRENT} -> ${FILE}" ) done - diff --git a/contrib/rootfs-builder/rootfs-files b/contrib/rootfs-builder/rootfs-files index 319a0f5f1..ac932eaf1 100644 --- a/contrib/rootfs-builder/rootfs-files +++ b/contrib/rootfs-builder/rootfs-files @@ -1,3 +1,6 @@ ./bin/busybox +./dev ./etc/group ./etc/passwd +./proc +./sys diff --git a/rootfs-386.tar.gz b/rootfs-386.tar.gz index 9e52effef..0e26e604c 100644 Binary files a/rootfs-386.tar.gz and b/rootfs-386.tar.gz differ diff --git a/rootfs-amd64.tar.gz b/rootfs-amd64.tar.gz index b440ce56e..d0f5fa515 100644 Binary files a/rootfs-amd64.tar.gz and b/rootfs-amd64.tar.gz differ