From 5c4f48b51f8e84643c95698e74ccf6179bd86584 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Tue, 14 Feb 2023 20:20:24 +0000 Subject: [PATCH 1/3] Add --quiet parameter to update action Reduces feedback output from fetching repo updates. --- README.md | 3 ++- deb-get | 20 +++++++++++++++----- docs/deb-get.1 | 4 ++-- docs/deb-get.1.md | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 531a3d66f..bc32bb82b 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ cog.out(f"```\n{help}\n```") ]]] --> ``` -deb-get {update [--repos-only] | upgrade | show | install +deb-get {update [--repos-only] [--quiet] | upgrade | show | install | reinstall | remove [--remove-repo] | purge [--remove-repo] | search [--include-unsupported] | cache | clean @@ -76,6 +76,7 @@ update When --repos-only is provided, only initialize and update deb-get's external repositories, without updating apt or looking for updates of installed packages. + When --quiet is provided the fetching of deb-get repository updates is done without progress feedback. upgrade upgrade is used to install the newest versions of all packages currently diff --git a/deb-get b/deb-get index 0604c4fcf..355d7a50d 100755 --- a/deb-get +++ b/deb-get @@ -651,12 +651,22 @@ function refresh_supported_cache_lists() { function update_repos() { local REPO_URL="" + # preserve current behaviour for now but allow modification via env + local CURL_VERBOSITY="-q --show-progress --progress=bar:force:noscroll " + local WGET_VERBOSITY="-q" + + if [[ "$*" == *"--quiet"* ]] ; then + CURL_VERBOSITY="-Ss" + WGET_VERBOSITY="-q" + export WGET_VERBOSITY CURL_VERBOSITY + fi + for REPO in $(find "${ETC_DIR}" -maxdepth 1 -name "*.repo" ! -name 00-builtin.repo ! -name 99-local.repo -type f -printf "%f\n" | sed "s/.repo$//"); do export REPO fancy_message info "Updating ${ETC_DIR}/${REPO}" REPO_URL="$(head -n 1 "${ETC_DIR}/${REPO}.repo")" - ${ELEVATE} wget -q --show-progress --progress=bar:force:noscroll "${REPO_URL}/manifest" -O "${ETC_DIR}/${REPO}.repo" + ${ELEVATE} wget ${WGET_VERBOSITY} "${REPO_URL}/manifest" -O "${ETC_DIR}/${REPO}.repo" # ${ELEVATE} rm "${ETC_DIR}/${REPO}.d/* # we currently leave old litter : either <- this or maybe rm older ones # although so long as manifest is good we are OK @@ -668,10 +678,10 @@ function update_repos() { awk -F/ '/github/ {print "# fetching github repo"; print "GITREPO="$4"/"$5;\ print "BRANCH="$6;\ - print "curl -L https://api.github.com/repos/${GITREPO}/tarball/${BRANCH} | ${ELEVATE} tar zx --wildcards \"*/${REPO}*/packages/*\" --strip-components=3"} + print "curl ${CURL_VERBOSITY} -L https://api.github.com/repos/${GITREPO}/tarball/${BRANCH} | ${ELEVATE} tar zx --wildcards \"*/${REPO}*/packages/*\" --strip-components=3"} ! /github/ {print "# fetching non-github repo"; print "tail -n +2 \"${ETC_DIR}/${REPO}.repo\" | sed \"s/^#//\" | ${ELEVATE} sort -u -o \"${ETC_DIR}/${REPO}.repo.tmp\"";\ - print "${ELEVATE} wget -q --show-progress --progress=bar:force:noscroll -N -B \"${REPO_URL}/packages/\" -i \"${ETC_DIR}/${REPO}.repo.tmp\" -P \"${ETC_DIR}/${REPO}.d\""; + print "${ELEVATE} wget ${WGET_VERBOSITY} -N -B \"${REPO_URL}/packages/\" -i \"${ETC_DIR}/${REPO}.repo.tmp\" -P \"${ETC_DIR}/${REPO}.d\""; print "${ELEVATE} rm \"${ETC_DIR}/${REPO}.repo.tmp\"" } '\ <<<${REPO_URL} | bash - @@ -1480,14 +1490,14 @@ case "${ACTION}" in list_debs "" --raw | grep "${1}" fi;; update) - if [ -n "${1}" ] && [ "${1}" != --repos-only ]; then + if [ -n "${1}" ] && [ "${1}" != --repos-only ] && [ "${1}" != --quiet ]; then fancy_message fatal "Unknown option supplied: ${1}" fi elevate_privs create_cache_dir create_etc_dir init_repos - update_repos + update_repos "$@" if [ "${1}" != --repos-only ]; then APPS="$(list_local_apps)" APPS="${APPS} diff --git a/docs/deb-get.1 b/docs/deb-get.1 index 2143784d8..490530934 100644 --- a/docs/deb-get.1 +++ b/docs/deb-get.1 @@ -14,7 +14,7 @@ . ftr VB CB . ftr VBI CBI .\} -.TH "deb-get" "1" "October 6, 2022" "deb-get" "deb-get User Manual" +.TH "deb-get" "1" "February 14, 2022" "deb-get" "deb-get User Manual" .hy .SH NAME .PP @@ -25,7 +25,7 @@ deb-get - An installation manager for 3rd-Party deb packages .IP .nf \f[C] -deb-get {update [--repos-only] | upgrade | show | install +deb-get {update [--repos-only] [--quiet] | upgrade | show | install | reinstall | remove [--remove-repo] | purge [--remove-repo] | search [--include-unsupported] | cache | clean diff --git a/docs/deb-get.1.md b/docs/deb-get.1.md index fce7c550b..be9449e23 100644 --- a/docs/deb-get.1.md +++ b/docs/deb-get.1.md @@ -1,6 +1,6 @@ --- author: Martin Wimpress -date: October 6, 2022 +date: February 14, 2022 footer: deb-get header: deb-get User Manual section: 1 @@ -16,7 +16,7 @@ deb-get - An installation manager for 3rd-Party deb packages **deb-get** \[*COMMAND*\]... ``` -deb-get {update [--repos-only] | upgrade | show | install +deb-get {update [--repos-only] [--quiet] | upgrade | show | install | reinstall | remove [--remove-repo] | purge [--remove-repo] | search [--include-unsupported] | cache | clean From 70b87477df53fb507772ef05eb955e60605549b1 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Tue, 28 Feb 2023 13:53:30 +0000 Subject: [PATCH 2/3] Add completion options --- deb-get_completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deb-get_completion b/deb-get_completion index 098da839c..92f6de57d 100644 --- a/deb-get_completion +++ b/deb-get_completion @@ -6,8 +6,8 @@ function _deb-get() { elif [ "${COMP_CWORD}" -ge 2 ]; then local command="${COMP_WORDS[1]}" - if [ "${COMP_CWORD}" = 2 ] && [ "${command}" = update ]; then - COMPREPLY=($(compgen -W "--repos-only" "\\${COMP_WORDS[2]}")) + if [ "${command}" = update ] && [ "${COMP_CWORD}" -le 3 ]; then + COMPREPLY=($(compgen -W "--repos-only --quiet" "\\${COMP_WORDS[${COMP_CWORD}]}")) elif [ "${command}" = show ]; then COMPREPLY=($(compgen -W "$(deb-get list --include-unsupported --raw | tr "\n" " ")" "${COMP_WORDS[${COMP_CWORD}]}")) elif [ "${COMP_CWORD}" = 2 ] && [ "${command}" = search ]; then From fd63631385c5e477fa65d0fd28c4127c7dc245da Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Tue, 28 Feb 2023 13:55:08 +0000 Subject: [PATCH 3/3] Fix option handling and feedback --- deb-get | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deb-get b/deb-get index 355d7a50d..f636e63bc 100755 --- a/deb-get +++ b/deb-get @@ -1492,13 +1492,19 @@ case "${ACTION}" in update) if [ -n "${1}" ] && [ "${1}" != --repos-only ] && [ "${1}" != --quiet ]; then fancy_message fatal "Unknown option supplied: ${1}" + elif [ -n "${2}" ] && [ "${2}" != --repos-only ] && [ "${2}" != --quiet ]; then + fancy_message fatal "Unknown option supplied: ${2}" + fi + if [ -n "${3}" ] ; then + fancy_message error "Ignoring extra options from : ${3}" fi elevate_privs create_cache_dir create_etc_dir init_repos update_repos "$@" - if [ "${1}" != --repos-only ]; then + #if [ "${1}" != --repos-only ]; then + if [[ "$*" != *"--repos-only"* ]] ; then APPS="$(list_local_apps)" APPS="${APPS} $(list_repo_apps)"