aur/build.sh

91 lines
2.9 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
2023-12-09 14:19:53 +01:00
export BUILDDIR=/build
2022-06-28 10:30:05 +02:00
build() {
2023-04-09 09:51:46 +02:00
local upd=$1
2023-12-09 14:19:53 +01:00
rm -rf /build/*
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
2024-04-22 22:08:32 +02:00
sudo pacman -Syu --noconfirm
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"
2024-05-20 19:49:27 +02:00
git config --global init.defaultBranch master
2023-12-09 14:19:53 +01:00
git remote set-url origin "${CI_REPO_CLONE_URL}"
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
2023-08-05 14:40:59 +02:00
repo=$(grep -oPm 1 'gitea\.com\/\K(\w|-)+\/(\w|-)+' .SRCINFO)
if [[ -n "${repo}" ]]; then
update_gitea_tag "${repo}"
fi
2022-06-28 10:30:05 +02:00
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
2023-05-29 16:14:46 +02:00
git clone https://aur.archlinux.org/"${p}".git --depth 1 || echo "ERR: Package ${p} not found in AUR"
2022-06-28 10:30:05 +02:00
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
2023-12-27 10:32:14 +01:00
LAST_COMMIT=$(git --no-pager log --oneline | grep -v 'CI SKIP' | cut -d' ' -f1 | sed -n '5p')
2023-12-26 09:46:12 +01:00
LAST_COMMIT=${CI_PREV_COMMIT_SHA:-$LAST_COMMIT}
echo "Finding removed packages from ${LAST_COMMIT}"
del=$(git --no-pager diff ${LAST_COMMIT}..HEAD aur.txt | tail -n +4 | grep -E '^-' | cut -c2-)
del+=$(git --no-pager diff --name-status ${LAST_COMMIT}..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
2023-12-10 10:09:22 +01:00
echo "Removing packages ${del}"
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