2023-12-03 02:09:46 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
restoreDir="/etc/restore"
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_before() {
|
2023-12-03 02:09:46 -05:00
|
|
|
mkdir -p "$restoreDir" || exit 1
|
|
|
|
pushd "$restoreDir" || exit 2
|
|
|
|
|
|
|
|
pacman -Qqe > "pkglist.txt"
|
|
|
|
comm -13 <(pacman -Qqdt | sort) <(pacman -Qqdtt | sort) > optdeplist.txt
|
|
|
|
pacman -Qqem > foreignpkglist.txt
|
|
|
|
|
|
|
|
cat > restore.sh <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Install non-foreign packages from pgklist:
|
|
|
|
pacman -S --needed \$(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt))
|
|
|
|
|
|
|
|
# Remove packages not listed.
|
|
|
|
#pacman -Rsu \$(comm -23 <(pacman -Qq | sort) <(sort pkglist.txt))
|
|
|
|
|
|
|
|
# Install AUR packages
|
|
|
|
paru -Sa --fm thunar - <foreign-pkglist.txt
|
|
|
|
|
|
|
|
EOF
|
|
|
|
popd || exit 2
|
|
|
|
}
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_after() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_fail() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_final() {
|
2023-12-03 02:09:46 -05:00
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2023-12-03 06:44:35 -05:00
|
|
|
before) hook_before || exit $?;;
|
|
|
|
after) hook_after || exit $?;;
|
|
|
|
fail) hook_fail || exit $?;;
|
|
|
|
finally) hook_final || exit $?;;
|
2023-12-03 02:09:46 -05:00
|
|
|
esac
|