[projects/pld-ftp-admin] consistency-check.sh: build the lists in parallel with -j

arekm arekm at pld-linux.org
Tue Oct 27 10:56:27 CET 2026


commit 9da94db07ea316d05f5466d10ac4e10519ad6d46
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Oct 27 00:33:02 2026 +0100

    consistency-check.sh: build the lists in parallel with -j
    
    The nine poldek runs went one after another.  -j N runs up to N of them
    at once, by default one per 4 CPUs.  Each run gets a poldek cache of its
    own, as the shared one is locked and was wiped by --cleana, and writes
    its report under a unique name that mv publishes whole.  Messages get
    the arch and list as a prefix.

 wwwbin/consistency-check.sh | 55 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/wwwbin/consistency-check.sh b/wwwbin/consistency-check.sh
index f1359d2..2d4667e 100755
--- a/wwwbin/consistency-check.sh
+++ b/wwwbin/consistency-check.sh
@@ -1,4 +1,5 @@
 #!/bin/sh
+# usage: consistency-check.sh [-j N]
 
 export LC_ALL=C
 
@@ -55,7 +56,6 @@ gen_list() {
 	arch=$1
 	shift
 	date
-	poldek --cleana
 	poldek \
 	 -O "auto directory dependencies = yes" \
 	 -O "unique package names = no" \
@@ -73,18 +73,59 @@ gen_list_uniq() {
 	gen_list $arch -Q -O "unique package names = yes" "$@"
 }
 
-t=$(mktemp)
 ftpdir=$HOME/ftp
-for arch in x86_64 i686 x32 ; do
+
+# job ARCH LIST: writes the LIST report for ARCH to $HOME/www
+job() {
+	arch=$1
+	list=$2
 	if [ "$arch" = x86_64 ]; then
 		outfext=.txt
 	else
 		outfext=-$arch.txt
 	fi
-	gen_list      $arch -s $ftpdir/PLD/$arch/RPMS/ -s $ftpdir/PLD/noarch/RPMS/ > $t && cat $t > $HOME/www/main$outfext
-	gen_list      $arch -s $ftpdir/PLD/$arch/RPMS/ -s $ftpdir/PLD/noarch/RPMS/ -s $ftpdir/ready/$arch/RPMS/ -s $ftpdir/ready/noarch/RPMS/ > $t && cat $t > $HOME/www/main-ready$outfext
-	gen_list_uniq $arch -s $ftpdir/PLD/$arch/RPMS/ -s $ftpdir/PLD/noarch/RPMS/ -s $ftpdir/ready/$arch/RPMS/ -s $ftpdir/ready/noarch/RPMS/ -s $ftpdir/test/$arch/RPMS/ -s $ftpdir/test/noarch/RPMS/ > $t && cat $t > $HOME/www/main-ready-test$outfext
+	main="-s $ftpdir/PLD/$arch/RPMS/ -s $ftpdir/PLD/noarch/RPMS/"
+	ready="-s $ftpdir/ready/$arch/RPMS/ -s $ftpdir/ready/noarch/RPMS/"
+	test="-s $ftpdir/test/$arch/RPMS/ -s $ftpdir/test/noarch/RPMS/"
+	# a poldek cache of its own, as jobs run at once; a fresh one needs no --cleana
+	cache=$(mktemp -d)
+	# a unique name, as two runs may overlap; mv publishes the report whole
+	tmp=$(mktemp "$HOME/www/.$list$outfext.XXXXXX")
+	# not an EXIT trap: an exit from a signal trap in this subshell does not run it
+	trap 'rm -rf "$cache" "$tmp"; exit 1' INT TERM
+	case $list in
+	main)		gen_list      $arch --cachedir="$cache" $main ;;
+	main-ready)	gen_list      $arch --cachedir="$cache" $main $ready ;;
+	main-ready-test) gen_list_uniq $arch --cachedir="$cache" $main $ready $test ;;
+	esac > "$tmp" && chmod 644 "$tmp" && mv "$tmp" "$HOME/www/$list$outfext"
+	rm -rf "$cache" "$tmp"
+}
+
+if [ "$1" = --job ]; then
+	shift
+	# unbuffered, or the jobs' messages mix in the middle of lines
+	job "$@" 2>&1 | sed -u "s|^|[$1 $2] |" >&2
+	exit
+fi
+
+# poldek --verify runs on one CPU, but takes much memory
+jobs=$(( $(nproc) / 4 ))
+[ "$jobs" -ge 1 ] || jobs=1
+while getopts j: opt; do
+	case $opt in
+	j) jobs=$OPTARG ;;
+	*) echo "usage: $0 [-j N]" >&2; exit 2 ;;
+	esac
 done
+# xargs -P 0 would run all of them at once
+case $jobs in
+''|*[!0-9]*|0*) echo "usage: $0 [-j N]" >&2; exit 2 ;;
+esac
+
+for arch in x86_64 i686 x32; do
+	for list in main main-ready main-ready-test; do
+		echo $arch $list
+	done
+done | xargs -P "$jobs" -n 2 sh "$0" --job
 
 chmod 644 $HOME/www/*.txt
-rm -f $t
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/9da94db07ea316d05f5466d10ac4e10519ad6d46



More information about the pld-cvs-commit mailing list