arch/build-pkg/build-all-without-docker.sh

120 lines
2.8 KiB
Bash
Raw Normal View History

2021-06-26 16:46:42 +02:00
#!/usr/bin/env bash
echo "Please consider using ./build-all.sh instead. This script is outdated."
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
}
function build-pkg() {
# $1: package-name
local PKG
PKG="$1"
2021-05-02 19:45:37 +02:00
# Check if PKGBUILD exists, otherwise skip
[ -f "../pkg/${PKG}/PKGBUILD" ] || {
echo "Directory ../pkg/${PKG} does not contain a PKGBUILD file - skipping it!";
2021-05-11 22:34:00 +02:00
SKIPPED_PKGS+=("${PKG}");
2021-05-02 19:25:48 +02:00
return 0;
}
cd "../pkg/${PKG}" || return $?
2021-05-02 19:45:37 +02:00
# Build and copy to /home/custompkgs
2021-05-03 16:24:25 +02:00
# build-with-makepkg || {
build-with-aurutils || {
2021-05-02 19:25:48 +02:00
echo "Failed to build package ${PKG}!";
2021-05-11 22:34:00 +02:00
return 1
2021-05-02 18:02:20 +02:00
}
2021-04-29 14:52:03 +02:00
cd ../../build-pkg || return $?
}
2021-05-11 22:34:00 +02:00
function push-pkg() {
arch-repo-push-new || return $? # Push remote repository
echo "Running 'pacman -Sy' to update de-p1st mirror database ..."
sudo pacman -Sy || return $?
}
2021-05-13 19:28:31 +02:00
function build-and-push() {
for PKG in "$@"; do
build-pkg "${PKG}" || return $?
done
push-pkg || return $?
}
2021-06-16 20:21:21 +02:00
function space_separated_to_array() {
# arg $1: name of variable with space separated list
# arg $2: name of array to store values into
local -n ptr=$1 || return $?
local -n ptr2=$2 || return $?
# ptr space separated list.
# Store this as array ptr2.
# Without newline at last array element: https://unix.stackexchange.com/a/519917/315162
# shellcheck disable=SC2034
readarray -d " " -t ptr2 < <(printf '%s' "$ptr")
}
function main() {
2021-05-02 19:45:37 +02:00
# Usage:
2021-05-11 22:34:00 +02:00
# Without arguments: Build all packages and watch out for dependencies between them:
# First build packages on wich others depend
# Then add them to de-p1st mirror
# And repeat these steps until all packages are built
# First argument "all": Build all packages, ordered by name
# Multiple arguments: Build the the specified packages in their given order
SKIPPED_PKGS=()
if [ "$1" = "all" ]; then
for PKG in ../pkg/*; do
2021-05-11 22:34:00 +02:00
build-pkg "$(basename "${PKG}")" || return $?
done
elif [ "$#" -gt "0" ]; then
# List of packages is given as arguments
for PKG in "$@"; do
build-pkg "$PKG" || return $?
done
else
2021-06-16 20:21:21 +02:00
PKGLIST=pkglist-AUR.txt # TODO
mapfile -t STAGES < "${PKGLIST}"
# shellcheck disable=SC2034
for line in "${STAGES[@]}"; do
space_separated_to_array line pkgs
# shellcheck disable=SC2154
build-and-push "${pkgs[@]}" || exit $?
done
fi
2021-05-11 22:34:00 +02:00
push-pkg || return $?
2021-05-02 18:02:20 +02:00
if [ "${#FAILED_PKGS[@]}" -gt "0" ]; then
echo ""
2021-05-11 22:34:00 +02:00
echo "Warning: Some packages were skipped: ${SKIPPED_PKGS[*]}"
2021-05-02 18:02:20 +02:00
return 1
fi
}
main "$@"