From bb2c1e32b6614b01f9acef03871a0a403e59b06d Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 01 Aug 2012 03:05:48 -0400 Subject: Move metadata validation to oh_changelog_parse(). --- (limited to 'lib') 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}" -- cgit v0.9.1