mirror of
https://github.com/edu4rdshl/archlinux-pkgrecover.git
synced 2026-07-17 23:24:46 +00:00
Add the --no-db flag to the --paclog option to allow the user to no use the pacman db in case it's corrupted.
This commit is contained in:
parent
fea9035a11
commit
ab8e455e6b
1 changed files with 17 additions and 13 deletions
|
|
@ -70,21 +70,25 @@ using_paclog() {
|
||||||
|
|
||||||
# Get the list of packages upgraded after the given date
|
# Get the list of packages upgraded after the given date
|
||||||
mapfile -t paclog_matching_packages < <(paclog --after "$1" | grep -oE "(upgraded|installed) (\S+)" | cut -d ' ' -f 2 | sort -u)
|
mapfile -t paclog_matching_packages < <(paclog --after "$1" | grep -oE "(upgraded|installed) (\S+)" | cut -d ' ' -f 2 | sort -u)
|
||||||
mapfile -t installed_packages < <(pacman -Qq)
|
|
||||||
|
|
||||||
matching_packages=()
|
matching_packages=()
|
||||||
|
|
||||||
# Find the common elements between the two arrays
|
if [[ $2 == "--no-db" ]] || [[ $3 == "--no-db" ]]; then
|
||||||
for pkg in "${paclog_matching_packages[@]}"; do
|
matching_packages=("${paclog_matching_packages[@]}")
|
||||||
for installed_pkg in "${installed_packages[@]}"; do
|
else
|
||||||
if [[ "$pkg" == "$installed_pkg" ]]; then
|
mapfile -t installed_packages < <(pacman -Qq)
|
||||||
matching_packages+=("$pkg")
|
# Find the common elements between the two arrays
|
||||||
fi
|
for pkg in "${paclog_matching_packages[@]}"; do
|
||||||
|
for installed_pkg in "${installed_packages[@]}"; do
|
||||||
|
if [[ "$pkg" == "$installed_pkg" ]]; then
|
||||||
|
matching_packages+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
done
|
fi
|
||||||
|
|
||||||
# $2 is the dry-run flag, if set, just print the packages, else reinstall them piped to pacman
|
# $2 is the dry-run flag, if set, just print the packages, else reinstall them piped to pacman
|
||||||
if [[ $2 == "--dry-run" ]]; then
|
if [[ $3 == "--dry-run" ]] || [[ $2 == "--dry-run" ]]; then
|
||||||
echo "The following packages will be reinstalled:"
|
echo "The following packages will be reinstalled:"
|
||||||
for pkg in "${matching_packages[@]}"; do
|
for pkg in "${matching_packages[@]}"; do
|
||||||
echo "$pkg"
|
echo "$pkg"
|
||||||
|
|
@ -99,7 +103,7 @@ usage() {
|
||||||
echo "Usage: $0 [OPTIONS]"
|
echo "Usage: $0 [OPTIONS]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --pacman-db \"<date>\" [--dry-run] Reinstall packages upgraded after the given date using pacman database. Please quote the date in the format 'YYYY-MM-DD HH:MM:SS'"
|
echo " --pacman-db \"<date>\" [--dry-run] Reinstall packages upgraded after the given date using pacman database. Please quote the date in the format 'YYYY-MM-DD HH:MM:SS'"
|
||||||
echo " --paclog \"<date>\" [--dry-run] Reinstall packages upgraded after the given date using pacman log. Please quote the date in the format 'YYYY-MM-DD HH:MM:SS'"
|
echo " --paclog \"<date>\" [--no-db] [--dry-run] Reinstall packages upgraded after the given date using pacman log. Please quote the date in the format 'YYYY-MM-DD HH:MM:SS'"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,12 +117,12 @@ while [[ $# -gt 0 ]]; do
|
||||||
--pacman-db)
|
--pacman-db)
|
||||||
check_dependencies
|
check_dependencies
|
||||||
using_pacman_db "$2" "$3"
|
using_pacman_db "$2" "$3"
|
||||||
shift 3
|
exit 0
|
||||||
;;
|
;;
|
||||||
--paclog)
|
--paclog)
|
||||||
check_dependencies
|
check_dependencies
|
||||||
using_paclog "$2" "$3"
|
using_paclog "$2" "$3" "$4"
|
||||||
shift 3
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue