Bug fixing && switching away from compression

i think i fixed a bug...
This commit is contained in:
FUH22860 2023-01-31 12:15:40 +01:00 committed by GitHub
commit 8ad9f2e816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 53 deletions

View File

@ -1,13 +1,7 @@
# Update # Update
Update script written in bash for Arch. Keeps all your pacman and aur packages as well as your flatpaks up to date with one simple script. It also backups a list of all your pacman/aur pkg's and flatpaks. As well as your fstab and the makepkg.conf to the location that you specify in the config. Update script written in bash for Arch. Keeps all your pacman and aur packages as well as your flatpaks up to date with one simple script. It also backups a list of all your pacman/aur pkg's and flatpaks. As well as your fstab and the makepkg.conf to the location that you specify in the config.
## Dependencies
Needed dependencies
```bash
pacman -S zip
```
## Installation ## Installation
```bash ```bash
@ -27,8 +21,8 @@ Usage: update [OPTION]
options: options:
no flag same as -a no flag same as -a
-f updates using flatpak update only -f updates using flatpak update only
-y updates using an aur-helper only -p updates using a pacman-wrapper only
-a updates using flatpak update and an aur-helper -a updates using flatpak update and a pacman-wrapper
-g shutdowns the computer afterwards (needs to be the last or only option to work properly) -g shutdowns the computer afterwards (needs to be the last or only option to work properly)
-r reboots the computer afterwards (needs to be the last or only option to work properly) -r reboots the computer afterwards (needs to be the last or only option to work properly)
``` ```

View File

@ -1,4 +1,4 @@
VER = "v1.2" VER = "v1.3"
install: install:
@echo "==> Installing update $(VER)..." @echo "==> Installing update $(VER)..."

73
update
View File

@ -1,12 +1,11 @@
#!/bin/bash #!/bin/bash
# updates via an aur-helper and flatpak with flags # updates using a pacman-wrapper and flatpak-update with flags
# version 1.2 # version 1.3
IGreen="\033[0;92m" # Green IGreen="\033[0;92m" # Green
NC="\033[0m" # Text Reset NC="\033[0m" # Text Reset
TMP="/tmp/backup"
DIR="$(pwd)"
source "${HOME}"/.config/update.conf source "${HOME}"/.config/update.conf
@ -17,42 +16,41 @@ Help() {
echo "options:" echo "options:"
echo "no flag same as -a" echo "no flag same as -a"
echo "-f updates using flatpak update only" echo "-f updates using flatpak update only"
echo "-y updates using an aur-helper only" echo "-p updates using a pacman-wrapper only"
echo "-a updates using flatpak update and an aur-helper" echo "-a updates using flatpak update and a pacman-wrapper"
echo "-g shutdowns the computer afterwards (needs to be the last or only option to work properly)" echo "-g shutdowns the computer afterwards (needs to be the last or only option to work properly)"
echo "-r reboots the computer afterwards (needs to be the last or only option to work properly)" echo "-r reboots the computer afterwards (needs to be the last or only option to work properly)"
} }
# creates package lists, moves them into a zip, adds some other files to the zip and backups the pacman database in the form of a tar # creates package lists, moves them into a tar, adds some other files and adds the pacman database
# it then rsyncs the zip and the tar to the backup location # it then rsyncs the tar to the backup location
before_backup() { before_backup() {
pacman -Q > pacman-pre.txt [[ ! -d /tmp/backup ]] && mkdir /tmp/backup
flatpak list > flatpak-pre.txt pacman -Q > "${TMP}"/pacman-pre.txt
zip --quiet --move before-backup.zip.new pacman-pre.txt flatpak-pre.txt flatpak list > "${TMP}"/flatpak-pre.txt
zip --quiet --grow before-backup.zip.new /etc/fstab /etc/makepkg.conf tar -cJf "${TMP}"/before-backup.tar.xz.new "${TMP}"/pacman-pre.txt "${TMP}"/flatpak-pre.txt /var/lib/pacman/local &> /dev/null
tar -cJf pacman-database.tar.xz.new /var/lib/pacman/local &> /dev/null rsync "${TMP}"/before-backup.tar.xz.new "${backup_location}"
rsync --remove-source-files before-backup.zip.new pacman-database.tar.xz.new "${backup_location}" rename before-backup.tar.xz.new before-backup.tar.xz "${backup_location}"/before-backup.tar.xz.new
rename before-backup.zip.new before-backup.zip "${backup_location}"/before-backup.zip.new
rename pacman-database.tar.xz.new pacman-database.tar.xz "${backup_location}"/pacman-database.tar.xz.new
} }
# moves the package lists into a zip, it then rsyncs the zip to the backup location # moves the package lists into a tar, it then rsyncs the tar to the backup location
after_backup() { after_backup() {
zip --quiet --move after-backup.zip.new pacman-after.txt flatpak-after.txt tar -cJf "${TMP}"/after-backup.tar.xz.new "${TMP}"/pacman-after.txt "${TMP}"/flatpak-after.txt &> /dev/null
rsync --remove-source-files after-backup.zip.new "${backup_location}" rsync "${TMP}"/after-backup.tar.xz.new "${backup_location}"
rename after-backup.zip.new after-backup.zip "${backup_location}"/after-backup.zip.new rename after-backup.tar.xz.new after-backup.tar.xz "${backup_location}"/after-backup.tar.xz.new
rm -r /tmp/backup
} }
# updates using aur-helper # updates using a pacman-wrapper
update_with_aur_helper() { update_with_pacman_wrapper() {
"${aur_helper}" "${pacman_wrapper}"
pacman -Q > pacman-after.txt pacman -Q > "${TMP}"/pacman-after.txt
} }
# updates using flatpak update # updates using flatpak-update
update_with_flatpak() { update_with_flatpak() {
flatpak update -u --noninteractive flatpak update -u --noninteractive
flatpak list > flatpak-after.txt flatpak list > "${TMP}"/flatpak-after.txt
} }
[[ $1 = --help ]] && Help && exit 0; [[ $1 = --help ]] && Help && exit 0;
@ -62,28 +60,27 @@ while [ -f /var/lib/pacman/db.lck ]; do {
} }
done done
[[ ! -d /tmp/backup ]] && mkdir /tmp/backup; before_backup && echo -e "${IGreen} pre-backup complete ${NC}"
cd /tmp/backup && before_backup && echo -e "${IGreen} pre-backup complete ${NC}"
[[ -z $1 ]] && update_with_aur_helper && update_with_flatpak; [[ -z $1 ]] && update_with_pacman_wrapper && update_with_flatpak;
while getopts 'fyagr' OPTIONS; do while getopts 'fpagr' OPTIONS; do
case "$OPTIONS" in case "$OPTIONS" in
f) f)
update_with_flatpak ;; update_with_flatpak ;;
y) p)
update_with_aur_helper ;; update_with_pacman_wrapper ;;
a) a)
update_with_aur_helper; update_with_flatpak ;; update_with_pacman_wrapper; update_with_flatpak ;;
g) g)
[[ $1 = -g ]] && update_with_aur_helper && update_with_flatpak; [[ $1 = -g ]] && update_with_pacman_wrapper && update_with_flatpak;
after_backup && cd "${DIR}" || return; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && shutdown now ;; after_backup && echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && shutdown now ;;
r) r)
[[ $1 = -r ]] && update_with_aur_helper && update_with_flatpak; [[ $1 = -r ]] && update_with_pacman_wrapper && update_with_flatpak;
after_backup && cd "${DIR}" || return; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;; after_backup && echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;;
?) ?)
Help Help
exit 1;; exit 1;;
esac esac
done done
after_backup && cd "${DIR}" || return; rm -r /tmp/backup; echo -e "${IGreen} after-backup complete ${NC}" after_backup && echo -e "${IGreen} after-backup complete ${NC}"

View File

@ -1,5 +1,5 @@
# Backup to this folder # Backup to this folder
backup_location=~/ backup_location=~/
# use this aur-helper # use this pacman-wrapper
aur_helper=paru pacman_wrapper=paru