summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/changelog.sh71
1 files changed, 29 insertions, 42 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
index 0fc07b5..bced08d 100644
--- a/lib/changelog.sh
+++ b/lib/changelog.sh
@@ -1,6 +1,6 @@
# Functions for parsing changelogs
#
-# Copyright (C) 2012, 2018 Patrick McDermott
+# Copyright (C) 2012, 2018, 2019 Patrick McDermott
#
# This file is part of opkbuild.
#
@@ -17,13 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with opkbuild. If not, see <http://www.gnu.org/licenses/>.
-OB_CHANGELOG_SOURCE=
-OB_CHANGELOG_VERSION=
-OB_CHANGELOG_DISTRIBUTION=
-OB_CHANGELOG_CHANGES=
-OB_CHANGELOG_MAINTAINER=
-OB_CHANGELOG_DATE=
-
_ob_parse_changelog_error()
{
local file=
@@ -68,24 +61,20 @@ _ob_get_changelog_expect_str()
## specified at
## <http://specs.proteanos.com/spf-2.0/metadata.html#changelog>. For
## each version entry, \fBob_parse_changelog\fP calls \fIentry_cb\fP
-## after setting \fIOB_CHANGELOG_SOURCE\fP to the source package name,
-## \fIOB_CHANGELOG_VERSION\fP to the source package version,
-## \fIOB_CHANGELOG_DISTRIBUTION\fP to the list of distributions into
-## which the package should be installed, \fIOB_CHANGELOG_CHANGES\fP to
-## the formatted heading (source package name, source package version,
-## and distributions list) and change details,
-## \fIOB_CHANGELOG_MAINTAINER\fP to the name and e-mail address of the
-## package maintainer, and \fPOB_CHANGELOG_DATE\fP to the date of
-## packaging. \fBob_parse_changelog\fP stops parsing either at the end
-## of the \fIchangelog\fP file or when \fIentry_cb\fP returns non-zero.
+## with the source package name, the source package version, the list
+## of distributions into which the package should be installed, the
+## formatted heading (source package name, source package version, and
+## distributions list) and change details, the name and e-mail address
+## of the package maintainer, and the date of packaging as arguments.
+## \fBob_parse_changelog\fP stops parsing either at the end of the
+## \fIchangelog\fP file or when \fIentry_cb\fP returns non-zero.
## @operand file req The file to parse, or "-" for standard input.
## @operand entry_cb req Callback to run for each entry.
## @return Returns 0 after parsing, or 125 on missing arguments.
## @stderr Prints error messages on parse errors.
-## @pure maybe This function sets global variables, but they're only intended
-## for use by \fIentry_cb\fP, which is called during the lifetime of
-## this function. Whether this function is subshell-safe in
-## practice depends on whether \fIentry_cb\fP is subshell-safe.
+## @pure maybe This function has no side effects. Whether this function is
+## subshell-safe in practice depends on whether \fIentry_cb\fP is
+## subshell-safe.
ob_parse_changelog()
{
local file=
@@ -94,6 +83,7 @@ ob_parse_changelog()
local line=
local line_=
local expect=
+ local changes=
local blank_lines=
local source=
local distribution=
@@ -118,7 +108,7 @@ ob_parse_changelog()
case "${line}" in
'')
if [ "${expect}" = 'start_changes' ]; then
- OB_CHANGELOG_CHANGES="${OB_CHANGELOG_CHANGES}${_OB_LF}${line}"
+ changes="${changes}${_OB_LF}${line}"
elif [ "${expect}" = 'next_or_eof' ]; then
:
elif [ "${expect}" != 'changes_or_trailer' ]; then
@@ -146,10 +136,10 @@ ob_parse_changelog()
"${version% *}" != "${version}" ]; then
_ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_bad_heading'
- OB_CHANGELOG_SOURCE=
- OB_CHANGELOG_VERSION=
- OB_CHANGELOG_DISTRIBUTION=
- OB_CHANGELOG_CHANGES=
+ source=''
+ version=''
+ distribution=''
+ changes=''
else
if ! ob_validate_source_name "${source}"; then
_ob_parse_changelog_error \
@@ -161,13 +151,10 @@ ob_parse_changelog()
"${file}" "${line_nr}" \
'changelog_bad_source_version' "${version}"
fi
- OB_CHANGELOG_SOURCE="${source}"
- OB_CHANGELOG_VERSION="${version}"
- OB_CHANGELOG_DISTRIBUTION="${distribution}"
- OB_CHANGELOG_CHANGES="${line}"
+ changes="${line}"
fi
expect='start_changes'
- blank_lines=
+ blank_lines=''
;;
' -- '*)
if [ "${expect}" != 'changes_or_trailer' ]; then
@@ -182,18 +169,18 @@ ob_parse_changelog()
"${maintainer}" = "${date}" ]; then
_ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_bad_trailer'
- OB_CHANGELOG_MAINTAINER=
- OB_CHANGELOG_DATE=
- elif [ -n "${OB_CHANGELOG_SOURCE}" ]; then
- OB_CHANGELOG_MAINTAINER="${maintainer}"
- OB_CHANGELOG_DATE="${date}"
- "${entry_cb}"
+ maintainer=''
+ date=''
+ elif [ -n "${source}" ]; then
+ "${entry_cb}" "${source}" "${version}" \
+ "${distribution}" "${changes}" \
+ "${maintainer}" "${date}"
if [ ${?} -ne 0 ]; then
return 0
fi
fi
expect='next_or_eof'
- blank_lines=
+ blank_lines=''
;;
' --'*)
_ob_parse_changelog_error "${file}" "${line_nr}" \
@@ -206,14 +193,14 @@ ob_parse_changelog()
'changelog_found_change' \
"$(_ob_get_changelog_expect_str "${expect}")"
fi
- OB_CHANGELOG_CHANGES="${OB_CHANGELOG_CHANGES}${_OB_LF}${blank_lines}${line}"
+ changes="${changes}${_OB_LF}${blank_lines}${line}"
expect='changes_or_trailer'
- blank_lines=
+ blank_lines=''
;;
*)
_ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_bad_line'
- blank_lines=
+ blank_lines=''
;;
esac
done <<-EOF