Skip to content

Commit 4fae2a3

Browse files
committed
build
1 parent 9adbcca commit 4fae2a3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,51 @@ if test "${get_colors_sourced:-}" != "1"; then
256256
fi
257257
##### END pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/get_colors.sh
258258

259+
# shellcheck source=../../../helper-scripts/usr/libexec/helper-scripts/package_installed_check.bsh
260+
##### BEGIN pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/package_installed_check.bsh
261+
#!/bin/bash
262+
263+
## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <[email protected]>
264+
## See the file COPYING for copying conditions.
265+
266+
## NOTE: Must not include bashisms!
267+
268+
## NOTE: code duplication: Function pkg_installed is duplicated elsewhere in derivative-maker source code.
269+
pkg_installed() {
270+
local package_name dpkg_query_output
271+
local requested_action status error_state
272+
273+
package_name="$1"
274+
## Cannot use '&>' because it is a bashism.
275+
dpkg_query_output="$(dpkg-query --show --showformat='${Status}' "$package_name" 2>/dev/null)" || true
276+
## dpkg_query_output Examples:
277+
## install ok half-configured
278+
## install ok installed
279+
280+
requested_action=$(printf '%s' "$dpkg_query_output" | awk '{print $1}')
281+
status=$(printf '%s' "$dpkg_query_output" | awk '{print $2}')
282+
error_state=$(printf '%s' "$dpkg_query_output" | awk '{print $3}')
283+
284+
if [ "$requested_action" = 'install' ]; then
285+
true "$0: INFO: $package_name is installed, ok."
286+
return 0
287+
fi
288+
289+
true "$0: INFO: $package_name is not installed, ok."
290+
return 1
291+
}
292+
293+
if [ "${BASH_SOURCE}" = "${0}" ]; then
294+
## Script was executed.
295+
## This is useful to allow non-Bash shell scripts to use this functionality.
296+
set -o errexit
297+
set -o nounset
298+
set -o errtrace
299+
set -o pipefail
300+
pkg_installed "$1"
301+
fi
302+
##### END pasted by build-dist-installer-cli from file /usr/libexec/helper-scripts/package_installed_check.bsh
303+
259304
########################
260305
## END DEFAULT VALUES ##
261306
########################
@@ -365,6 +410,9 @@ get_su_cmd(){
365410
has su && sucmd=su && break
366411
[ -z "${sucmd:-}" ] && sucmd=''
367412
test -z "${sucmd}" && {
413+
if pkg_installed user-sysmaint-split; then
414+
die 1 "${underline}get_su_cmd:${nounderline} Failed to find program to run commands with administrative ('root') privileges. Package 'user-sysmaint-split' detected. You need to boot into sysmaint session."
415+
fi
368416
die 1 "${underline}get_su_cmd:${nounderline} Failed to find program to run commands with administrative ('root') privileges. This program requires either one of the following programs to be installed:
369417
- sudo (recommended)
370418
- doas

0 commit comments

Comments
 (0)