diff options
Diffstat (limited to 'lib/metadata.sh')
-rw-r--r-- | lib/metadata.sh | 124 |
1 files changed, 33 insertions, 91 deletions
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}" "${@}" |