aur/build.sh

79 lines
2.4 KiB
Bash
Raw Normal View History

2023-02-11 11:26:44 +01:00
#!/bin/bash
2023-04-09 09:51:46 +02:00
# shellcheck disable=SC3044,SC3009,SC2312
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() {
2023-04-09 09:51:46 +02:00
local upd=$1
if grep -c 'git+' PKGBUILD >/dev/null && ! grep -c '#tag=' PKGBUILD >/dev/null; then
makepkg --noprepare --nodeps --nobuild --skippgpcheck --noconfirm
makepkg --printsrcinfo >.SRCINFO
2023-04-09 09:51:46 +02:00
if [[ "${upd}" = true ]]; then
update_pkg
fi
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
2023-04-09 09:51:46 +02:00
if pacman -Si "${name}" 2>/dev/null | 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
2023-03-22 08:43:41 +01:00
echo "Building package ${name}-${epoch}${ver}-${rel}"
2023-03-18 13:43:33 +01:00
if makepkg --nodeps --skippgpcheck --noconfirm --sign || makepkg -C -s --skippgpcheck --noconfirm --sign || makepkg -C -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
2023-04-09 09:51:46 +02:00
if [[ -f PKGBUILD ]]; then
2022-06-28 10:30:05 +02:00
echo "--> ${d}"
2023-04-09 09:51:46 +02:00
if [[ -f update.sh ]]; then
2022-06-28 10:30:05 +02:00
./update.sh
fi
if ! grep -c 'pkgver()' PKGBUILD >/dev/null; then
2023-02-04 09:29:40 +01:00
repo=$(grep -oPm 1 'github\.com\/\K(\w|-)+\/(\w|-)+' .SRCINFO)
2023-04-09 09:51:46 +02:00
if [[ -n "${repo}" ]]; then
2023-03-17 19:42:20 +01:00
update_github_tag "${repo}"
2022-06-28 10:30:05 +02:00
fi
fi
2023-03-17 19:45:25 +01:00
update_pkg
2023-04-09 09:51:46 +02: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
2023-04-09 09:51:46 +02: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-)
2023-04-09 10:07:33 +02:00
del+=$(git --no-pager diff --name-status ${CI_PREV_COMMIT_SHA}..HEAD | grep -Po 'D\s+(\K.*)(?=/PKGBUILD)')
2023-04-09 09:51:46 +02:00
if [[ -n "${del}" ]]; then
2022-07-02 10:47:43 +02:00
# 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