From 91cf37b0744192b4465e4f80ec444e9b39d305f5411d677641c340eaf66cf125 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 14 Mar 2026 18:34:05 +0300 Subject: [PATCH] Be less dependent on meta4ra-check --- build/bin/cksum | 2 +- build/bin/hashes-check | 36 +++++++++++++++++++ build/{distfiles => }/bin/hashes-gen | 0 build/distfiles/bin/metadir-from-file | 2 +- build/distfiles/dl/default.rc | 12 +++---- .../dl/gcc-4-compile-with-gcc-5.patch.do | 2 +- .../dl/gcc-4-compile-with-gcc-5.patch.hashes | 11 ++++++ .../dl/gcc-4-compile-with-gcc-5.patch.meta4 | 17 --------- build/lib/mk-pkg | 6 ++-- build/lib/pkg-inst | 18 ++++------ build/pkg/cp-arch | 4 +-- doc/Build/Distfiles/Tutorial | 5 ++- lib/rc | 2 ++ 13 files changed, 70 insertions(+), 47 deletions(-) create mode 100755 build/bin/hashes-check rename build/{distfiles => }/bin/hashes-gen (100%) create mode 100644 build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.hashes delete mode 100644 build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.meta4 diff --git a/build/bin/cksum b/build/bin/cksum index 7a8501a..55bcbd9 100755 --- a/build/bin/cksum +++ b/build/bin/cksum @@ -38,7 +38,7 @@ while [ $# -ne 0 ] ; do *) printf %d:%s, $(printf %s "$arg" | wc -c) "$arg" esac -done | "$DISTFILES"/bin/hashes-gen "$hashers" >$tmp +done | "$BASS_ROOT"/build/bin/hashes-gen "$hashers" >$tmp read _name hsh <$tmp [ -n "$hsh" ] perl -MMIME::Base64 \ diff --git a/build/bin/hashes-check b/build/bin/hashes-check new file mode 100755 index 0000000..66d00d4 --- /dev/null +++ b/build/bin/hashes-check @@ -0,0 +1,36 @@ +#!/bin/sh -e +# Check data against provided hashes + +hashes="$1" +[ -s "$hashes" ] +hashers="$2" +[ -n "$hashers" ] || hashers="$(meta4ra-hashers-detect 2>/dev/null)" +tmp=$(mktemp -d) +trap "rm -fr $tmp" HUP PIPE INT QUIT TERM EXIT +while read name cmd ; do + sed -n "s/^$name \(.*\)$/\1/p" <$hashes >$tmp/their + if [ -s $tmp/their ] ; then + cat >$tmp/hasher <&2 + exit 1 +} +mkfifo $tmp/pipe +$tmp/hasher <$tmp/pipe >$tmp/our & +tee $tmp/pipe +wait +read our rem <$tmp/our +read their <$tmp/their +[ "$our" = "$their" ] || { + echo "hash mismatch: $our != $their" >&2 + exit 1 +} diff --git a/build/distfiles/bin/hashes-gen b/build/bin/hashes-gen similarity index 100% rename from build/distfiles/bin/hashes-gen rename to build/bin/hashes-gen diff --git a/build/distfiles/bin/metadir-from-file b/build/distfiles/bin/metadir-from-file index 9b12d8c..f190972 100755 --- a/build/distfiles/bin/metadir-from-file +++ b/build/distfiles/bin/metadir-from-file @@ -8,4 +8,4 @@ sname=$0 . "$BASS_ROOT"/lib/rc dst=$(basename $1) mkdir -p $dst "$BASS_ROOT"/bin/filessize $1 >$dst/size -"$DISTFILES"/bin/hashes-gen "$BASS_HASHERS" <$1 >$dst/hashes +"$BASS_ROOT"/build/bin/hashes-gen "$BASS_HASHERS" <$1 >$dst/hashes diff --git a/build/distfiles/dl/default.rc b/build/distfiles/dl/default.rc index d0c4d84..38e9e2c 100644 --- a/build/distfiles/dl/default.rc +++ b/build/distfiles/dl/default.rc @@ -8,14 +8,12 @@ dst=$1 if [ -r cache/$dst ] ; then echo using cache/$dst... >&2 if [ -s "$metadir"/hashes ] ; then - meta4ra-check \ - -progress \ - -hashers "$BASS_HASHERS" \ - -plain "$metadir"/hashes \ - &1 >/dev/null || { + $PV cache/$dst | + "$BASS_ROOT"/build/bin/hashes-check "$metadir"/hashes "$BASS_HASHERS" \ + 2>&1 >/dev/null || { echo hash check failed >&2 exit 1 - } + } else echo warning: no $metadir/hashes >&2 if [ -s "$metadir"/size ] ; then @@ -58,7 +56,7 @@ meta4ra) echo trying ${url}... >&2 if [ -s "$metadir"/hashes ] ; then meta4ra-dl -progress -size $size "$url" | - meta4ra-check -plain -hashers "$BASS_HASHERS" "$metadir"/hashes \ + "$BASS_ROOT"/build/bin/hashes-check "$metadir"/hashes "$BASS_HASHERS" \ >$fn || { echo hash check failed >&2 rm $fn diff --git a/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.do b/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.do index a0d6711..f41f5a8 100644 --- a/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.do +++ b/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.do @@ -4,4 +4,4 @@ v1.5.0 >/dev/null p=gnu/packages/patches/gcc-4-compile-with-gcc-5.patch ( cd ../repo/guix.git ; git archive @ $p | tar xfO - $p ) >$3 -meta4ra-check -pipe $1.meta4 $1 <$3 >/dev/null +../../bin/hashes-check $1.hashes "$BASS_HASHERS" <$3 >/dev/null diff --git a/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.hashes b/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.hashes new file mode 100644 index 0000000..b384712 --- /dev/null +++ b/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.hashes @@ -0,0 +1,11 @@ +blake3-256 0cba0a01e2201c78ff5f803a3a4d64ff3ec19c35f49f1ea8556e050a453ac770 +blake2b-512 aeb809e7801aa2625bfd814c950a0a302cfb1ee9147d9b32e5d858e7ba34d9b193becd00472a148e3be5fe4c388370de9ac0d4022d38ac42537ce42dda50ebe3 +blake2b-256 2bf78b04c60c32a4e4263074ddb5511d530648ce88f5e27ca5f7493d512c3da0 +skein-512 3b3715c9579625272d3b505fde2655a9307473ef3785415c9c0866baad924aa2407e31f53979b0d8d7fa2a17d0fb81f016fe8cdb6b0f7d54b0a98b654aad521a +shake128 31c9e64268463d4ddd73a5e743493a2b0dcfda87728b20f68eedcb98512786a3 +shake256 fffa62fc68476dcae4dc1b3c9065c7ad970c01756485da216aa61951a65cdaa62a6bdec4ef37b9d349657e504d5d19112a18d84cf6eced36dbc3c195a768317c +sha-512 04c38b68ccce8642259011bb8dc73d51f980e2b60c80941e5125bd5d5e68f1693f7d599c10abb5106d789c66130e314115963474465e451be3a20d618016e661 +sha-256 5b084cfc9741d960bd57d799758a98a5f1f436e38308aac2299b439de0a90103 +streebog-512 615fb79a7a3082e4192d9d319c3fd038ed281f3aedd9abec4848f1b35e6de56d8c5c022ed0b24209460dc4538aa6aeeb2001d290be0b4689114151bef3e1bbac +streebog-256 f7b6b9ce119c2b0c793731051c9d015393981568d6a724567bc4d596c14464d0 +xxh3-128 57b1e630fdfc601b9b146d3bbf7f130a diff --git a/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.meta4 b/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.meta4 deleted file mode 100644 index 605b6d6..0000000 --- a/build/distfiles/dl/gcc-4-compile-with-gcc-5.patch.meta4 +++ /dev/null @@ -1,17 +0,0 @@ - - - - 0cba0a01e2201c78ff5f803a3a4d64ff3ec19c35f49f1ea8556e050a453ac770 - aeb809e7801aa2625bfd814c950a0a302cfb1ee9147d9b32e5d858e7ba34d9b193becd00472a148e3be5fe4c388370de9ac0d4022d38ac42537ce42dda50ebe3 - 2bf78b04c60c32a4e4263074ddb5511d530648ce88f5e27ca5f7493d512c3da0 - 3b3715c9579625272d3b505fde2655a9307473ef3785415c9c0866baad924aa2407e31f53979b0d8d7fa2a17d0fb81f016fe8cdb6b0f7d54b0a98b654aad521a - 31c9e64268463d4ddd73a5e743493a2b0dcfda87728b20f68eedcb98512786a3 - fffa62fc68476dcae4dc1b3c9065c7ad970c01756485da216aa61951a65cdaa62a6bdec4ef37b9d349657e504d5d19112a18d84cf6eced36dbc3c195a768317c - 04c38b68ccce8642259011bb8dc73d51f980e2b60c80941e5125bd5d5e68f1693f7d599c10abb5106d789c66130e314115963474465e451be3a20d618016e661 - 5b084cfc9741d960bd57d799758a98a5f1f436e38308aac2299b439de0a90103 - 615fb79a7a3082e4192d9d319c3fd038ed281f3aedd9abec4848f1b35e6de56d8c5c022ed0b24209460dc4538aa6aeeb2001d290be0b4689114151bef3e1bbac - f7b6b9ce119c2b0c793731051c9d015393981568d6a724567bc4d596c14464d0 - 57b1e630fdfc601b9b146d3bbf7f130a - 2264 - - diff --git a/build/lib/mk-pkg b/build/lib/mk-pkg index 1b6fdac..83156fd 100755 --- a/build/lib/mk-pkg +++ b/build/lib/mk-pkg @@ -38,11 +38,11 @@ tmp=$(mktemp -d $TMPDIR/$namenhash-mk-pkg.XXXXXX) trap "rm -fr $tmp" HUP PIPE INT QUIT TERM EXIT echo $namenhash | tee $tmp/name | - "$DISTFILES"/bin/hashes-gen "$BASS_HASHERS" >$tmp/name.hashes + "$BASS_ROOT"/build/bin/hashes-gen "$BASS_HASHERS" >$tmp/name.hashes cat >$tmp/buildinfo <$tmp/buildinfo.hashes +"$BASS_ROOT"/build/bin/hashes-gen "$BASS_HASHERS" <$tmp/buildinfo >$tmp/buildinfo.hashes chmod -R a-w $namenhash { @@ -51,7 +51,7 @@ chmod -R a-w $namenhash } | { $COMPRESSOR || touch $tmp/tar-pipe-failed ; } | { tee $tmp/$namenhash || touch $tmp/tar-pipe-failed ; } | -{ "$DISTFILES"/bin/hashes-gen "$BASS_HASHERS" || touch $tmp/tar-pipe-failed +{ "$BASS_ROOT"/build/bin/hashes-gen "$BASS_HASHERS" || touch $tmp/tar-pipe-failed } >$tmp/$namenhash.hashes [ ! -e $tmp/tar-pipe-failed ] diff --git a/build/lib/pkg-inst b/build/lib/pkg-inst index 19db3cf..2855809 100755 --- a/build/lib/pkg-inst +++ b/build/lib/pkg-inst @@ -42,19 +42,13 @@ else tmp=$(mktemp -d "$SKELBINS"/$ARCH/tmp/$NAMENHASH.XXXXXX) trap "$BASS_ROOT/bin/rm-r $tmp" HUP PIPE INT QUIT TERM EXIT cd $tmp - if command -v meta4ra-check >/dev/null ; then - $TAR xf $skelpkg bin.hashes || $TAR xf $skelpkg bin.meta4 - [ -s bin.hashes ] && opts="-plain bin.hashes" || opts="-pipe bin.meta4" - $TAR xfO $skelpkg bin | { - meta4ra-check -hashers "$BASS_HASHERS" $opts $NAMENHASH || - touch untar-failed - } | $TAR xf - || touch untar-failed - else - echo warning: skipping checksum verification >&2 - $TAR xfO $skelpkg bin | $TAR xf - || touch untar-failed - fi + $TAR xf $skelpkg bin.hashes + $TAR xfO $skelpkg bin | { + "$BASS_ROOT"/build/bin/hashes-check bin.hashes "$BASS_HASHERS" || + touch untar-failed + } | $TAR xf - || touch untar-failed [ ! -e untar-failed ] - rm -f $fn.meta4 + rm -f $fn.hashes find $tmp/$namenhash -type f -or -type d -exec $FSYNC {} + chmod +w $tmp/$NAMENHASH mv $tmp/$NAMENHASH "$SKELBINS"/$ARCH/$NAMENHASH || diff --git a/build/pkg/cp-arch b/build/pkg/cp-arch index d786f09..c4bf7c7 100755 --- a/build/pkg/cp-arch +++ b/build/pkg/cp-arch @@ -24,8 +24,8 @@ find . -type f -and -not -name "*.do" -and -not -path "*/.redo/*" | while read p oursize=$("$BASS_ROOT"/bin/filessize $pkg) theirsize=$("$BASS_ROOT"/bin/filessize "$dst"/$arch/$base) if [ "$oursize" -eq "$theirsize" ] ; then - "$DISTFILES"/bin/hashes-gen "$hashers" <$pkg >$tmp/hshour & - "$DISTFILES"/bin/hashes-gen "$hashers" <"$dst"/$arch/$base >$tmp/hshtheir & + "$BASS_ROOT"/build/bin/hashes-gen "$hashers" <$pkg >$tmp/hshour & + "$BASS_ROOT"/build/bin/hashes-gen "$hashers" <"$dst"/$arch/$base >$tmp/hshtheir & wait read hshour <$tmp/hshour read hshtheir <$tmp/hshtheir diff --git a/doc/Build/Distfiles/Tutorial b/doc/Build/Distfiles/Tutorial index 166a076..163f41d 100644 --- a/doc/Build/Distfiles/Tutorial +++ b/doc/Build/Distfiles/Tutorial @@ -24,15 +24,14 @@ Store tarball's size in it: $ stat -f %z $tarball >$DISTFILES/meta/$tarball/size $ stat -f %z $tarball.sig >$DISTFILES/meta/$tarball.sig/size -A [Index/Programs] meta4ra-create Compute its checksum. There is no preferred algorithm. One could be satisfied with non-cryptographic, but very fast XXH3. Somebody want to use fast cryptographic BLAKE3 or BLAKE2. Somebody likes Skein. Somebody requires GOST Streebog ones. Maybe there are people preferring slow SHA2 family of algorithms. Let's precompute a bunch of them. We -will use meta4ra-hash utility: +will use hashes-gen script: - $ $DISTFILES/bin/hashes-gen <$tarball >$DISTFILES/meta/$tarball/hashes + $ $BASS_ROOT/build/bin/hashes-gen <$tarball >$DISTFILES/meta/$tarball/hashes Then we must store a list of URLs where it can be fetched. That may be just trivial: diff --git a/lib/rc b/lib/rc index e475307..20c114d 100644 --- a/lib/rc +++ b/lib/rc @@ -44,6 +44,8 @@ export SKELBINS=${SKELBINS:-/tmp/skelbins} [ -d $SKELBINS/$ARCH ] || mkdir -p $SKELBINS/$ARCH export SKELPKGS=${SKELPKGS:-"$BASS_ROOT"/build/pkg} +[ -n "$PV" ] || command -v pv >/dev/null 2>/dev/null && PV=pv || PV=cat + # Program to use for downloading distfiles: "meta4ra", "wget", "aria2c". export DISTFILE_FETCHER="${DISTFILE_FETCHER:-meta4ra}" if ! type FETCHER_URLS_SORT 2>/dev/null >/dev/null ; then -- 2.52.0