-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurman
executable file
·119 lines (104 loc) · 2.14 KB
/
aurman
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#argument parsing
#number of command line flags specified
flagcount=0
# force update?
force=0
# remove rather than isntall?
remove=0
#number of args that are not flags
extra_args=0
while getopts ":fur" opt; do
case $opt in
f)
echo "Force!"
force=1
((flagcount++))
;;
u)
sudo -k pacman -Syu
((flagcount++))
;;
r)
remove=1
((flagcount++))
;;
\?)
echo "invalid option!"
;;
esac
done
cd ~/aur/packages
extra_args=$(($# - flagcount))
#remove flags from args
if ((extra_args > 0)); then
shift $flagcount
fi
if ((remove == 1)); then
if ((extra_args == 0)); then
echo "ERROR: specifiy at least 1 package to remove!"
exit 1
fi
echo "number of args $extra_args"
for pkg in "$@"
do
echo "removing $pkg"
if [ -d "$pkg" ]; then
echo "found aur download, removing..."
rm -rf $pkg
fi
sudo -k pacman -Rns $pkg
done
exit 0
fi
# get names of packages to be updated
# if there are more cmd args than flags parsed, the remaining are treated as package names
if ((extra_args > 0)); then
DIRECTS="$@"
# if no option or only flags are specified, update all
else
DIRECTS="$(ls -I *.sh)"
fi
echo directories: $DIRECTS
# turn space delimited list into newline delimited list for easy iteration and remove any flags given
DIRECTS=$(echo $DIRECTS | tr ' ' '\n' | grep -e '^-' -v)
echo directories: $DIRECTS
#iterate over packages and update each
for DIRECT in $DIRECTS
do
#check if package directory already exists (update) or not (install)
if [ -d $DIRECT ]; then
# package exists, we need to update
echo updating $DIRECT
if [ "$force" -eq "1" ]; then
# force update
echo removing old install files
rm -rf ./$DIRECT
echo cloning aur repo package
git clone https://aur.archlinux.org/$DIRECT.git
else
# if no force, update git repo
cd $DIRECT
git pull
cd ..
fi
else
echo installing $DIRECT
git clone https://aur.archlinux.org/$DIRECT.git
fi
echo `pwd`
cd $DIRECT
$EDITOR PKGBUILD
read -p "Are you sure? " -n 1 -r
echo
echo "got ${REPLY}"
if [[ $REPLY == y ]]; then
echo "running makepkg"
makepkg -si --needed
else
echo "skipping"
fi
sudo -k
cd ..
done
echo done