From dede53943fe8480984445057c363fe9f9fbedcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 8 May 2023 14:24:20 +0200 Subject: [PATCH] mkosi.build: use bash, use array for configuration options, shellcheckify With bash, we can use an array for options. This is nice because we can construct the commandline more easily. The file is now shellcheck-clean. --- mkosi.presets/00-base/mkosi.build | 193 +++++++++++++++--------------- 1 file changed, 97 insertions(+), 96 deletions(-) diff --git a/mkosi.presets/00-base/mkosi.build b/mkosi.presets/00-base/mkosi.build index e19251157d..dc1940ae29 100755 --- a/mkosi.presets/00-base/mkosi.build +++ b/mkosi.presets/00-base/mkosi.build @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: LGPL-2.1-or-later set -e @@ -37,119 +37,120 @@ EOF chmod +x "$BUILDDIR"/bpftool fi -if [ ! -f "$BUILDDIR"/build.ninja ] ; then +if [ ! -f "$BUILDDIR"/build.ninja ]; then sysvinit_path=$(realpath /etc/init.d) init_path=$(realpath /sbin/init 2>/dev/null) - if [ -z "$init_path" ] ; then + if [ -z "$init_path" ]; then rootprefix="" else rootprefix=${init_path%/lib/systemd/systemd} rootprefix=/${rootprefix#/} fi + CONFIGURE_OPTS=( + -D sysvinit-path="$sysvinit_path" + -D rootprefix="$rootprefix" + -D default-timeout-sec="${DEFAULT_TIMEOUT_SEC:-10}" + -D default-user-timeout-sec="${DEFAULT_TIMEOUT_SEC:-10}" + -D man=false + -D translations=false + -D version-tag="${VERSION_TAG}" + -D mode=developer + -D b_sanitize="${SANITIZERS:-none}" + -D install-tests=true + -D tests=unsafe + -D slow-tests=true + -D utmp=true + -D hibernate=true + -D ldconfig=true + -D resolve=true + -D efi=true + -D tpm=true + -D environment-d=true + -D binfmt=true + -D repart=true + -D sysupdate=true + -D coredump=true + -D pstore=true + -D oomd=true + -D logind=true + -D hostnamed=true + -D localed=true + -D machined=true + -D portabled=true + -D sysext=true + -D userdb=true + -D homed=true + -D networkd=true + -D timedated=true + -D timesyncd=true + -D remote=true + -D nss-myhostname=true + -D nss-mymachines=true + -D nss-resolve=true + -D nss-systemd=true + -D firstboot=true + -D randomseed=true + -D backlight=true + -D vconsole=true + -D quotacheck=true + -D sysusers=true + -D tmpfiles=true + -D importd=true + -D hwdb=true + -D rfkill=true + -D xdg-autostart=true + -D translations=true + -D polkit=true + -D acl=true + -D audit=true + -D blkid=true + -D fdisk=true + -D kmod=true + -D pam=true + -D pwquality=true + -D microhttpd=true + -D libcryptsetup=true + -D libcurl=true + -D idn=true + -D libidn2=true + -D qrencode=true + -D gcrypt=true + -D gnutls=true + -D openssl=true + -D cryptolib=openssl + -D p11kit=true + -D libfido2=true + -D tpm2=true + -D elfutils=true + -D zstd=true + -D xkbcommon=true + -D pcre2=true + -D glib=true + -D dbus=true + -D bootloader=true + -D kernel-install=true + -D analyze=true + -D bpf-framework=true + -D ukify=true + ) + # On debian-like systems the library directory is not /usr/lib64 but /usr/lib//. # It is important to use the right one especially for cryptsetup plugins, otherwise they will be # installed in the wrong directory and not be found by cryptsetup. Assume native build. if grep -q -e "ID=debian" -e "ID_LIKE=debian" /etc/os-release && command -v dpkg 2>/dev/null; then - LIBDIR="-Drootlibdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" - PAMDIR="-Dpamlibdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" + CONFIGURE_OPTS+=( + -D rootlibdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" + -D pamlibdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" + ) fi - # Cannot quote $LIBDIR and $PAMDIR, because they may be empty, and meson will fail. - # shellcheck disable=SC2086 - meson setup "$BUILDDIR" \ - ${LIBDIR:-} \ - ${PAMDIR:-} \ - -D "sysvinit-path=$sysvinit_path" \ - -D "rootprefix=$rootprefix" \ - -D default-timeout-sec=${DEFAULT_TIMEOUT_SEC:-10} \ - -D default-user-timeout-sec=${DEFAULT_TIMEOUT_SEC:-10} \ - -D man=false \ - -D translations=false \ - -D version-tag="${VERSION_TAG}" \ - -D mode=developer \ - -D b_sanitize="${SANITIZERS:-none}" \ - -D install-tests=true \ - -D tests=unsafe \ - -D slow-tests=true \ - -D utmp=true \ - -D hibernate=true \ - -D ldconfig=true \ - -D resolve=true \ - -D efi=true \ - -D tpm=true \ - -D environment-d=true \ - -D binfmt=true \ - -D repart=true \ - -D sysupdate=true \ - -D coredump=true \ - -D pstore=true \ - -D oomd=true \ - -D logind=true \ - -D hostnamed=true \ - -D localed=true \ - -D machined=true \ - -D portabled=true \ - -D sysext=true \ - -D userdb=true \ - -D homed=true \ - -D networkd=true \ - -D timedated=true \ - -D timesyncd=true \ - -D remote=true \ - -D nss-myhostname=true \ - -D nss-mymachines=true \ - -D nss-resolve=true \ - -D nss-systemd=true \ - -D firstboot=true \ - -D randomseed=true \ - -D backlight=true \ - -D vconsole=true \ - -D quotacheck=true \ - -D sysusers=true \ - -D tmpfiles=true \ - -D importd=true \ - -D hwdb=true \ - -D rfkill=true \ - -D xdg-autostart=true \ - -D translations=true \ - -D polkit=true \ - -D acl=true \ - -D audit=true \ - -D blkid=true \ - -D fdisk=true \ - -D kmod=true \ - -D pam=true \ - -D pwquality=true \ - -D microhttpd=true \ - -D libcryptsetup=true \ - -D libcurl=true \ - -D idn=true \ - -D libidn2=true \ - -D qrencode=true \ - -D gcrypt=true \ - -D gnutls=true \ - -D openssl=true \ - -D cryptolib=openssl \ - -D p11kit=true \ - -D libfido2=true \ - -D tpm2=true \ - -D elfutils=true \ - -D zstd=true \ - -D xkbcommon=true \ - -D pcre2=true \ - -D glib=true \ - -D dbus=true \ - -D bootloader=true \ - -D kernel-install=true \ - -D analyze=true \ - -D bpf-framework=true \ - -D ukify=true + meson setup "$BUILDDIR" "${CONFIGURE_OPTS[@]}" fi ninja -C "$BUILDDIR" "$@" -if [ "$WITH_TESTS" = 1 ] ; then +if [ "$WITH_TESTS" = 1 ]; then if [ -n "$SANITIZERS" ]; then export ASAN_OPTIONS="$MKOSI_ASAN_OPTIONS" export UBSAN_OPTIONS="$MKOSI_UBSAN_OPTIONS"