diff --git a/repo/pacman-boot-backup-hook/50_bootbackup.hook b/repo/pacman-boot-backup-hook/50_bootbackup.hook new file mode 100644 index 0000000..6f43549 --- /dev/null +++ b/repo/pacman-boot-backup-hook/50_bootbackup.hook @@ -0,0 +1,20 @@ +[Trigger] +Type = Package +Operation = Install +Operation = Upgrade +Operation = Remove +Target = systemd + +[Trigger] +Type = Path +Operation = Install +Operation = Upgrade +Target = boot/vmlinuz-* +Target = usr/lib/modules/*/vmlinuz +Target = usr/lib/initcpio/* + +[Action] +Description = Backup boot partition... +When = PreTransaction +Exec = /usr/share/libalpm/scripts/backup-boot-partition pre +AbortOnFail diff --git a/repo/pacman-boot-backup-hook/CHANGELOG b/repo/pacman-boot-backup-hook/CHANGELOG new file mode 100644 index 0000000..13f7b95 --- /dev/null +++ b/repo/pacman-boot-backup-hook/CHANGELOG @@ -0,0 +1,32 @@ +v1.7 (2023/10/21): +- Introduce compatibility for users that have installed kernels other than the default linux kernel +- Removed install script which was merely used to notify users about a breaking change that was introduced 5 years ago in v1.4 + - removed ncurses dependency alongside with it + +v1.6 (2023/07/12): +- ncurses is a runtime dependency because `tput` is used in the .install script +- the config file is now listed in the `backup` PKGBUILD array to respect the user configuration on package upgrades + +v1.5 (2020/09/20): +- rsync is no longer a dependency of this package. + - The previous version only stopped using it, without removing it as a dependency. + +v1.4 (2018/08/01): +- Simplified package by dropping rsync dependency + - cp is now used in favor of rsync +- Removed possibility to customize backup source directory (always backup /boot) + +v1.3 (2018/01/14): +- The hook trigger has been modified to match that of 90-linux.hook +- The hook names were changed in order to execute not too early/late + - In particular, execution order now plays nicely together with systemd-boot-pacman-hook AUR package + +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/repo/pacman-boot-backup-hook/LICENSE b/repo/pacman-boot-backup-hook/LICENSE new file mode 100644 index 0000000..34bcf64 --- /dev/null +++ b/repo/pacman-boot-backup-hook/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Markus Schanz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/repo/pacman-boot-backup-hook/PKGBUILD b/repo/pacman-boot-backup-hook/PKGBUILD new file mode 100644 index 0000000..8c8bc18 --- /dev/null +++ b/repo/pacman-boot-backup-hook/PKGBUILD @@ -0,0 +1,35 @@ +# Maintainer: Markus Schanz +pkgname=pacman-boot-backup-hook +pkgver=1.7 +pkgrel=1 +pkgdesc="Pacman hook that creates a copy of the /boot directory prior and post to upgrades of the systemd package or when mkinitcpio is triggered." +arch=('any') +backup=(etc/pacman-boot-backup.conf) +license=('MIT') +changelog=CHANGELOG + +source=('LICENSE' + 'backup-boot-partition' + '50_bootbackup.hook' + 'uu_bootbackup.hook' + 'pacman-boot-backup.conf') +sha256sums=('c70e605b0f57a2e4a20f76ff77935cb3bfce4adcf8b654aba4ef4e5103b431f2' + '2445f388b4bc94382d25e01175babc804821090706d9ac69b5fadfbf5c60d5a9' + 'bfdb5d9f83f1cd9d9a427cb302883b4ddfa53e4e39e45c3006066baf5b84ce81' + 'a4b17a1dddaa6516258431fa67ecf236a128d3c7d640598423e13b2404e14e31' + '1cefb346964c3aa4db829bffa788c39839f7a0959f294c91cdb43ae591c8472d') + +package() { + install -m 0755 -d $pkgdir/usr/share/licenses/$pkgname + install -m 0644 $srcdir/LICENSE $pkgdir/usr/share/licenses/$pkgname + + install -m 0755 -d $pkgdir/etc + 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/uu_bootbackup.hook $pkgdir/usr/share/libalpm/hooks + + install -m 0755 -d $pkgdir/usr/share/libalpm/scripts + install -m 0755 $srcdir/backup-boot-partition $pkgdir/usr/share/libalpm/scripts +} diff --git a/repo/pacman-boot-backup-hook/backup-boot-partition b/repo/pacman-boot-backup-hook/backup-boot-partition new file mode 100644 index 0000000..958ae82 --- /dev/null +++ b/repo/pacman-boot-backup-hook/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_DEST=${BACKUP_PATH_DEST:-/.bootbackup}/$1 + +rm -rf "${BACKUP_PATH_DEST}" +mkdir -p "${BACKUP_PATH_DEST}" +cp -aT /boot "${BACKUP_PATH_DEST}" diff --git a/repo/pacman-boot-backup-hook/pacman-boot-backup.conf b/repo/pacman-boot-backup-hook/pacman-boot-backup.conf new file mode 100644 index 0000000..9cacd3e --- /dev/null +++ b/repo/pacman-boot-backup-hook/pacman-boot-backup.conf @@ -0,0 +1,11 @@ +# Configuration of pacman-boot-backup-hook +# +# Use this configuration to override the default directories from/to which +# 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 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_DEST=/.bootbackup diff --git a/repo/pacman-boot-backup-hook/uu_bootbackup.hook b/repo/pacman-boot-backup-hook/uu_bootbackup.hook new file mode 100644 index 0000000..292f0be --- /dev/null +++ b/repo/pacman-boot-backup-hook/uu_bootbackup.hook @@ -0,0 +1,19 @@ +[Trigger] +Type = Package +Operation = Install +Operation = Upgrade +Operation = Remove +Target = systemd + +[Trigger] +Type = Path +Operation = Install +Operation = Upgrade +Target = boot/vmlinuz-* +Target = usr/lib/modules/*/vmlinuz +Target = usr/lib/initcpio/* + +[Action] +Description = Backup boot partition... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/backup-boot-partition post