]> code.delx.au - monosys/blob - aur-install
lib-ext-backup: set backup pool props
[monosys] / aur-install
1 #!/bin/bash
2
3 set -eu
4
5 PKGNAME="$1"
6 if [ -z "$PKGNAME" ]; then
7 echo "Usage: $0 pkgname"
8 exit 1
9 fi
10
11 shift
12 MAKEPKG_CMD=("$@")
13 if [ ${#MAKEPKG_CMD[@]} -eq 0 ]; then
14 MAKEPKG_CMD=("makepkg" "-sri")
15 fi
16
17 function enter_directory {
18 mkdir -p "$1"
19 cd "$1"
20 }
21
22 function fetch_latest_changes {
23 if [ ! -d .git ]; then
24 git init
25 git remote add origin "https://aur.archlinux.org/${PKGNAME}"
26 fi
27 git fetch
28 git reset origin/master
29 }
30
31 function show_diff {
32 git diff -R
33 }
34
35 function ask_user_to_continue {
36 read -r -p "Ok? (y/n) " ok
37 if [ "$ok" != "y" ]; then
38 return 1
39 fi
40 }
41
42 function build_and_install {
43 git checkout .
44 "${MAKEPKG_CMD[@]}"
45 }
46
47 enter_directory "/var/abs/${PKGNAME}"
48 fetch_latest_changes
49 show_diff
50 ask_user_to_continue
51 build_and_install