85 lines
1.9 KiB
Bash
Executable file
85 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
set -Eeuo pipefail
|
|
|
|
RED=$(tput setaf 1)
|
|
BOLD=$(tput bold)
|
|
RESET=$(tput sgr0)
|
|
readonly RED BOLD RESET
|
|
|
|
traperr() {
|
|
s=$?
|
|
echo "$0: $BASH_COMMAND"
|
|
exit $s
|
|
}
|
|
|
|
trap traperr ERR
|
|
|
|
PACKAGES=("$@")
|
|
EXTRA_ARGS=()
|
|
REPOSITORY="grawlinson"
|
|
|
|
if [ ${#PACKAGES[@]} -eq 0 ]; then
|
|
echo "${BOLD}${RED}ERROR:${RESET}${BOLD} no packages specified${RESET}"
|
|
exit 1
|
|
fi
|
|
|
|
for package in "${PACKAGES[@]}"; do
|
|
(
|
|
# change to package directory
|
|
cd "$package" || exit 1
|
|
|
|
# capture output for parsing dependencies
|
|
makepkg_output=$(makepkg --printsrcinfo)
|
|
|
|
#
|
|
# cache various downloads
|
|
#
|
|
# rust - crates
|
|
if grep -q "depends = rust\|cargo" <<<"$makepkg_output"; then
|
|
EXTRA_ARGS+=(
|
|
--bind-rw /var/cache/cargo/git:/build/.cargo/git
|
|
--bind-rw /var/cache/cargo/registry:/build/.cargo/registry
|
|
)
|
|
fi
|
|
|
|
# go - modules
|
|
if grep -q "depends = go" <<<"$makepkg_output"; then
|
|
EXTRA_ARGS+=(
|
|
--bind-rw /var/cache/golang/pkg:/build/go/pkg
|
|
--bind-rw /var/cache/golang/build:/build/.cache/go-build
|
|
)
|
|
fi
|
|
|
|
# dart - packages
|
|
if grep -q "depends = dart" <<<"$makepkg_output"; then
|
|
EXTRA_ARGS+=(--bind-rw /var/cache/dartlang:/build/.pub-cache)
|
|
fi
|
|
|
|
# javascript - npm/yarn/pkg
|
|
if grep -q "depends = npm\|yarn\|nodejs" <<<"$makepkg_output"; then
|
|
EXTRA_ARGS+=(
|
|
--bind-rw /var/cache/javascript/npm:/build/.npm
|
|
--bind-rw /var/cache/javascript/pkg-cache:/build/.pkg-cache
|
|
--bind-rw /var/cache/javascript/yarn:/build/.cache/yarn
|
|
|
|
)
|
|
fi
|
|
|
|
# build signed package in chroot & add to local repo
|
|
aur build \
|
|
--chroot \
|
|
--gpg-sign \
|
|
--remove \
|
|
--force \
|
|
--database="$REPOSITORY" \
|
|
--makepkg-conf="/etc/aurutils/makepkg-$REPOSITORY.conf" \
|
|
"${EXTRA_ARGS[@]}"
|
|
|
|
# reset EXTRA_ARGS
|
|
EXTRA_ARGS=()
|
|
)
|
|
done
|
|
|
|
exit 0
|
|
|
|
# vim: set ts=2 sw=2 et
|