From b5b2f0b1bfdf52fb313d68a4134f46995166d4c4 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Fri, 23 Jan 2015 14:08:04 +1000 Subject: repo-add: improve removing old packages The -R/--remove option left the old package in place when delta packages were to be generated. It was also removed before we ensure the generation of the entry for the new package was generated without error. Remove the old package at the end of database entry and delta generation. Also improve the help message to clarify it is the old package that is removed. Signed-off-by: Allan McRae --- scripts/repo-add.sh.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 5089f993..49b1c3e7 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -59,7 +59,7 @@ Multiple packages to add can be specified on the command line.\n")" printf -- "$(gettext "Options:\n")" printf -- "$(gettext " -d, --delta generate and add delta for package update\n")" printf -- "$(gettext " -n, --new only add packages that are not already in the database\n")" - printf -- "$(gettext " -R, --remove remove package file from disk when updating database entry\n")" + printf -- "$(gettext " -R, --remove remove old package file from disk after updating database\n")" printf -- "$(gettext " -f, --files update database's file list\n")" elif [[ $cmd == "repo-remove" ]] ; then printf -- "$(gettext "Usage: repo-remove [options] ...\n")" @@ -306,14 +306,13 @@ db_write_entry() { local oldfilename=$(grep -A1 FILENAME "$pkgentry/desc" | tail -n1) local oldfile="$(dirname "$1")/$oldfilename" fi - elif (( RMEXISTING )); then - # only remove existing package if we're not doing deltas + fi + if (( RMEXISTING )); then + # gather information needed to remove old file pkgentry=$(find_pkgentry "$pkgname") if [[ -n $pkgentry ]]; then local oldfilename="$(sed -n '/^%FILENAME%$/ {n;p;q;}' "$pkgentry/desc")" local oldfile="$(dirname "$1")/$oldfilename" - msg2 "$(gettext "Removing existing package '%s'")" "$oldfilename" - rm -f ${oldfile} ${oldfile}.sig fi fi fi @@ -412,6 +411,11 @@ db_write_entry() { fi fi + if (( RMEXISTING )); then + msg2 "$(gettext "Removing old package file '%s'")" "$oldfilename" + rm -f ${oldfile} ${oldfile}.sig + fi + return 0 } # end db_write_entry -- cgit v1.2.3-70-g09d2