mirror of
https://github.com/moparisthebest/arch-ppa
synced 2024-12-21 22:18:48 -05:00
145 lines
3.2 KiB
Bash
Executable File
145 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# requires:
|
|
# https://aur.archlinux.org/packages/clean-chroot-manager
|
|
# https://aur.archlinux.org/packages/aurutils
|
|
|
|
basedir="$(pwd)"
|
|
src_dir="${basedir}/src"
|
|
repo_name=aur
|
|
pkg_dir="${basedir}/$repo_name"
|
|
ccm='sudo ccm64'
|
|
ccm_root='/scratch/chroot64'
|
|
aurweb='https://aur.archlinux.org'
|
|
|
|
if [ `whoami` == 'root' ]; then
|
|
echo "Must not be run as root."
|
|
exit 1;
|
|
fi
|
|
|
|
[ -e ppa.cfg ] && source ppa.cfg
|
|
|
|
clone_update_aur() {
|
|
declare -r startdir=$PWD
|
|
|
|
while IFS= read -r; do
|
|
if [[ -d $REPLY ]]
|
|
then
|
|
|
|
if [[ ! -d $REPLY/.git ]]
|
|
then
|
|
rm -rf tmp
|
|
git clone "$aurweb/$REPLY".git tmp
|
|
mv tmp/.git $REPLY
|
|
rm -rf tmp
|
|
fi
|
|
|
|
cd "$REPLY"
|
|
|
|
git fetch -v # returns 0 even if nothing was fetched
|
|
|
|
if [[ $(git rev-parse HEAD) != $(git rev-parse '@{upstream}') ]]; then
|
|
if [[ -d $logdir ]]; then
|
|
git --no-pager log --patch --stat '..@{upstream}' >> "$logdir/$REPLY".patch
|
|
fi
|
|
|
|
git reset --hard HEAD
|
|
git merge
|
|
fi
|
|
|
|
cd "$startdir"
|
|
else
|
|
git clone "$aurweb/$REPLY".git
|
|
fi
|
|
done
|
|
}
|
|
|
|
add() {
|
|
cd "$src_dir"
|
|
aurchain "$@" | clone_update_aur
|
|
}
|
|
|
|
update() {
|
|
cd "$src_dir"
|
|
if [ "$#" -gt 0 ]; then
|
|
aurchain "$@" | clone_update_aur
|
|
else
|
|
aurchain * | clone_update_aur
|
|
fi
|
|
}
|
|
|
|
sign_packages() {
|
|
cd "$pkg_dir"
|
|
for pkg in "$@"; do
|
|
gpg -v "${pkg}.sig" 2>/dev/null || (rm -f "${pkg}.sig"; gpg --detach-sign --use-agent "$pkg")
|
|
done
|
|
}
|
|
|
|
build() {
|
|
cd "$src_dir"
|
|
if [ "$#" -gt 0 ]; then
|
|
$ccm d
|
|
failed=''
|
|
# create .SRCINFO, so aurqueue can use it next
|
|
for dir in "$@"
|
|
do
|
|
cd $dir
|
|
makepkg --printsrcinfo > .SRCINFO
|
|
cd "$src_dir"
|
|
done
|
|
for dir in $(aurqueue "$@")
|
|
do
|
|
cd $dir
|
|
$ccm s || failed="$failed $dir"
|
|
cd "$src_dir"
|
|
done
|
|
|
|
# save packages
|
|
cd "$pkg_dir"
|
|
for pkg in "$ccm_root"/root/repo/*pkg.tar*
|
|
do
|
|
mv "$pkg" .
|
|
sign_packages "$(basename "$pkg")"
|
|
done
|
|
repose -f -z $repo_name
|
|
sign_packages $repo_name.db $repo_name.files
|
|
|
|
if [ "$failed" == "" ]
|
|
then
|
|
# success!, nuke the chroot
|
|
$ccm n
|
|
else
|
|
# some failures, just delete the packages
|
|
$ccm d
|
|
echo "failed packages:$failed"
|
|
fi
|
|
|
|
else
|
|
build *
|
|
fi
|
|
}
|
|
|
|
build_deps() {
|
|
cd "$src_dir"
|
|
if [ "$#" -gt 0 ]; then
|
|
build $(aurchain "$@")
|
|
else
|
|
# regular build? if we are building all no use looking up deps...
|
|
build
|
|
fi
|
|
}
|
|
|
|
build_changed() {
|
|
commit="$1"
|
|
[ "$commit" == "" ] && commit=HEAD
|
|
build $(git diff-tree --no-commit-id --name-status -r "$commit" | grep -v ^D | grep PKGBUILD$ | sed -e 's@/PKGBUILD$@@' -e 's@.*/@@' | tr '\n' ' ')
|
|
}
|
|
|
|
if [ "$#" -gt 0 ]; then
|
|
[ -d "$src_dir" ] || mkdir -p "$src_dir"
|
|
[ -d "$pkg_dir" ] || mkdir -p "$pkg_dir"
|
|
$*
|
|
else
|
|
echo "Must specify a command, eg: add, build, list, clean"
|
|
exit 1
|
|
fi |