comparison sbin/fpkg @ 693:3633a41b862b

fpkg: Use modern documentation: "#:" instead of ': ...'. While there: fix some documented behaviour: some command run in all running jails (not only in compatible jails).
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 01 Oct 2024 16:16:28 +0200
parents d1cb22ba641d
children 5931f16f098f
comparison
equal deleted inserted replaced
692:d1cb22ba641d 693:3633a41b862b
1 #!/bin/sh 1 #!/bin/sh
2 # -*- indent-tabs-mode: nil; -*- 2 # -*- indent-tabs-mode: nil; -*-
3 : 'A pkg frontend for common operations that also operates in all 3 #:
4 running jails. 4 #: A pkg frontend for common operations that also operates in all
5 5 #: running jails.
6 :Author: Franz Glasner 6 #:
7 :Copyright: (c) 2019-2024 Franz Glasner. 7 #: :Author: Franz Glasner
8 All rights reserved. 8 #: :Copyright: (c) 2019-2024 Franz Glasner.
9 :License: BSD 3-Clause "New" or "Revised" License. 9 #: All rights reserved.
10 See LICENSE for details. 10 #: :License: BSD 3-Clause "New" or "Revised" License.
11 If you cannot find LICENSE see 11 #: See LICENSE for details.
12 <https://opensource.org/licenses/BSD-3-Clause> 12 #: If you cannot find LICENSE see
13 :ID: @(#)@@SIMPLEVERSIONTAG@@ 13 #: <https://opensource.org/licenses/BSD-3-Clause>
14 14 #: :ID: @(#)@@SIMPLEVERSIONTAG@@
15 ' 15 #:
16
16 17
17 # shellcheck disable=SC2034 # VERSION appears unused 18 # shellcheck disable=SC2034 # VERSION appears unused
18 VERSION='@@VERSION@@' 19 VERSION='@@VERSION@@'
19 20
20 # shellcheck disable=SC2016 # no expansion 21 # shellcheck disable=SC2016 # no expansion
61 and all visible and compatible jails 62 and all visible and compatible jails
62 63
63 config <name> 64 config <name>
64 65
65 Retrieve the value of a given configuration option on the local host 66 Retrieve the value of a given configuration option on the local host
66 and all running visible and compatible jails 67 and all running visible jails
67 68
68 uversion 69 uversion
69 70
70 Call `freebsd-version -u` on the local host and all running visible 71 Call `freebsd-version -u` on the local host and all running visible
71 and compatible jails 72 jails
72 73
73 vv 74 vv
74 75
75 `pkg -vv` on the local host and all running visible jails 76 `pkg -vv` on the local host and all running visible jails
76 77
100 101
101 A "compatible jail" is a jail that'"'"'s "freebsd-version -u" is the same 102 A "compatible jail" is a jail that'"'"'s "freebsd-version -u" is the same
102 as the host'"'"'s. 103 as the host'"'"'s.
103 ' 104 '
104 105
105 # 106 #:
106 # Configuration directory 107 #: Configuration directory
107 # 108 #:
108 : ${CONFIGDIR:="@@ETCDIR@@"} 109 : ${CONFIGDIR:="@@ETCDIR@@"}
109 110
110 # shellcheck disable=SC1091 # not following... 111 # shellcheck disable=SC1091 # not following...
111 [ -r "${CONFIGDIR}/pkgtools.conf" ] && . "${CONFIGDIR}/pkgtools.conf" 112 [ -r "${CONFIGDIR}/pkgtools.conf" ] && . "${CONFIGDIR}/pkgtools.conf"
112 113
114 : ${FPKG_UPDATE_FLAGS=} 115 : ${FPKG_UPDATE_FLAGS=}
115 : ${FPKG_UPGRADE_FLAGS=} 116 : ${FPKG_UPGRADE_FLAGS=}
116 : ${FPKG_SIGN:='===> '} 117 : ${FPKG_SIGN:='===> '}
117 : ${FPKG_SKIPSIGN:='----> '} 118 : ${FPKG_SKIPSIGN:='----> '}
118 119
119 # 120 #:
120 # The official FreeBSD binary repository 121 #: The official FreeBSD binary repository
121 # 122 #:
122 : ${FREEBSD_REPO:=FreeBSD} 123 : ${FREEBSD_REPO:=FreeBSD}
123 124
124 # 125 #:
125 # Local repository with ports with default OPTIONS (i.e. unchanged) 126 #: Local repository with ports with default OPTIONS (i.e. unchanged)
126 # but newer than the packages in the "FreeBSD" repository. 127 #: but newer than the packages in the "FreeBSD" repository.
127 # Some sort of a fast-track repository. 128 #: Some sort of a fast-track repository.
128 # 129 #:
129 : ${LOCALBSDPORTS_REPO:=LocalBSDPorts} 130 : ${LOCALBSDPORTS_REPO:=LocalBSDPorts}
130 131
131 132
133 #: Check whether the jail `_jail` has the same FreeBSD userland version
134 #: as the host the the current process runs.
135 #:
136 #: Args:
137 #: $1 (str): the running jail (name or jail id) to check for
138 #:
139 #: Returns:
140 #: int: 0 (truthy) if the userland versions match, 1 (falsy) otherwise
141 #:
132 has_same_userland_version() { 142 has_same_userland_version() {
133 : 'Check whether the jail `_jail` has the same FreeBSD userland version
134 as the host the the current process runs.
135
136 Args:
137 _jail: the running jail (name or jail id) to check for
138
139 Returns:
140 0 if the userland versions match, 1 otherwise
141
142 '
143 local _jail _host_version _jail_version 143 local _jail _host_version _jail_version
144 144
145 _jail="$1" 145 _jail="$1"
146 146
147 _host_version="$(/bin/freebsd-version -u)" || exit 1 147 _host_version="$(/bin/freebsd-version -u)" || exit 1
151 fi 151 fi
152 return 1 152 return 1
153 } 153 }
154 154
155 155
156 #:
157 #: Do a local `freebsd-version -u` and also for all running jails
158 #:
156 command_uversion() { 159 command_uversion() {
157 : ' Do a local `freebsd-version -u` and also for all running jails
158
159 '
160 local _jail _OLDIFS 160 local _jail _OLDIFS
161 161
162 printf 'LOCALHOST: %s\n' "$(/bin/freebsd-version -u)" 162 printf 'LOCALHOST: %s\n' "$(/bin/freebsd-version -u)"
163 _OLDIFS="$IFS" 163 _OLDIFS="$IFS"
164 IFS=$'\n' 164 IFS=$'\n'
167 done 167 done
168 IFS="$_OLDIFS" 168 IFS="$_OLDIFS"
169 } 169 }
170 170
171 171
172 #:
173 #: Do a local `pkg audit -Fr` and also for all running jails
174 #:
172 command_audit() { 175 command_audit() {
173 : 'Do a local `pkg audit -Fr` and also for all running jails
174
175 '
176 local _j _OLDIFS 176 local _j _OLDIFS
177 177
178 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 178 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
179 pkg audit ${FPKG_AUDIT_FLAGS} 179 pkg audit ${FPKG_AUDIT_FLAGS}
180 _OLDIFS="$IFS" 180 _OLDIFS="$IFS"
189 done 189 done
190 IFS="$_OLDIFS" 190 IFS="$_OLDIFS"
191 } 191 }
192 192
193 193
194 #:
195 #: Do a local `pkg update` and also for all running jails
196 #:
194 command_update() { 197 command_update() {
195 : 'Do a local `pkg update` and also for all running jails
196
197 '
198 local _j _OLDIFS 198 local _j _OLDIFS
199 199
200 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 200 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
201 pkg update ${FPKG_UPDATE_FLAGS} 201 pkg update ${FPKG_UPDATE_FLAGS}
202 _OLDIFS="$IFS" 202 _OLDIFS="$IFS"
211 done 211 done
212 IFS="$_OLDIFS" 212 IFS="$_OLDIFS"
213 } 213 }
214 214
215 215
216 #:
217 #: Do a local `pkg upgrade` and also for all running jails
218 #:
216 command_upgrade() { 219 command_upgrade() {
217 : 'Do a local `pkg upgrade` and also for all running jails
218
219 '
220 local _j _OLDIFS 220 local _j _OLDIFS
221 221
222 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 222 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
223 pkg upgrade ${FPKG_UPGRADE_FLAGS} 223 pkg upgrade ${FPKG_UPGRADE_FLAGS}
224 _OLDIFS="$IFS" 224 _OLDIFS="$IFS"
233 done 233 done
234 IFS="$_OLDIFS" 234 IFS="$_OLDIFS"
235 } 235 }
236 236
237 237
238 #:
239 #: Do a local `pkg upgrade -n` and also for all running jails
240 #:
238 command_check_upgrade() { 241 command_check_upgrade() {
239 : 'Do a local `pkg upgrade -n` and also for all running jails
240
241 '
242 local _j _OLDIFS 242 local _j _OLDIFS
243 243
244 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 244 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
245 pkg upgrade -n ${FPKG_UPGRADE_FLAGS} 245 pkg upgrade -n ${FPKG_UPGRADE_FLAGS}
246 _OLDIFS="$IFS" 246 _OLDIFS="$IFS"
255 done 255 done
256 IFS="$_OLDIFS" 256 IFS="$_OLDIFS"
257 } 257 }
258 258
259 259
260 #:
261 #: Check the fast-track repository versions against the canonical
262 #: FreeBSD repository versions.
263 #:
264 #: Input (Globals):
265 #: FREEBSD_REPO: the (canonical) FreeBSD repository name
266 #: LOCALBSDPORTS_REPO: the fast-track repository name
267 #:
260 command_check_fasttrack() { 268 command_check_fasttrack() {
261 : 'Check the fast-track repository versions against the canonical
262 FreeBSD repository versions.
263
264 Input (Globals):
265 FREEBSD_REPO: the (canonical) FreeBSD repository name
266 LOCALBSDPORTS_REPO: the fast-track repository name
267
268 '
269 local _name _repo _j _OLDIFS 269 local _name _repo _j _OLDIFS
270 270
271 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 271 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
272 pkg query '%n %R' | 272 pkg query '%n %R' |
273 while read -r _name _repo; do 273 while read -r _name _repo; do
296 done 296 done
297 IFS="$_OLDIFS" 297 IFS="$_OLDIFS"
298 } 298 }
299 299
300 300
301 #:
302 #: The `pkg config name` command on the host and all running jails
303 #:
304 #: Args:
305 #: $1 (str): the configuration option to retrieve to
306 #:
307 #: Output (stdout):
308 #: The value of the configuration option
309 #:
301 command_config() { 310 command_config() {
302 : 'The `pkg config name` command on the host and all running jails
303
304 Args:
305 _name: the configuration option to retrieve to
306
307 '
308 local _name _j _OLDIFS 311 local _name _j _OLDIFS
309 312
310 _name="$1" 313 _name="$1"
311 314
312 if [ -z "${_name}" ]; then 315 if [ -z "${_name}" ]; then
326 done 329 done
327 IFS="$_OLDIFS" 330 IFS="$_OLDIFS"
328 } 331 }
329 332
330 333
334 #:
335 #: The `pkg -vv` command on the host and all running compatible jails
336 #:
331 command_vv() { 337 command_vv() {
332 : 'The `pkg -vv` command on the host and all running compatible jails
333
334 '
335 local _j _OLDIFS 338 local _j _OLDIFS
336 339
337 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 340 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
338 pkg -vv 341 pkg -vv
339 _OLDIFS="$IFS" 342 _OLDIFS="$IFS"
347 fi 350 fi
348 done 351 done
349 IFS="$_OLDIFS" 352 IFS="$_OLDIFS"
350 } 353 }
351 354
352 355 #:
356 #: Call `etcupdate status` on the host and all running jails
357 #:
353 command_etcupdate_status() { 358 command_etcupdate_status() {
354 : 'Call `etcupdate status` on the host and all running jails
355
356 '
357 local _j _OLDIFS 359 local _j _OLDIFS
358 360
359 printf '%sLOCALHOST\n' "${FPKG_SIGN}" 361 printf '%sLOCALHOST\n' "${FPKG_SIGN}"
360 /usr/sbin/etcupdate status 362 /usr/sbin/etcupdate status
361 _OLDIFS="$IFS" 363 _OLDIFS="$IFS"