From 748b5cd68e17f60852c1308e5d97465d7b08587ccce7742c98cc7c06b4fe11f0 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 14 Mar 2026 17:10:36 +0300 Subject: [PATCH] Be less dependent on meta4ra-hash --- build/bin/cksum | 5 +++-- build/distfiles/bin/dl-urls | 2 +- build/distfiles/bin/hashes-gen | 4 ++++ build/distfiles/bin/metadir-from-file | 4 ++-- build/distfiles/dl/default.rc | 4 ++-- build/lib/mk-pkg | 6 +++--- build/lib/pkg-inst | 2 +- build/pkg/cp-arch | 5 +++-- doc/Build/Distfiles/Tutorial | 2 +- doc/Build/Tutorial | 4 ++-- lib/rc | 2 +- 11 files changed, 23 insertions(+), 17 deletions(-) diff --git a/build/bin/cksum b/build/bin/cksum index 7b13b1a..7a8501a 100755 --- a/build/bin/cksum +++ b/build/bin/cksum @@ -24,6 +24,7 @@ sname="$0" . "$BASS_ROOT"/lib/rc tmp=$(mktemp) trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT +hashers=$(echo "$BASS_HASHERS" | head -1) while [ $# -ne 0 ] ; do arg="$1" shift @@ -37,8 +38,8 @@ while [ $# -ne 0 ] ; do *) printf %d:%s, $(printf %s "$arg" | wc -c) "$arg" esac -done | meta4ra-hash -hashers "$META4RA_HASHERS" >$tmp -read hsh rem <$tmp +done | "$DISTFILES"/bin/hashes-gen "$hashers" >$tmp +read _name hsh <$tmp [ -n "$hsh" ] perl -MMIME::Base64 \ -e 'print MIME::Base64::encode_base64url(pack "H*", "'$hsh'") . "\n";' diff --git a/build/distfiles/bin/dl-urls b/build/distfiles/bin/dl-urls index 7f59f93..8d21aa3 100755 --- a/build/distfiles/bin/dl-urls +++ b/build/distfiles/bin/dl-urls @@ -1,7 +1,7 @@ #!/bin/sh -e # List available download URLs for specified meta/target -[ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../.. +[ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../../.. sname=$0 . "$BASS_ROOT"/lib/rc redo-ifchange $1/urls diff --git a/build/distfiles/bin/hashes-gen b/build/distfiles/bin/hashes-gen index 41ced2b..1c991c2 100755 --- a/build/distfiles/bin/hashes-gen +++ b/build/distfiles/bin/hashes-gen @@ -3,6 +3,10 @@ hashers="$1" [ -n "$hashers" ] || hashers="$(meta4ra-hashers-detect 2>/dev/null)" +if command -v meta4ra-hash >/dev/null 2>/dev/null ; then + meta4ra-hash -all -hashers "$hashers" + exit +fi tmp=$(mktemp -d) trap "rm -fr $tmp" HUP PIPE INT QUIT TERM EXIT cd $tmp diff --git a/build/distfiles/bin/metadir-from-file b/build/distfiles/bin/metadir-from-file index d93e58b..9b12d8c 100755 --- a/build/distfiles/bin/metadir-from-file +++ b/build/distfiles/bin/metadir-from-file @@ -1,11 +1,11 @@ #!/bin/sh -e # Generate metadir from specified file -[ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../../../.. +[ -n "$BASS_ROOT" ] || BASS_ROOT="$(dirname "$(realpath -- "$0")")"/../../.. sname=$0 . "$BASS_ROOT"/lib/rc [ -n "$1" ] dst=$(basename $1) mkdir -p $dst "$BASS_ROOT"/bin/filessize $1 >$dst/size -meta4ra-hash -all -hashers "$META4RA_HASHERS" <$1 >$dst/hashes +"$DISTFILES"/bin/hashes-gen "$BASS_HASHERS" <$1 >$dst/hashes diff --git a/build/distfiles/dl/default.rc b/build/distfiles/dl/default.rc index a1cca62..d0c4d84 100644 --- a/build/distfiles/dl/default.rc +++ b/build/distfiles/dl/default.rc @@ -10,7 +10,7 @@ if [ -r cache/$dst ] ; then if [ -s "$metadir"/hashes ] ; then meta4ra-check \ -progress \ - -hashers "$META4RA_HASHERS" \ + -hashers "$BASS_HASHERS" \ -plain "$metadir"/hashes \ &1 >/dev/null || { echo hash check failed >&2 @@ -58,7 +58,7 @@ meta4ra) echo trying ${url}... >&2 if [ -s "$metadir"/hashes ] ; then meta4ra-dl -progress -size $size "$url" | - meta4ra-check -plain -hashers "$META4RA_HASHERS" "$metadir"/hashes \ + meta4ra-check -plain -hashers "$BASS_HASHERS" "$metadir"/hashes \ >$fn || { echo hash check failed >&2 rm $fn diff --git a/build/lib/mk-pkg b/build/lib/mk-pkg index deee96d..1b6fdac 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 | - meta4ra-hash -hashers "$META4RA_HASHERS" -all >$tmp/name.hashes + "$DISTFILES"/bin/hashes-gen "$BASS_HASHERS" >$tmp/name.hashes cat >$tmp/buildinfo <$tmp/buildinfo.hashes +"$DISTFILES"/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 ; } | -{ meta4ra-hash -hashers "$META4RA_HASHERS" -all || touch $tmp/tar-pipe-failed +{ "$DISTFILES"/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 faa2d92..19db3cf 100755 --- a/build/lib/pkg-inst +++ b/build/lib/pkg-inst @@ -46,7 +46,7 @@ else $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 "$META4RA_HASHERS" $opts $NAMENHASH || + meta4ra-check -hashers "$BASS_HASHERS" $opts $NAMENHASH || touch untar-failed } | $TAR xf - || touch untar-failed else diff --git a/build/pkg/cp-arch b/build/pkg/cp-arch index 79ddb07..d786f09 100755 --- a/build/pkg/cp-arch +++ b/build/pkg/cp-arch @@ -11,6 +11,7 @@ dst="$(realpath -- "$1")" [ -d "$dst" ] arch="$(basename -- "$2")" [ -n "$arch" ] || arch=$ARCH +hashers=$(echo "$BASS_HASHERS" | head -1) tmp=$(mktemp -d ${TMPDIR:-/tmp}/cp-arch.XXXXXX) trap "rm -fr $tmp" HUP PIPE INT QUIT TERM EXIT @@ -23,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 - meta4ra-hash -hashers "$META4RA_HASHERS" <$pkg >$tmp/hshour & - meta4ra-hash -hashers "$META4RA_HASHERS" <"$dst"/$arch/$base >$tmp/hshtheir & + "$DISTFILES"/bin/hashes-gen "$hashers" <$pkg >$tmp/hshour & + "$DISTFILES"/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 9dfab2e..166a076 100644 --- a/doc/Build/Distfiles/Tutorial +++ b/doc/Build/Distfiles/Tutorial @@ -32,7 +32,7 @@ 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: - $ meta4ra-hash -all <$tarball >$DISTFILES/meta/$tarball/hashes + $ $DISTFILES/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/doc/Build/Tutorial b/doc/Build/Tutorial index 43e4876..bd5c698 100644 --- a/doc/Build/Tutorial +++ b/doc/Build/Tutorial @@ -151,11 +151,11 @@ Let's describe what is happening in the skel: Current BASS'es source code revision. A [Index/Variables] SETLOCK - A [Index/Variables] META4RA_HASHERS + A [Index/Variables] BASS_HASHERS A [Index/Variables] FSYNC A [Index/Variables] TAR A [Index/Variables] TMPDIR - * $SETLOCK, $META4RA_HASHERS, $FSYNC, $TAR, $TMPDIR + * $SETLOCK, $BASS_HASHERS, $FSYNC, $TAR, $TMPDIR And of course they could be overridden in most cases with your $BASS_RC. diff --git a/lib/rc b/lib/rc index 4bd89a9..e475307 100644 --- a/lib/rc +++ b/lib/rc @@ -25,7 +25,7 @@ if [ -z "$SETLOCK" ] ; then } fi -export META4RA_HASHERS="${META4RA_HASHERS:-$(meta4ra-hashers-detect 2>/dev/null)}" +export BASS_HASHERS="${BASS_HASHERS:-$(meta4ra-hashers-detect 2>/dev/null)}" export FSYNC=${FSYNC:-$(command -v fsync 2>/dev/null || command -v sync)} export TAR=${TAR:-bsdtar} -- 2.52.0