summaryrefslogtreecommitdiff
path: root/src/aur
diff options
context:
space:
mode:
Diffstat (limited to 'src/aur')
-rwxr-xr-xsrc/aur74
1 files changed, 45 insertions, 29 deletions
diff --git a/src/aur b/src/aur
index 86b93e6..e4c535c 100755
--- a/src/aur
+++ b/src/aur
@@ -47,51 +47,66 @@ main() {
load_files libretools
check_vars libretools DIFFTOOL || exit 1
+ local startdir="$(pwd)"
local missing_deps=()
local ret=0
- for _pkg in "$@"; do
-
- # Remove the version
- _pkg="${_pkg%%[<>=]*}"
-
- if [[ -f "${_pkg}/PKGBUILD" ]]; then
- warning "${_pkg} already existed."
+ local pkg
+ local copy_new
+ local copy_old
+ for pkg in "$@"; do
+ pkg="${pkg%%[<>=]*}" # remove the version
+ msg "Processing package: %s" "$pkg"
+ copy_new="$startdir/$pkg"
+ copy_old=
+
+ if [[ -f "${copy_new}/PKGBUILD" ]]; then
+ warning "%s already exists, will compare with new version." "$pkg"
# Store our copy of the PKGBUILD dir
- _diff="${PWD}/${_pkg}"
- pushd $(mktemp --tmpdir -d ${_pkg}.XXXX) &>/dev/null
- msg2 "Downloading PKGBUILD into ${PWD} for diff"
+ copy_old=$copy_new
+ copy_new="$(mktemp --tmpdir -d aur-${pkg}.new.XXXX)/$pkg"
+ cd "${copy_new%/*}"
fi
- msg "Downloading $_pkg..."
- local url=https://aur.archlinux.org/packages/${_pkg:0:2}/${_pkg}/$_pkg.tar.gz
+ msg2 "Downloading"
+ local url="https://aur.archlinux.org/packages/${pkg:0:2}/$pkg/$pkg.tar.gz"
set -o pipefail
- if ! wget -O- "$url" | bsdtar xf -; then
+ if ! wget -O- -q "$url" | bsdtar xf -; then
ret=$(($ret|2))
- error "Couldn't get $_pkg"
+ error "Couldn't get %s" "$pkg"
continue
fi
set +o pipefail
- pushd $_pkg &>/dev/null
-
- if [[ ! -z $_diff ]]; then
+ if [[ -n $copy_old ]]; then
msg2 "Diffing files"
+ cd "$copy_new"
+
# Diff all files with our difftool
+ local diffed=false
for file in *; do
- "${DIFFTOOL}" "${_diff}/${file}" "${file}"
+ if ! cmp -s "${copy_old}/${file}" "${copy_new}/${file}" ; then
+ warning "%s != %s" "${copy_old}/${file}" "${copy_new}/${file}"
+ diffed=true
+ "${DIFFTOOL}" "${copy_old}/${file}" "${copy_new}/${file}"
+ fi
done
- read -p "Press enter to continue."
+ if $diffed; then
+ read -p "Press enter to continue."
+ fi
# Go back to our copy to continue working
- pushd "${_diff}" &>/dev/null
+ cd "$copy_old"
+ rm -rf -- "${copy_new%/*}"
+ else
+ cd "$copy_new"
fi
. PKGBUILD
################################################################
- pkgbuild-check-nonfree
+ pkgbuild-check-nonfree -c
case $? in
0) :;;
15) warning "This PKGBUILD links to known unfree packages";;
@@ -103,7 +118,7 @@ main() {
local s=0
pkgbuild-check-licenses || s=$?
for i in 1 2 4; do
- if [[ $s -eq $(($s & $i)) ]]; then
+ if [[ $i -eq $(($s & $i)) ]]; then
case $i in
1) warning "pkgbuild-check-licenses encountered an error";;
2) warning "This PKGBUILD has an uncommon license";;
@@ -115,31 +130,32 @@ main() {
################################################################
- _deps=(
+ local _deps=(
# depends
"${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"
# mksource depends
"${mkdepends[@]}" "${mkmakedepends[@]}" "${mkcheckdepends[@]}"
)
+ local _dep
+ msg2 "Checking dependencies"
for _dep in "${_deps[@]}"; do
_dep=${_dep/[<>=]*/}
if ! is_built $_dep; then
if ! pacman -Sddp "$_dep" &>/dev/null ; then
- msg2 "$_dep will be get from AUR"
+ plain "%s: will be downloaded from AUR" "$_dep"
missing_deps+=($_dep)
fi
else
- msg2 "$_dep is on repos"
+ plain "%s: is on repos" "$_dep"
fi
done
-
- popd &>/dev/null
+ cd "$startdir"
done
if [[ ${#missing_deps[*]} -gt 0 ]]; then
- msg2 "Retrieving missing deps: %s" "${missing_deps[*]}"
+ msg "Retrieving missing deps: %s" "${missing_deps[*]}"
"$0" "${missing_deps[@]}"
- ret=$(($ret|2))
+ ret=$(($ret|$?))
fi
return $ret;
}