repo-add: Add --prevent-downgrade option
Implements FS#17752 Signed-off-by: Luca Bertozzi <ekarndam@autistici.org>
This commit is contained in:
parent
99c5809bbf
commit
c8062d753c
1 changed files with 16 additions and 3 deletions
|
@ -42,6 +42,7 @@ REPO_DB_SUFFIX=
|
||||||
LOCKFILE=
|
LOCKFILE=
|
||||||
CLEAN_LOCK=0
|
CLEAN_LOCK=0
|
||||||
USE_COLOR='y'
|
USE_COLOR='y'
|
||||||
|
PREVENT_DOWNGRADE=0
|
||||||
|
|
||||||
# Import libmakepkg
|
# Import libmakepkg
|
||||||
source "$LIBRARY"/util/message.sh
|
source "$LIBRARY"/util/message.sh
|
||||||
|
@ -63,6 +64,7 @@ Multiple packages to add can be specified on the command line.\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 " -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
|
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")"
|
||||||
printf -- "\n"
|
printf -- "\n"
|
||||||
|
@ -248,9 +250,17 @@ db_write_entry() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if (( RMEXISTING )); then
|
|
||||||
pkgentry=$(find_pkgentry "$pkgname")
|
pkgentry=$(find_pkgentry "$pkgname")
|
||||||
if [[ -n $pkgentry ]]; then
|
if [[ -n $pkgentry ]]; then
|
||||||
|
|
||||||
|
local version=$(sed -n '/^%VERSION%$/ {n;p;q}' "$pkgentry/desc")
|
||||||
|
if (( $(vercmp "$version" "$pkgver") > 0 )); then
|
||||||
|
warning "$(gettext "A newer version for '%s' is already present in database")" "$pkgname"
|
||||||
|
if (( PREVENT_DOWNGRADE )); then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (( RMEXISTING )); then
|
||||||
local oldfilename="$(sed -n '/^%FILENAME%$/ {n;p;q;}' "$pkgentry/desc")"
|
local oldfilename="$(sed -n '/^%FILENAME%$/ {n;p;q;}' "$pkgentry/desc")"
|
||||||
local oldfile="$(dirname "$1")/$oldfilename"
|
local oldfile="$(dirname "$1")/$oldfilename"
|
||||||
fi
|
fi
|
||||||
|
@ -618,6 +628,9 @@ while (( $# )); do
|
||||||
-v|--verify)
|
-v|--verify)
|
||||||
VERIFY=1
|
VERIFY=1
|
||||||
;;
|
;;
|
||||||
|
-p|--prevent-downgrade)
|
||||||
|
PREVENT_DOWNGRADE=1
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
args+=("$1")
|
args+=("$1")
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Reference in a new issue