arch/build-pkg.sh
2021-05-02 19:25:48 +02:00

70 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
function build-pkg() {
# $1: package-name
local PKG
PKG="$1"
# check if PKGBUILD exists, otherwise skip
[ -f "pkg/${PKG}/PKGBUILD" ] || {
echo "Directory pkg/${PKG} does not contain a PKGBUILD file - skipping it!";
FAILED_PKGS+=("${PKG}");
return 0;
}
cd "pkg/${PKG}" || return $?
# build and copy to /home/custompkgs
BUILD_CMD=('makepkg' '-Ccsr' '&&' 'cp' '"${PKG}-"*.pkg.tar.zst' '/home/custompkgs/')
# BUILD_CMD=('aur' 'build' '-c')
"${BUILD_CMD[@]}" || {
echo "Failed to build package ${PKG}!";
FAILED_PKGS+=("${PKG}");
}
cd ../.. || return $?
}
function build-all() {
for PKG in pkg/*; do
build-pkg "$(basename "${PKG}")" || return $?
done
}
function main() {
# usage:
# either zero arguments to build all packages
# or the names of the packages to build as arguments
FAILED_PKGS=()
if [ "$#" -gt "0" ]; then
# at least one argument is given
for PKG in "$@"; do
build-pkg "$PKG" || return $?
done
else
# no arguments given
build-all || return $?
fi
# push remote repository
echo ""
arch-repo-push-new || exit
if [ "${#FAILED_PKGS[@]}" -gt "0" ]; then
echo ""
echo "Warning: Not all packages were build successfully: ${FAILED_PKGS[*]}"
return 1
fi
}
main "$@"