summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/package.sh75
1 files changed, 35 insertions, 40 deletions
diff --git a/lib/package.sh b/lib/package.sh
index da6d688..df129c7 100644
--- a/lib/package.sh
+++ b/lib/package.sh
@@ -21,7 +21,6 @@ _ob_package_dir=
_ob_package_format_full=
_ob_package_format=
_ob_binary_packages=
-_ob_got_binary_packages=false
_ob_source_parameters=
_ob_binary_parameters=
@@ -35,6 +34,38 @@ _ob_package_do()
return 0
}
+_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
+ # Validate the name.
+ if ! ob_validate_binary_name "${pkg}"; then
+ _ob_warn_msg 'bad_binary_name' "${pkg}"
+ 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
+
+ return 0
+}
+
## @brief Initialize libopkbuild for a source package
## @details \fBob_init_package\fP() detects the version of and parses all
## metadata of a source package. This function must be called before
@@ -65,7 +96,7 @@ ob_init_package()
return 1
fi
- _ob_binary_packages=
+ _ob_find_binary_packages
_ob_package_do 'parse_package_metadata' || return ${?}
@@ -82,19 +113,14 @@ ob_init_package()
## @stdout Prints the resulting list of binary packages.
## @stderr Prints warning messages on invalid binary package names and duplicate
## "clean" binary package names.
-## @pure maybe This function caches a list of all binary packages to an internal
-## global variable to save time and avoid repeating warning messages
-## on subsequent invocations. It should therefore first be called
-## outside a subshell, though this is not required.
+## @pure yes This function has no side effects.
ob_get_binary_packages()
{
local opt=
local host_arch=
local host_plat=
- local pkg=
- local pkgs_clean=
- local pkg_clean=
local pkgs=
+ local pkg=
OPTIND=1
while getopts 'a:p:' opt; do
@@ -112,37 +138,6 @@ ob_get_binary_packages()
done
shift $((${OPTIND} - 1))
- if ! ${_ob_got_binary_packages}; then
-
- pkgs_clean=' '
- _ob_binary_packages=''
-
- for pkg in $(_ob_package_do 'get_binary_packages'); do
-
- # Validate the name.
- if ! ob_validate_binary_name "${pkg}"; then
- _ob_warn_msg 'bad_binary_name' "${pkg}"
- 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
-
- _ob_got_binary_packages=true
-
- fi
-
pkgs=''
for pkg in ${_ob_binary_packages}; do