diff options
author | Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de> | 2023-03-20 09:47:46 +0100 |
---|---|---|
committer | Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de> | 2023-03-20 09:47:46 +0100 |
commit | 3a7f9acd625d69d48cc8a8a8b04dcd7ba9b78037 (patch) | |
tree | 6b424bcfb1273a1e47ee4cfcb494d508c1c5ad8f | |
parent | 82f78cc4ded0008991a135b944f553b54b969a0c (diff) | |
download | midipix_build-3a7f9acd625d69d48cc8a8a8b04dcd7ba9b78037.tar.bz2 midipix_build-3a7f9acd625d69d48cc8a8a8b04dcd7ba9b78037.tar.xz |
Implements --theme in {build,pkgtool}.sh.
-rwxr-xr-x | build.sh | 9 | ||||
-rw-r--r-- | etc/README.md | 9 | ||||
-rw-r--r-- | etc/build.usage | 6 | ||||
-rw-r--r-- | etc/build.usage.short | 6 | ||||
-rw-r--r-- | etc/pkgtool.usage | 3 | ||||
-rwxr-xr-x | pkgtool.sh | 18 | ||||
-rw-r--r-- | subr.ex/ex_init.subr | 25 |
7 files changed, 63 insertions, 13 deletions
@@ -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] [[=]<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.
@@ -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 <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/etc/build.usage b/etc/build.usage index 0e2f14ff..ccba4be9 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,10 +1,10 @@ [97musage[90m: [33m./[93mbuild.sh [90m[[33m-[93ma nt32[90m|[93mnt64[90m] [[33m-[93mb debug[90m|[93mrelease[90m] [[33m-[93mC dir[90m[[93m,[90m..]] [[33m-[93mD kind[90m[[93m,[90m..]][0m [90m[[33m-[93mF ipv4[90m|[93mipv6[90m|[93moffline[90m] [[33m-[93mh[90m|[33m--[93mhelp[90m] [[33m-[93mp jobs[90m|[33m-[93mP[90m] [[33m-[93mr ALL[90m|[93mLAST[90m][0m [90m[[33m-[93mr [90m[[93m*[90m[[93m*[90m[[93m*[90m]]][93mname[90m[[93m,[90m..][[93m:ALL[90m|[93mLAST[90m|[[93m^[90m|[93m<[90m|[93m<=[90m|[93m>[90m|[93m>=[90m][93mstep,[90m..]] [[33m-[93mR[90m] - [90m[[33m-[93mv[90m] [[33m-[93mV [90m[[93m+[90m][93mtag[90m|[93mpat[90m[[93m,[90m..][90m][0m + [90m[[33m-[93mv[90m] [[33m-[93mV [90m[[93m+[90m][93mtag[90m|[93mpat[90m[[93m,[90m..][90m][0m - [90m[[33m--[93mas-needed[90m] [90m[[33m--[93mdebug-minipix[90m] [90m[[33m--[93mreset-state[90m][0m - [90m[[33m--[93mroar[90m] [[[93m=[90m][90m<[93mgroup[90m>|<[93mvariable name[90m>[93m=[90m<[93mvariable override[90m>[ ..]][0m + [90m[[33m--[93mas-needed[90m] [90m[[33m--[93mdebug-minipix[90m] [90m[[33m--[93mreset-state[90m] [[33m--[93mroar[90m][0m + [90m[[33m--[93mtheme theme[90m] [[[93m=[90m][90m<[93mgroup[90m>|<[93mvariable name[90m>[93m=[90m<[93mvariable override[90m>[ ..]][0m [33m-[93ma nt32[90m|[93mnt64[0m [96mSelects 32-bit or 64-bit architecture; defaults to [93mnt64[96m.[0m [33m-[93mb debug[90m|[93mrelease[0m [96mSelects debug or release build kind; defaults to [93mdebug[96m.[0m 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 @@ [97musage[90m: [33m./[93mbuild.sh [90m[[33m-[93ma nt32[90m|[93mnt64[90m] [[33m-[93mb debug[90m|[93mrelease[90m] [[33m-[93mC dir[90m[[93m,[90m..]] [[33m-[93mD kind[90m[[93m,[90m..]][0m [90m[[33m-[93mF ipv4[90m|[93mipv6[90m|[93moffline[90m] [[33m-[93mh[90m|[33m--[93mhelp[90m] [[33m-[93mp jobs[90m|[33m-[93mP[90m] [[33m-[93mr ALL[90m|[93mLAST[90m][0m [90m[[33m-[93mr [90m[[93m*[90m[[93m*[90m[[93m*[90m]]][93mname[90m[[93m,[90m..][[93m:ALL[90m|[93mLAST[90m|[[93m^[90m|[93m<[90m|[93m<=[90m|[93m>[90m|[93m>=[90m][93mstep,[90m..]] [[33m-[93mR[90m] - [90m[[33m-[93mv[90m] [[33m-[93mV [90m[[93m+[90m][93mtag[90m|[93mpat[90m[[93m,[90m..][90m][0m + [90m[[33m-[93mv[90m] [[33m-[93mV [90m[[93m+[90m][93mtag[90m|[93mpat[90m[[93m,[90m..][90m][0m - [90m[[33m--[93mas-needed[90m] [90m[[33m--[93mdebug-minipix[90m] [90m[[33m--[93mreset-state[90m][0m - [90m[[33m--[93mroar[90m] [[[93m=[90m][90m<[93mgroup[90m>|<[93mvariable name[90m>[93m=[90m<[93mvariable override[90m>[ ..]][0m + [90m[[33m--[93mas-needed[90m] [90m[[33m--[93mdebug-minipix[90m] [90m[[33m--[93mreset-state[90m] [[33m--[93mroar[90m][0m + [90m[[33m--[93mtheme theme[90m] [[[93m=[90m][90m<[93mgroup[90m>|<[93mvariable name[90m>[93m=[90m<[93mvariable override[90m>[ ..]][0m [33m-[93ma nt32[90m|[93mnt64[0m [96mSelects 32-bit or 64-bit architecture; defaults to [93mnt64[96m.[0m [33m-[93mb debug[90m|[93mrelease[0m [96mSelects debug or release build kind; defaults to [93mdebug[96m.[0m 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 @@ -[97musage[90m: [33m./[93mpkgtool.sh [90m[[33m-[93ma nt32[90m|[93mnt64[90m] [[33m-[93mb [93mdebug[90m|[93mrelease[90m] [[33m-[93mi[90m|[33m-[93mm [90m<[93mdname[90m> [33m-[93mM [90m<[93mdname[90m>|[33m-[93mr[90m|[33m-[93mR[90m|[33m-[93mt[90m] [[33m-[93mv[90m][0m +[97musage[90m: [33m./[93mpkgtool.sh [90m[[33m-[93ma nt32[90m|[93mnt64[90m] [[33m-[93mb [93mdebug[90m|[93mrelease[90m] [[33m-[93mi[90m|[33m-[93mm [90m<[93mdname[90m> [33m-[93mM [90m<[93mdname[90m>|[33m-[93mr[90m|[33m-[93mR[90m|[33m-[93mt[90m][0m + [90m[[93m--theme theme[90m] [90m[[33m-[93mv[90m][0m [90m[<[93mvariable name[90m>[93m=[90m<[93mvariable override[90m>[ ..]] [93mname[90m [33m-[93ma nt32[90m|[93mnt64[0m [96mSelects 32-bit or 64-bit architecture; defaults to [93mnt64[96m.[0m @@ -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 |