-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild-packages.sh
executable file
·118 lines (103 loc) · 2.32 KB
/
build-packages.sh
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
#!/usr/bin/env bash
set -e
cmd_usage() {
cat <<-_EOF
Options:
help|-h - Print usage information
build|-b - Build and install all packages
rebuild|-r - Rebuild all packages
needed|-n - Build packages that are not built
missing|-m) - Build and install packages that are not yet installed
clean|-c - Clean all packages
uninstall|-u - Uninstall all packages
srcinfo|-s - Regenerate .SRCINFOs of all packages
_EOF
exit 0
}
cmd_build() {
sudo test true
PACKAGES=$(cat projects.list)
for package in $PACKAGES
do
cd ${package}
yes | makepkg -sfi
echo "----------------------"
cd ..
done
}
cmd_rebuild() {
for package in ./*/
do
cd ${package}
yes | makepkg -sfr --holdver
echo "----------------------"
cd ..
done
}
cmd_needed() {
for package in ./*/
do
cd ${package}
yes | makepkg -sr || true
echo "----------------------"
cd ..
done
}
cmd_missing() {
sudo test true
PACKAGES=$(cat projects.list)
pacman -Q | awk '{print $1}' > packages_on_system.txt
readarray -t package_on_system_list < packages_on_system.txt
for package in $PACKAGES
do
result="$(value_in_array "${package}")"
if [ "false" = "${result}" ]
then
cd "${package}"
echo "##### ${package} #####"
yes | makepkg -si
echo "----------------------"
cd ..
fi
done
}
value_in_array() {
readarray -t package_on_system_list < packages_on_system.txt
[[ " ${package_on_system_list[@]} " =~ " ${1} " ]] && echo "true" || echo "false"
}
cmd_clean() {
for package in ./*/
do
cd ${package}
makepkg -dCo
cd ..
done
}
cmd_uninstall() {
sudo test true
PACKAGES=$(cat projects.list)
for package in $PACKAGES
do
yes | sudo pacman -Rdd ${package} || true
echo "----------------------"
done
}
cmd_srcinfo() {
for package in ./*/
do
cd ${package}
makepkg --printsrcinfo > .SRCINFO
cd ..
done
}
case "$1" in
help|-h) shift; cmd_usage "$@" ;;
build|-b) shift; cmd_build "$@" ;;
rebuild|-r) shift; cmd_rebuild "$@" ;;
needed|-n) shift; cmd_needed "$@" ;;
missing|-m) shift; cmd_missing "$@" ;;
clean|-c) shift; cmd_clean "$@" ;;
uninstall|-u) shift; cmd_uninstall "$@" ;;
srcinfo|-s) shift; cmd_srcinfo "$@" ;;
*) cmd_usage "$@" ;;
esac