From 3a7f9acd625d69d48cc8a8a8b04dcd7ba9b78037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luc=C3=ADa=20Andrea=20Illanes=20Albornoz?= Date: Mon, 20 Mar 2023 09:47:46 +0100 Subject: Implements --theme in {build,pkgtool}.sh. --- build.sh | 9 +++++++++ etc/README.md | 9 +++++---- etc/build.usage | 6 +++--- etc/build.usage.short | 6 +++--- etc/pkgtool.usage | 3 ++- pkgtool.sh | 18 +++++++++++++++++- subr.ex/ex_init.subr | 25 ++++++++++++++++++++++++- 7 files changed, 63 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index 30ca7d30..53225efb 100755 --- a/build.sh +++ b/build.sh @@ -78,6 +78,7 @@ buildp_init() { || ! ex_init_getopts \ "${_bi_rstatus}" "buildp_init_getopts_fn" \ "${_bi_optstring}" "${@}" \ + || ! ex_init_theme "${_bi_rstatus}" "${_bi_name_base}" "${ARG_THEME:-}" \ || ! ex_init_logging "${_bi_rstatus}" \$ARG_VERBOSE_TAGS "${ARG_VERBOSE}" \ || ! ex_pkg_load_vars "${_bi_rstatus}" \$ARCH \$BUILD_KIND \ || ! ex_init_prereqs "${_bi_rstatus}" "${DEFAULT_PREREQS}" \ @@ -210,6 +211,14 @@ buildp_init_getopts_fn() { --debug-minipx) ARG_DEBUG_MINIPIX=1; _bpigf_shiftfl=1; ;; --help) _bpigf_shiftfl=1; ;; --reset-state) ARG_RESET_PKG=1; _bpigf_shiftfl=1; ;; + --theme) shift 3; + if [ "${#}" != 1 ]; then + rtl_setrstatus "${_bpigf_rstatus}" 'missing argument to --theme option'; + return 1; + else + ARG_THEME="${1:-}"; _bpigf_shiftfl=2; + fi; + ;; # {{{ --roar --roar) printf "%s\n" ' diff --git a/etc/README.md b/etc/README.md index 9417cb79..5fa748db 100644 --- a/etc/README.md +++ b/etc/README.md @@ -809,10 +809,10 @@ VERSION`` and/or ``URLS_GIT``, respectively. usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST] [-r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]] [-R] - [-v] [-V [+]tag|pat[,..]] + [-v] [-V [+]tag|pat[,..]] - [--as-needed] [--debug-minipix] [--reset-state] - [--roar] [[=]|=[ ..]] + [--as-needed] [--debug-minipix] [--reset-state] [--roar] + [--theme theme] [[=]|=[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build kind; defaults to debug. @@ -910,7 +910,8 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[ ## 4.6. ``pkgtool.sh`` ``` -usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m -M |-r|-R|-t] [-v] +usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m -M |-r|-R|-t] + [--theme theme] [-v] [=[ ..]] name -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. diff --git a/etc/build.usage b/etc/build.usage index 0e2f14ff..ccba4be9 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,10 +1,10 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST] [-r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]] [-R] - [-v] [-V [+]tag|pat[,..]] + [-v] [-V [+]tag|pat[,..]] - [--as-needed] [--debug-minipix] [--reset-state] - [--roar] [[=]<group>|<variable name>=<variable override>[ ..]] + [--as-needed] [--debug-minipix] [--reset-state] [--roar] + [--theme theme] [[=]<group>|<variable name>=<variable override>[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build kind; defaults to debug. diff --git a/etc/build.usage.short b/etc/build.usage.short index 43b2ad1c..db8ee464 100644 --- a/etc/build.usage.short +++ b/etc/build.usage.short @@ -1,10 +1,10 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] [-F ipv4|ipv6|offline] [-h|--help] [-p jobs|-P] [-r ALL|LAST] [-r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]] [-R] - [-v] [-V [+]tag|pat[,..]] + [-v] [-V [+]tag|pat[,..]] - [--as-needed] [--debug-minipix] [--reset-state] - [--roar] [[=]<group>|<variable name>=<variable override>[ ..]] + [--as-needed] [--debug-minipix] [--reset-state] [--roar] + [--theme theme] [[=]<group>|<variable name>=<variable override>[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build kind; defaults to debug. diff --git a/etc/pkgtool.usage b/etc/pkgtool.usage index 446ac3a3..4b24d09e 100644 --- a/etc/pkgtool.usage +++ b/etc/pkgtool.usage @@ -1,4 +1,5 @@ -usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m <dname> -M <dname>|-r|-R|-t] [-v] +usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-i|-m <dname> -M <dname>|-r|-R|-t] + [--theme theme] [-v] [<variable name>=<variable override>[ ..]] name -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. diff --git a/pkgtool.sh b/pkgtool.sh index a309cf9e..2faa0747 100755 --- a/pkgtool.sh +++ b/pkgtool.sh @@ -32,6 +32,9 @@ pkgtoolp_init() { || ! ex_init_getopts \ "${_pi_rstatus}" "pkgtoolp_init_getopts_fn" \ "${_pi_optstring}" "${@}" \ + || ! ex_init_theme \ + "${_pi_rstatus}" "${_pi_name_base}" \ + "${ARG_THEME:-}" \ || ! ex_init_prereqs "${_pi_rstatus}" "${_pi_prereqs}" \ || ! ex_pkg_load_vars \ "${_pi_rstatus}" \$ARCH \$BUILD_KIND \ @@ -89,7 +92,20 @@ pkgtoolp_init_getopts_fn() { ;; longopt) - _ppigf_rc=1; + local _ppigf_verb="${1}" _ppigf_rstatus="${2#\$}" _ppigf_opt="${3}"; + + case "${_ppigf_opt}" in + --theme) shift 3; + if [ "${#}" != 1 ]; then + rtl_setrstatus "${_ppigf_rstatus}" 'missing argument to --theme option'; + return 1; + else + ARG_THEME="${1:-}"; _ppigf_shiftfl=2; + fi; + ;; + + *) _ppigf_shiftfl=0; ;; + esac; ;; opt) diff --git a/subr.ex/ex_init.subr b/subr.ex/ex_init.subr index 3fb6ccec..fcabce07 100644 --- a/subr.ex/ex_init.subr +++ b/subr.ex/ex_init.subr @@ -115,7 +115,7 @@ ex_init_getopts() { while [ "${#}" -gt 0 ]; do case "${1}" in --*) - "${_eig_fn}" longopt "${_eig_rstatus}" "${1}"; + "${_eig_fn}" longopt "${_eig_rstatus}" "${1}" ${2:-}; _eig_fn_rc="${?}"; case "${_eig_fn_rc}" in @@ -407,4 +407,27 @@ ex_init_prereqs() { return "${_eip_rc}"; }; +# +# ex_init_theme() - initialise theme +# @_rstatus: reference to out variable of status string on failure +# @_name_base: base name for theme file(s) +# @_theme: theme name +# +# Return: zero (0) on success, non-zero (>0) on failure +# +ex_init_theme() { + local _eit_rstatus="${1#\$}" _eit_name_base="${2}" _eit_theme="${3}" \ + _eit_rc=0 _eit_theme_fname=""; + + _eit_theme_fname="etc/${_eit_name_base}${_eit_theme:+.${_eit_theme}}.theme"; + if ! [ -e "${_eit_theme_fname}" ]; then + _eit_rc=1; + exp_setrstatus "${_eit_rstatus}" 'failed to source \`'"${_eit_theme_fname}"''\''.'; + else + . "${_eit_theme_fname}"; + fi; + + return "${_eit_rc}"; +}; + # vim:filetype=sh textwidth=0 -- cgit v1.2.3