Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --quiet parameter to update action #760

Merged
merged 3 commits into from Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -59,7 +59,7 @@ cog.out(f"```\n{help}\n```")
]]] -->
```

deb-get {update [--repos-only] | upgrade | show <pkg list> | install <pkg list>
deb-get {update [--repos-only] [--quiet] | upgrade | show <pkg list> | install <pkg list>
| reinstall <pkg list> | remove [--remove-repo] <pkg list>
| purge [--remove-repo] <pkg list>
| search [--include-unsupported] <regex> | cache | clean
Expand All @@ -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
Expand Down
28 changes: 22 additions & 6 deletions deb-get
Expand Up @@ -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
Expand All @@ -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 -
Expand Down Expand Up @@ -1480,15 +1490,21 @@ 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}"
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
update_repos "$@"
#if [ "${1}" != --repos-only ]; then
if [[ "$*" != *"--repos-only"* ]] ; then
APPS="$(list_local_apps)"
APPS="${APPS}
$(list_repo_apps)"
Expand Down
4 changes: 2 additions & 2 deletions deb-get_completion
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/deb-get.1
Expand Up @@ -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
Expand All @@ -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 <pkg list> | install <pkg list>
deb-get {update [--repos-only] [--quiet] | upgrade | show <pkg list> | install <pkg list>
| reinstall <pkg list> | remove [--remove-repo] <pkg list>
| purge [--remove-repo] <pkg list>
| search [--include-unsupported] <regex> | cache | clean
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand All @@ -16,7 +16,7 @@ deb-get - An installation manager for 3rd-Party deb packages
**deb-get** \[*COMMAND*\]...

```
deb-get {update [--repos-only] | upgrade | show <pkg list> | install <pkg list>
deb-get {update [--repos-only] [--quiet] | upgrade | show <pkg list> | install <pkg list>
| reinstall <pkg list> | remove [--remove-repo] <pkg list>
| purge [--remove-repo] <pkg list>
| search [--include-unsupported] <regex> | cache | clean
Expand Down