pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

commit f91b3641b7f8535dc0801d07790e8ff6adc05c67
parent 64a18b0c09e69d64c5e855d8a80cdf9386a3a784
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Sun, 11 Jun 2023 21:32:07 +0200

Second stage busybox builds

Diffstat:
Mcommand/pthbs-build | 41+++++++++++++++++++++++++++++++++--------
Mcommand/pthbs-download | 6++----
Mcommand/pthbs-install | 9++++++++-
Mcommand/pthbs-makegen | 3++-
Mcommand/pthbs-makegen-downloads | 3++-
Mdownloadlist.sha256 | 5+++++
Mpackages/busybox | 13++++---------
Mpackages/busybox:bootstrap | 5++---
Mpackages/default.environment | 4++--
Mtemplates/pkg/busybox | 11+++--------
Mtemplates/pkg/busybox:bootstrap | 7+++----
Mtemplates/pkg/gnu-make:bootstrap | 4++--
12 files changed, 68 insertions(+), 43 deletions(-)

diff --git a/command/pthbs-build b/command/pthbs-build @@ -9,11 +9,18 @@ script=$(realpath "$1") pthbs_package=${1##*/} pthbs_package=${pthbs_package%%:*}.$bsh +if test -f "make/package.sha256.${bsh}.env"; then + envfile="make/package.sha256.${bsh}.env" + envhash=$(pthbs-getenvhash "$envfile") || exit $? + envdir=$HOME/versions/env.$envhash +fi + mkdir -p "$workdir" env \ basedir="$basedir" \ workdir="$workdir" \ script="$script" \ + envdir="$envdir" \ awk -v single_quote="'" >"$workdir/pthbs-setup" ' BEGIN { sandbox = 1 @@ -28,7 +35,7 @@ function q(s) { # quote string for sh } function fatal(msg) { - printf "FATAL: %s %s:%d: \"%s\"\n", msg, FILENAME, FNR, $0 >"/dev/stderr" + printf "FATAL: pthbs-build: %s %s:%d: \"%s\"\n", msg, FILENAME, FNR, $0 >"/dev/stderr" exit 1 } @@ -49,10 +56,10 @@ function at_filehash(hash_type, file_hash, dst){ /^#\+/ { if($0 == "#+*") { sandbox = 0 - next - } else { - fatal("dependencies not implemented yet:") + } else if(!length(ENVIRON["envdir"])) { + fatal("dependency specified but no envfile:") } + next } /^#@/ { if($1 == "#@git") { @@ -76,7 +83,17 @@ function at_filehash(hash_type, file_hash, dst){ next } /^$/ { - print "exec sh -xe "q(ENVIRON["script"]) + if(sandbox) { + fatal("Sandboxing not supported yet") + } + if(length(ENVIRON["envdir"])){ + printf "exec env" + printf " %s", "pthbs_build_environment="q(ENVIRON["envdir"]) + printf " %s", "PATH="q(ENVIRON["envdir"]"/command") + print " "q(ENVIRON["envdir"]"/command/sh")" -xe "q(ENVIRON["script"]) + } else { + print "exec sh -xe "q(ENVIRON["script"]) + } exit 0 } { @@ -93,6 +110,7 @@ if test -z "$JOBS"; then fi fi +ret=0 if env -i \ PATH="$PATH" \ JOBS="$JOBS" \ @@ -101,8 +119,15 @@ if env -i \ pthbs_package="$pthbs_package" \ sh -xe "$workdir/pthbs-setup" </dev/null; then echo "BUILD SUCCESFUL" - pthbs-install "$workdir/destdir" "$pthbs_package" || echo "INSTALL FAILED: exitcode $$" + if ! pthbs-install "$workdir/destdir" "$pthbs_package"; then + ret=1 + echo "INSTALL FAILED" + fi else - echo "BUILD FAILED: exitcode $$" + ret=$? + echo "BUILD FAILED: exitcode $ret" +fi +if test -z "$pthbs_skip_cleanup"; then + rm -rf "$workdir" || ret=$? fi -rm -rf "$workdir" +exit $ret diff --git a/command/pthbs-download b/command/pthbs-download @@ -1,8 +1,4 @@ #!/bin/sh -echo >&2 "$0 not implemented yet" -set -x -: "$@" - test $# -gt 3 || exit 2 checksum_format=$1 checksum=$2 @@ -36,6 +32,8 @@ check() { exit 1 } +set -x + mkdir -p "downloads/$checksum_format" || exit $? if check; then diff --git a/command/pthbs-install b/command/pthbs-install @@ -9,10 +9,17 @@ pthbs_package="$2" if ! test -f "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.install-links"; then echo >&2 "ERROR: link file not found" - exit 2 + exit 1 fi +pthbs-digest-tree >"$pthbs_destdir/pthbs-digest" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/" || exit $? +mv "$pthbs_destdir/pthbs-digest" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.pthbs-digest" || exit $? + if test -e "$pthbs_versions/$pthbs_package"; then + if ! diff -u "$pthbs_versions/$pthbs_package" "$pthbs_destdir/${pthbs_versions%/}/$pthbs_package/.pthbs-digest"; then + echo >&2 "ERROR: digest file mismatch - packages with same buildhash differ" + exit 3 + fi N=1 while test -e "$pthbs_versions/$pthbs_package.$N"; do N=$(1+$N) diff --git a/command/pthbs-makegen b/command/pthbs-makegen @@ -80,6 +80,7 @@ function make_envfile( n, envfile, envhash) { for(n=1; n<=env_count; n++) { printf " %s", envdep[n] } + printf "\n\t%s", "if test -e "q("$(VERSIONS)/env."envhash)"; then rm -r "q("$(VERSIONS)/env."envhash)"; fi" printf "\n\t%s", "mkdir -p "q("$(VERSIONS)/env."envhash) for(n=1; n<=env_count; n++) { printf "\n\t%s", "pthbs-link "q("$(VERSIONS)/"env[n])" "q("$(VERSIONS)/env."envhash) @@ -136,7 +137,7 @@ END{ } env_installdir = "$(VERSIONS)/env." make_envfile() printf "%s: %s %s\n", ENVIRON["scriptname"], env_installdir"/.pthbs-env", "namedenv/.exists" - printf "\t%s\n\n", "busybox -sTf "q(env_installdir)" "q("namedenv/"envname) + printf "\t%s\n\n", "busybox ln -sTf "q(env_installdir)" "q("namedenv/"envname) printf ".PHONY: %s\n", ENVIRON["scriptname"] } ' "$script" diff --git a/command/pthbs-makegen-downloads b/command/pthbs-makegen-downloads @@ -13,6 +13,7 @@ function fatal(msg) { } /^$/ { next } +/^#/ { next } /^[0-9a-f]{64} [0-9]+ /{ printf "%s:\n", "make/file."format"."$1".downloaded" @@ -20,7 +21,7 @@ function fatal(msg) { for(n=1; n<=NF; n++){ printf " %s", q($n) } - printf "\n\n" + printf "\n\t%s\n\n", "touch "q("$@") next } diff --git a/downloadlist.sha256 b/downloadlist.sha256 @@ -1,2 +1,7 @@ dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3 2348200 https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz 8d284d896fca1c981b55850e92acd3ad9648a69227c028dda7ae3402af878edd 1125800 https://github.com/libcgroup/libcgroup/releases/download/v3.0/libcgroup-3.0.0.tar.gz +ab66fc2d1c3ec0359b8e08843c9f33b63e8707efdff5e4cc5c200eae24722cbf 21490848 https://ftpmirror.gnu.org/gnu/binutils/binutils-2.33.1.tar.xz +c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e 72411232 https://ftpmirror.gnu.org/gnu/gcc/gcc-9.4.0/gcc-9.4.0.tar.xz +75d5d255a2a273b6e651f82eecfabf6cbcd8eaeae70e86b417384c8f4a58d8d3 36159 http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=3d5db9ebe860 + +# 995bc76ccf0c40d752b5ea67c022232a17eef6c9ec80ea74ea742e3c19992813 1078912 linux-headers-4.19.88-1.tar.xz diff --git a/packages/busybox b/packages/busybox @@ -2,23 +2,18 @@ #+* #+musl-cross-make.82eddae52f39e802227bbec1e7641684bee0527d489786471dc183439a9b894f #+gnu-make.9e49ba21cb717e439f08ea97fbca88beb48e58d8a3e974ffcd633a5f73b338c5 -#+busybox.6d6253b047166a043210efc6fc25699c90bdbb0563dbd8ab0ca3153a01a6f3f6 +#+busybox.c16d531b39dd7b221a2cde667a82657170b29d61e215ff92d36859d302533e24 #@git:aa4d303a3139107919f73cece4eaf85a7dc75db6:busybox #@sha256:e653a2f29743ec8f96d68f62c4db7c76db5ff769ec9e7cd6671397c7cc2b942f:busybox/.config : ${JOBS:=1} -mcm=/home/ccx/versions/musl-cross-make.82eddae52f39e802227bbec1e7641684bee0527d489786471dc183439a9b894f -make=/home/ccx/versions/gnu-make.9e49ba21cb717e439f08ea97fbca88beb48e58d8a3e974ffcd633a5f73b338c5 -bb=/home/ccx/versions/busybox.6d6253b047166a043210efc6fc25699c90bdbb0563dbd8ab0ca3153a01a6f3f6 -export PATH="$bb/bin:$mcm/bin:$make/bin" -export CC="$mcm/bin/x86_64-linux-musl-gcc" -export CXX="$mcm/bin/x86_64-linux-musl-g++" +export CC="$pthbs_build_environment/command/x86_64-linux-musl-gcc" export CFLAGS="-D_GNU_SOURCE" export LDFLAGS="-static" cd busybox -$make/bin/make V=1 LDFLAGS=-static HOSTLDFLAGS=-static \ +make V=1 CROSS_COMPILE=x86_64-linux-musl- LDFLAGS=-static HOSTLDFLAGS=-static \ HOSTCC="$CC -static" CC="$CC -static" HOSTCFLAGS=-D_GNU_SOURCE -j$JOBS mkdir -p "$pthbs_destdir/home/ccx/versions/$pthbs_package/command" @@ -26,7 +21,7 @@ cp -a busybox "$pthbs_destdir/home/ccx/versions/$pthbs_package/command/" cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" echo false | ./command/busybox --list >/dev/null # test if it works ./command/busybox --list | awk ' -{ print "./command/busybox\t./command/busybox" $0 } +{ print "./command/busybox\t./command/" $0 } END { print "./command/busybox\t./command/busybox" } ' >.install-links.new mv .install-links.new .install-links diff --git a/packages/busybox:bootstrap b/packages/busybox:bootstrap @@ -9,12 +9,11 @@ make=/home/ccx/versions/gnu-make.9e49ba21cb717e439f08ea97fbca88beb48e58d8a3e974f export PATH="$mcm/bin:$make/bin:$PATH" export CC="$mcm/bin/x86_64-linux-musl-gcc" -export CXX="$mcm/bin/x86_64-linux-musl-g++" export CFLAGS="-D_GNU_SOURCE" export LDFLAGS="-static" cd busybox -$make/bin/make V=1 LDFLAGS=-static HOSTLDFLAGS=-static \ +$make/bin/make V=1 CROSS_COMPILE=x86_64-linux-musl- LDFLAGS=-static HOSTLDFLAGS=-static \ HOSTCC="$CC -static" CC="$CC -static" HOSTCFLAGS=-D_GNU_SOURCE -j$JOBS mkdir -p "$pthbs_destdir/home/ccx/versions/$pthbs_package/command" @@ -22,7 +21,7 @@ cp -a busybox "$pthbs_destdir/home/ccx/versions/$pthbs_package/command/" cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" echo false | ./command/busybox --list >/dev/null # test if it works ./command/busybox --list | awk ' -{ print "./command/busybox\t./command/busybox" $0 } +{ print "./command/busybox\t./command/" $0 } END { print "./command/busybox\t./command/busybox" } ' >.install-links.new mv .install-links.new .install-links diff --git a/packages/default.environment b/packages/default.environment @@ -1 +1 @@ -#+busybox.adf5048c38bc2bca753b6949eb1e9effcd803fa1138f11a209fc891fb153cc80- \ No newline at end of file +#+busybox.63495dcc0263b847d3c17f49888290a870ca9eaba5a76754407f5c6a1cd66514+ \ No newline at end of file diff --git a/templates/pkg/busybox b/templates/pkg/busybox @@ -8,18 +8,13 @@ #@sha256:e653a2f29743ec8f96d68f62c4db7c76db5ff769ec9e7cd6671397c7cc2b942f:busybox/.config : ${JOBS:=1} -mcm={{pkg_install_dir("musl-cross-make:bootstrap")}} -make={{pkg_install_dir("gnu-make:bootstrap")}} -bb={{pkg_install_dir("busybox:bootstrap")}} -export PATH="$bb/bin:$mcm/bin:$make/bin" -export CC="$mcm/bin/x86_64-linux-musl-gcc" -export CXX="$mcm/bin/x86_64-linux-musl-g++" +export CC="$pthbs_build_environment/command/{{triplet}}-gcc" export CFLAGS="-D_GNU_SOURCE" export LDFLAGS="-static" cd busybox -$make/bin/make V=1 LDFLAGS=-static HOSTLDFLAGS=-static \ +make V=1 CROSS_COMPILE={{triplet}}- LDFLAGS=-static HOSTLDFLAGS=-static \ HOSTCC="$CC -static" CC="$CC -static" HOSTCFLAGS=-D_GNU_SOURCE -j$JOBS mkdir -p "$pthbs_destdir{{versions}}/$pthbs_package/command" @@ -27,7 +22,7 @@ cp -a busybox "$pthbs_destdir{{versions}}/$pthbs_package/command/" cd "$pthbs_destdir{{versions}}/$pthbs_package" echo false | ./command/busybox --list >/dev/null # test if it works ./command/busybox --list | awk ' -{ print "./command/busybox\t./command/busybox" $0 } +{ print "./command/busybox\t./command/" $0 } END { print "./command/busybox\t./command/busybox" } ' >.install-links.new mv .install-links.new .install-links diff --git a/templates/pkg/busybox:bootstrap b/templates/pkg/busybox:bootstrap @@ -9,13 +9,12 @@ mcm={{pkg_install_dir("musl-cross-make:bootstrap")}} make={{pkg_install_dir("gnu-make:bootstrap")}} export PATH="$mcm/bin:$make/bin:$PATH" -export CC="$mcm/bin/x86_64-linux-musl-gcc" -export CXX="$mcm/bin/x86_64-linux-musl-g++" +export CC="$mcm/bin/{{triplet}}-gcc" export CFLAGS="-D_GNU_SOURCE" export LDFLAGS="-static" cd busybox -$make/bin/make V=1 LDFLAGS=-static HOSTLDFLAGS=-static \ +$make/bin/make V=1 CROSS_COMPILE={{triplet}}- LDFLAGS=-static HOSTLDFLAGS=-static \ HOSTCC="$CC -static" CC="$CC -static" HOSTCFLAGS=-D_GNU_SOURCE -j$JOBS mkdir -p "$pthbs_destdir{{versions}}/$pthbs_package/command" @@ -23,7 +22,7 @@ cp -a busybox "$pthbs_destdir{{versions}}/$pthbs_package/command/" cd "$pthbs_destdir{{versions}}/$pthbs_package" echo false | ./command/busybox --list >/dev/null # test if it works ./command/busybox --list | awk ' -{ print "./command/busybox\t./command/busybox" $0 } +{ print "./command/busybox\t./command/" $0 } END { print "./command/busybox\t./command/busybox" } ' >.install-links.new mv .install-links.new .install-links diff --git a/templates/pkg/gnu-make:bootstrap b/templates/pkg/gnu-make:bootstrap @@ -8,8 +8,8 @@ pthbs_versions=/home/ccx/versions mcm={{versions}}/musl-cross-make.{{pkg_sha256("musl-cross-make:bootstrap")}} export PATH="$mcm/bin:$PATH" -export CC="$mcm/bin/x86_64-linux-musl-gcc" -export CXX="$mcm/bin/x86_64-linux-musl-g++" +export CC="$mcm/bin/{{triplet}}-gcc" +export CXX="$mcm/bin/{{triplet}}-g++" export CFLAGS="-D_GNU_SOURCE" export LDFLAGS="-static"