diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-03-19 20:43:42 +0100 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-03-19 20:43:42 +0100 |
commit | 11ef380346ff5e91634b614b4cc9e23740270957 (patch) | |
tree | 198637e076e88053b36844744d5125b432f3d701 /subr/pkgtool_init.subr | |
parent | 847bee79d77df86299bb5ac909b15b22ad221bd7 (diff) | |
download | midipix_build-11ef380346ff5e91634b614b4cc9e23740270957.tar.bz2 midipix_build-11ef380346ff5e91634b614b4cc9e23740270957.tar.xz |
subr/{build,pkgtool}_init.subr: minor cleanup.
subr/rtl_complex.subr:rtl_{check_prereqs,prompt,rc}(): initial implementation.
Diffstat (limited to 'subr/pkgtool_init.subr')
-rw-r--r-- | subr/pkgtool_init.subr | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/subr/pkgtool_init.subr b/subr/pkgtool_init.subr index 309dc612..f5eb21fc 100644 --- a/subr/pkgtool_init.subr +++ b/subr/pkgtool_init.subr @@ -74,7 +74,7 @@ pkgtoolp_init_getopts() { done; if [ "${_rc:-0}" -eq 0 ]; then if [ "${#}" -ne 1 ]\ - && [ -z "${PKGTOOL_PKG_NAME}" ]; then + && [ -z "${PKGTOOL_PKG_NAME:-}" ]; then _rc=1; _status="Error: missing package name."; elif [ "${#}" -eq 1 ]; then PKGTOOL_PKG_NAME="${1}"; export PKGTOOL_PKG_NAME; @@ -83,29 +83,32 @@ pkgtoolp_init_getopts() { fi; return "${_rc}"; }; +pkgtoolp_init_getopts_help() { + local _opt=""; + while getopts a:b:hirst _opt 2>/dev/null; do + case "${_opt}" in + h) cat etc/build.usage; exit 0; ;; + esac; done; shift $((${OPTIND}-1)); +}; + pkgtoolp_init_prereqs() { - local _cmd="" _cmds_missing="" _rc=0; _status=""; - for _cmd in \ + if ! rtl_check_prereqs \ awk bzip2 cat chmod cp date find grep hostname mkdir \ mktemp mv paste printf readlink rm sed sort tar test \ - touch tr uniq; do - if ! which "${_cmd}" >/dev/null 2>&1; then - _cmds_missing="${_cmds_missing:+${_cmds_missing} }${_cmd}"; - fi; - done; - if [ -n "${_cmds_missing}" ]; then - _rc=1; _status="Error: missing prerequisite package(s): ${_cmds_missing}"; + touch tr uniq; then + printf "%s\n" "${_status}" >&2; exit 1; elif ! (FNAME="$(mktemp)" && { trap "rm -f \"\${FNAME}\"" EXIT; \ sed -i'' -e '' "${FNAME}" >/dev/null 2>&1; }); then - _rc=1; _status="Error: sed(1) in \${PATH} does not support the \`-i' option."; - fi; return "${_rc}"; + printf "Error: sed(1) in \${PATH} does not support the \`-i' option.\n" >&2; exit 1; + fi; }; pkgtool_init() { local _fname="" _rc=0; _status=""; if ! pkgtoolp_init_env \ - || ! pkgtoolp_init_getopts "${@}" \ + || ! pkgtoolp_init_getopts_help "${@}" \ || ! pkgtoolp_init_prereqs \ + || ! pkgtoolp_init_getopts "${@}" \ || ! ex_pkg_load_vars \ || ! pkgtoolp_init_args; then _rc=1; _status="${_status}"; |