From 888356f8a16d95cd98e99094a3dbf9d442b3ee03 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 21 Jun 2020 22:04:37 -0400 Subject: ob_qualify_package_name(): New function --- diff --git a/NEWS b/NEWS index fd7a007..5e134d5 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ libopkbuild: format 2.x. * The modification time in manual pages is now parsed and formatted correctly. + * A new function ob_qualify_package_name() has been added. opkbuild version 4.1.4 ---------------------- diff --git a/lib/metadata.sh b/lib/metadata.sh index da3ff60..44fc427 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -334,3 +334,29 @@ ob_get_system_path() return 0 } + +## @brief Get a possibly architecture-qualified package name +## @details \fBob_qualify_package_name\fP() qualifies the name of a binary +## package with the host architecture if the package is in a section +## whose packages are coinstallable. +## @operand name req The name of the binary package. +## @operand host_arch req The host architecture. +## @return Returns 0. +## @stdout Prints \fIname\fP, possibly followed by a colon and \fIhost_arch\fP. +## @pure yes This function has no side effects. +ob_qualify_package_name() +{ + local name="${1}" + local host_arch="${2}" + shift 2 || _ob_abort + local sect= + + sect="$(ob_get_binary_parameter "${name}" 'Section')" + if _ob_metadata_do 'section_is_coinstallable' "${sect}"; then + printf '%s:%s' "${name}" "${host_arch}" + else + printf '%s' "${name}" + fi + + return 0 +} diff --git a/lib/metadata/proteanos.sh b/lib/metadata/proteanos.sh index 2713423..66f2ea8 100644 --- a/lib/metadata/proteanos.sh +++ b/lib/metadata/proteanos.sh @@ -164,3 +164,18 @@ _ob_get_system_path() return 0 } + +_ob_section_is_coinstallable() +{ + local sect="${1}" + shift 1 || _ob_abort + + case "${sect}" in + 'lib') + return 0 + ;; + *) + return 1 + ;; + esac +} diff --git a/man/local.mk b/man/local.mk index 6e6d3a2..958967e 100644 --- a/man/local.mk +++ b/man/local.mk @@ -51,6 +51,7 @@ man3_MANS = \ %reldir%/ob_arch_is_concerned.3 \ %reldir%/ob_plat_is_concerned.3 \ %reldir%/ob_get_system_path.3 \ + %reldir%/ob_qualify_package_name.3 \ %reldir%/ob_parse_control.3 \ %reldir%/ob_set_binary_substvar.3 \ %reldir%/ob_set_source_substvar.3 \ -- cgit v0.9.1