diff --git a/doc/repo-add.8.asciidoc b/doc/repo-add.8.asciidoc index 57c0880b..352a4e5f 100644 --- a/doc/repo-add.8.asciidoc +++ b/doc/repo-add.8.asciidoc @@ -60,6 +60,10 @@ Common Options *\--nocolor*:: 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*:: 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 @@ -71,10 +75,6 @@ repo-add Options 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. -*-R, \--remove*:: - Remove old package files from the disk when updating their entry in the - database. - *\--include-sigs*:: Include package PGP signatures in the repository database (if available) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 7dbc77e2..c1832fe3 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -67,7 +67,6 @@ Multiple packages to add can be specified on the command line.\n")" printf -- "\n" printf -- "$(gettext "Options:\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")" elif [[ $cmd == "repo-remove" ]] ; then printf -- "$(gettext "Usage: repo-remove [options] ...\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 " -k, --key use the specified key to sign the database\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 "\n\ 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 notfound=1 local pkgentry=$(find_pkgentry "$pkgname") + local repodir=${LOCKFILE%/*}/ while [[ -n $pkgentry ]]; do notfound=0 msg2 "$(gettext "Removing existing entry '%s'...")" \ "${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" # remove entries in "files" database