summaryrefslogtreecommitdiffhomepage
path: root/subr/ex_setup_args.subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de>2017-11-22 01:32:50 +0000
committerLucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de>2017-11-22 02:35:10 +0000
commit32ad217d197203a97dfcc0076e748731d2315c0b (patch)
tree1f4dd5799daa9ac8540cddcc45b4c1557cb0ac70 /subr/ex_setup_args.subr
parent465073d1a9f8ead60dbe66a26b55c0c1927e63c6 (diff)
downloadmidipix_build-32ad217d197203a97dfcc0076e748731d2315c0b.tar.bz2
midipix_build-32ad217d197203a97dfcc0076e748731d2315c0b.tar.xz
subr/*: reorganised as {ex{,_{pkg,rtl,setup}},pkg}_*.
Diffstat (limited to 'subr/ex_setup_args.subr')
-rw-r--r--subr/ex_setup_args.subr67
1 files changed, 67 insertions, 0 deletions
diff --git a/subr/ex_setup_args.subr b/subr/ex_setup_args.subr
new file mode 100644
index 00000000..637a7d38
--- /dev/null
+++ b/subr/ex_setup_args.subr
@@ -0,0 +1,67 @@
+BUILD_ARGS_SPEC="
+ ARG_IPV4_ONLY:-4
+ ARG_IPV6_ONLY:-6
+ ARCH:arg:-a
+ BUILD:arg:-b
+ ARG_CLEAN:-c
+ ARG_DEBUG_MINIPIX:--debug-minipix
+ ARG_IGNORE_SHA256SUMS:-i
+ ARG_OFFLINE:-N
+ ARG_RELAXED:-R
+ ARG_RESTART:arg:-r
+ ARG_TARBALL:selfarg:-t
+ ARG_TARBALL:selfarg:-t.bz2
+ ARG_TARBALL:selfarg:-t.gz
+ ARG_TARBALL:selfarg:-t.xz
+ ARG_VERBOSE:-v
+ ARG_XTRACE:-x";
+
+ex_setup_args() {
+ 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_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
+ selfarg:*)
+ ex_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
+ *)
+ ex_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 [ -n "${ARG_TARBALL}" ]; then
+ if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then
+ TARBALL_SUFFIX="${ARG_TARBALL#-t.}";
+ else
+ TARBALL_SUFFIX=xz;
+ fi;
+ fi;
+ if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
+ set -o xtrace;
+ fi;
+ if [ -n "${ARG_RESTART}" ]; then
+ if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then
+ ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}";
+ fi;
+ BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
+ fi;
+ while [ ${#} -gt 0 ]; do
+ case "${1}" in
+ *=*) ex_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
+ *) BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;;
+ esac; shift; done;
+};
+
+# vim:filetype=sh