debuginfo-kernel-install: Change argument handling

-F|-r are flags now and their value (kernel reference) is an argument.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
Виталий Чикунов 2023-12-11 05:11:47 +03:00
parent 27c38739fa
commit 60059d1b48

View File

@ -27,12 +27,12 @@ log() {
show_help()
{
cat <<EOF
Usage: $PROG [OPTIONS...]
Usage: $PROG [OPTIONS...] [-f|-r] REFERENCE
Find and install debuginfo package corresponding to already installed kernel from
the ALT Packages Archive (requires Internet access for direct downloads)
Options:
-F, --file=FILE Find package for this FILE (such as /boot/vmlinuz)
-F, --file REFERENCE is a filename (such as /boot/vmlinuz)
-f, -y, --force Force installation (assume 'yes' to all prompts)
--headers-only Only install kernel headers
-H, --headers Add kernel headers to install plan
@ -40,7 +40,7 @@ Options:
-n, --dry-run Tell apt to download packages, but don't install
-q, --quiet Do not show (experimental & Internet access) warning"
--reinstall Try to reihnstall packages
-r, --release=RELEASE Find package for this kernel RELEASE
-r, --release REFERENCE is a kernel release (such as 6.6.1-alt1)
-v, --verbose Increase verbosity
Note: If there is a dependency between debuginfo packages, it won't be automatically resolved.
@ -51,22 +51,22 @@ EOF
declare -i verbose=0
dryrun=
file=
force=
headers=
headers_modules=y
isfile=
isrelease=
kernel=y
quiet=
reinstall=
release=
TEMP=$(getopt -n "$PROG" -o f,y,F:,r:,v,n,H,q,h -l file:,reinstall,release:,verbose,dry-run,force,download-only,headers,headers-only,no-headers-modules,no-kernel,quiet,help -- "$@") || show_help 1
TEMP=$(getopt -n "$PROG" -o f,y,F,r,v,n,H,q,h -l file,reinstall,release,verbose,dry-run,force,download-only,headers,headers-only,no-headers-modules,no-kernel,quiet,help -- "$@") || show_help 1
eval set -- "$TEMP"
while :; do
case "$1" in
--download-only) dryrun+=" $1" ;;
-F | --file) shift; file="$1" ;;
-F | --file) isfile=y ;;
-f | --force) force=y ;;
--headers-only) headers=y; kernel= ;;
-H | --headers) headers=y ;;
@ -76,13 +76,22 @@ while :; do
--no-kernel) kernel= ;;
-q | --quiet) quiet=y ;;
--reinstall) reinstall=--reinstall ;;
-r | --release) shift; release="$1" ;;
-r | --release) isrelease=y ;;
--) shift; break ;;
-v | --verbose) verbose+=1 ;;
esac
shift
done
if [[ "$#" -lt 1 ]]; then
if [[ -n "$isfile" ]] || [[ -n "$isrelease" ]]; then
fatal "Argument is required"
fi
elif [[ "$#" -gt 1 ]]; then
fatal "Too many arguments"
fi
ref=${1-}
if [ -t 1 ] && [ ! -v NO_COLOR ]; then
# No need to determine FGBG colors if we don't use bright colors.
GREEN=$'\e[32m' YELLOW=$'\e[33m' MAGENTA=$'\e[35m' BRIGHT=$'\e[1m' NORM=$'\e[0m'
@ -133,6 +142,21 @@ find_kernel_package() {
fi
}
file=
release=
if [[ -n "$isfile" ]]; then
file=$ref
elif [[ -n "$isrelease" ]]; then
release=$ref
elif [[ -e "$ref" ]]; then
file=$ref
elif [[ "$ref" =~ / ]]; then
file=$ref
else
release=$ref
fi
unset ref isfile isrelease
if [[ -n "$file" ]]; then
if [[ ! -e "$file" ]]; then
fatal "Requested file ($file) not found"