Skip to content

Commit 4db7d29

Browse files
committed
releng/docker/build-init.sh: add an uption to update packages
1 parent aa8654b commit 4db7d29

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

releng/docker/build-init.sh

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ Usage: $0 [options]
3131
-p <package>
3232
Install the named Void Linux package in the container
3333
before building. May be specified more than once to
34-
install more than one package. (This triggers a full
35-
XBPS package upgrade before installation.)
34+
install more than one package.
3635
3736
-t <tag>
3837
Specify specific tag or commit hash to fetch
3938
(Ignored if /zbm already contains a ZFSBootMenu tree)
4039
40+
-u
41+
Update all Void packages, except kernels and zfs, in the container
42+
(Specify more than once to attempt kernel and zfs updates as well)
43+
4144
-V
4245
Do not attempt to update the version recorded in the source tree
4346
@@ -54,13 +57,43 @@ Usage: $0 [options]
5457
EOF
5558
}
5659

60+
hold_kern_zfs() {
61+
local kernels zpkg
62+
63+
# Hold all kernel packages
64+
kernels="$(xbps-query -p pkgname --regex -s 'linux[0-9]+\.[0-9]')" || kernels=
65+
if [ -n "${kernels}" ]; then
66+
cut -d' ' -f2 <<< "${kernels}" | xargs xbps-pkgdb -m hold
67+
fi
68+
69+
# Hold ZFS packages
70+
for zpkg in zfs libzfs zfs-lts libzfs-lts; do
71+
xbps-query -p pkgname "${zpkg}" >/dev/null 2>&1 || continue
72+
xbps-pkgdb -m hold "${zpkg}"
73+
done
74+
}
75+
76+
update_packages() {
77+
case "${1,,}" in
78+
full) ;;
79+
*) hold_kern_zfs ;;
80+
esac
81+
82+
# Attempt to update xbps first
83+
xbps-install -Syu xbps || return 1
84+
85+
# Update all other packages
86+
xbps-install -Syu || return 1
87+
}
88+
5789
PACKAGES=()
5890
CONFIGEVALS=()
5991
GENARGS=()
6092

93+
UPDATE=
6194
SKIP_VERSIONING=
6295

63-
while getopts "hb:o:t:e:p:V" opt; do
96+
while getopts "hb:o:t:e:p:uV" opt; do
6497
case "${opt}" in
6598
b)
6699
BUILDROOT="${OPTARG}"
@@ -77,6 +110,13 @@ while getopts "hb:o:t:e:p:V" opt; do
77110
e)
78111
CONFIGEVALS+=( "${OPTARG}" )
79112
;;
113+
u)
114+
if [ -n "${UPDATE}" ]; then
115+
UPDATE="full"
116+
else
117+
UPDATE="yes"
118+
fi
119+
;;
80120
V)
81121
SKIP_VERSIONING="yes"
82122
;;
@@ -110,12 +150,14 @@ if [ -z "${ZBMTAG}" ]; then
110150
fi
111151
fi
112152

113-
if [ "${#PACKAGES[@]}" -gt 0 ]; then
114-
# Trigger a sync and upgrade to make sure the package is installable
115-
xbps-install -Syu xbps
153+
# Update packages, if desired
154+
if [ -n "${UPDATE}" ]; then
155+
update_packages "${UPDATE}" || error "failed to update packages"
156+
fi
116157

158+
if [ "${#PACKAGES[@]}" -gt 0 ]; then
117159
# Install all requested packages
118-
xbps-install -Sy "${PACKAGES[@]}"
160+
xbps-install -Sy "${PACKAGES[@]}" || error "failed to install requested packages"
119161
fi
120162

121163
# If a custom rc.pre.d exists, run every executable file therein

0 commit comments

Comments
 (0)