From 640aedf03f7773b35abfa34c11a3e000f6688db3 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sun, 6 Feb 2022 17:27:48 -0300 Subject: [PATCH] Add checkParameters() --- build.sh | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/build.sh b/build.sh index 5f3e202..34ae0ff 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,14 @@ #!/usr/bin/env bash -# TODO: Get the .pkg.tar.zst from calpkgs - getAnyPackages() { pkgs=($(find -H "$PWD/any" -mindepth 1 -type f -regex '.*.pkg.tar.zst.*')) for arch in "x86_64" "i686" "aarch64"; do - cd $arch - - for pkg in "${pkgs[@]}"; do - ln -sf "$pkg" "$(basename $pkg)" - #echo "ln -sf $pkg $(basename $pkg)" - done - - cd .. + cd $arch + for pkg in "${pkgs[@]}"; do + ln -sf "$pkg" "$(basename $pkg)" + #echo "ln -sf $pkg $(basename $pkg)" + done + cd .. done } @@ -20,22 +16,34 @@ buildDatabase() { #lastFolder=$(pwd -P) #cd db || { echo "Couldn't cd into 'db'." 1>&2 && exit 1; } for arch in "x86_64" "i686" "aarch64"; do - cd $arch + cd $arch - while read -r pkg; do - repo-add -s -n -R -k "199980CE93F18E62" calrepo.db.tar.gz "$pkg" - rm -rf *.old* - #echo "repo-add -s -n -R -k calrepo.db.tar.gz $pkg" - done < <(find -L "$PWD" -mindepth 1 -type f -regex '.*.pkg.tar.zst') + while read -r pkg; do + repo-add -s -n -R -k "199980CE93F18E62" calrepo.db.tar.gz "$pkg" + rm -rf *.old* + #echo "repo-add -s -n -R -k calrepo.db.tar.gz $pkg" + done < <(find -L "$PWD" -mindepth 1 -type f -regex '.*.pkg.tar.zst') - cd .. + cd .. done #cd "$lastFolder" || { echo "Couldn't cd into '$lastFolder'." 1>&2 && exit 1; } } +checkParamaters() { + dryRunFlag=false + while getopts ':hd' flag; do + case $flag in + h) usage && exit 0 ;; + d) dryRunFlag=true ;; + ?) printf '%s: invalid option -''%s'\\n "${0##*/}" "$OPTARG" && exit 1 ;; + esac + done +} + runScript() { + checkParamaters "$@" getAnyPackages buildDatabase } -runScript +runScript "$@"