summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schanz2018-01-07 20:34:31 +0100
committerMarkus Schanz2018-01-07 20:36:38 +0100
commit98f0cf1a4fafd827266009d78bf193b690942068 (patch)
tree4bdb25248f4ad82dec44ca5cf9f3558135577bc8
parent766320157ec3499c287e88d48ee02cb6c1e104b6 (diff)
downloadaur-98f0cf1a4fafd827266009d78bf193b690942068.tar.gz
The backup is now performed prior AND after a package upgrade!
-rw-r--r--.SRCINFO16
-rw-r--r--CHANGELOG5
-rw-r--r--PKGBUILD23
-rw-r--r--backup-boot-partition10
-rw-r--r--bootbackup.post.hook13
-rw-r--r--bootbackup.pre.hook (renamed from 50_bootbackup.hook)4
-rw-r--r--pacman-boot-backup.conf7
-rw-r--r--pre-kernel-upgrade-rsync5
-rw-r--r--systemd-boot.hook9
9 files changed, 55 insertions, 37 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 9b1c21e13eae..7f76dc189009 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,19 +1,21 @@
pkgbase = pacman-boot-backup-hook
- pkgdesc = Pacman hook that uses rsync to backup the /boot directory prior to upgrades of the linux or systemd package.
- pkgver = 1.1
+ pkgdesc = Pacman hook that uses rsync to backup the /boot directory prior and post to upgrades of the linux or systemd package.
+ pkgver = 1.2
pkgrel = 1
changelog = CHANGELOG
arch = any
license = custom:MIT
depends = rsync
source = LICENSE
- source = 50_bootbackup.hook
+ source = backup-boot-partition
+ source = bootbackup.post.hook
+ source = bootbackup.pre.hook
source = pacman-boot-backup.conf
- source = pre-kernel-upgrade-rsync
md5sums = ac9ac34b11dd5a53d096a734ab677479
- md5sums = f731f5aee99eecc75d6c0686742d3a23
- md5sums = 27819f1384ade1a543a1c110bf9fc846
- md5sums = 0fdff0b79eb987701a2c54c40910fed0
+ md5sums = 3cd8131ceb4563164ab12cc7b7d61ed6
+ md5sums = 688911051c14693e4a65e043ecb5bde4
+ md5sums = 05868b278d10a4d5b1493d8b33d34139
+ md5sums = c5d37420cddc494cba64930ea54518b1
pkgname = pacman-boot-backup-hook
diff --git a/CHANGELOG b/CHANGELOG
index 3df6196278e1..b3f245aca381 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,10 @@
+v1.2 (2018/01/07):
+- The hook now also creates a backup after the package upgrade
+ The post hook is performed after the 90-linux.hook
+
v1.1 (2018/01/05):
- The location of the data to be backedup (and where to) can now be configured
v1.0 (2017/12/31):
- Initial release
+
diff --git a/PKGBUILD b/PKGBUILD
index 06f1ed3f1584..e116b1c15312 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,21 +1,23 @@
# Maintainer: Markus Schanz <coksnuss@googlemail.com>
pkgname=pacman-boot-backup-hook
-pkgver=1.1
+pkgver=1.2
pkgrel=1
-pkgdesc="Pacman hook that uses rsync to backup the /boot directory prior to upgrades of the linux or systemd package."
+pkgdesc="Pacman hook that uses rsync to backup the /boot directory prior and post to upgrades of the linux or systemd package."
arch=('any')
license=('custom:MIT')
changelog=CHANGELOG
depends=('rsync')
source=('LICENSE'
- '50_bootbackup.hook'
- 'pacman-boot-backup.conf'
- 'pre-kernel-upgrade-rsync')
+ 'backup-boot-partition'
+ 'bootbackup.post.hook'
+ 'bootbackup.pre.hook'
+ 'pacman-boot-backup.conf')
md5sums=('ac9ac34b11dd5a53d096a734ab677479'
- 'f731f5aee99eecc75d6c0686742d3a23'
- '27819f1384ade1a543a1c110bf9fc846'
- '0fdff0b79eb987701a2c54c40910fed0')
+ '3cd8131ceb4563164ab12cc7b7d61ed6'
+ '688911051c14693e4a65e043ecb5bde4'
+ '05868b278d10a4d5b1493d8b33d34139'
+ 'c5d37420cddc494cba64930ea54518b1')
package() {
install -m 0755 -d $pkgdir/usr/share/licenses/$pkgname
@@ -25,8 +27,9 @@ package() {
install -m 0644 $srcdir/pacman-boot-backup.conf $pkgdir/etc
install -m 0755 -d $pkgdir/usr/share/libalpm/hooks
- install -m 0644 $srcdir/50_bootbackup.hook $pkgdir/usr/share/libalpm/hooks
+ install -m 0644 $srcdir/bootbackup.post.hook $pkgdir/usr/share/libalpm/hooks
+ install -m 0644 $srcdir/bootbackup.pre.hook $pkgdir/usr/share/libalpm/hooks
install -m 0755 -d $pkgdir/usr/share/libalpm/scripts
- install -m 0755 $srcdir/pre-kernel-upgrade-rsync $pkgdir/usr/share/libalpm/scripts
+ install -m 0755 $srcdir/backup-boot-partition $pkgdir/usr/share/libalpm/scripts
}
diff --git a/backup-boot-partition b/backup-boot-partition
new file mode 100644
index 000000000000..bd7bf6cf6f86
--- /dev/null
+++ b/backup-boot-partition
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+[[ "$1" != "pre" && "$1" != "post" ]] && exit 1
+[[ -f /etc/pacman-boot-backup.conf ]] && . /etc/pacman-boot-backup.conf
+
+BACKUP_PATH_SRC=$(echo ${BACKUP_PATH_SRC:-/boot} | sed 's#/$##')
+BACKUP_PATH_DEST=$(echo ${BACKUP_PATH_DEST:-/.bootbackup} | sed 's#/$##')/$1
+
+mkdir -p "${BACKUP_PATH_DEST}"
+/usr/bin/rsync -azq --delete "${BACKUP_PATH_SRC}/" "${BACKUP_PATH_DEST}"
diff --git a/bootbackup.post.hook b/bootbackup.post.hook
new file mode 100644
index 000000000000..7d7aebb7e932
--- /dev/null
+++ b/bootbackup.post.hook
@@ -0,0 +1,13 @@
+[Trigger]
+Operation = Install
+Operation = Upgrade
+Operation = Remove
+Type = Package
+Target = linux
+Target = systemd
+
+[Action]
+Description = Backup boot partition...
+When = PostTransaction
+Depends = rsync
+Exec = /usr/share/libalpm/scripts/backup-boot-partition post
diff --git a/50_bootbackup.hook b/bootbackup.pre.hook
index bdc3853b748b..dec38891ace3 100644
--- a/50_bootbackup.hook
+++ b/bootbackup.pre.hook
@@ -7,8 +7,8 @@ Target = linux
Target = systemd
[Action]
-Description = Backing up /boot...
+Description = Backup boot partition...
When = PreTransaction
Depends = rsync
-Exec = /usr/share/libalpm/scripts/pre-kernel-upgrade-rsync
+Exec = /usr/share/libalpm/scripts/backup-boot-partition pre
AbortOnFail
diff --git a/pacman-boot-backup.conf b/pacman-boot-backup.conf
index 869b535979da..4836ecf4adb1 100644
--- a/pacman-boot-backup.conf
+++ b/pacman-boot-backup.conf
@@ -4,10 +4,9 @@
# backups are created/stored when the linux or systemd package is upgraded.
# By default the contents of /boot will be backed up to /.bootbackup
#
-# Note: The values of the variables will be passed to rsync. Therefore, if you
-# wish to only backup the files _within_ the source directory, make sure to
-# append a slash to its path.
-# WARNING: Any contents under the destination path will be deleted by rsync!
+# Note: The script creates two subdirectories "pre" and "post" within the
+# destination path. These directories will contain the backup of the source
+# directory prior and after the package upgrade, respectively.
#BACKUP_PATH_SRC=/boot/
#BACKUP_PATH_DEST=/.bootbackup
diff --git a/pre-kernel-upgrade-rsync b/pre-kernel-upgrade-rsync
deleted file mode 100644
index a7452894e047..000000000000
--- a/pre-kernel-upgrade-rsync
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-[[ -f /etc/pacman-boot-backup.conf ]] && . /etc/pacman-boot-backup.conf
-
-/usr/bin/rsync -azq --delete "${BACKUP_PATH_SRC:-/boot/}" "${BACKUP_PATH_DEST:-/.bootbackup}"
diff --git a/systemd-boot.hook b/systemd-boot.hook
deleted file mode 100644
index 4c3dbab6de17..000000000000
--- a/systemd-boot.hook
+++ /dev/null
@@ -1,9 +0,0 @@
-[Trigger]
-Type = Package
-Operation = Upgrade
-Target = systemd
-
-[Action]
-Description = Upgrading systemd-boot...
-When = PostTransaction
-Exec = /usr/bin/bootctl update