diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-01-12 13:45:25 (EST) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-01-12 14:17:44 (EST) |
commit | f9a48ef542e978df9af08e1afbff59287d8af10e (patch) | |
tree | 83e257bdeb09cf16875b6073287cc091024bf404 /src | |
parent | cc04fd727f847bff912e8d8d3a14b06765928fb5 (diff) |
cmd/build: Improve option handling
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/build.sh | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/cmd/build.sh b/src/cmd/build.sh index 3a3da4f..a3e903b 100644 --- a/src/cmd/build.sh +++ b/src/cmd/build.sh @@ -211,8 +211,8 @@ cmd_build_main() local build_plat= local host_arch= local host_plat= - local first_arg= - local arg= + local opts= + local opt= local source= local version= local dist= @@ -242,23 +242,37 @@ cmd_build_main() build_plat="$(cat -- "${root}/etc/proteanos_plat")" host_arch="${build_arch}" host_plat="${build_plat}" + opts='' while getopts "${opkbuild_optstring}" opt 2>/dev/null; do case "${opt}" in a) host_arch="${OPTARG}";; p) host_plat="${OPTARG}";; + *) + opts="${opts}${opt} " + eval "opt_${opt}_set=\"\${OPTARG:+set}\"" + eval "opt_${opt}=\"\${OPTARG:-}\"" + ;; + ?) + print_cmd_usage 'build' >&2 + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 1 + ;; esac done + shift $((${OPTIND} - 1)) - first_arg=true - _cmd_build_pkg_dir='' - for arg in "${@}"; do - if ${first_arg}; then - set -- - first_arg=false - else - set -- "${@}" "${_cmd_build_pkg_dir}" + if [ ${#} -ne 1 ]; then + print_cmd_usage 'build' >&2 + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 1 + fi + _cmd_build_pkg_dir="${1}" + set -- -a "${host_arch}" -p "${host_plat}" + for opt in ${opts}; do + set -- "${@}" "-${opt}" + if eval "[ x\"\${opt_${opt}_set}\" = x'set' ]"; then + eval "set -- \"\${@}\" \"\${opt_${opt}}\"" fi - _cmd_build_pkg_dir="${arg}" done if ! profile_detect "${root}"; then |