From aff3b5b4bf49466fa5b8842f04a316e6e65788cc Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Mon, 29 May 2023 13:55:46 -0500 Subject: [PATCH 1/3] linux-base: post-install hook for /boot freespace --- srcpkgs/linux-base/files/50-bootsize.postinst | 31 +++++++++++++++++++ srcpkgs/linux-base/template | 7 +++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/linux-base/files/50-bootsize.postinst diff --git a/srcpkgs/linux-base/files/50-bootsize.postinst b/srcpkgs/linux-base/files/50-bootsize.postinst new file mode 100644 index 000000000000..bb323222883d --- /dev/null +++ b/srcpkgs/linux-base/files/50-bootsize.postinst @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Kernel hook to check for filled /boot partitions +# +# Arguments passed to this script: $1 pkgname, $2 version. +# +PKGNAME="$1" +VERSION="$2" + +# freespace = blocksize * freeblocks +freespace=$(( $(stat -f -c %S /boot) * $(stat -f -c %f /boot) )) + +# freespace for /boot is <= 100MB +if [ $freespace -le 104857600 ]; then + if [ -t 1 -a -n "$(tput colors)" ]; then + # Set output to be bold and red, if supported + tput setaf 1 + tput bold + fi + cat <<-'ENDMSG' + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * WARNING: /boot has less than 100MB available. Use `vkpurge` to ensure * + * there will be sufficient space to write the next kernel and generate * + * its initrd. Your system may otherwise become unbootable. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + ENDMSG + if [ -t 1 -a -n "$(tput colors)" ]; then + # Reset output back to normal + tput sgr0 + fi +fi diff --git a/srcpkgs/linux-base/template b/srcpkgs/linux-base/template index 249f21fa27f2..d04e7ad12bb6 100644 --- a/srcpkgs/linux-base/template +++ b/srcpkgs/linux-base/template @@ -1,8 +1,7 @@ # Template file for 'linux-base' pkgname=linux-base -version=2021.07.21 +version=2023.05.29 revision=1 -build_style=meta short_desc="Linux kernel base dependencies" maintainer="Érico Nogueira " license="Public Domain" @@ -16,3 +15,7 @@ case "$XBPS_TARGET_MACHINE" in depends="linux-firmware-amd linux-firmware-nvidia linux-firmware-network dracut" ;; esac + +do_install() { + vinstall ${FILESDIR}/50-bootsize.postinst 0755 etc/kernel.d/post-install 50-bootsize +} From f1da7ae327f0d8057b40ec4d1385196c88bacd8f Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Fri, 2 Jun 2023 17:47:37 -0500 Subject: [PATCH 2/3] Update srcpkgs/linux-base/files/50-bootsize.postinst Co-authored-by: classabbyamp <5366828+classabbyamp@users.noreply.github.com> --- srcpkgs/linux-base/files/50-bootsize.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/linux-base/files/50-bootsize.postinst b/srcpkgs/linux-base/files/50-bootsize.postinst index bb323222883d..1141ddabb699 100644 --- a/srcpkgs/linux-base/files/50-bootsize.postinst +++ b/srcpkgs/linux-base/files/50-bootsize.postinst @@ -24,7 +24,7 @@ if [ $freespace -le 104857600 ]; then * its initrd. Your system may otherwise become unbootable. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ENDMSG - if [ -t 1 -a -n "$(tput colors)" ]; then + if [ -z "$NO_COLOR" -a -t 1 -a -n "$(tput colors)" ]; then # Reset output back to normal tput sgr0 fi From 299ca69498a18c125c4a448581a68c6791f702a1 Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Fri, 2 Jun 2023 17:47:46 -0500 Subject: [PATCH 3/3] Update srcpkgs/linux-base/files/50-bootsize.postinst Co-authored-by: classabbyamp <5366828+classabbyamp@users.noreply.github.com> --- srcpkgs/linux-base/files/50-bootsize.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/linux-base/files/50-bootsize.postinst b/srcpkgs/linux-base/files/50-bootsize.postinst index 1141ddabb699..ee49af0c3712 100644 --- a/srcpkgs/linux-base/files/50-bootsize.postinst +++ b/srcpkgs/linux-base/files/50-bootsize.postinst @@ -12,7 +12,7 @@ freespace=$(( $(stat -f -c %S /boot) * $(stat -f -c %f /boot) )) # freespace for /boot is <= 100MB if [ $freespace -le 104857600 ]; then - if [ -t 1 -a -n "$(tput colors)" ]; then + if [ -z "$NO_COLOR" -a -t 1 -a -n "$(tput colors)" ]; then # Set output to be bold and red, if supported tput setaf 1 tput bold