forked from CamilleScholtz/bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allmk
executable file
·57 lines (46 loc) · 1.04 KB
/
allmk
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
#!/bin/bash
#
# allmk - Recompile all installed packages
# onodera, https://github.com/onodera-punpun
## CONFIGURATION
# Config location
config="/etc/mk.conf"
# Upgraded packages list location
upgraded="/home/onodera/upgraded"
## EXECUTE
ports="$(ports -l)"
installed="$(pkginfo -i | cut -d " " -f 1)"
order="$(grep "^order" "$config" | cut -d " " -f 2-)"
for package in $installed; do
location="$(echo "$ports" | grep "/$package$")"
# Recompile
if [[ -n "$(grep "$location" "$upgraded")" ]]; then
continue
fi
# Order
if [[ "$(echo "$location" | wc -l)" -ge 2 ]]; then
for line in $order; do
location="$(echo "$location" | grep "^$line/")"
if [[ "$?" -eq 0 ]]; then
break
fi
done
fi
cd "/usr/ports/$location"
echo "=======> RECOMPILING: $location"
read -p "Do you want to recompile this package? [Y/n] " answer
case "$answer" in
[Nn]*)
echo "$location" >> "$upgraded"
continue
;;
*)
sudo pkgmk -d -u -f
if [[ "$?" -ge 1 ]]; then
exit 1
else
echo "$location" >> "$upgraded"
fi
;;
esac
done