summaryrefslogtreecommitdiffstats
path: root/lib/changelog.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-01 03:05:48 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-01 03:05:48 (EDT)
commitbb2c1e32b6614b01f9acef03871a0a403e59b06d (patch)
tree1b47e8954cf3dfd4137f163507478606dd88e915 /lib/changelog.sh
parentd256ad5b12b1a9251a99b55f112d738b4350ec5c (diff)
Move metadata validation to oh_changelog_parse().
Diffstat (limited to 'lib/changelog.sh')
-rw-r--r--lib/changelog.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
index f757e90..847bd4f 100644
--- a/lib/changelog.sh
+++ b/lib/changelog.sh
@@ -21,6 +21,15 @@
. @@LIBDIR@@/messages
+# Constant global parameters:
+OH_SOURCE_RE='^[a-z0-9][a-z0-9+.-]+$'
+OH_SOURCE_VERSION_ID_RE='^'
+OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'[0-9a-z.~]+'
+OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(\+sip[1-9][0-9]*)?'
+OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(-[1-9][0-9]*)?'
+OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(\+[a-z0-9]+-[1-9][0-9]*)?'
+OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'$'
+
# TODO: Either add an error callback to oh_changelog_parse() or make a central
# error handling library.
# TODO: Move message strings into locales.
@@ -90,6 +99,18 @@ ${_line}"
OH_CHANGELOG_DISTRIBUTION=
OH_CHANGELOG_CHANGES=
else
+ echo "${_source}" | \
+ grep -E "${OH_SOURCE_RE}" >/dev/null 2>&1
+ if [ "${?}" -ne 0 ]; then
+ oh_changelog_parse_error "${_file}" "${_line_nr}" \
+ "${oh_str_bad_source}"
+ fi
+ echo "${_version}" | \
+ grep -E "${OH_SOURCE_VERSION_ID_RE}" >/dev/null 2>&1
+ if [ "${?}" -ne 0 ]; then
+ oh_changelog_parse_error "${_file}" "${_line_nr}" \
+ "${oh_str_bad_source_version}"
+ fi
OH_CHANGELOG_SOURCE="${_source}"
OH_CHANGELOG_VERSION="${_version}"
OH_CHANGELOG_DISTRIBUTION="${_distribution}"