From 0c6d4c7ab6ae34a972dfbf5ec6736be17a2719b2 Mon Sep 17 00:00:00 2001 From: Jan Alexander Steffens Date: Thu, 17 Nov 2016 15:27:34 +0000 Subject: [PATCH] overhaul sed'ding --- 80-linux.hook | 6 +++--- PKGBUILD | 23 ++++++++--------------- linux.install | 14 ++++---------- linux.preset | 6 +++--- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/80-linux.hook b/80-linux.hook index a32248e..9851151 100644 --- a/80-linux.hook +++ b/80-linux.hook @@ -2,10 +2,10 @@ Type = File Operation = Install Operation = Upgrade -Target = boot/vmlinuz-linux +Target = boot/vmlinuz-%PKGBASE% Target = usr/lib/initcpio/* [Action] -Description = Updating Arch Linux initramfs image +Description = Updating %PKGBASE% initcpios When = PostTransaction -Exec = /usr/bin/mkinitcpio -p linux +Exec = /usr/bin/mkinitcpio -p %PKGBASE% diff --git a/PKGBUILD b/PKGBUILD index a3e1bf2..bf1ce82 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -31,8 +31,8 @@ sha256sums=('3e9150065f193d3d94bcf46a1fe9f033c7ef7122ab71d75a7fb5a2f0c9a7e11a' 'SKIP' '2ac8818414beb7dbacbd3ad450c516e6ada804827132a7132f63b8189e5f5151' '93a4ad4f6c7bb9296fddec436ed7477a5a5c11cf4d6e68482fa6610442cbcb1f' - '2d4424928ae3c5f63ee618b4685580f4bd24faf1778553dbd961f85a88ea0910' - 'f0d90e756f14533ee67afda280500511a62465b4f76adcc5effa95a40045179c' + '834bd254b56ab71d73f59b3221f056c72f559553c04718e350ab2a3e2991afe0' + 'a8cae3381e5669a70e20e36562d7433f61b13d24ad8c688cf6c398d5128e2c02' '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99') validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds @@ -115,24 +115,17 @@ _package() { cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}" # set correct depmod command for install - cp -f "${startdir}/${install}" "${startdir}/${install}.pkg" + sed -e "s|%PKGBASE%|${pkgbase}|g;s|%KERNVER%|${_kernver}|g" \ + "${startdir}/${install}" > "${startdir}/${install}.pkg" true && install=${install}.pkg - sed \ - -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \ - -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \ - -i "${startdir}/${install}" # install mkinitcpio preset file for kernel - install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset" - sed \ - -e "1s|'linux.*'|'${pkgbase}'|" \ - -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgbase}\"|" \ - -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgbase}.img\"|" \ - -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgbase}-fallback.img\"|" \ - -i "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset" + sed "s|%PKGBASE%|${pkgbase}|g" "${srcdir}/linux.preset" | + install -D -m644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset" # install pacman hook for initramfs regeneration - install -D -m644 "${srcdir}/80-linux.hook" "${pkgdir}/usr/share/libalpm/hooks/80-linux.hook" + sed "s|%PKGBASE%|${pkgbase}|g" "${srcdir}/80-linux.hook" | + install -D -m644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/80-${pkgbase}.hook" # remove build and source links rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build} diff --git a/linux.install b/linux.install index 15dc8b6..0462775 100644 --- a/linux.install +++ b/linux.install @@ -1,13 +1,7 @@ -# arg 1: the new package version -# arg 2: the old package version - -KERNEL_NAME= -KERNEL_VERSION= - post_install () { # updating module dependencies echo ">>> Updating module dependencies. Please wait ..." - depmod ${KERNEL_VERSION} + depmod %KERNVER% } post_upgrade() { @@ -17,7 +11,7 @@ post_upgrade() { # updating module dependencies echo ">>> Updating module dependencies. Please wait ..." - depmod ${KERNEL_VERSION} + depmod %KERNVER% if [ $(vercmp $2 3.13) -lt 0 ]; then echo ">>> WARNING: AT keyboard support is no longer built into the kernel." @@ -28,6 +22,6 @@ post_upgrade() { post_remove() { # also remove the compat symlinks - rm -f boot/initramfs-linux${KERNEL_NAME}.img - rm -f boot/initramfs-linux${KERNEL_NAME}-fallback.img + rm -f boot/initramfs-%PKGBASE%.img + rm -f boot/initramfs-%PKGBASE%-fallback.img } diff --git a/linux.preset b/linux.preset index b06292d..09e7952 100644 --- a/linux.preset +++ b/linux.preset @@ -1,14 +1,14 @@ # mkinitcpio preset file for the 'linux' package ALL_config="/etc/mkinitcpio.conf" -ALL_kver="/boot/vmlinuz-linux" +ALL_kver="/boot/vmlinuz-%PKGBASE%" PRESETS=('default' 'fallback') #default_config="/etc/mkinitcpio.conf" -default_image="/boot/initramfs-linux.img" +default_image="/boot/initramfs-%PKGBASE%.img" #default_options="" #fallback_config="/etc/mkinitcpio.conf" -fallback_image="/boot/initramfs-linux-fallback.img" +fallback_image="/boot/initramfs-%PKGBASE%-fallback.img" fallback_options="-S autodetect"