summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/control.sh6
-rw-r--r--lib/metadata.sh19
-rw-r--r--lib/metadata/proteanos.sh11
-rw-r--r--lib/output.sh6
-rw-r--r--lib/package.sh26
5 files changed, 40 insertions, 28 deletions
diff --git a/lib/control.sh b/lib/control.sh
index 35913aa..76ba516 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -245,8 +245,7 @@ ob_set_binary_substvar()
value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")"
# Convert package name to clean form.
- package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \
- tr -C 'a-z0-9' '_')"
+ package="$(ob_clean_name "${package}")"
# TODO: Maybe disallow variable names beginning with hyphens, and/or
# otherwise make this safer.
@@ -326,8 +325,7 @@ ob_substvars()
# Perform the substitution.
name_tr="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')"
- package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \
- tr -C 'a-z0-9' '_')"
+ package="$(ob_clean_name "${package}")"
if eval "[ x\"\${_ob_substvar_src_${name_tr}:+set}\" = x'set' ]"
then
name_tr="_ob_substvar_src_${name_tr}"
diff --git a/lib/metadata.sh b/lib/metadata.sh
index da0c893..bc7e717 100644
--- a/lib/metadata.sh
+++ b/lib/metadata.sh
@@ -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
diff --git a/lib/metadata/proteanos.sh b/lib/metadata/proteanos.sh
index 7b235e5..6d68ccb 100644
--- a/lib/metadata/proteanos.sh
+++ b/lib/metadata/proteanos.sh
@@ -19,6 +19,7 @@
_OB_NAME_RE_PROTEANOS='^[a-z0-9][a-z0-9+.-]+$'
_OB_VERSION_RE_PROTEANOS='^'
+_OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'([1-9][0-9]*:)?'
_OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'[0-9a-z.~+]+'
_OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(\+sip[1-9][0-9]*)?'
_OB_VERSION_RE_PROTEANOS=${_OB_VERSION_RE_PROTEANOS}'(-[0-9]+)?'
@@ -69,6 +70,16 @@ _ob_validate_binary_name()
return 0
}
+_ob_clean_name()
+{
+ local name="${1}"
+ shift 1 || _ob_abort
+
+ printf '%s' "${name}" | sed 's/-/_h_/g; s/+/_p_/g; s/[.]/_d_/g;'
+
+ return 0
+}
+
_ob_validate_version()
{
local version="${1}"
diff --git a/lib/output.sh b/lib/output.sh
index 056c929..defadee 100644
--- a/lib/output.sh
+++ b/lib/output.sh
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with opkbuild. If not, see <http://www.gnu.org/licenses/>.
-## @brief Print an error message and exit
+## @brief Print an error message
## @details \fBob_error\fP() prints \fIarguments\fP according to \fIformat\fP.
## @operand format req The format string. See \fBprintf\fP(1) for the syntax
## of \fIformat\fP.
@@ -25,7 +25,7 @@
## \fIformat\fP.
## @return Returns 0.
## @stderr Prints the formatted message, preceded by the program name and
-## "Error:".
+## "Error:" (or a translation thereof).
## @pure yes This function has no side effects.
ob_error()
{
@@ -46,7 +46,7 @@ ob_error()
## \fIformat\fP.
## @return Returns 0.
## @stderr Prints the formatted message, preceded by the program name and
-## "Warning:".
+## "Warning:" (or a translation thereof).
## @pure yes This function has no side effects.
ob_warn()
{
diff --git a/lib/package.sh b/lib/package.sh
index 138609c..dbf6b67 100644
--- a/lib/package.sh
+++ b/lib/package.sh
@@ -36,11 +36,8 @@ _ob_package_do()
_ob_find_binary_packages()
{
- local pkgs_clean=
local pkg=
- local pkg_clean=
- pkgs_clean=' '
_ob_binary_packages=''
for pkg in $(_ob_package_do 'get_binary_packages'); do
@@ -50,16 +47,6 @@ _ob_find_binary_packages()
continue
fi
- # Make sure the "clean" name is unique.
- pkg_clean="$(printf '%s' "${pkg}" | tr 'a-z' 'A-Z' | \
- tr -C 'A-Z0-9' '_')"
- case "${pkgs_clean}" in *" ${pkg_clean} "*)
- _ob_warn_msg 'duplicate_clean_binary_name' \
- "${pkg_clean}"
- continue
- esac
- pkgs_clean="${pkgs_clean}${pkg_clean} "
-
_ob_binary_packages="${_ob_binary_packages} ${pkg}"
done
@@ -111,8 +98,7 @@ ob_init_package()
## @option -a host_plat The platform by which to filter binary packages.
## @return Returns 0 on success.
## @stdout Prints the resulting list of binary packages.
-## @stderr Prints warning messages on invalid binary package names and duplicate
-## "clean" binary package names.
+## @stderr Prints warning messages on invalid binary package names.
## @pure yes This function has no side effects.
ob_get_binary_packages()
{
@@ -208,9 +194,8 @@ ob_get_binary_parameter()
return 1
fi
- # Convert package name to its uppercase "clean" form.
- package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \
- tr -C 'A-Z0-9' '_')"
+ # Convert package name to clean form.
+ package="$(ob_clean_name "${package}")"
# Convert field name to uppercase and validate.
case "${name}" in *[!A-Za-z0-9-]* | '')
@@ -308,9 +293,8 @@ _ob_set_binary_parameter()
return 1
fi
- # Convert package name to its uppercase "clean" form.
- package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \
- tr -C 'A-Z0-9' '_')"
+ # Convert package name to clean form.
+ package="$(ob_clean_name "${package}")"
# Convert field name to uppercase and validate.
case "${name}" in *[!A-Za-z0-9-]* | '')