-
Notifications
You must be signed in to change notification settings - Fork 8
/
sabayon-maint-helper
executable file
·110 lines (85 loc) · 2.72 KB
/
sabayon-maint-helper
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
#!/bin/bash
# Copyright 2016-2018 See AUTHORS file
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
. /sbin/sabayondevkit-functions.sh
help_msg() {
echo "
sabayon-maint-helper:
Script for builder boxes maintenance.
-h|--help This message.
--installed Upgrades all the packages installed in the box.
--obsolete Upgrades ONLY the packages that are listed obsolete in eix-test-obsolete.
--all Tries to upgrade all package without any euristics
--category Tries to upgrade/install all the packages in the specified category
e.g. sabayon-maint-helper 'app-office'
Some options could be set also as environment variables:
EMERGE_DEFAULT_ARGS Default emerge options
NOTE: This script MUST be execute as root.
"
}
parse_args() {
local short_opts="h"
local long_opts="help arch: host-arch: unprivileged stagingdir: image-descr: image:"
$(set -- $(getopt -u -q -a -o "$short_opts" -l "$long_opts" -- "$@"))
while [ $# -gt 0 ] ; do
case "$1" in
-h|--help)
help_msg
exit 1
;;
--installed)
echo "Trying to upgrade all the installed packages"
rebuild_all
;;
--obsolete)
echo "Upgrading the packages that are marked as obsolete"
build_obsolete
;;
--all)
echo "Upgrading/Installing everything available to install"
build_all_availables
;;
--category)
echo "Upgrading/Installing everything inside the '$2' category"
build_category_installed "$2"
shift
;;
--)
help_msg
exit 1
;;
*)
echo "Invalid parameter $1."
exit 1
;;
esac
shift
done
return 0
}
main() {
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
[ -z "$@" ] && help_msg && exit 1
(
echo "Acquiring lock"
flock -x -w 10 200 || ( echo "Failed acquiring lock in 10 seconds" && exit 1 )
parse_args "$@"
) 200>/var/lock/.repomaint
}
main "$@"