From f91fa546f65af9ca7cdbe2b419c181df609969b7 Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Fri, 14 Oct 2022 08:04:54 +0400 Subject: [PATCH] repo-add: do not recreate the database if nothing was changed Signed-off-by: Ivan Shapovalov Signed-off-by: Allan McRae --- scripts/repo-add.sh.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index bd03afad..0ec998ad 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -43,6 +43,7 @@ CLEAN_LOCK=0 USE_COLOR='y' PREVENT_DOWNGRADE=0 INCLUDE_SIGS=0 +DB_MODIFIED=0 # Import libmakepkg source "$LIBRARY"/util/compress.sh @@ -341,6 +342,8 @@ db_write_entry() { rm -f ${oldfile} ${oldfile}.sig fi + DB_MODIFIED=1 + return 0 } # end db_write_entry @@ -361,6 +364,8 @@ db_remove_entry() { local filesentry=$(echo "$pkgentry" | sed 's/\(.*\)\/db\//\1\/files\//') rm -rf "$filesentry" + DB_MODIFIED=1 + pkgentry=$(find_pkgentry "$pkgname") done return $notfound @@ -695,13 +700,13 @@ for arg in "${args[@]:1}"; do done # if the whole operation was a success, re-zip and rotate databases -if (( !fail )); then +if (( !fail )) && (( DB_MODIFIED )); then msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE" create_db rotate_db else msg "$(gettext "No packages modified, nothing to do.")" - exit 1 + exit $(( fail != 0 )) fi exit 0