summaryrefslogtreecommitdiffstats
path: root/lib/metadata.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/metadata.sh')
-rw-r--r--lib/metadata.sh64
1 files changed, 63 insertions, 1 deletions
diff --git a/lib/metadata.sh b/lib/metadata.sh
index da3ff60..bc7e717 100644
--- a/lib/metadata.sh
+++ b/lib/metadata.sh
@@ -1,6 +1,6 @@
# Functions for parsing and validating package metadata
#
-# Copyright (C) 2012, 2014, 2018, 2019 Patrick McDermott
+# Copyright (C) 2012, 2014, 2018-2020 Patrick McDermott
#
# This file is part of opkbuild.
#
@@ -61,6 +61,25 @@ ob_validate_binary_name()
return 0
}
+## @brief Convert a source or binary package name to a "clean" identifier name
+## @details \fBob_clean_name\fP() encodes characters in a source or binary
+## package name that would be invalid in a shell variable or function
+## name. This conversion is performed by the metadata plugin selected
+## at libopkbuild's build time.
+## @operand name req The source or binary package name to convert.
+## @return Returns 0 on success.
+## @stdout Prints the converted name.
+## @pure yes This function has no side effects.
+ob_clean_name()
+{
+ local name="${1}"
+ shift 1 || _ob_abort
+
+ _ob_metadata_do 'clean_name' "${name}" || return ${?}
+
+ return 0
+}
+
## @brief Parse a source package version
## @details \fBob_parse_version\fP() validates and parses a source package
## version identifier using the metadata plugin selected at
@@ -334,3 +353,46 @@ ob_get_system_path()
return 0
}
+
+## @brief Validate a section name
+## @details \fBob_validate_section\fP() validates a package archive section name
+## against the list in the metadata plugin selected at libopkbuild's
+## build time.
+## @operand section req The section name to validate.
+## @return Returns 0 if valid or 1 if invalid.
+## @pure yes This function has no side effects.
+ob_validate_section()
+{
+ local section="${1}"
+ shift 1 || _ob_abort
+
+ _ob_metadata_do 'validate_section' "${section}" || return ${?}
+
+ 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
+}