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