repo-add: do not recreate the database if nothing was changed

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Ivan Shapovalov 2022-10-14 08:04:54 +04:00 committed by Allan McRae
parent b4f11d5496
commit f91fa546f6

View file

@ -43,6 +43,7 @@ CLEAN_LOCK=0
USE_COLOR='y' USE_COLOR='y'
PREVENT_DOWNGRADE=0 PREVENT_DOWNGRADE=0
INCLUDE_SIGS=0 INCLUDE_SIGS=0
DB_MODIFIED=0
# Import libmakepkg # Import libmakepkg
source "$LIBRARY"/util/compress.sh source "$LIBRARY"/util/compress.sh
@ -341,6 +342,8 @@ db_write_entry() {
rm -f ${oldfile} ${oldfile}.sig rm -f ${oldfile} ${oldfile}.sig
fi fi
DB_MODIFIED=1
return 0 return 0
} # end db_write_entry } # end db_write_entry
@ -361,6 +364,8 @@ db_remove_entry() {
local filesentry=$(echo "$pkgentry" | sed 's/\(.*\)\/db\//\1\/files\//') local filesentry=$(echo "$pkgentry" | sed 's/\(.*\)\/db\//\1\/files\//')
rm -rf "$filesentry" rm -rf "$filesentry"
DB_MODIFIED=1
pkgentry=$(find_pkgentry "$pkgname") pkgentry=$(find_pkgentry "$pkgname")
done done
return $notfound return $notfound
@ -695,13 +700,13 @@ for arg in "${args[@]:1}"; do
done done
# if the whole operation was a success, re-zip and rotate databases # 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" msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
create_db create_db
rotate_db rotate_db
else else
msg "$(gettext "No packages modified, nothing to do.")" msg "$(gettext "No packages modified, nothing to do.")"
exit 1 exit $(( fail != 0 ))
fi fi
exit 0 exit 0