From a430f27040f8cf4f928ede395b8e6e0a34585c11 Mon Sep 17 00:00:00 2001 From: Martin D Kealey Date: Sat, 24 Sep 2022 14:02:15 +1000 Subject: [PATCH] Add --jobs and --no-clean options to installation scripts --- install-driver-no-dkms.sh | 29 ++++++++++++++++++++--------- install-driver.sh | 27 ++++++++++++++++++--------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/install-driver-no-dkms.sh b/install-driver-no-dkms.sh index 7a8ef3f..8409330 100755 --- a/install-driver-no-dkms.sh +++ b/install-driver-no-dkms.sh @@ -19,20 +19,30 @@ fi # support for NoPrompt allows non-interactive use of this script no_prompt=0 +no_clean=0 +make_opts=() +make_build_opts=() # get the options for ((;$#;)) do case $1 in - NoPrompt) + -y|--no-prompt|NoPrompt) no_prompt=1 ;; + -d|--dirty|--no-clean|NoClean) + no_clean=1 ;; + -j[0-9]*|--jobs|--jobs=*) + make_build_opts+=( "$1" ) ;; + -j) + make_build_opts+=( "${@:1:2}" ) ; shift ;; # include second arg if present -h|--help|*) cat <<- EndOfHelp - Usage: $0 [NoPrompt] - $0 --help - NoPrompt - noninteractive mode - -h|--help - Show help + Usage: $0 [--no-prompt|-y] [--no-clean|-d] [--jobs[=N]|-jN] + $0 --help|-h + --no-prompt non-interactive mode + --no-clean use existing built objects + --help show this message EndOfHelp - [[ $1 = -h || $1 = --help ]] # don't use non-zero exit status when help requested + [[ $1 = -h || $1 = --help ]] # use zero exit status when help requested exit ;; esac @@ -57,9 +67,10 @@ printf 'Starting installation...\n' printf 'Copying options and blacklist files into /etc/modprobe.d\n' cp -fv "$options_file" "$blacklist_file" /etc/modprobe.d -make clean +(( no_clean )) || +make "${make_opts[@]}" clean -make || { +make "${make_opts[@]}" "${make_build_opts[@]}" || { status=$? printf 'An error occurred. Error = %d\n' "$status" printf 'Please report this error.\n' @@ -69,7 +80,7 @@ make || { exit "$status" } -make install || { +make "${make_opts[@]}" install || { status=$? printf 'An error occurred. Error = %d\n' "$status" printf 'Please report this error.\n' diff --git a/install-driver.sh b/install-driver.sh index 25079c7..2523998 100755 --- a/install-driver.sh +++ b/install-driver.sh @@ -14,24 +14,28 @@ drv_version=5.13.1 drv_dir=$PWD -clear - # support for NoPrompt allows non-interactive use of this script no_prompt=0 +no_clean=0 # get the options for ((;$#;)) do case $1 in - NoPrompt) + -y|--no-prompt|NoPrompt) no_prompt=1 ;; - *h|*help|*) + -d|--dirty|--no-clean|NoClean) + no_clean=1 ;; + -j*) + printf '(dkms build ignores "%s" option)\n' "$1" ;; + -h|--help|*) cat <<- EndOfHelp - Usage: $0 [NoPrompt] - $0 --help - NoPrompt - noninteractive mode - -h|--help - Show help + Usage: $0 [--no-prompt|-y] [--no-clean|-d] + $0 --help|-h + --no-prompt non-interactive mode + --no-clean use existing built objects + --help show this message EndOfHelp - [[ $1 = -h || $1 = --help ]] # don't use non-zero exit status when help requested + [[ $1 = -h || $1 = --help ]] # use zero exit status when help requested exit ;; esac @@ -57,6 +61,8 @@ fi # information that helps with bug reports +clear + # displays script name and version printf 'Running %s version %s\n' "${0##*/}" "$SCRIPT_VERSION" @@ -72,6 +78,9 @@ printf 'Starting installation...\n' printf 'Copying source files to: %s\n' "/usr/src/$drv_name-$drv_version" cp -rf "$drv_dir" "/usr/src/$drv_name-$drv_version" +(( no_clean )) || +find "/usr/src/$drv_name-$drv_version" '(' -name '*.o' -o -name '*.ko' -o -name '*.o.cmd' ')' -delete + # sets module parameters (driver options) # blacklist the in-kernel module (driver) so that there is no conflict printf 'Copying options and blacklist files into: %s\n' "/etc/modprobe.d"