90 lines
2.8 KiB
Bash
Executable File
90 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# shellcheck disable=SC3044,SC3009,SC2312
|
|
|
|
. .util.sh
|
|
export BUILDDIR=/build
|
|
|
|
build() {
|
|
local upd=$1
|
|
|
|
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
|
|
if [[ "${upd}" = true ]]; then
|
|
update_pkg
|
|
fi
|
|
fi
|
|
name=$(grep -m1 'pkgname' .SRCINFO | cut -d'=' -f2 | tr -d ' ')
|
|
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 ' ')
|
|
if [[ -n "${epoch}" ]]; then
|
|
epoch=${epoch}:
|
|
fi
|
|
|
|
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
|
|
|
|
if ! compgen -G "/repo/${name}-${epoch}${ver}-${rel}-*.pkg.tar.zst" >/dev/null; then
|
|
echo "Building package ${name}-${epoch}${ver}-${rel}"
|
|
if makepkg --nodeps --skippgpcheck --noconfirm --sign || makepkg -C -s --skippgpcheck --noconfirm --sign || makepkg -C -s --skippgpcheck --nocheck --noconfirm --sign; then
|
|
for pkg in *.pkg.tar.zst; do
|
|
cp "${pkg}"{,.sig} /repo/
|
|
repo-add -R -s /repo/nyyu.db.tar.zst /repo/"${pkg}"
|
|
done
|
|
sudo pacman -Syu
|
|
fi
|
|
fi
|
|
}
|
|
|
|
git config --global user.email "drone@nyyu.dev"
|
|
git config --global user.name "drone"
|
|
git remote set-url origin "${CI_REPO_CLONE_URL}"
|
|
# shellcheck disable=SC2016
|
|
git config credential.helper '!f() { sleep 1; echo "username=drone"; echo "password=${GIT_PASSWORD}"; }; f'
|
|
|
|
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(\w|-)+\/(\w|-)+' .SRCINFO)
|
|
if [[ -n "${repo}" ]]; then
|
|
update_github_tag "${repo}"
|
|
fi
|
|
repo=$(grep -oPm 1 'gitea\.com\/\K(\w|-)+\/(\w|-)+' .SRCINFO)
|
|
if [[ -n "${repo}" ]]; then
|
|
update_gitea_tag "${repo}"
|
|
fi
|
|
fi
|
|
update_pkg
|
|
build true
|
|
fi
|
|
cd ..
|
|
done
|
|
|
|
while read -r p; do
|
|
git clone https://aur.archlinux.org/"${p}".git --depth 1 || echo "ERR: Package ${p} not found in AUR"
|
|
cd "${p}" || continue
|
|
build false
|
|
cd ..
|
|
done <aur.txt
|
|
|
|
LAST_COMMIT=$(git --no-pager log --oneline | grep -v 'CI SKIP' | cut -d' ' -f1 | sed -n '5p')
|
|
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)')
|
|
if [[ -n "${del}" ]]; then
|
|
# shellcheck disable=SC2086
|
|
echo "Removing packages ${del}"
|
|
repo-remove -s /repo/nyyu.db.tar.zst ${del} || true
|
|
fi
|