From 5d4590b055c631a47a7d966c81470ab9cc93156f Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Tue, 1 Mar 2022 17:24:33 -0300 Subject: [PATCH] Fix bugs, refactor and remove relPkgFile variable --- pkgbuild.sh | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/pkgbuild.sh b/pkgbuild.sh index 0fd0c9d..873da96 100755 --- a/pkgbuild.sh +++ b/pkgbuild.sh @@ -51,16 +51,35 @@ buildPackage() { fi } +printWarnings() { + [ ${#warnings[@]} -eq 0 ] && return + for warning in "${warnings[@]}"; do + echo "::warning::$1 ——— $warning" + done +} + +namcapAnalysis() { + pacman -S --noconfirm namcap + mapfile -t warnings < <(namcap PKGBUILD) + printWarnings "PKGBUILD" + pkgFile=$(sudo -u calbuilder makepkg --packagelist) + pkgFile=$(basename "$pkgFile") + if [ -f "$pkgFile" ]; then + mapfile -t warnings < <(namcap "$pkgFile") + printWarnings "$pkgFile" + fi +} + exportPackageFiles() { sudo -u calbuilder makepkg --printsrcinfo > .SRCINFO exportFile "srcInfo" ".SRCINFO" pkgFile=$(sudo -u calbuilder makepkg --packagelist) + pkgFile=$(basename "$pkgFile") if [ -f "$pkgFile" ]; then - relPkgFile="$(realpath --relative-base="$baseDir" "$pkgFile")" - exportFile "pkgFile" "$relPkgFile" "$pkgFile" + exportFile "pkgFile" "$pkgFile" if [ -n "$gpgPrivateKey" ]; then - exportFile "pkgFileSig" "$relPkgFile.sig" "$pkgFile.sig" + exportFile "pkgFileSig" "$pkgFile.sig" fi fi } @@ -68,31 +87,10 @@ exportPackageFiles() { exportFile() { echo "::set-output name=$1::$2" if [ "$inBaseDir" = false ]; then - [ $# -eq 2 ] && pkgFile=$2 || pkgFile=$3 mv "$pkgFile" /github/workspace fi } -namcapAnalysis() { - pacman -S --noconfirm namcap - - mapfile -t warnings < <(namcap PKGBUILD) - printWarnings "PKGBUILD" - pkgFile=$(sudo -u calbuilder makepkg --packagelist) - if [ -f "$pkgFile" ]; then - relPkgFile="$(realpath --relative-base="$baseDir" "$pkgFile")" - mapfile -t warnings < <(namcap "$pkgFile") - printWarnings "$relPkgFile" - fi -} - -printWarnings() { - [ ${#warnings[@]} -eq 0 ] && return - for warning in "${warnings[@]}"; do - echo "::warning::$1 ——— $warning" - done -} - getInputs() { gpgPrivateKey="$INPUT_GPGPRIVATEKEY" gpgPublicKey="$INPUT_GPGPUBLICKEY" @@ -120,17 +118,14 @@ runScript() { installAurDeps buildPackage - exportPackageFiles namcapAnalysis + exportPackageFiles findArgs+=("-not" "-name" "$relPkgFile*" "-not" "-name" ".SRCINFO") newFiles=$(find -H "$PWD" "${findArgs[@]}") files=$(printf '%s\n%s\n' "$newFiles" "$oldFiles") mapfile -t toRemove < <(echo "$files" | sort | uniq -u) rm -rf "${toRemove[@]}" - - cd .. - ls -al } runScript "$@"