From 81ed0781d9a00859102102b214fc534dcbb630fd Mon Sep 17 00:00:00 2001 From: Christian Schendel Date: Tue, 16 Sep 2025 21:23:31 +0200 Subject: [PATCH] fix upload skripts --- upload-to-dalci-3rdparty-repo | 32 ++++++++++++++-------------- upload-to-dalci-repo | 39 +++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/upload-to-dalci-3rdparty-repo b/upload-to-dalci-3rdparty-repo index c1b54b8..d053976 100755 --- a/upload-to-dalci-3rdparty-repo +++ b/upload-to-dalci-3rdparty-repo @@ -9,10 +9,20 @@ color_ok="\e[1;32m==>\e[0m" color_error="\e[1;31m==>\e[0m" color_warning="\e[1;35m==>\e[0m" +show_progress() { + pid=$1 + spin='—\|/' + i=0 + while kill -0 "$pid" 2>/dev/null; do + i=$(((i + 1) % 4)) + spinner="${spin:$i:1}" + printf '\b%s' "$spinner" + sleep .1 + done +} show_cursor() { tput cnorm - exit 1 } hide_cursor() { @@ -22,7 +32,6 @@ hide_cursor() { trap show_cursor INT TERM hide_cursor - configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-3rdparty-repo.cfg" ## check for config file @@ -40,6 +49,7 @@ EOF echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" echo -e "\b$color_warning please edit it before running this script again" show_cursor + exit fi # secure the config file @@ -55,20 +65,9 @@ EOF # shellcheck source=/dev/null source "$configfile" -show_progress() { - pid=$1 - spin='—\|/' - i=0 - while kill -0 "$pid" 2>/dev/null; do - i=$(((i + 1) % 4)) - spinner="${spin:$i:1}" - printf '\b%s' "$spinner" - sleep .1 - done -} check_for_pkg() { - pkg=$(find ./ -type f -name "*.pkg.tar.zst") - if [ ! -z "$pkg" ]; then + mapfile -t pkg < <(find ./ -maxdepth 1 -name "*.pkg.tar.zst") + if [ ${#pkg[@]} -gt 0 ]; then : else echo -e "\b$color_error no packges found." @@ -76,6 +75,7 @@ check_for_pkg() { echo -e "\b\twhich holds the Arch-packages." echo -e "\b$color_ok Exiting now." show_cursor + exit fi } @@ -92,8 +92,8 @@ upload_package() { --data-binary "@$file" fi done - echo -e "\n\b$color_ok packges uploaded" } check_for_pkg upload_package & show_progress $! +echo -e "\b$color_ok Done!" show_cursor diff --git a/upload-to-dalci-repo b/upload-to-dalci-repo index ffdaa94..b4f29a1 100755 --- a/upload-to-dalci-repo +++ b/upload-to-dalci-repo @@ -9,9 +9,20 @@ color_ok="\e[1;32m==>\e[0m" color_error="\e[1;31m==>\e[0m" color_warning="\e[1;35m==>\e[0m" +show_progress() { + pid=$1 + spin='—\|/' + i=0 + while kill -0 "$pid" 2>/dev/null; do + i=$(((i + 1) % 4)) + spinner="${spin:$i:1}" + printf '\b%s' "$spinner" + sleep .1 + done +} + show_cursor() { tput cnorm - exit 1 } hide_cursor() { @@ -21,13 +32,14 @@ hide_cursor() { trap show_cursor INT TERM hide_cursor +configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" + ## check for config file -if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" ]]; then - configfile="${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" +if [[ -r "$configfile" ]]; then configfile_secured="${TMPDIR:-/tmp}/tmp.upload-to-dalci-repo.cfg" else echo -e "\b$color_error no configuration found" - cat > "${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" << EOF + cat > "$configfile" << EOF forgejo_repo_url="https://{domain}/api/packages/{owner}/arch/{group}" forgejo_user="your_username" forgejo_token="your_token_or_password" @@ -37,6 +49,7 @@ EOF echo -e "\b$color_note ${XDG_CONFIG_HOME:-$HOME/.config}/upload-to-dalci-repo.cfg" echo -e "\b$color_warning please edit it before running this script again" show_cursor + exit fi # secure the config file @@ -52,20 +65,9 @@ EOF # shellcheck source=/dev/null source "$configfile" -show_progress() { - pid=$1 - spin='—\|/' - i=0 - while kill -0 "$pid" 2>/dev/null; do - i=$(((i + 1) % 4)) - spinner="${spin:$i:1}" - printf '\b%s' "$spinner" - sleep .1 - done -} check_for_pkg() { - pkg=$(find ./ -type f -name "*.pkg.tar.zst") - if [ ! -z "$pkg" ]; then + mapfile -t pkg < <(find ./ -maxdepth 1 -name "*.pkg.tar.zst") + if [ ${#pkg[@]} -gt 0 ]; then : else echo -e "\b$color_error no packges found." @@ -73,6 +75,7 @@ check_for_pkg() { echo -e "\b\twhich holds the Arch-packages." echo -e "\b$color_ok Exiting now." show_cursor + exit fi } @@ -89,8 +92,8 @@ upload_package() { --data-binary "@$file" fi done - echo -e "\n\b$color_ok packges uploaded" } check_for_pkg upload_package & show_progress $! +echo -e "\b$color_ok Done!" show_cursor