#!/bin/bash set -eu PKGNAME="$1" if [ -z "$PKGNAME" ]; then echo "Usage: $0 pkgname" exit 1 fi shift MAKEPKG_CMD=("$@") if [ ${#MAKEPKG_CMD[@]} -eq 0 ]; then MAKEPKG_CMD=("makepkg" "-sr") fi function enter_directory { mkdir -p "$1" cd "$1" } function fetch_latest_changes { if [ ! -d .git ]; then git init git remote add origin "https://aur.archlinux.org/${PKGNAME}" fi git fetch git reset origin/master } function show_diff { git diff -R } function ask_user_to_continue { read -r -p "Ok? (y/n) " ok if [ "$ok" != "y" ]; then return 1 fi } function build_and_install { git checkout . "${MAKEPKG_CMD[@]}" } enter_directory "/var/abs/${PKGNAME}" fetch_latest_changes show_diff ask_user_to_continue build_and_install