1
0
mirror of https://github.com/moparisthebest/arch-ppa synced 2024-11-30 12:32:15 -05:00
arch-ppa/ppa

201 lines
4.4 KiB
Plaintext
Raw Normal View History

2017-03-31 16:45:46 -04:00
#!/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'
2017-03-31 23:02:11 -04:00
ccm_root='/scratch/chroot64'
2017-03-31 16:45:46 -04:00
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
2017-05-15 13:07:26 -04:00
if [[ ! -d $REPLY/.git-nosub ]]
2017-03-31 16:45:46 -04:00
then
rm -rf tmp
git clone "$aurweb/$REPLY".git tmp
2017-05-15 13:07:26 -04:00
mv tmp/.git "$REPLY"/.git-nosub
2017-03-31 16:45:46 -04:00
rm -rf tmp
fi
cd "$REPLY"
2017-05-15 13:07:26 -04:00
mv .git-nosub .git
2017-03-31 16:45:46 -04:00
git fetch -v # returns 0 even if nothing was fetched
git reset --hard HEAD
git merge
2017-03-31 16:45:46 -04:00
cd "$startdir"
else
git clone "$aurweb/$REPLY".git
fi
2017-05-15 13:07:26 -04:00
# .git folders make it a git submodule, we don't want that, need to gitignore .git-nosub
mv "$REPLY"/.git "$REPLY"/.git-nosub
# we don't ever want to track these
rm -f "$REPLY"/.SRCINFO
2017-03-31 16:45:46 -04:00
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
2017-03-31 23:02:11 -04:00
$ccm d
failed=''
# create .SRCINFO, so aurqueue can use it next
for dir in "$@"
do
cd $dir
makepkg --printsrcinfo > .SRCINFO
cd "$src_dir"
done
2017-03-31 16:45:46 -04:00
for dir in $(aurqueue "$@")
do
cd $dir
2017-03-31 23:02:11 -04:00
$ccm s || failed="$failed $dir"
2017-03-31 16:45:46 -04:00
cd "$src_dir"
done
# save packages
cd "$pkg_dir"
2017-03-31 23:02:11 -04:00
for pkg in "$ccm_root"/root/repo/*pkg.tar*
do
mv "$pkg" .
sign_packages "$(basename "$pkg")"
done
2017-03-31 16:45:46 -04:00
repose -f -z $repo_name
sign_packages $repo_name.db $repo_name.files
2017-03-31 23:02:11 -04:00
if [ "$failed" == "" ]
then
# success!, nuke the chroot
2018-09-06 21:21:03 -04:00
echo $ccm n
2017-03-31 23:02:11 -04:00
else
# some failures, just delete the packages
$ccm d
echo "failed packages:$failed"
fi
2017-03-31 16:45:46 -04:00
else
build *
fi
}
rebuild_db() {
cd "$pkg_dir"
repose -f -z $repo_name
sign_packages $repo_name.db $repo_name.files
}
2018-06-19 12:10:51 -04:00
echo_deps() {
cd "$src_dir"
aurchain "$@"
}
2017-03-31 16:45:46 -04:00
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' ' ')
}
2017-04-03 00:20:36 -04:00
build_changed_deps() {
commit="$1"
[ "$commit" == "" ] && commit=HEAD
build_deps $(git diff-tree --no-commit-id --name-status -r "$commit" | grep -v ^D | grep PKGBUILD$ | sed -e 's@/PKGBUILD$@@' -e 's@.*/@@' | tr '\n' ' ')
}
2018-06-19 01:34:16 -04:00
echo_changed() {
commit="$1"
[ "$commit" == "" ] && commit=HEAD
git diff-tree --no-commit-id --name-status -r "$commit" | grep -v ^D | grep PKGBUILD$ | sed -e 's@/PKGBUILD$@@' -e 's@.*/@@' | tr '\n' ' '
}
2018-09-08 15:48:14 -04:00
list_official_packages() {
cd "$src_dir"
ls | xargs -n1 -I {} pacman -Ss '^{}$' | egrep -v "^($repo_name| )"
}
2018-09-08 15:52:17 -04:00
list_installed_paclist() {
paclist $repo_name | cut -d' ' -f1
}
list_installed() {
comm -12 <(pacman -Qq | sort) <(pacman -Slq $repo_name | sort)
}
2017-04-03 00:20:36 -04:00
reinstall() {
2018-09-08 15:52:17 -04:00
list_installed | xargs sudo pacman -S --noconfirm
2017-04-03 00:20:36 -04:00
}
2018-09-08 16:03:31 -04:00
update_installed() {
update $(list_installed | xargs aurchain)
}
2018-06-19 16:56:15 -04:00
clean() {
# git clean -e 'aur/*' -dxn | grep -v .git
git clean -e '*.git*' -e 'aur/*' -dxf
}
undo() {
patch -p1 -R < undo.diff
}
2018-06-19 17:04:17 -04:00
grep_deps() {
grep "$1" src/*/PKGBUILD
}
2017-03-31 16:45:46 -04:00
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
2018-09-06 21:21:03 -04:00
fi