From bce6b16f954fe00453d768476d1226a8e3d148d9 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Thu, 18 Mar 2021 22:38:16 +0100 Subject: [PATCH 1/3] 10-linux-modules-pre.hook: consistent sh -x usage --- 10-linux-modules-pre.hook | 2 +- PKGBUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/10-linux-modules-pre.hook b/10-linux-modules-pre.hook index 34e7221..916b84d 100644 --- a/10-linux-modules-pre.hook +++ b/10-linux-modules-pre.hook @@ -8,4 +8,4 @@ Target = usr/lib/modules/*/vmlinuz Description = Saving Linux kernel modules... When = PreTransaction Depends = rsync -Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/usr/lib/modules/${KVER}" /usr/lib/modules/backup/; fi' +Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/usr/lib/modules/${KVER}" /usr/lib/modules/backup/; fi' diff --git a/PKGBUILD b/PKGBUILD index 8ffb97b..60ecce4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -17,7 +17,7 @@ source=("linux-modules-cleanup.conf" sha256sums=('4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf' '5d947290ef8c94b33c79c531e5615f4c9bea38e7649092d34af3bf0af5b1ca24' '900502d030e925fca6188b9448fbaf6562d6e23cd5c50938cdf00522825f76c2' - 'f7ea2947c3fbe1510b3ea5cc5793b8197f0718dcb12daea3da9b27b3cf1c4116' + '6af04ba07098792c22a60416aba6f6c148cd200f6edadbe8751b6183adcfcf74' '7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c') package() { From f22c812af56a735299cc9fcf4a1c8ede53a7f797 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Thu, 18 Mar 2021 23:04:13 +0100 Subject: [PATCH 2/3] *.hook: use cp(1)'s capabilities to use hardlinks instead of rsync(1) `cp -ral` is 10x faster than `rsync -AHXal` --- .SRCINFO | 7 +++---- 10-linux-modules-post.hook | 3 +-- 10-linux-modules-pre.hook | 4 ++-- PKGBUILD | 7 +++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index fe5355d..ca0bb0d 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,12 +1,11 @@ pkgbase = kernel-modules-hook pkgdesc = Keeps your system fully functional after a kernel upgrade - pkgver = 0.1.7 + pkgver = 0.1.8 pkgrel = 1 url = https://github.com/saber-nyan/kernel-modules-hook install = kernel-modules-hook.install arch = any license = UNLICENSE - depends = rsync source = linux-modules-cleanup.conf source = linux-modules-cleanup.service source = 10-linux-modules-post.hook @@ -14,8 +13,8 @@ pkgbase = kernel-modules-hook source = UNLICENSE sha256sums = 4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf sha256sums = 5d947290ef8c94b33c79c531e5615f4c9bea38e7649092d34af3bf0af5b1ca24 - sha256sums = 900502d030e925fca6188b9448fbaf6562d6e23cd5c50938cdf00522825f76c2 - sha256sums = f7ea2947c3fbe1510b3ea5cc5793b8197f0718dcb12daea3da9b27b3cf1c4116 + sha256sums = 3b90321be042ea728e27bef530aeb22cecc4cd0aeda625ab4a72fb46dae3abee + sha256sums = dc99191391b847deecf81abded84b03eb832ca1b36e56a4a4deec8bf1332f051 sha256sums = 7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c pkgname = kernel-modules-hook diff --git a/10-linux-modules-post.hook b/10-linux-modules-post.hook index 55174ac..09f93a9 100644 --- a/10-linux-modules-post.hook +++ b/10-linux-modules-post.hook @@ -8,5 +8,4 @@ Target = usr/lib/modules/*/vmlinuz Description = Restoring Linux kernel modules... When = PostTransaction Depends = coreutils -Depends = rsync -Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/usr/lib/modules/backup/${KVER}" /usr/lib/modules/; fi; rm -rf /usr/lib/modules/backup' +Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/backup/${KVER}"; then cp -ral "/usr/lib/modules/backup/${KVER}" /usr/lib/modules/; fi; rm -rf /usr/lib/modules/backup' diff --git a/10-linux-modules-pre.hook b/10-linux-modules-pre.hook index 916b84d..ea9d17d 100644 --- a/10-linux-modules-pre.hook +++ b/10-linux-modules-pre.hook @@ -7,5 +7,5 @@ Target = usr/lib/modules/*/vmlinuz [Action] Description = Saving Linux kernel modules... When = PreTransaction -Depends = rsync -Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/usr/lib/modules/${KVER}" /usr/lib/modules/backup/; fi' +Depends = coreutils +Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/usr/lib/modules/${KVER}"; then mkdir -p /usr/lib/modules/backup; cp -ral "/usr/lib/modules/${KVER}" /usr/lib/modules/backup; fi' diff --git a/PKGBUILD b/PKGBUILD index 60ecce4..e7280ad 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,13 +1,12 @@ # Maintainer: Artoria Pendragon # Hooks: https://www.reddit.com/r/archlinux/comments/4zrsc3/keep_your_system_fully_functional_after_a_kernel/d6yin0r/ pkgname=kernel-modules-hook -pkgver=0.1.7 +pkgver=0.1.8 pkgrel=1 pkgdesc="Keeps your system fully functional after a kernel upgrade" arch=('any') url="https://github.com/saber-nyan/kernel-modules-hook" license=('UNLICENSE') -depends=('rsync') install="${pkgname}.install" source=("linux-modules-cleanup.conf" "linux-modules-cleanup.service" @@ -16,8 +15,8 @@ source=("linux-modules-cleanup.conf" "UNLICENSE") sha256sums=('4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf' '5d947290ef8c94b33c79c531e5615f4c9bea38e7649092d34af3bf0af5b1ca24' - '900502d030e925fca6188b9448fbaf6562d6e23cd5c50938cdf00522825f76c2' - '6af04ba07098792c22a60416aba6f6c148cd200f6edadbe8751b6183adcfcf74' + '3b90321be042ea728e27bef530aeb22cecc4cd0aeda625ab4a72fb46dae3abee' + 'dc99191391b847deecf81abded84b03eb832ca1b36e56a4a4deec8bf1332f051' '7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c') package() { From f32e6af98791647ced421bffcade4795ffd5d1ec Mon Sep 17 00:00:00 2001 From: Moviuro Date: Fri, 19 Mar 2021 08:16:16 +0100 Subject: [PATCH 3/3] *.service: use mv(1) instead of rsync Again, this is much faster. --- .SRCINFO | 2 +- PKGBUILD | 2 +- linux-modules-cleanup.service | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index ca0bb0d..17397ee 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -12,7 +12,7 @@ pkgbase = kernel-modules-hook source = 10-linux-modules-pre.hook source = UNLICENSE sha256sums = 4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf - sha256sums = 5d947290ef8c94b33c79c531e5615f4c9bea38e7649092d34af3bf0af5b1ca24 + sha256sums = f8d3ee1fc95f9a6c754aed063cfb5d3b0d6dbd35eb5c310988881e16cf665345 sha256sums = 3b90321be042ea728e27bef530aeb22cecc4cd0aeda625ab4a72fb46dae3abee sha256sums = dc99191391b847deecf81abded84b03eb832ca1b36e56a4a4deec8bf1332f051 sha256sums = 7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c diff --git a/PKGBUILD b/PKGBUILD index e7280ad..d77cbb7 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -14,7 +14,7 @@ source=("linux-modules-cleanup.conf" "10-linux-modules-pre.hook" "UNLICENSE") sha256sums=('4169b44c297ddb7aad2220c6eba7c7942e3396f92528c59617955ab5560cb4cf' - '5d947290ef8c94b33c79c531e5615f4c9bea38e7649092d34af3bf0af5b1ca24' + 'f8d3ee1fc95f9a6c754aed063cfb5d3b0d6dbd35eb5c310988881e16cf665345' '3b90321be042ea728e27bef530aeb22cecc4cd0aeda625ab4a72fb46dae3abee' 'dc99191391b847deecf81abded84b03eb832ca1b36e56a4a4deec8bf1332f051' '7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c') diff --git a/linux-modules-cleanup.service b/linux-modules-cleanup.service index 35a60dc..8bc75d8 100644 --- a/linux-modules-cleanup.service +++ b/linux-modules-cleanup.service @@ -3,7 +3,7 @@ Description=Clean up modules from old kernels [Service] Type=oneshot -ExecStart=/bin/bash -exc 'for i in /usr/lib/modules/[0-9]*; do if [[ $${i##*/} = \'%v\' ]] || pacman -Qo "$${i}"; then continue; fi; rsync -AHXal "$${i}" /usr/lib/modules/.old/; rm -rf "$${i}"; done' +ExecStart=/bin/bash -exc 'for i in /usr/lib/modules/[0-9]*; do if [[ $${i##*/} = \'%v\' ]] || pacman -Qo "$${i}"; then continue; fi; mkdir -p /usr/lib/modules/.old; mv "$${i}" /usr/lib/modules/.old/; done' [Install] WantedBy=basic.target