Add remove option for repo-remove to remove old package files.

Also update documentation.
This commit is contained in:
Aidan Epstein 2025-04-30 22:46:46 -07:00 committed by Allan McRae
parent 53b1db84ef
commit 4ddc642398
2 changed files with 15 additions and 5 deletions

View file

@ -60,6 +60,10 @@ Common Options
*\--nocolor*:: *\--nocolor*::
Remove color from 'repo-add' and 'repo-remove' output. Remove color from 'repo-add' and 'repo-remove' output.
*-R, \--remove*::
Remove old package files from the disk when updating or removing their
entry in the database.
*-w, \--wait-for-lock*:: *-w, \--wait-for-lock*::
Wait for the lock file to be acquired. If unset, command will fail with Wait for the lock file to be acquired. If unset, command will fail with
exit code 2 if acquiring the lock fails. If set, it will retry to acquire exit code 2 if acquiring the lock fails. If set, it will retry to acquire
@ -71,10 +75,6 @@ repo-add Options
Only add packages that are not already in the database. Warnings will be Only add packages that are not already in the database. Warnings will be
printed upon detection of existing packages, but they will not be re-added. printed upon detection of existing packages, but they will not be re-added.
*-R, \--remove*::
Remove old package files from the disk when updating their entry in the
database.
*\--include-sigs*:: *\--include-sigs*::
Include package PGP signatures in the repository database (if available) Include package PGP signatures in the repository database (if available)

View file

@ -67,7 +67,6 @@ Multiple packages to add can be specified on the command line.\n")"
printf -- "\n" printf -- "\n"
printf -- "$(gettext "Options:\n")" printf -- "$(gettext "Options:\n")"
printf -- "$(gettext " -n, --new only add packages that are not already in the database\n")" printf -- "$(gettext " -n, --new only add packages that are not already in the database\n")"
printf -- "$(gettext " -R, --remove remove old package file from disk after updating database\n")"
printf -- "$(gettext " -p, --prevent-downgrade do not add package to database if a newer version is already present\n")" printf -- "$(gettext " -p, --prevent-downgrade do not add package to database if a newer version is already present\n")"
elif [[ $cmd == "repo-remove" ]] ; then elif [[ $cmd == "repo-remove" ]] ; then
printf -- "$(gettext "Usage: repo-remove [options] <path-to-db> <packagename> ...\n")" printf -- "$(gettext "Usage: repo-remove [options] <path-to-db> <packagename> ...\n")"
@ -87,6 +86,7 @@ packages to remove can be specified on the command line.\n")"
printf -- "$(gettext " -s, --sign sign database with GnuPG after update\n")" printf -- "$(gettext " -s, --sign sign database with GnuPG after update\n")"
printf -- "$(gettext " -k, --key <key> use the specified key to sign the database\n")" printf -- "$(gettext " -k, --key <key> use the specified key to sign the database\n")"
printf -- "$(gettext " -v, --verify verify database's signature before update\n")" printf -- "$(gettext " -v, --verify verify database's signature before update\n")"
printf -- "$(gettext " -R, --remove remove old package file from disk after updating database\n")"
printf -- "$(gettext " -w, --wait-for-lock retry to acquire lock file until success\n")" printf -- "$(gettext " -w, --wait-for-lock retry to acquire lock file until success\n")"
printf -- "$(gettext "\n\ printf -- "$(gettext "\n\
See %s(8) for more details and descriptions of the available options.\n")" $cmd See %s(8) for more details and descriptions of the available options.\n")" $cmd
@ -355,11 +355,21 @@ db_remove_entry() {
local pkgname=$1 local pkgname=$1
local notfound=1 local notfound=1
local pkgentry=$(find_pkgentry "$pkgname") local pkgentry=$(find_pkgentry "$pkgname")
local repodir=${LOCKFILE%/*}/
while [[ -n $pkgentry ]]; do while [[ -n $pkgentry ]]; do
notfound=0 notfound=0
msg2 "$(gettext "Removing existing entry '%s'...")" \ msg2 "$(gettext "Removing existing entry '%s'...")" \
"${pkgentry##*/}" "${pkgentry##*/}"
if (( RMEXISTING )); then
local oldfilename="$(sed -n '/^%FILENAME%$/ {n;p;q;}' "$pkgentry/desc")"
local oldfile="$repodir/$oldfilename"
msg2 "$(gettext "Removing old package file '%s'")" "$oldfilename"
rm -f ${oldfile} ${oldfile}.sig
fi
rm -rf "$pkgentry" rm -rf "$pkgentry"
# remove entries in "files" database # remove entries in "files" database