summaryrefslogtreecommitdiffstats
path: root/lib/changelog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/changelog.sh')
-rw-r--r--lib/changelog.sh170
1 files changed, 0 insertions, 170 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
deleted file mode 100644
index 01e4644..0000000
--- a/lib/changelog.sh
+++ /dev/null
@@ -1,170 +0,0 @@
-# opkhelper
-# lib/changelog
-# Functions for parsing changelogs.
-#
-# Copyright (C) 2012 Patrick "P. J." McDermott
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-[ -n "${_OH_CHANGELOG_SH}" ] && return 0
-_OH_CHANGELOG_SH=true
-
-. @@LIBDIR@@/messages
-. @@LIBDIR@@/locale
-. @@LIBDIR@@/util
-
-# 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}"'$'
-
-_changelog_parse_error()
-{
- _line_nr="${1}"
- _error="${2}"
- shift 2
-
- _file_info=$(printf '%20s(l%d):' "${OH_SOURCE_DIR}/changelog" "${_line_nr}")
- oh_warn "${_file_info} ${_error}" "${@}"
-}
-
-_changelog_get_expect_str()
-{
- eval echo \$\{oh_str_changelog_expect_"${1}"\}
-}
-
-oh_changelog_parse()
-{
- # Parsing logic based on that of dpkg.
-
- _cb="${1}"
-
- _expect=first_heading
- _line_nr=0
- _entries=0
-
- while IFS= read _line; do
- _line_nr=$(($_line_nr + 1))
- if [ -z "${_line}" ]; then
- if [ "${_expect}" = start_changes ]; then
- OH_CHANGELOG_CHANGES="${OH_CHANGELOG_CHANGES}
-${_line}"
- elif [ "${_expect}" = next_or_eof ]; then
- :
- elif [ "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_blank_line}" \
- "$(_changelog_get_expect_str "${_expect}")"
- else
- _blank_lines="${_blank_lines}
-${_line}"
- fi
- elif [ "${_line# }" = "${_line}" ]; then
- if [ "${_expect}" != first_heading -a \
- "${_expect}" != next_or_eof ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_heading}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- _source="${_line%% (*}"
- _line_="${_line#* (}"
- _distribution="${_line_##*) }"
- _line_="${_line_%) *}"
- _version="${_line_}"
- if [ -z "${_source}" -o -z "${_distribution}" -o \
- -z "${_version}" -o \
- "${_version% *}" != "${_version}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_heading}"
- OH_CHANGELOG_SOURCE=
- OH_CHANGELOG_VERSION=
- OH_CHANGELOG_DISTRIBUTION=
- OH_CHANGELOG_CHANGES=
- else
- echo "${_source}" | \
- grep -E "${OH_SOURCE_RE}" >/dev/null 2>&1
- if [ "${?}" -ne 0 ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_source}" "${source}"
- fi
- echo "${_version}" | \
- grep -E "${OH_SOURCE_VERSION_ID_RE}" >/dev/null 2>&1
- if [ "${?}" -ne 0 ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_source_version}" "${_version}"
- fi
- OH_CHANGELOG_SOURCE="${_source}"
- OH_CHANGELOG_VERSION="${_version}"
- OH_CHANGELOG_DISTRIBUTION="${_distribution}"
- OH_CHANGELOG_CHANGES="${_line}"
- fi
- _expect=start_changes
- _blank_lines=
- elif [ "${_line# -- }" != "${_line}" ]; then
- if [ "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_trailer}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- _line="${_line# -- }"
- _maintainer="${_line%% *}"
- _date="${_line#* }"
- if [ -z "${_maintainer}" -o -z "${_date}" -o \
- "${_maintainer}" = "${_date}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_trailer}"
- OH_CHANGELOG_MAINTAINER=
- OH_CHANGELOG_DATE=
- elif [ -n "${OH_CHANGELOG_SOURCE}" ]; then
- OH_CHANGELOG_MAINTAINER="${_maintainer}"
- OH_CHANGELOG_DATE="${_date}"
- _entries=$(($_entries + 1))
- "${_cb}"
- [ ${?} -ne 0 ] && return ${_entries}
- fi
- _expect=next_or_eof
- _blank_lines=
- elif [ "${_line# --}" != "${_line}" ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_trailer}"
- elif [ "${_line## }" != "${_line}" ]; then
- if [ "${_expect}" != start_changes -a \
- "${_expect}" != changes_or_trailer ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_change}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
- OH_CHANGELOG_CHANGES="${OH_CHANGELOG_CHANGES}
-${_blank_lines}${_line}"
- _expect=changes_or_trailer
- _blank_lines=
- else
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_bad_line}"
- _blank_lines=
- fi
- done <"${OH_SOURCE_DIR}/changelog"
-
- if [ "${_expect}" != next_or_eof ]; then
- _changelog_parse_error "${_line_nr}" \
- "${oh_str_changelog_found_eof}" \
- "$(_changelog_get_expect_str "${_expect}")"
- fi
-
- return ${_entries}
-}