2021-04-29 14:49:02 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-05-02 19:45:37 +02:00
|
|
|
function build-with-aurutils() {
|
|
|
|
aur build -c
|
|
|
|
}
|
|
|
|
|
|
|
|
function build-with-makepkg() {
|
|
|
|
makepkg -Ccsr
|
|
|
|
|
|
|
|
case "$?" in
|
|
|
|
0)
|
|
|
|
# Copy the build package to /home/custompkgs
|
2021-05-02 20:04:20 +02:00
|
|
|
cp --no-clobber "${PKG}-"*.pkg.tar.zst /home/custompkgs/ || return $?
|
2021-05-02 19:45:37 +02:00
|
|
|
;;
|
|
|
|
13)
|
|
|
|
# Exit code 13: A package has already been built.
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# Some other makepkg error occurred.
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2021-04-29 14:49:02 +02:00
|
|
|
function build-pkg() {
|
|
|
|
# $1: package-name
|
|
|
|
local PKG
|
|
|
|
PKG="$1"
|
|
|
|
|
2021-05-02 19:45:37 +02:00
|
|
|
# Check if PKGBUILD exists, otherwise skip
|
2021-04-29 14:49:02 +02:00
|
|
|
[ -f "pkg/${PKG}/PKGBUILD" ] || {
|
2021-05-02 19:25:48 +02:00
|
|
|
echo "Directory pkg/${PKG} does not contain a PKGBUILD file - skipping it!";
|
|
|
|
FAILED_PKGS+=("${PKG}");
|
|
|
|
return 0;
|
2021-04-29 14:49:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-29 14:52:03 +02:00
|
|
|
cd "pkg/${PKG}" || return $?
|
2021-04-29 14:49:02 +02:00
|
|
|
|
2021-05-02 19:45:37 +02:00
|
|
|
# Build and copy to /home/custompkgs
|
2021-05-02 20:04:20 +02:00
|
|
|
build-with-makepkg || {
|
|
|
|
# build-with-aurutils || {
|
2021-05-02 19:25:48 +02:00
|
|
|
echo "Failed to build package ${PKG}!";
|
2021-05-02 18:02:20 +02:00
|
|
|
FAILED_PKGS+=("${PKG}");
|
|
|
|
}
|
2021-04-29 14:52:03 +02:00
|
|
|
|
|
|
|
cd ../.. || return $?
|
2021-04-29 14:49:02 +02:00
|
|
|
}
|
|
|
|
|
2021-04-29 14:52:03 +02:00
|
|
|
|
2021-04-29 14:49:02 +02:00
|
|
|
function build-all() {
|
|
|
|
for PKG in pkg/*; do
|
2021-04-29 14:52:03 +02:00
|
|
|
build-pkg "$(basename "${PKG}")" || return $?
|
2021-04-29 14:49:02 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2021-05-02 19:45:37 +02:00
|
|
|
# Usage:
|
|
|
|
# Either zero arguments to build all packages
|
|
|
|
# or the names of the packages to build as arguments
|
2021-04-29 14:49:02 +02:00
|
|
|
|
2021-05-02 18:02:20 +02:00
|
|
|
FAILED_PKGS=()
|
|
|
|
|
2021-04-29 14:49:02 +02:00
|
|
|
|
|
|
|
if [ "$#" -gt "0" ]; then
|
2021-05-02 19:45:37 +02:00
|
|
|
# At least one argument is given
|
2021-04-29 14:49:02 +02:00
|
|
|
|
|
|
|
for PKG in "$@"; do
|
|
|
|
build-pkg "$PKG" || return $?
|
|
|
|
done
|
|
|
|
|
|
|
|
else
|
2021-05-02 19:45:37 +02:00
|
|
|
# No arguments given
|
2021-04-29 14:49:02 +02:00
|
|
|
build-all || return $?
|
|
|
|
fi
|
|
|
|
|
2021-05-02 19:45:37 +02:00
|
|
|
# Push remote repository
|
2021-05-02 18:02:20 +02:00
|
|
|
echo ""
|
2021-04-29 14:49:02 +02:00
|
|
|
arch-repo-push-new || exit
|
2021-05-02 18:02:20 +02:00
|
|
|
|
|
|
|
if [ "${#FAILED_PKGS[@]}" -gt "0" ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Warning: Not all packages were build successfully: ${FAILED_PKGS[*]}"
|
|
|
|
return 1
|
|
|
|
|
|
|
|
fi
|
2021-04-29 14:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|