1
0
mirror of https://github.com/moparisthebest/arch-ppa synced 2024-11-21 08:15:01 -05:00

Adds update function

This commit is contained in:
Ryan McGuire 2016-04-15 06:18:07 -04:00
parent a67d1c7740
commit b91db4ddee
2 changed files with 43 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
chroot chroot
*~ *~
pkg pkg
src/**/*.gz
src/**/*.xz
src/**/*.log

View File

@ -39,6 +39,7 @@ install_system_deps() {
fi fi
} }
pkg_dep devtools pkg_dep devtools
pkg_dep git
) )
} }
@ -132,6 +133,45 @@ add() {
) )
} }
update() {
# Update a package and it's dependencies from the AUR
(
set -e
if [ ! -d $basedir/src/$1 ]; then
echo "No package called $1 found in src"
return 1
fi
for pkg in "$@"; do
check_in_git() {
(
cd $basedir
if (! git ls-files $1 --error-unmatch >/dev/null 2>&1); then
echo "$1 is not under git control yet. Add and commit it before updating."
return 1
fi
)
}
check_in_git $basedir/src
check_in_git $basedir/src/$pkg
find_deps $pkg | while read dep; do
check_in_git $basedir/src/$dep
done
# Check if package has uncommited changes
if [ $(git -C $basedir diff HEAD $basedir/src/$pkg | wc -l) -gt 0 ]; then
echo "Package $pkg has uncommited changes. Commit or discard those changes first."
return 1
fi
# Use a temporary dir to download all PKGBUILDS atomically
[ -z "$tmp_dl" ] && tmp_dl=`mktemp -d`
cd $tmp_dl
arch-nspawn $chroot/root --bind=$tmp_dl:/src cower -q -t /src -d -d $pkg >/dev/null 2>&1
cp -a * $basedir/src
done
git -C $basedir diff --name-status $basedir/src/
)
}
list() { list() {
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo "Must specify repository name to list" echo "Must specify repository name to list"