From 05044fb06d846d67500865714c876633c82417eb Mon Sep 17 00:00:00 2001 From: sakaki Date: Sun, 27 Jul 2014 17:43:11 +0100 Subject: [PATCH] Script modified to deal with crontab usage. Specifically, dealing with the case where TERM set to 'dumb' or unset (causes tput to fail); also exporting variables necessary for build. Version moved to 1.0.3 --- buildkernel | 19 ++++++++++++------- buildkernel.8 | 2 +- buildkernel.conf.5 | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/buildkernel b/buildkernel index c8555b0..c5078e7 100755 --- a/buildkernel +++ b/buildkernel @@ -31,7 +31,7 @@ shopt -s nullglob # ********************** variables ********************* PROGNAME="$(basename "${0}")" CONFFILE="/etc/${PROGNAME}.conf" -VERSION="1.0.2" +VERSION="1.0.3" DEFAULTEFIBOOTFILE="bootx64.efi" EFIBOOTFILE="${DEFAULTEFIBOOTFILE}" NEWVERSION="$(basename $(realpath "/usr/src/linux"))" @@ -67,15 +67,20 @@ CMDLINE_REAL_RESUME="/dev/mapper/vg1-swap" # you can use xconfig etc if you like - override in /etc/buildkernel.conf CONFIGTYPE="menuconfig" # following should already be in the environment; but to be safe... -NUMCPUS=$(grep -E 'processor\s+:' /proc/cpuinfo | wc -l) -NUMCPUSPLUSONE=$(( NUMCPUS + 1 )) +export NUMCPUS=$(grep -E 'processor\s+:' /proc/cpuinfo | wc -l) +export NUMCPUSPLUSONE=$(( NUMCPUS + 1 )) +export MAKEOPTS="${MAKEOPTS--j${NUMCPUSPLUSONE} -l${NUMCPUS}}" +export EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS---jobs=${NUMCPUSPLUSONE} --load-average=${NUMCPUS}}" # below silently updates an old config, auto-choosing defaults for new values CONFIGUPDATETYPE="olddefconfig" SILENTUPDATETYPE="olddefconfig" -RED_TEXT="$(tput setaf 1)$(tput bold)" -GREEN_TEXT="$(tput setaf 2)$(tput bold)" -YELLOW_TEXT="$(tput setaf 3)$(tput bold)" -RESET_ATTS="$(tput sgr0)" +RED_TEXT="" GREEN_TEXT="" YELLOW_TEXT="" RESET_ATTS="" +if [[ -v TERM && -n "${TERM}" && "${TERM}" != "dumb" ]]; then + RED_TEXT="$(tput setaf 1)$(tput bold)" + GREEN_TEXT="$(tput setaf 2)$(tput bold)" + YELLOW_TEXT="$(tput setaf 3)$(tput bold)" + RESET_ATTS="$(tput sgr0)" +fi # used in subshells UNCOMPRESSEDINITRAMFS="${BOOTDIR}/initramfs.cpio" INITRAMFSDIR="${BOOTDIR}/initramfs" diff --git a/buildkernel.8 b/buildkernel.8 index a784d95..7c1536a 100644 --- a/buildkernel.8 +++ b/buildkernel.8 @@ -1,4 +1,4 @@ -.TH BUILDKERNEL 8 "Version 1.0.2: July 2014" +.TH BUILDKERNEL 8 "Version 1.0.3: July 2014" .SH NAME buildkernel \- build secure boot kernel, save to EFI system partition .SH SYNOPSIS diff --git a/buildkernel.conf.5 b/buildkernel.conf.5 index f9a4bbd..7cf64be 100644 --- a/buildkernel.conf.5 +++ b/buildkernel.conf.5 @@ -1,4 +1,4 @@ -.TH BUILDKERNEL 5 "Version 1.0.2: July 2014" +.TH BUILDKERNEL 5 "Version 1.0.3: July 2014" .SH NAME buildkernel.conf \- a configuration file for \fBbuildkernel\fR(8) .SH SYNOPSIS