aur/build.sh

78 lines
2.2 KiB
Bash
Raw Normal View History

2021-05-19 09:48:07 +02:00
#!/bin/bash
2022-07-02 10:47:43 +02:00
# shellcheck disable=SC3044,SC3009
2021-05-19 09:59:59 +02:00
2022-06-28 10:30:05 +02:00
. .util.sh
2022-06-28 10:30:05 +02:00
build() {
2022-11-16 22:37:48 +01:00
local upd=$1
2022-06-28 10:30:05 +02:00
if grep -c 'git+' PKGBUILD >/dev/null && ! grep -c '#tag=' PKGBUILD >/dev/null; then
2021-05-19 13:39:48 +02:00
makepkg --nodeps --nobuild --skippgpcheck --noconfirm
2022-12-28 21:18:12 +01:00
makepkg --printsrcinfo >.SRCINFO
2022-11-16 22:37:48 +01:00
if [[ "${upd}" = true ]]; then
update_pkg
fi
2021-05-19 13:26:30 +02:00
fi
2021-06-04 08:35:25 +02:00
name=$(grep -m1 'pkgname' .SRCINFO | cut -d'=' -f2 | tr -d ' ')
2021-05-19 13:17:53 +02:00
ver=$(grep 'pkgver' .SRCINFO | cut -d'=' -f2 | tr -d ' ')
rel=$(grep 'pkgrel' .SRCINFO | cut -d'=' -f2 | tr -d ' ')
epoch=$(grep 'epoch' .SRCINFO | cut -d'=' -f2 | tr -d ' ')
2022-11-16 22:37:48 +01:00
if [[ -n "${epoch}" ]]; then
2022-06-28 10:30:05 +02:00
epoch=${epoch}:
2021-05-19 12:24:22 +02:00
fi
2021-05-19 11:53:25 +02:00
if pacman -Si "${name}" | grep -v nyyu | grep -c -E '^Repository' >/dev/null; then
echo "WARN: Found ${name} in arch repo"
fi
2022-06-28 10:30:05 +02:00
if ! compgen -G "/repo/${name}-${epoch}${ver}-${rel}-*.pkg.tar.zst" >/dev/null; then
2022-12-28 21:18:12 +01:00
if makepkg -s --nodeps --skippgpcheck --noconfirm --sign || makepkg -s --skippgpcheck --noconfirm --sign || makepkg -s --skippgpcheck --nocheck --noconfirm --sign; then
2022-06-28 10:30:05 +02:00
for pkg in *.pkg.tar.zst; do
cp "${pkg}"{,.sig} /repo/
repo-add -R -s /repo/nyyu.db.tar.zst /repo/"${pkg}"
2021-05-19 11:53:25 +02:00
done
2021-06-05 21:01:44 +02:00
sudo pacman -Sy
2021-05-19 11:53:25 +02:00
fi
2021-05-19 09:48:07 +02:00
fi
2021-05-19 11:26:24 +02:00
}
2022-08-01 07:58:04 +02:00
git config --global user.email "drone@nyyu.dev"
git config --global user.name "drone"
2022-11-16 22:07:36 +01:00
git remote set-url origin "${CI_REPO_REMOTE}"
2022-07-02 10:47:43 +02:00
# shellcheck disable=SC2016
2022-06-25 11:23:01 +02:00
git config credential.helper '!f() { sleep 1; echo "username=drone"; echo "password=${GIT_PASSWORD}"; }; f'
2021-08-20 07:09:29 +02:00
2022-06-28 10:30:05 +02:00
for d in */; do
cd "${d}" || continue
if [ -f PKGBUILD ]; then
echo "--> ${d}"
if [ -f update.sh ]; then
./update.sh
fi
if ! grep -c 'pkgver()' PKGBUILD >/dev/null; then
repo=$(grep -oPm 1 'github\.com\/\K([a-z0-9]|-)+\/([a-z0-9]|-)+' .SRCINFO)
if [ -n "${repo}" ]; then
update_github_tag "${repo}" && update_pkg
fi
fi
2022-11-16 22:37:48 +01:00
build true
2022-06-28 10:30:05 +02:00
fi
2021-05-19 09:48:07 +02:00
cd ..
done
2021-05-19 11:26:24 +02:00
while read -r p; do
2022-06-28 10:30:05 +02:00
git clone https://aur.archlinux.org/"${p}".git || continue
cd "${p}" || continue
2022-11-16 22:37:48 +01:00
build false
2021-05-19 11:26:24 +02:00
cd ..
done <aur.txt
2021-09-25 09:58:23 +02:00
2022-11-16 22:17:52 +01:00
del=$(git --no-pager diff ${CI_PREV_COMMIT_SHA}..HEAD aur.txt | tail -n +4 | grep -E '^-' | cut -c2-)
2022-07-02 10:47:43 +02:00
if [ -n "${del}" ]; then
# shellcheck disable=SC2086
2022-11-16 22:17:52 +01:00
repo-remove -s /repo/nyyu.db.tar.zst ${del} || true
2022-07-02 10:47:43 +02:00
fi