From f0f7c029f3accd89eeb1193f2bead049bc7d26bf Mon Sep 17 00:00:00 2001 From: Tk-Glitch Date: Fri, 1 May 2020 00:22:00 +0200 Subject: [PATCH] Add a simple post transaction hook to clean remnant dir/files Since the move to the new hooking mechanisms, we got remnant files after package upgrade. They aren't part of the package and get generated by the depmod hook. This addresses the issue by checking for tkg kernels module dirs and removing the ones missing a vmlinuz file (which is part of the package). Due to the way it works, it'll also get rid of all past remnants to stay transparent for users. --- linux54-tkg/PKGBUILD | 12 +++++++++++- linux54-tkg/linux54-tkg-config/90-cleanup.hook | 14 ++++++++++++++ linux54-tkg/linux54-tkg-config/cleanup | 10 ++++++++++ linux55-tkg/PKGBUILD | 12 +++++++++++- linux55-tkg/linux55-tkg-config/90-cleanup.hook | 14 ++++++++++++++ linux55-tkg/linux55-tkg-config/cleanup | 10 ++++++++++ linux56-tkg/PKGBUILD | 12 +++++++++++- linux56-tkg/linux56-tkg-config/90-cleanup.hook | 14 ++++++++++++++ linux56-tkg/linux56-tkg-config/cleanup | 10 ++++++++++ linux57-rc-tkg/PKGBUILD | 10 ++++++++++ linux57-rc-tkg/linux57-tkg-config/90-cleanup.hook | 14 ++++++++++++++ linux57-rc-tkg/linux57-tkg-config/cleanup | 10 ++++++++++ 12 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 linux54-tkg/linux54-tkg-config/90-cleanup.hook create mode 100755 linux54-tkg/linux54-tkg-config/cleanup create mode 100644 linux55-tkg/linux55-tkg-config/90-cleanup.hook create mode 100755 linux55-tkg/linux55-tkg-config/cleanup create mode 100644 linux56-tkg/linux56-tkg-config/90-cleanup.hook create mode 100755 linux56-tkg/linux56-tkg-config/cleanup create mode 100644 linux57-rc-tkg/linux57-tkg-config/90-cleanup.hook create mode 100755 linux57-rc-tkg/linux57-tkg-config/cleanup diff --git a/linux54-tkg/PKGBUILD b/linux54-tkg/PKGBUILD index 03f0391..41866fc 100644 --- a/linux54-tkg/PKGBUILD +++ b/linux54-tkg/PKGBUILD @@ -89,7 +89,7 @@ pkgname=("${pkgbase}" "${pkgbase}-headers") _basekernel=5.4 _sub=35 pkgver="${_basekernel}"."${_sub}" -pkgrel=49 +pkgrel=50 pkgdesc='Linux-tkg' arch=('x86_64') # no i686 in here url="http://www.kernel.org/" @@ -101,6 +101,8 @@ source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.x "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" 'config.x86_64' # stock Arch config 'config_hardened.x86_64' # hardened Arch config + 90-cleanup.hook + cleanup # ARCH Patches 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # TkG @@ -125,6 +127,8 @@ sha256sums=('bf338980b1670bca287f9994b7441c2361907635879169c64ae78364efc5f491' '7fda2ef7e81faa2ea7e4e1a4d73c0ffcdcc259a1345b9248bddde68b1c06af4f' 'b7f23bbc09b6c571b76f851f0389386a6f3a64f3d7b1b8509c8550228b0f4537' '1f4a20d6eaaa0d969af93152a65191492400c6aa838fc1c290b0dd29bb6019d8' + '1e15fc2ef3fa770217ecc63a220e5df2ddbcf3295eb4a021171e7edd4c6cc898' + '66a03c246037451a77b4d448565b1d7e9368270c7d02872fbd0b5d024ed0a997' '31dc68e84aecfb7d069efb1305049122c65694676be8b955634abcf0675922a2' 'd02bf5ca08fd610394b9d3a0c3b176d74af206f897dee826e5cbaec97bb4a4aa' '55db7c30c6d5e7d88cf38a4c757e447faf11a7440afbc081c3da12757073cca7' @@ -893,6 +897,10 @@ hackbase() { # remove build and source links rm "$modulesdir"/{source,build} + # install cleanup pacman hook and script + install -Dm644 "${srcdir}"/90-cleanup.hook "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" + install -Dm755 "${srcdir}"/cleanup "${pkgdir}/usr/share/libalpm/scripts/cleanup" + msg2 "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } @@ -998,6 +1006,8 @@ function exit_cleanup { rm -rf "$_where"/*.patch rm -rf "$_where"/*-profile.cfg rm -f "$_where"/config* + rm -f "$_where"/*.hook + rm -f "$_where"/cleanup # Community patches removal in case of failure for _p in ${_community_patches[@]}; do diff --git a/linux54-tkg/linux54-tkg-config/90-cleanup.hook b/linux54-tkg/linux54-tkg-config/90-cleanup.hook new file mode 100644 index 0000000..99f5221 --- /dev/null +++ b/linux54-tkg/linux54-tkg-config/90-cleanup.hook @@ -0,0 +1,14 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Operation = Remove +Target = usr/lib/modules/*/ +Target = !usr/lib/modules/*/?* + +[Action] +Description = Cleaning up... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/cleanup +NeedsTargets + diff --git a/linux54-tkg/linux54-tkg-config/cleanup b/linux54-tkg/linux54-tkg-config/cleanup new file mode 100755 index 0000000..c00c08d --- /dev/null +++ b/linux54-tkg/linux54-tkg-config/cleanup @@ -0,0 +1,10 @@ +#!/bin/bash + +for _f in /usr/lib/modules/*tkg*; do + if [[ ! -e ${_f}/vmlinuz ]]; then + rm -rf "$_f" + fi +done + +# vim:set ft=sh sw=2 et: + diff --git a/linux55-tkg/PKGBUILD b/linux55-tkg/PKGBUILD index 85b1e7c..b7bcf28 100644 --- a/linux55-tkg/PKGBUILD +++ b/linux55-tkg/PKGBUILD @@ -89,7 +89,7 @@ pkgname=("${pkgbase}" "${pkgbase}-headers") _basekernel=5.5 _sub=19 pkgver="${_basekernel}"."${_sub}" -pkgrel=34 +pkgrel=35 pkgdesc='Linux-tkg' arch=('x86_64') # no i686 in here url="http://www.kernel.org/" @@ -101,6 +101,8 @@ source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.x "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" 'config.x86_64' # stock Arch config #'config_hardened.x86_64' # hardened Arch config + 90-cleanup.hook + cleanup # ARCH Patches 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # TkG @@ -125,6 +127,8 @@ source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.x sha256sums=('a6fbd4ee903c128367892c2393ee0d9657b6ed3ea90016d4dc6f1f6da20b2330' '87648336978813d429eb334a34a9c84af2806062f8d9feb10ee324cad48c4c5c' '0b414b6974b732cfb71b6f45b6210d127528aa6452132e9b9338719ac021bf06' + '1e15fc2ef3fa770217ecc63a220e5df2ddbcf3295eb4a021171e7edd4c6cc898' + '66a03c246037451a77b4d448565b1d7e9368270c7d02872fbd0b5d024ed0a997' '31dc68e84aecfb7d069efb1305049122c65694676be8b955634abcf0675922a2' 'd02bf5ca08fd610394b9d3a0c3b176d74af206f897dee826e5cbaec97bb4a4aa' '8fa175556f5339bae1f2e4f30def3ed3b8568fbec54f6ac670f54522ffd41145' @@ -945,6 +949,10 @@ hackbase() { # remove build and source links rm "$modulesdir"/{source,build} + # install cleanup pacman hook and script + install -Dm644 "${srcdir}"/90-cleanup.hook "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" + install -Dm755 "${srcdir}"/cleanup "${pkgdir}/usr/share/libalpm/scripts/cleanup" + msg2 "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } @@ -1050,6 +1058,8 @@ function exit_cleanup { rm -rf "$_where"/*.patch rm -rf "$_where"/*-profile.cfg rm -f "$_where"/config* + rm -f "$_where"/*.hook + rm -f "$_where"/cleanup # Community patches removal in case of failure for _p in ${_community_patches[@]}; do diff --git a/linux55-tkg/linux55-tkg-config/90-cleanup.hook b/linux55-tkg/linux55-tkg-config/90-cleanup.hook new file mode 100644 index 0000000..99f5221 --- /dev/null +++ b/linux55-tkg/linux55-tkg-config/90-cleanup.hook @@ -0,0 +1,14 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Operation = Remove +Target = usr/lib/modules/*/ +Target = !usr/lib/modules/*/?* + +[Action] +Description = Cleaning up... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/cleanup +NeedsTargets + diff --git a/linux55-tkg/linux55-tkg-config/cleanup b/linux55-tkg/linux55-tkg-config/cleanup new file mode 100755 index 0000000..c00c08d --- /dev/null +++ b/linux55-tkg/linux55-tkg-config/cleanup @@ -0,0 +1,10 @@ +#!/bin/bash + +for _f in /usr/lib/modules/*tkg*; do + if [[ ! -e ${_f}/vmlinuz ]]; then + rm -rf "$_f" + fi +done + +# vim:set ft=sh sw=2 et: + diff --git a/linux56-tkg/PKGBUILD b/linux56-tkg/PKGBUILD index 9b653d8..9117b80 100644 --- a/linux56-tkg/PKGBUILD +++ b/linux56-tkg/PKGBUILD @@ -89,7 +89,7 @@ pkgname=("${pkgbase}" "${pkgbase}-headers") _basekernel=5.6 _sub=8 pkgver="${_basekernel}"."${_sub}" -pkgrel=17 +pkgrel=18 pkgdesc='Linux-tkg' arch=('x86_64') # no i686 in here url="http://www.kernel.org/" @@ -101,6 +101,8 @@ source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.x "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" 'config.x86_64' # stock Arch config - https://www.archlinux.org/packages/core/x86_64/linux/ 'config_hardened.x86_64' # hardened Arch config - https://www.archlinux.org/packages/extra/x86_64/linux-hardened/ + 90-cleanup.hook + cleanup # ARCH Patches 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # TkG @@ -127,6 +129,8 @@ sha256sums=('e342b04a2aa63808ea0ef1baab28fc520bd031ef8cf93d9ee4a31d4058fcb622' '762e16040b6eaa69739cf1cfeb8b30813d481ae6bea98d97bb80239cd43c7882' '6ac452e2124f92747a57c5a50e11ca2f1e8112669845b4431311545c7fd2a36c' '116c8bee112e4bbf65fb7ef4770a24ed8e4d17dbb9d6d7911fa7b8cf13c1b086' + '1e15fc2ef3fa770217ecc63a220e5df2ddbcf3295eb4a021171e7edd4c6cc898' + '66a03c246037451a77b4d448565b1d7e9368270c7d02872fbd0b5d024ed0a997' '31dc68e84aecfb7d069efb1305049122c65694676be8b955634abcf0675922a2' 'd02bf5ca08fd610394b9d3a0c3b176d74af206f897dee826e5cbaec97bb4a4aa' '3a8936db7a311753e2d75650819d69366cc013008379380f11fcea092eabf92f' @@ -954,6 +958,10 @@ hackbase() { # remove build and source links rm "$modulesdir"/{source,build} + # install cleanup pacman hook and script + install -Dm644 "${srcdir}"/90-cleanup.hook "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" + install -Dm755 "${srcdir}"/cleanup "${pkgdir}/usr/share/libalpm/scripts/cleanup" + msg2 "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } @@ -1059,6 +1067,8 @@ function exit_cleanup { rm -rf "$_where"/*.patch rm -rf "$_where"/*-profile.cfg rm -f "$_where"/config* + rm -f "$_where"/*.hook + rm -f "$_where"/cleanup # Community patches removal in case of failure for _p in ${_community_patches[@]}; do diff --git a/linux56-tkg/linux56-tkg-config/90-cleanup.hook b/linux56-tkg/linux56-tkg-config/90-cleanup.hook new file mode 100644 index 0000000..99f5221 --- /dev/null +++ b/linux56-tkg/linux56-tkg-config/90-cleanup.hook @@ -0,0 +1,14 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Operation = Remove +Target = usr/lib/modules/*/ +Target = !usr/lib/modules/*/?* + +[Action] +Description = Cleaning up... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/cleanup +NeedsTargets + diff --git a/linux56-tkg/linux56-tkg-config/cleanup b/linux56-tkg/linux56-tkg-config/cleanup new file mode 100755 index 0000000..c00c08d --- /dev/null +++ b/linux56-tkg/linux56-tkg-config/cleanup @@ -0,0 +1,10 @@ +#!/bin/bash + +for _f in /usr/lib/modules/*tkg*; do + if [[ ! -e ${_f}/vmlinuz ]]; then + rm -rf "$_f" + fi +done + +# vim:set ft=sh sw=2 et: + diff --git a/linux57-rc-tkg/PKGBUILD b/linux57-rc-tkg/PKGBUILD index 6f20fee..d108aa5 100644 --- a/linux57-rc-tkg/PKGBUILD +++ b/linux57-rc-tkg/PKGBUILD @@ -96,6 +96,8 @@ options=('!strip') source=("https://git.kernel.org/torvalds/t/linux-${_basekernel}-${_sub}.tar.gz" 'config.x86_64' # stock Arch config #'config_hardened.x86_64' # hardened Arch config + 90-cleanup.hook + cleanup # ARCH Patches 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch # TkG @@ -120,6 +122,8 @@ source=("https://git.kernel.org/torvalds/t/linux-${_basekernel}-${_sub}.tar.gz" ) sha256sums=('861dec2280e325d7bdc1d21278df4c8c5c3aa01cb825e5062da85ff17f5b043f' '0352c5ef2030d6bbdeae2325454d20575339917411c646004e5c7b7b5794db60' + '1e15fc2ef3fa770217ecc63a220e5df2ddbcf3295eb4a021171e7edd4c6cc898' + '66a03c246037451a77b4d448565b1d7e9368270c7d02872fbd0b5d024ed0a997' '31dc68e84aecfb7d069efb1305049122c65694676be8b955634abcf0675922a2' 'd02bf5ca08fd610394b9d3a0c3b176d74af206f897dee826e5cbaec97bb4a4aa' '4604141e95f3b30bbfac6a27bd642c5e1b616ee1292107c9cb9ebe76f261230e' @@ -945,6 +949,10 @@ hackbase() { # remove build and source links rm "$modulesdir"/{source,build} + # install cleanup pacman hook and script + install -Dm644 "${srcdir}"/90-cleanup.hook "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook" + install -Dm755 "${srcdir}"/cleanup "${pkgdir}/usr/share/libalpm/scripts/cleanup" + msg2 "Fixing permissions..." chmod -Rc u=rwX,go=rX "$pkgdir" } @@ -1050,6 +1058,8 @@ function exit_cleanup { rm -rf "$_where"/*.patch rm -rf "$_where"/*-profile.cfg rm -f "$_where"/config* + rm -f "$_where"/*.hook + rm -f "$_where"/cleanup # Community patches removal in case of failure for _p in ${_community_patches[@]}; do diff --git a/linux57-rc-tkg/linux57-tkg-config/90-cleanup.hook b/linux57-rc-tkg/linux57-tkg-config/90-cleanup.hook new file mode 100644 index 0000000..99f5221 --- /dev/null +++ b/linux57-rc-tkg/linux57-tkg-config/90-cleanup.hook @@ -0,0 +1,14 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Operation = Remove +Target = usr/lib/modules/*/ +Target = !usr/lib/modules/*/?* + +[Action] +Description = Cleaning up... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/cleanup +NeedsTargets + diff --git a/linux57-rc-tkg/linux57-tkg-config/cleanup b/linux57-rc-tkg/linux57-tkg-config/cleanup new file mode 100755 index 0000000..c00c08d --- /dev/null +++ b/linux57-rc-tkg/linux57-tkg-config/cleanup @@ -0,0 +1,10 @@ +#!/bin/bash + +for _f in /usr/lib/modules/*tkg*; do + if [[ ! -e ${_f}/vmlinuz ]]; then + rm -rf "$_f" + fi +done + +# vim:set ft=sh sw=2 et: +