diff options
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | lib/changelog.sh | 26 | ||||
-rw-r--r-- | lib/control.sh | 67 | ||||
-rw-r--r-- | lib/deps.sh | 32 | ||||
-rw-r--r-- | lib/locale.sh | 45 | ||||
-rw-r--r-- | lib/metadata.sh | 124 | ||||
-rw-r--r-- | lib/metadata/proteanos.sh | 65 | ||||
-rw-r--r-- | lib/output.sh | 12 | ||||
-rw-r--r-- | lib/package.sh | 117 | ||||
-rw-r--r-- | lib/package/2.sh | 23 |
10 files changed, 159 insertions, 356 deletions
@@ -40,9 +40,7 @@ Tasks * Drop mksysconf. * In executables, print error (using `printf`) and exit if `ob_set_text_domain()` fails. - * Make `set -e` and drop `return 125` from library functions. `shift` - arguments, and exit (with `kill`) if `shift` returns non-zero (POSIX only - says the shell "may exit"). + * Make `set -e`. * Make `ob_error()` non-fatal and use in libopkbuild in places where functions return on error. diff --git a/lib/changelog.sh b/lib/changelog.sh index 7cb6c0b..3216f94 100644 --- a/lib/changelog.sh +++ b/lib/changelog.sh @@ -19,16 +19,12 @@ _ob_parse_changelog_error() { - local file= - local line_nr= - local msg_id= + local file="${1}" + local line_nr="${2}" + local msg_id="${3}" + shift 3 || _ob_abort local file_info= - file="${1}" - line_nr="${2}" - msg_id="${3}" - shift 3 - file_info="$(printf '%20s(l%d)' "${file}" "${line_nr}")" _ob_warn_msg "${msg_id}" "${file_info}" "${@}" @@ -57,15 +53,16 @@ _ob_get_changelog_expect_str() ## \fIchangelog\fP file or when \fIentry_cb\fP returns non-zero. ## @operand file req The file to parse, or "-" for standard input. ## @operand entry_cb req Callback to run for each entry. -## @return Returns 0 after parsing, or 125 on missing arguments. +## @return Returns 0 after parsing. ## @stderr Prints error messages on parse errors. ## @pure maybe This function has no side effects. Whether this function is ## subshell-safe in practice depends on whether \fIentry_cb\fP is ## subshell-safe. ob_parse_changelog() { - local file= - local entry_cb= + local file="${1}" + local entry_cb="${2}" + shift 2 || _ob_abort local line_nr= local line= local line_= @@ -78,13 +75,6 @@ ob_parse_changelog() local maintainer= local date= - if [ ${#} -eq 2 ]; then - file="${1}" - entry_cb="${2}" - else - return 125 - fi - # Parsing logic based on that of dpkg. line_nr=0 diff --git a/lib/control.sh b/lib/control.sh index 58bf68b..c29d4a0 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -21,15 +21,11 @@ _OB_SUBSTVARS_MAX_DEPTH=50 _ob_parse_control_error() { - local file= - local line_nr= - local msg_id= - local file_info= - file="${1}" line_nr="${2}" msg_id="${3}" - shift 3 + shift 3 || _ob_abort + local file_info= if [ ${line_nr} -eq 0 ]; then file_info="$(printf '%20s' "${file}")" @@ -61,20 +57,20 @@ _ob_parse_control_error() ## @operand user_data req Data to pass to \fIfield_cb\fP. ## @operand req_fields opt Required fields that must appear in the control file. ## @operand opt_fields opt Optional fields that may appear in the control file. -## @return Returns 0 after parsing, or 125 if called with an incorrect number of -## arguments. +## @return Returns 0 after parsing. ## @stderr Prints error messages on parse errors. ## @pure maybe This function has no side effects. Whether this function is ## subshell-safe in practice depends on whether \fIfield_cb\fP is ## subshell-safe. ob_parse_control() { - local file= - local field_cb= - local user_data= + local file="${1}" + local field_cb="${2}" + local user_data="${3}" + shift 3 || _ob_abort + local check_fields= local req_fields= local opt_fields= - local check_fields= local got_fields= local line_nr= local line= @@ -82,20 +78,11 @@ ob_parse_control() local value= local sep= - if [ ${#} -eq 3 ]; then - file="${1}" - field_cb="${2}" - user_data="${3}" - check_fields='false' - elif [ ${#} -eq 5 ]; then - file="${1}" - field_cb="${2}" - user_data="${3}" - req_fields=" ${4} " - opt_fields=" ${5} " + check_fields='false' + if [ ${#} -eq 2 ]; then + req_fields=" ${1} " + opt_fields=" ${2} " check_fields='true' - else - return 125 fi got_fields=' ' @@ -195,24 +182,18 @@ ob_parse_control() ## of uppercase and lowercase Latin letters, digits, and ## hyphens and must be at least one character long. ## @operand value req The value of the substitution variable. -## @return Returns 0 on success, or 125 if called with an incorrect number of -## arguments or if \fIname\fP is empty or contains invalid characters. +## @return Returns 0 on success, or 1 if \fIname\fP is empty or contains invalid +## characters. ## @pure no This function sets an internal global variable. ob_set_substvar() { - local name= - local value= - - if [ ${#} -eq 2 ]; then - name="${1}" - value="${2}" - else - return 125 - fi + local name="${1}" + local value="${2}" + shift 2 || _ob_abort # Convert variable name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') - return 125 + return 1 esac name="$(tr 'a-z-' 'A-Z_' <<-EOF ${name} @@ -234,13 +215,13 @@ ob_set_substvar() ## \fBob_set_substvar\fP(3) in a string. The format for variable ## substitutions is \fI${var}\fP, and substitutions can be nested. ## @operand string req The string in which to substitute variables. -## @return Returns 0 on success, 1 on possible recursion, or 125 if called with -## an incorrect number of arguments. +## @return Returns 0 on success or 1 on possible recursion. ## @stderr Prints a warning on possible recursion. ## @pure yes This function has no side effects. ob_substvars() { - local string= + local string="${1}" + shift 1 || _ob_abort local depth= local lhs= local name= @@ -248,12 +229,6 @@ ob_substvars() local old_rhs= local value= - if [ ${#} -eq 1 ]; then - string="${1}" - else - return 125 - fi - # Logic inspired by that of dpkg's Dpkg::Substvars::substvars() subroutine. depth=0 diff --git a/lib/deps.sh b/lib/deps.sh index 64553aa..348839a 100644 --- a/lib/deps.sh +++ b/lib/deps.sh @@ -79,37 +79,37 @@ ob_parse_dep() p) pkg_var="${OPTARG}" if ! _ob_validate_var_name "${pkg_var}"; then - return 125 + _ob_abort fi ;; q) archqual_var="${OPTARG}" if ! _ob_validate_var_name "${archqual_var}"; then - return 125 + _ob_abort fi ;; r) rel_var="${OPTARG}" if ! _ob_validate_var_name "${rel_var}"; then - return 125 + _ob_abort fi ;; v) ver_var="${OPTARG}" if ! _ob_validate_var_name "${ver_var}"; then - return 125 + _ob_abort fi ;; A) arches_var="${OPTARG}" if ! _ob_validate_var_name "${arches_var}"; then - return 125 + _ob_abort fi ;; l) plats_var="${OPTARG}" if ! _ob_validate_var_name "${plats_var}"; then - return 125 + _ob_abort fi ;; a) @@ -119,17 +119,14 @@ ob_parse_dep() host_plat="${OPTARG}" ;; ?) - return 125 + _ob_abort ;; esac done shift $(($OPTIND - 1)) - if [ ${#} -eq 1 ]; then - dep="${1}" - else - return 125 - fi + dep="${1}" + shift 1 || _ob_abort # pkg[:archqual] [(rel ver)] [\[arches\]] [<plats>] dep_re='s/^ *([^ \(\[<]+) *(\((<<|<=|=|>=|>>) *(.+)\))?' @@ -200,7 +197,7 @@ ob_parse_dep() ## Required. ## @option -u - Treat \fIdeps\fP as a union list. ## @operand deps req The list of dependencies to reduce. -## @return Returns 0 on success or 125 on invalid option or missing \fIdeps\fP. +## @return Returns 0 on success. ## @stdout Prints the reduced list of dependencies. ## @pure yes This function has no side effects. ob_reduce_deps() @@ -230,17 +227,14 @@ ob_reduce_deps() union='true' ;; ?) - return 125 + _ob_abort ;; esac done shift $(($OPTIND - 1)) - if [ ${#} -eq 1 ]; then - deps="${1}" - else - return 125 - fi + local deps="${1}" + shift 1 || _ob_abort IFS=',' for dep_and in ${deps}; do diff --git a/lib/locale.sh b/lib/locale.sh index e6132d2..3628670 100644 --- a/lib/locale.sh +++ b/lib/locale.sh @@ -24,15 +24,11 @@ _OB_LOCALE_PATH="${LOCALEDIR}/%s/LC_MESSAGES/%s.ms" ## @brief Get the current message domain ## @details \fBob_get_text_domain\fP prints the currently loaded message domain. -## @return Returns 0 on success or 125 if any arguments are given. +## @return Returns 0 on success. ## @stdout Prints the name of the currently loaded message domain. ## @pure yes This function has no side effects. ob_get_text_domain() { - if [ ${#} -ne 0 ]; then - return 125 - fi - printf '%s' "${_ob_text_domain}" return 0 } @@ -62,20 +58,19 @@ _ob_try_load_messages() ## should have its own message domain. libopkbuild also has its own ## message domain and temporarily switches to it when needed. ## @operand text_domain req The message domain to load. -## @return Returns 0 on success, 1 if the message domain cannot be loaded, or -## 125 if \fItext_domain\fP is missing or invalid. +## @return Returns 0 on success or 1 if \fItext_domain\fP is missing or invalid +## or if the message domain cannot be loaded. ## @pure no This function sets an internal global variable and loads a message ## catalog that sets numerous message variables. ob_set_text_domain() { - if [ ${#} -eq 1 ]; then - _ob_text_domain="${1}" - else - return 125 - fi - case "${_ob_text_domain}" in *[!A-Za-z0-9_]*) - return 125 + local text_domain="${1}" + shift 1 || _ob_abort + + case "${text_domain}" in *[!A-Za-z0-9_]* | '') + return 1 esac + _ob_text_domain="${text_domain}" # Make sure LC_MESSAGES is set. if [ -z "${LC_MESSAGES}" ]; then @@ -108,13 +103,8 @@ ob_set_text_domain() ob_set_locale_path() { - local format= - - if [ ${#} -eq 1 ]; then - format="${1}" - else - return 125 - fi + local format="${1}" + shift 1 || _ob_abort _OB_LOCALE_PATH="${format}" @@ -125,18 +115,13 @@ ob_set_locale_path() ## @details \fBob_get_msg\fP prints a message, identified by a message ID, from ## the currently loaded message catalog. ## @operand msgid req The ID of the message to print -## @return Returns 0 on success or 125 if \fImsgid\fP is missing. +## @return Returns 0 on success. ## @stdout Prints the requested message from the current message domain. ## @pure yes This function has no side effects. ob_get_msg() { - local msgid= - - if [ ${#} -eq 1 ]; then - msgid="${1}" - else - return 125 - fi + local msgid="${1}" + shift 1 || _ob_abort eval "printf '%s' \"\${msg_${_ob_text_domain}_${msgid}}\"" @@ -146,7 +131,7 @@ ob_get_msg() _ob_get_msg() { local msgid="${1}" - shift 1 + shift 1 || _ob_abort local orig_text_domain= orig_text_domain="$(ob_get_text_domain)" diff --git a/lib/metadata.sh b/lib/metadata.sh index 2ca3eeb..c6f5a16 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -19,10 +19,8 @@ _ob_metadata_do() { - local func= - - func="${1}" - shift 1 + local func="${1}" + shift 1 || _ob_abort "_ob_${func}" "${@}" @@ -34,18 +32,12 @@ _ob_metadata_do() ## against the rules of the metadata plugin selected at libopkbuild's ## build time. ## @operand name req The source package name to validate. -## @return Returns 0 if valid, 1 if invalid, or 125 if given an incorrect number -## of arguments. +## @return Returns 0 if valid or 1 if invalid. ## @pure yes This function has no side effects. ob_validate_source_name() { - local name= - - if [ ${#} -eq 1 ]; then - name="${1}" - else - return 125 - fi + local name="${1}" + shift 1 || _ob_abort _ob_metadata_do 'validate_source_name' "${name}" @@ -57,18 +49,12 @@ ob_validate_source_name() ## against the rules of the metadata plugin selected at libopkbuild's ## build time. ## @operand name req The binary package name to validate. -## @return Returns 0 if valid, 1 if invalid, or 125 if given an incorrect number -## of arguments. +## @return Returns 0 if valid or 1 if invalid. ## @pure yes This function has no side effects. ob_validate_binary_name() { - local name= - - if [ ${#} -eq 1 ]; then - name="${1}" - else - return 125 - fi + local name="${1}" + shift 1 || _ob_abort _ob_metadata_do 'validate_binary_name' "${name}" @@ -85,9 +71,7 @@ ob_validate_binary_name() ## @option -d distrev_var The name of the variable in which to store the ## distribution revision. ## @operand version req The version to validate and parse. -## @return Returns 0 on success; 1 on invalid \fIversion\fP; or 125 if given an -## invalid variable name as an argument to \fB-u\fP or \fB-d\fP, an -## invalid option, or an incorrect number of operands. +## @return Returns 0 on success or 1 on invalid \fIversion\fP. ## @pure maybe This function has side effects when used with either or both of ## the \fB-u\fP and \fB-d\fP options. Without these options, this ## function only validates a version identifier. The purpose of @@ -107,27 +91,24 @@ ob_parse_version() u) upstreamver_var="${OPTARG}" if ! _ob_validate_var_name "${upstreamver_var}"; then - return 125 + _ob_abort fi ;; d) distrev_var="${OPTARG}" if ! _ob_validate_var_name "${distrev_var}"; then - return 125 + _ob_abort fi ;; ?) - return 125 + _ob_abort ;; esac done shift $(($OPTIND - 1)) - if [ ${#} -eq 1 ]; then - version="${1}" - else - return 125 - fi + version="${1}" + shift 1 || _ob_abort if ! _ob_metadata_do 'validate_version' "${version}"; then return 1 @@ -149,16 +130,12 @@ ob_parse_version() ## @details \fBob_get_system_arch\fP gets the architecture of the build ## (running) system using the metadata plugin selected at libopkbuild's ## build time. -## @return Returns 0 on success, 1 if the system's architecture cannot be -## determined, or 125 if given any arguments. +## @return Returns 0 on success or 1 if the system's architecture cannot be +## determined. ## @stdout Prints the system's architecture. ## @pure yes This function has no side effects. ob_get_system_arch() { - if [ ${#} -gt 0 ]; then - return 125 - fi - _ob_metadata_do 'get_system_arch' return ${?} @@ -168,16 +145,12 @@ ob_get_system_arch() ## @details \fBob_get_system_arch\fP gets the platform of the build (running) ## system using the metadata plugin selected at libopkbuild's build ## time. -## @return Returns 0 on success, 1 if the system's platform cannot be -## determined, or 125 if given any arguments. +## @return Returns 0 on success or 1 if the system's platform cannot be +## determined. ## @stdout Prints the system's platform. ## @pure yes This function has no side effects. ob_get_system_plat() { - if [ ${#} -gt 0 ]; then - return 125 - fi - _ob_metadata_do 'get_system_plat' return ${?} @@ -185,21 +158,15 @@ ob_get_system_plat() ob_match_arch() { - local match_arch= - local arch_field= + local match_arch="${1}" + local arch_field="${2}" + shift 2 || _ob_abort local field_arch= local match_arch_rest= local field_arch_rest= local match_arch_part= local field_arch_part= - if [ ${#} -eq 2 ]; then - match_arch="${1}" - arch_field="${2}" - else - return 125 - fi - for field_arch in ${arch_field}; do # "all" == "all" @@ -242,17 +209,11 @@ ob_match_arch() ob_match_plat() { - local plat= - local plat_field= + local plat="${1}" + local plat_field="${2}" + shift 2 || _ob_abort local p= - if [ ${#} -eq 2 ]; then - plat="${1}" - plat_field="${2}" - else - return 125 - fi - for p in ${plat_field}; do if [ "${plat}" = 'all' ]; then if [ "${p}" = 'all' ]; then @@ -274,19 +235,13 @@ ob_match_plat() ob_arch_is_concerned() { - local host_arch= - local arches= + local host_arch="${1}" + local arches="${2}" + shift 2 || _ob_abort local arch= local not_arch= local seen_arch= - if [ ${#} -eq 2 ]; then - host_arch="${1}" - arches="${2}" - else - return 125 - fi - if [ "x${arches}" = 'x' ]; then return 0 elif [ "x${host_arch}" = 'xall' ]; then @@ -318,19 +273,13 @@ ob_arch_is_concerned() ob_plat_is_concerned() { - local host_plat= - local plats= + local host_plat="${1}" + local plats="${2}" + shift 2 || _ob_abort local plat= local not_plat= local seen_plat= - if [ ${#} -eq 2 ]; then - host_plat="${1}" - plats="${2}" - else - return 125 - fi - if [ "x${plats}" = 'x' ]; then return 0 elif [ "x${host_plat}" = 'xall' ]; then @@ -371,20 +320,13 @@ ob_plat_is_concerned() ## @operand path_id req One of \fBpackage-source\fP, \fBpackage-docs\fP, ## \fBbuildflags\fP, or \fBplatconf\fP. ## @operand args req Additional arguments specific to each \fIpath_id\fP. -## @return Returns 0 on success, or 125 if given an incorrect number of -## arguments. +## @return Returns 0 on success. ## @stdout Prints the requested path with \fIargs\fP. ## @pure yes This function has no side effects. ob_get_system_path() { - local path_id= - - if [ ${#} -ge 1 ]; then - path_id="${1}" - shift 1 - else - return 125 - fi + local path_id="${1}" + shift 1 || _ob_abort _ob_metadata_do 'get_system_path' "${path_id}" "${@}" diff --git a/lib/metadata/proteanos.sh b/lib/metadata/proteanos.sh index 514f8cb..4152847 100644 --- a/lib/metadata/proteanos.sh +++ b/lib/metadata/proteanos.sh @@ -27,9 +27,8 @@ _OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'$' _ob_validate_source_name() { - local name= - - name="${1}" + local name="${1}" + shift 1 || _ob_abort if grep -E "${_OB_NAME_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${name} @@ -49,9 +48,8 @@ _ob_validate_source_name() _ob_validate_binary_name() { - local name= - - name="${1}" + local name="${1}" + shift 1 || _ob_abort if grep -E "${_OB_NAME_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${name} @@ -71,9 +69,8 @@ _ob_validate_binary_name() _ob_validate_version() { - local version= - - version="${1}" + local version="${1}" + shift 1 || _ob_abort grep -E "${_OB_VERSION_RE_PROTEANOS}" >/dev/null 2>&1 <<-EOF ${version} @@ -84,9 +81,8 @@ _ob_validate_version() _ob_get_upstreamver() { - local version= - - version="${1}" + local version="${1}" + shift 1 || _ob_abort printf '%s' "${version%-*}" @@ -95,9 +91,8 @@ _ob_get_upstreamver() _ob_get_distrev() { - local version= - - version="${1}" + local version="${1}" + shift 1 || _ob_abort printf '%s' "${version##*-}" @@ -120,47 +115,33 @@ _ob_get_system_plat() _ob_get_system_path() { - local path_id= + local path_id="${1}" + shift 1 || _ob_abort local pkgver= - path_id="${1}" - shift 1 - case "${path_id}" in 'package-source') # source version - if [ ${#} -eq 2 ]; then - printf '/usr/src/%s_%s' "${1}" "${2}" - else - return 125 - fi + [ ${#} -eq 2 ] || _ob_abort + printf '/usr/src/%s_%s' "${1}" "${2}" ;; 'package-docs') # source version - if [ ${#} -eq 2 ]; then - printf '/usr/share/doc/%s' "${1}" - else - return 125 - fi + [ ${#} -eq 2 ] || _ob_abort + printf '/usr/share/doc/%s' "${1}" ;; 'buildflags') # arch - if [ ${#} -eq 1 ]; then - printf "${DATADIR}/opkbuild/buildflags/%s" "${1}" - else - return 125 - fi + [ ${#} -eq 1 ] || _ob_abort + printf "${DATADIR}/opkbuild/buildflags/%s" "${1}" ;; 'platconf') # source version plat - if [ ${#} -eq 3 ]; then - ob_parse_version -u 'pkgver' "${2}" - printf "${DATADIR}/platconf/%s/%s\n" "${3}" "${1}" - printf "${DATADIR}/platconf/%s/%s_%s\n" "${3}" "${1}" \ - "${pkgver}" - else - return 125 - fi + [ ${#} -eq 3 ] || _ob_abort + ob_parse_version -u 'pkgver' "${2}" + printf "${DATADIR}/platconf/%s/%s\n" "${3}" "${1}" + printf "${DATADIR}/platconf/%s/%s_%s\n" "${3}" "${1}" \ + "${pkgver}" ;; esac diff --git a/lib/output.sh b/lib/output.sh index 4fe45f1..9d08759 100644 --- a/lib/output.sh +++ b/lib/output.sh @@ -32,7 +32,7 @@ ob_error() { local format="${1}" - shift 1 + shift 1 || _ob_abort printf "$(_get_msg 'output_error_format')\n" "${0##*/}" "${@}" >&2 @@ -52,7 +52,7 @@ ob_error() ob_warn() { local format="${1}" - shift 1 + shift 1 || _ob_abort printf "$(_get_msg 'output_warning_format')\n" "${0##*/}" "${@}" >&2 @@ -72,7 +72,7 @@ ob_warn() ob_info() { local format="${1}" - shift 1 + shift 1 || _ob_abort printf "$(_get_msg 'output_info_format')\n" "${0##*/}" "${@}" >&2 @@ -82,7 +82,7 @@ ob_info() _ob_error_msg() { local msgid="${1}" - shift 1 + shift 1 || _ob_abort ob_error "$(_ob_get_msg "${msgid}")" "${@}" @@ -92,7 +92,7 @@ _ob_error_msg() _ob_warn_msg() { local msgid="${1}" - shift 1 + shift 1 || _ob_abort ob_warn "$(_ob_get_msg "${msgid}")" "${@}" @@ -102,7 +102,7 @@ _ob_warn_msg() _ob_info_msg() { local msgid="${1}" - shift 1 + shift 1 || _ob_abort ob_info "$(_ob_get_msg "${msgid}")" "${@}" diff --git a/lib/package.sh b/lib/package.sh index 8664c99..1a07019 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -25,13 +25,8 @@ _OB_BINARY_PARAMETERS= ob_init_package() { - local dir= - - if [ ${#} -eq 1 ]; then - dir="${1}" - else - return 125 - fi + local dir="${1}" + shift 1 || _ob_abort _OB_PACKAGE_DIR="$(cd "${dir}" && pwd)" @@ -55,10 +50,8 @@ ob_init_package() _ob_package_do() { - local func= - - func="${1}" - shift 1 + local func="${1}" + shift 1 || _ob_abort "_ob_${func}_${_OB_PACKAGE_FORMAT}" "${@}" @@ -81,16 +74,12 @@ ob_parse_package_metadata() cache_file="${OPTARG}" ;; ?) - return 125 + _ob_abort ;; esac done shift $(($OPTIND - 1)) - if [ ${#} -gt 0 ]; then - return 125 - fi - # Load a previously saved cache file, if any. if [ -n "${cache_file}" -a -r "${cache_file}" ]; then if [ "${cache_file#*/}" != "${cache_file}" ]; then @@ -151,16 +140,12 @@ ob_get_binary_packages() host_plat="${OPTARG}" ;; ?) - return 125 + _ob_abort ;; esac done shift $(($OPTIND - 1)) - if [ ${#} -gt 0 ]; then - return 125 - fi - # NB: If a source package lists no binary packages, this will be true each # call. if [ -z "${_OB_BINARY_PACKAGES}" ]; then @@ -218,17 +203,12 @@ ob_get_binary_packages() ob_get_source_parameter() { - local name= - - if [ ${#} -eq 1 ]; then - name="${1}" - else - return 125 - fi + local name="${1}" + shift 1 || _ob_abort # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') - return 125 + return 1 esac name="$(tr 'a-z-' 'A-Z_' <<-EOF ${name} @@ -242,18 +222,12 @@ ob_get_source_parameter() ob_get_binary_parameter() { - local package= - local name= - - if [ ${#} -eq 2 ]; then - package="${1}" - name="${2}" - else - return 125 - fi + local package="${1}" + local name="${2}" + shift 2 || _ob_abort if ! ob_validate_binary_name "${package}"; then - return 125 + return 1 fi # Convert package name to its uppercase "clean" form. @@ -264,7 +238,7 @@ ob_get_binary_parameter() # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') - return 125 + return 1 esac name="$(tr 'a-z-' 'A-Z_' <<-EOF ${name} @@ -278,10 +252,6 @@ ob_get_binary_parameter() ob_get_doc_package() { - if [ ${#} -gt 0 ]; then - return 125 - fi - _ob_package_do 'get_doc_package' return ${?} @@ -289,15 +259,9 @@ ob_get_doc_package() ob_get_doc_files() { - local arch= - local plat= - - if [ ${#} -eq 2 ]; then - arch="${1}" - plat="${2}" - else - return 125 - fi + local arch="${1}" + local plat="${2}" + shift 2 || _ob_abort _ob_package_do 'get_doc_files' "${arch}" "${plat}" @@ -306,10 +270,6 @@ ob_get_doc_files() ob_summarize_package_arch() { - if [ ${#} -gt 0 ]; then - return 125 - fi - # XXX: Stub. return 0 @@ -317,10 +277,6 @@ ob_summarize_package_arch() ob_summarize_package_plat() { - if [ ${#} -gt 0 ]; then - return 125 - fi - # XXX: Stub. return 0 @@ -328,13 +284,8 @@ ob_summarize_package_plat() ob_set_package_substvars() { - local pkg= - - if [ ${#} -eq 1 ]; then - pkg="${1}" - else - return 125 - fi + local pkg="${1}" + shift 1 || _ob_abort _ob_package_do 'set_package_substvars' "${pkg}" @@ -343,9 +294,8 @@ ob_set_package_substvars() _ob_set_binary_packages() { - local packages= - - packages="${1}" + local packages="${1}" + shift 1 || _ob_abort _OB_BINARY_PACKAGES="${packages}" @@ -354,15 +304,13 @@ _ob_set_binary_packages() _ob_set_source_parameter() { - local name= - local value= - - name="${1}" - value="${2}" + local name="${1}" + local value="${2}" + shift 2 || _ob_abort # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') - return 125 + return 1 esac name="$(tr 'a-z-' 'A-Z_' <<-EOF ${name} @@ -378,16 +326,13 @@ _ob_set_source_parameter() _ob_set_binary_parameter() { - local package= - local name= - local value= - - package="${1}" - name="${2}" - value="${3}" + local package="${1}" + local name="${2}" + local value="${3}" + shift 3 || _ob_abort if ! ob_validate_binary_name "${package}"; then - return 125 + return 1 fi # Convert package name to its uppercase "clean" form. @@ -398,7 +343,7 @@ _ob_set_binary_parameter() # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') - return 125 + return 1 esac name="$(tr 'a-z-' 'A-Z_' <<-EOF ${name} diff --git a/lib/package/2.sh b/lib/package/2.sh index 551f199..3e362f4 100644 --- a/lib/package/2.sh +++ b/lib/package/2.sh @@ -70,7 +70,7 @@ _ob_srcfield_2() local name="${1}" local value="${2}" local user_data="${3}" - shift 3 + shift 3 || _ob_abort _ob_set_source_parameter "${name}" "${value}" @@ -95,7 +95,7 @@ _ob_binfield_2() local name="${1}" local value="${2}" local pkg="${3}" - shift 3 + shift 3 || _ob_abort _ob_set_binary_parameter "${pkg}" "${name}" "${value}" @@ -127,13 +127,11 @@ _ob_get_doc_package_2() _ob_get_doc_files_2() { - local arch= - local plat= + local arch="${1}" + local plat="${2}" + shift 2 || _ob_abort local doc_pkg= - arch="${1}" - plat="${2}" - doc_pkg="$(_ob_get_doc_package_2)" cat <<-EOF @@ -148,13 +146,8 @@ _ob_get_doc_files_2() _ob_set_package_substvars_2() { - local pkg= - - if [ ${#} -eq 1 ]; then - pkg="${1}" - else - return 125 - fi + local pkg="${1}" + shift 1 || _ob_abort if [ -f "${_OB_PACKAGE_DIR}/substvars" ]; then ob_parse_control "${_OB_PACKAGE_DIR}/substvars" \ @@ -174,7 +167,7 @@ _ob_substvar_2() local name="${1}" local value="${2}" local user_data="${3}" - shift 3 + shift 3 || _ob_abort ob_set_substvar "${name}" "${value}" |