From 489a699e4598891c3ac7791c10b5dd21885e9771 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Thu, 12 Oct 2023 08:43:10 +0200 Subject: [PATCH] only short options are supported --- usr/bin/archboot-cpio.sh | 10 +++--- usr/lib/archboot/cpio.sh | 69 ---------------------------------------- 2 files changed, 5 insertions(+), 74 deletions(-) diff --git a/usr/bin/archboot-cpio.sh b/usr/bin/archboot-cpio.sh index 3451eeb55..d1362a80b 100755 --- a/usr/bin/archboot-cpio.sh +++ b/usr/bin/archboot-cpio.sh @@ -143,26 +143,26 @@ set -- "${OPTRET[@]}" unset _opt_short OPTRET while :; do case "$1" in - -c|--config) + -c) shift _f_config="$1" ;; - -k|--kernel) + -k) shift KERNEL="$1" ;; - -d|--generatedir) + -d) shift _opttargetdir="$1" ;; - -g|--generate) + -g) shift [[ -d "$1" ]] && die 'Invalid image path -- must not be a directory' if ! _optgenimg="$(readlink -f "$1")" || [[ ! -e "${_optgenimg%/*}" ]]; then die "Unable to write to path: '%s'" "$1" fi ;; - -h|--help) + -h) usage cleanup 0 ;; diff --git a/usr/lib/archboot/cpio.sh b/usr/lib/archboot/cpio.sh index 523578ef2..3db1964da 100644 --- a/usr/lib/archboot/cpio.sh +++ b/usr/lib/archboot/cpio.sh @@ -4,59 +4,6 @@ # simplified, stripped down, optimized for size and speed # by Tobias Powalowski -# no long options support in archboot -parseopts() { - local opt='' i='' shortopts="$1" - local -a unused_argv=() - shift - shift - while (( $# )); do - case "$1" in - --) # explicit end of options - shift - break - ;; - -[!-]*) # short option - for (( i = 1; i < ${#1}; i++ )); do - opt=${1:i:1} - # option doesn't exist - if [[ $shortopts != *$opt* ]]; then - printf "%s: invalid option -- '%s'\n" "${0##*/}" "$opt" - OPTRET=(--) - return 1 - fi - OPTRET+=("-$opt") - # option requires optarg - if [[ "$shortopts" == *"${opt}:"* ]]; then - # if we're not at the end of the option chunk, the rest is the optarg - if (( i < ${#1} - 1 )); then - OPTRET+=("${1:i+1}") - break - # if we're at the end, grab the the next positional, if it exists - elif (( i == ${#1} - 1 )) && [[ -n "$2" ]]; then - OPTRET+=("$2") - shift - break - # parse failure - else - printf "%s: option '%s' requires an argument\n" "${0##*/}" "-$opt" - OPTRET=(--) - return 1 - fi - fi - done - ;; - *) # non-option arg encountered, add it as a parameter - unused_argv+=("$1") - ;; - esac - shift - done - # add end-of-opt terminator and any leftover positional parameters - OPTRET+=('--' "${unused_argv[@]}" "$@") - return 0 -} - msg() { local mesg="$1"; shift # shellcheck disable=SC2059 @@ -368,22 +315,6 @@ run_build_hook() { return 0 } -try_enable_color() { - local colors - if ! colors="$(tput colors 2>"${_NO_LOG}")"; then - warning "Failed to enable color. Check your TERM environment variable" - return - fi - if (( colors > 0 )) && tput setaf 0 &>"${_NO_LOG}"; then - _color_none="$(tput sgr0)" - _color_bold="$(tput bold)" - _color_blue="$_color_bold$(tput setaf 4)" - _color_green="$_color_bold$(tput setaf 2)" - _color_red="$_color_bold$(tput setaf 1)" - _color_yellow="$_color_bold$(tput setaf 3)" - fi -} - install_modules() { command tar --hard-dereference -C / -cpf - "$@" | tar -C "${BUILDROOT}" -xpf - msg "Generating module dependencies"