#1099421 debrebuild: please add a --cache-size-limit option or some such

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Holger Levsen
Date:
2025-03-03 12:57:03 UTC
Severity:
normal
#1099421#5
Date:
2025-03-03 12:53:45 UTC
From:
To:
User reproducible-builds@lists.alioth.debian.org
Usertag environment

Dear Maintainer,

please add a --cache-size-limit option or some such.

from #debian-reproducible today:

< h01ger> josch: i just committed this crime: bin/debrebuild_cache_limiter.sh * r.d.n: add script to work around/implement a missing feature of debrebuild * https://salsa.debian.org/qa/jenkins.debian.net/-/commit/2db5e98
< h01ger> josch: for the upcoming debrebuild bug report, i'm not sure whether you can rely on atime being a sensible source of information and how to implement host specific limits. i guess with --cache-size, and then its up to the user how to call that
< h01ger> for the time being i intend to call bin/debrebuild_cache_limiter.sh manually, as i've been doing the last weeks anyway. (only 2-3 hosts really need it and there's i just ran one long command daily manually. this is a bit better and probably even safe to run in cron or some such...)

For easier reference, the script is as follows:

$ cat bin/debrebuild_cache_limiter.sh
#!/bin/bash
#
# Copyright 2025 Holger Levsen (holger@layer-acht.org)
# released under the GPLv2

CACHE=~rebuilderd/cache

if [ ! -d $CACHE ] ; then
	echo "$CACHE does not exist."
	exit 1
fi

case $HOSTNAME in
	ionos17*)	LIMIT=50  ;;
	codethink*)	LIMIT=20  ;;
	osuosl*)	LIMIT=333 ;;
	infom07*)	LIMIT=200 ;; # FIXME: drop extra partition again?
	infom08*)	LIMIT=100 ;;
	riscv64*)	LIMIT=180 ;;
	*)		echo "Limit for $HOSTNAME not defined."
			exit 1 ;;
esac

# delete 1000 oldest files
# FIXME: use atime, but then, this script should not exist in the first place... :)
find $CACHE -type f -printf '%T+ %p\n' | sort | head -n 1000|cut -d ' ' -f2-|xargs sudo rm

set -e
set -o pipefail

SIZE=$(du -sh $CACHE | grep G | cut -d 'G' -f 1)

if [ $SIZE -gt $LIMIT ] ; then
	echo "$CACHE is still ${SIZE}G, reducing further."
	$0
else
	echo "$CACHE is ${SIZE}G, voila."
fi

exit 0


& thanks a lot for debrebuild, it's extremely useful and very much works very
well!