From 34f21a5b49952dcb80acde5fafd85267c69e3b1d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 19:21:53 -0400 Subject: ob_parse_dep(): Swap -p and -P option letters Be consistent with opkbuild and other executable CLIs. --- diff --git a/TODO b/TODO index 3560873..0306620 100644 --- a/TODO +++ b/TODO @@ -6,7 +6,6 @@ General Cleanup * Add more error handling? * Finish manual pages for functions and utilities. - * Change/update option letters for `ob_parse_dep()`. * Reconsider using `getopts`. * Improve in-place locale loading, including the safety of `printf "${_OB_LOCALE_PATH}"`. diff --git a/lib/deps.sh b/lib/deps.sh index 9ae63fe..bc524cc 100644 --- a/lib/deps.sh +++ b/lib/deps.sh @@ -22,7 +22,7 @@ ## \fIpkg:archqual (rel ver) [arches] \fP, where the components ## \fI:archqual\fP, \fI(rel ver)\fP, \fI[arches]\fP, and \fI\fP ## are optional. -## @option -p pkg_var The name of the variable in which to store the +## @option -P pkg_var The name of the variable in which to store the ## package name. ## @option -q archqual_var The name of the variable in which to store the ## architecture qualifier, if any. @@ -37,20 +37,20 @@ ## @option -a host_arch The host architecture. If given, the dependency will ## only be printed on standard output if it applies to ## the given architecture. -## @option -P host_plat The host platform. If given, the dependency will +## @option -p host_plat The host platform. If given, the dependency will ## only be printed on standard output if it applies to ## the given platform. ## @operand dep req The dependency to parse. ## @return Returns 0. -## @stdout If \fB-a\fP and \fB\P\fP aren't given, the entire dependency string -## is printed, with normalized formatting. If \fB-a\fP and/or \fB-P\fP +## @stdout If \fB-a\fP and \fB\p\fP aren't given, the entire dependency string +## is printed, with normalized formatting. If \fB-a\fP and/or \fB-p\fP ## are given and the dependency applies to their arguments, the ## dependency string is printed, except for the architecture (if -## \fB-a\fP given) and/or platform (if \fB-P\fP given) restrictions, +## \fB-a\fP given) and/or platform (if \fB-p\fP given) restrictions, ## with normalized formatting. Normalized formatting is a string of the ## format \fIpkg:archqual\ (rel\ ver)\ [arches]\ \fP. ## @pure maybe This function has side effects when used with any of the options -## \fB-p\fP, \fB-q\fP, \fB-r\fP, \fB-v\fP, \fB-A\fP, or \fB-l\fP. +## \fB-P\fP, \fB-q\fP, \fB-r\fP, \fB-v\fP, \fB-A\fP, or \fB-l\fP. ob_parse_dep() { local opt= @@ -74,9 +74,9 @@ ob_parse_dep() local comp_var= OPTIND=1 - while getopts 'p:q:r:v:A:l:a:P:' opt; do + while getopts 'P:q:r:v:A:l:a:p:' opt; do case "${opt}" in - p) + P) pkg_var="${OPTARG}" if ! _ob_validate_var_name "${pkg_var}"; then _ob_abort @@ -115,7 +115,7 @@ ob_parse_dep() a) host_arch="${OPTARG}" ;; - P) + p) host_plat="${OPTARG}" ;; ?) @@ -245,7 +245,7 @@ ob_reduce_deps() for dep_or in ${dep_and}; do unset IFS dep="$(ob_parse_dep -a "${host_arch}" \ - -P "${host_plat}" "${dep_or}")" + -p "${host_plat}" "${dep_or}")" if [ -n "${dep}" ]; then if [ -n "${dep_or_list}" ]; then dep_or_list="${dep_or_list} | " @@ -262,7 +262,7 @@ ob_reduce_deps() fi else dep="$(ob_parse_dep -a "${host_arch}" \ - -P "${host_plat}" "${dep_and}")" + -p "${host_plat}" "${dep_and}")" if [ -n "${dep}" ]; then if [ -n "${dep_list}" ]; then dep_list="${dep_list}, " diff --git a/src/ob-buildenv.sh b/src/ob-buildenv.sh index dd16146..2b95f0f 100644 --- a/src/ob-buildenv.sh +++ b/src/ob-buildenv.sh @@ -26,7 +26,7 @@ setup_build_helper() IFS=', ' for dep in $(ob_get_source_parameter 'Build-Depends'); do unset IFS - ob_parse_dep -p dep_pkg "${dep}" >/dev/null + ob_parse_dep -P dep_pkg "${dep}" >/dev/null if [ -r "${HELPERDIR}/${dep_pkg}" ]; then . "${HELPERDIR}/${dep_pkg}" PATH="${helper_path}:${PATH}" diff --git a/src/ob-checkbuilddeps.sh b/src/ob-checkbuilddeps.sh index 05826ad..a7b6306 100644 --- a/src/ob-checkbuilddeps.sh +++ b/src/ob-checkbuilddeps.sh @@ -30,7 +30,7 @@ check_dep() local status= local pkg_ver= - ob_parse_dep -p dep_pkg -r dep_rel -v dep_ver "${dep}" + ob_parse_dep -P dep_pkg -r dep_rel -v dep_ver "${dep}" status="$("${OPKG}" status "${dep_pkg}")" if ! printf '%s\n' "${status}" | grep '^Status: .* .* installed$' \ -- cgit v0.9.1