Fix bugs, refactor and remove relPkgFile variable
This commit is contained in:
parent
d2171738d6
commit
5d4590b055
51
pkgbuild.sh
51
pkgbuild.sh
|
@ -51,16 +51,35 @@ buildPackage() {
|
||||||
fi
|
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() {
|
exportPackageFiles() {
|
||||||
sudo -u calbuilder makepkg --printsrcinfo > .SRCINFO
|
sudo -u calbuilder makepkg --printsrcinfo > .SRCINFO
|
||||||
exportFile "srcInfo" ".SRCINFO"
|
exportFile "srcInfo" ".SRCINFO"
|
||||||
|
|
||||||
pkgFile=$(sudo -u calbuilder makepkg --packagelist)
|
pkgFile=$(sudo -u calbuilder makepkg --packagelist)
|
||||||
|
pkgFile=$(basename "$pkgFile")
|
||||||
if [ -f "$pkgFile" ]; then
|
if [ -f "$pkgFile" ]; then
|
||||||
relPkgFile="$(realpath --relative-base="$baseDir" "$pkgFile")"
|
exportFile "pkgFile" "$pkgFile"
|
||||||
exportFile "pkgFile" "$relPkgFile" "$pkgFile"
|
|
||||||
if [ -n "$gpgPrivateKey" ]; then
|
if [ -n "$gpgPrivateKey" ]; then
|
||||||
exportFile "pkgFileSig" "$relPkgFile.sig" "$pkgFile.sig"
|
exportFile "pkgFileSig" "$pkgFile.sig"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -68,31 +87,10 @@ exportPackageFiles() {
|
||||||
exportFile() {
|
exportFile() {
|
||||||
echo "::set-output name=$1::$2"
|
echo "::set-output name=$1::$2"
|
||||||
if [ "$inBaseDir" = false ]; then
|
if [ "$inBaseDir" = false ]; then
|
||||||
[ $# -eq 2 ] && pkgFile=$2 || pkgFile=$3
|
|
||||||
mv "$pkgFile" /github/workspace
|
mv "$pkgFile" /github/workspace
|
||||||
fi
|
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() {
|
getInputs() {
|
||||||
gpgPrivateKey="$INPUT_GPGPRIVATEKEY"
|
gpgPrivateKey="$INPUT_GPGPRIVATEKEY"
|
||||||
gpgPublicKey="$INPUT_GPGPUBLICKEY"
|
gpgPublicKey="$INPUT_GPGPUBLICKEY"
|
||||||
|
@ -120,17 +118,14 @@ runScript() {
|
||||||
|
|
||||||
installAurDeps
|
installAurDeps
|
||||||
buildPackage
|
buildPackage
|
||||||
exportPackageFiles
|
|
||||||
namcapAnalysis
|
namcapAnalysis
|
||||||
|
exportPackageFiles
|
||||||
|
|
||||||
findArgs+=("-not" "-name" "$relPkgFile*" "-not" "-name" ".SRCINFO")
|
findArgs+=("-not" "-name" "$relPkgFile*" "-not" "-name" ".SRCINFO")
|
||||||
newFiles=$(find -H "$PWD" "${findArgs[@]}")
|
newFiles=$(find -H "$PWD" "${findArgs[@]}")
|
||||||
files=$(printf '%s\n%s\n' "$newFiles" "$oldFiles")
|
files=$(printf '%s\n%s\n' "$newFiles" "$oldFiles")
|
||||||
mapfile -t toRemove < <(echo "$files" | sort | uniq -u)
|
mapfile -t toRemove < <(echo "$files" | sort | uniq -u)
|
||||||
rm -rf "${toRemove[@]}"
|
rm -rf "${toRemove[@]}"
|
||||||
|
|
||||||
cd ..
|
|
||||||
ls -al
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runScript "$@"
|
runScript "$@"
|
||||||
|
|
Loading…
Reference in New Issue