diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-02-13 17:58:20 +0000 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-02-13 17:58:20 +0000 |
commit | 03dd23dc2758b451c7be60f3b2c420b84939eb53 (patch) | |
tree | 6810a70758cb5279d638fd758bb6e0dd62cd5798 | |
parent | 6c6417c564cbf849b4588e72fe56c2c4d210e958 (diff) | |
download | midipix_build-03dd23dc2758b451c7be60f3b2c420b84939eb53.tar.bz2 midipix_build-03dd23dc2758b451c7be60f3b2c420b84939eb53.tar.xz |
subr/build_args.subr: temporarily return to original getopts(1)-based implementation.
etc/build.usage: updated.
-rw-r--r-- | etc/build.usage | 20 | ||||
-rw-r--r-- | subr/build_args.subr | 73 |
2 files changed, 66 insertions, 27 deletions
diff --git a/etc/build.usage b/etc/build.usage index 8cba04f0..7a413779 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,16 +1,16 @@ -usage: ./build.sh [-a nt32|nt64] [-A] [-b debug|release] [-C dir[,..]] [-d] [-D kind[,..]] - [-F ipv4|ipv6|offline] [-h] [-P [jobs]] [-r [*]ALL|LAST|name[,..][:step,..]] - [-R] [-v[v[v[v]]]] [<group>[ ..]] +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] + [-F ipv4|ipv6|offline] [-h] [-P [jobs]] [-r ALL|LAST|name[,..][:step,..]] + [-R] [-v[v[v[v]]]] [--as-needed] [--debug-minipix] [<group>[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. - -A Don't build unless the midipix_build repository has received new commits. -b debug|release Selects debug or release build; defaults to debug. -C dir[,..] Clean build directory (build,) ${PREFIX} before processing build scripts (prefix,) source directory (src,) and/or destination directory (dest) after successful package builds. - -d Don't strip(1) minipix binaries to facilitate debugging minipix. -D kind[,..] Produce minimal midipix distribution directory (minipix,) package - tarballs (pkg,) RPM binary packages (rpm,) and/or deployable distribution - ZIP archive (zipdist.) + tarballs (pkg,) RPM binary packages (rpm,) compressed and optionally + signed binary and source tarballs containing ${PREFIX} sans ${BUILD_WORKDIR} + (t{bz2,gz,xz},) and/or deployable distribution ZIP archive (zipdist.) + {t{bz2,gz,xz},zipdist} imply minipix. -F ipv4|ipv6|offline Force IPv4 (ipv4) or IPv6 (ipv6) when downloading package archives and/or Git repositories or don't download either at all (offline.) @@ -20,12 +20,10 @@ usage: ./build.sh [-a nt32|nt64] [-A] [-b debug|release] [-C dir[,..]] [-d] [-D processors on the host system. If -R is not specified and at least one (1) package fails to build, all remaining package builds will be forcibly aborted for convenience. - -r [*]ALL[:step,..]|LAST|name[,..][:step,..] + -r ALL[:step,..]|LAST|name[,..][:step,..] Restart all packages/the specified comma-separated package(s) completely or at optionally specified comma-separated step(s) or restart the last failed package and resume build. - Prepend w/ `*' to automatically include dependencies. - Currently defined steps are: fetch_wget, fetch_git, fetch_extract, configure_patch_pre, configure_autotools, configure_patch, @@ -35,6 +33,8 @@ usage: ./build.sh [-a nt32|nt64] [-A] [-b debug|release] [-C dir[,..]] [-d] [-D -R Ignore build failures, skip printing package logs, and continue building (relaxed mode.) -v[v[v[v]]] Be verbose; -vv: always print package logs; -vvv: set xtrace during package builds; -vvvv: logs fileops. + --as-needed Don't build unless the midipix_build repository has received new commits. + --debug-minipix Don't strip(1) minipix binaries to facilitate debugging minipix. <group>[ ..] One of: host_deps, host_deps_rpm, host_toolchain, host_tools, minipix, native_packages, native_runtime, native_toolchain, and/or native_tools. diff --git a/subr/build_args.subr b/subr/build_args.subr index 35761819..08373261 100644 --- a/subr/build_args.subr +++ b/subr/build_args.subr @@ -2,24 +2,57 @@ # set -o noglob is assumed. # +BUILD_ARGS_SPEC=" + ARCH:arg:-a: + ARG_AS_NEEDED:--as-needed: + ARG_CLEAN_BUILDS:arg:-C: + ARG_DEBUG_MINIPIX:--debug-minipix: + ARG_DIST:arg:-D: + ARG_FETCH_FORCE:-F: + ARG_PARALLEL:optarg:-P:auto + ARG_RELAXED:-R: + ARG_RESTART:arg:-r: + ARG_VERBOSE:selfarg:-v: + ARG_VERBOSE:selfarg:-vv: + ARG_VERBOSE:selfarg:-vvv: + ARG_VERBOSE:selfarg:-vvvv: + BUILD:arg:-b:"; + build_args() { - local _opt=""; - while getopts a:Ab:C:dD:FhPr:Rv _opt; do - case "${_opt}" in - a) ARCH="${OPTARG}"; ;; - A) ARG_AS_NEEDED=1; ;; - b) BUILD="${OPTARG}"; ;; - C) ARG_CLEAN_BUILDS="${OPTARG}"; ;; - d) ARG_DEBUG_MINIPIX=1; ;; - D) ARG_DIST="${OPTARG}"; ;; - F) ARG_FETCH_FORCE=1; ;; - h) cat etc/build.usage; exit 0; ;; - P) ARG_PARALLEL="${OPTARG:-auto}"; ;; - r) ARG_RESTART="${OPTARG}"; ;; - R) ARG_RELAXED=1; ;; - v) : $((ARG_VERBOSE+=1)); ;; - *) cat etc/build.usage; exit 1; ;; - esac; done; shift $((${OPTIND}-1)); + local _spec="${BUILD_ARGS_SPEC}" _spec_arg="" _found=""; + while [ ${#} -gt 0 ]; do + if [ "${1#-}" = "${1}" ]; then + break; + fi; + for _spec_arg in ${_spec}; do + case "${_spec_arg}" in + *:${1}:*) + case "${_spec_arg#*:}" in + arg:*) + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; + optarg:*) + if [ -n "${2}" ]\ + && [ "x${2#-}" = "x${2}" ]; then + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; + shift; + else + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" \ + "${_spec_arg##*:}"; + fi; ;; + selfarg:*) + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; + *) + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" 1; ;; + esac; _found=1; break; ;; + *) _found=0; ;; + esac; + done; + if [ "${_found:-0}" -eq 0 ]; then + exec cat etc/build.usage; + else + shift; + fi; + done; if ex_rtl_lmatch "${ARG_DIST}" , zipdist\ && ! ex_rtl_lmatch "${ARG_DIST}" , minipix; then ARG_DIST="${ARG_DIST:+${ARG_DIST},}minipix"; @@ -40,6 +73,12 @@ build_args() { ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")"; ;; esac; + case "${ARG_VERBOSE}" in + -v) ARG_VERBOSE=1; ;; + -vv) ARG_VERBOSE=2; ;; + -vvv) ARG_VERBOSE=3; ;; + -vvvv) ARG_VERBOSE=4; ;; + esac; while [ ${#} -gt 0 ]; do case "${1}" in *=*) ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; |