summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/changelog.sh204
1 files changed, 104 insertions, 100 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
index 2f1515f..9aaa0b9 100644
--- a/lib/changelog.sh
+++ b/lib/changelog.sh
@@ -33,174 +33,178 @@ OB_CHANGELOG_DATE=
ob_parse_changelog()
{
- _ob_local _obpch_file _obpch_entry_cb \
- _obpch_line_nr _obpch_line _obpch_line_ \
- _obpch_expect _obpch_blank_lines \
- _obpch_source _obpch_distribution _obpch_version \
- _obpch_maintainer _obpch_date
+ local file=
+ local entry_cb=
+ local line_nr=
+ local line=
+ local line_=
+ local expect=
+ local blank_lines=
+ local source=
+ local distribution=
+ local version=
+ local maintainer=
+ local date=
if [ ${#} -eq 2 ]; then
- _obpch_file="${1}"
- _obpch_entry_cb="${2}"
+ file="${1}"
+ entry_cb="${2}"
else
- _ob_return 125
- return ${?}
+ return 125
fi
# Parsing logic based on that of dpkg.
- _obpch_line_nr=0
- _obpch_expect='first_heading'
+ line_nr=0
+ expect='first_heading'
- while IFS= read _obpch_line; do
- _obpch_line_nr=$(($_obpch_line_nr + 1))
- if [ -z "${_obpch_line}" ]; then
- if [ "${_obpch_expect}" = 'start_changes' ]; then
+ while IFS= read line; do
+ line_nr=$(($line_nr + 1))
+ if [ -z "${line}" ]; then
+ if [ "${expect}" = 'start_changes' ]; then
OB_CHANGELOG_CHANGES="${OB_CHANGELOG_CHANGES}
-${_obpch_line}"
- elif [ "${_obpch_expect}" = 'next_or_eof' ]; then
+${line}"
+ elif [ "${expect}" = 'next_or_eof' ]; then
:
- elif [ "${_obpch_expect}" != 'changes_or_trailer' ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ elif [ "${expect}" != 'changes_or_trailer' ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_found_blank_line' \
- "$(_ob_get_changelog_expect_str "${_obpch_expect}")"
+ "$(_ob_get_changelog_expect_str "${expect}")"
else
- _obpch_blank_lines="${_obpch_blank_lines}
-${_obpch_line}"
+ blank_lines="${blank_lines}
+${line}"
fi
- elif [ "${_obpch_line# }" = "${_obpch_line}" ]; then
- if [ "${_obpch_expect}" != 'first_heading' -a \
- "${_obpch_expect}" != 'next_or_eof' ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ elif [ "${line# }" = "${line}" ]; then
+ if [ "${expect}" != 'first_heading' -a \
+ "${expect}" != 'next_or_eof' ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_found_heading' \
- "$(_ob_get_changelog_expect_str "${_obpch_expect}")"
+ "$(_ob_get_changelog_expect_str "${expect}")"
fi
- _obpch_source="${_obpch_line%% (*}"
- _obpch_line_="${_obpch_line#* (}"
- _obpch_distribution="${_obpch_line_##*) }"
- _obpch_line_="${_obpch_line_%) *}"
- _obpch_version="${_obpch_line_}"
- if [ -z "${_obpch_source}" -o -z "${_obpch_distribution}" -o \
- -z "${_obpch_version}" -o \
- "${_obpch_version% *}" != "${_obpch_version}" ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ source="${line%% (*}"
+ line_="${line#* (}"
+ distribution="${line_##*) }"
+ line_="${line_%) *}"
+ version="${line_}"
+ if [ -z "${source}" -o -z "${distribution}" -o \
+ -z "${version}" -o \
+ "${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=
else
- if ! ob_validate_source_name "${_obpch_source}"; then
+ if ! ob_validate_source_name "${source}"; then
_ob_parse_changelog_error \
- "${_obpch_file}" "${_obpch_line_nr}" \
+ "${file}" "${line_nr}" \
'changelog_bad_source' "${source}"
fi
- if ! ob_parse_version "${_obpch_version}"; then
+ if ! ob_parse_version "${version}"; then
_ob_parse_changelog_error \
- "${_obpch_file}" "${_obpch_line_nr}" \
- 'changelog_bad_source_version' "${_obpch_version}"
+ "${file}" "${line_nr}" \
+ 'changelog_bad_source_version' "${version}"
fi
- OB_CHANGELOG_SOURCE="${_obpch_source}"
- OB_CHANGELOG_VERSION="${_obpch_version}"
- OB_CHANGELOG_DISTRIBUTION="${_obpch_distribution}"
- OB_CHANGELOG_CHANGES="${_obpch_line}"
+ OB_CHANGELOG_SOURCE="${source}"
+ OB_CHANGELOG_VERSION="${version}"
+ OB_CHANGELOG_DISTRIBUTION="${distribution}"
+ OB_CHANGELOG_CHANGES="${line}"
fi
- _obpch_expect='start_changes'
- _obpch_blank_lines=
- elif [ "${_obpch_line# -- }" != "${_obpch_line}" ]; then
- if [ "${_obpch_expect}" != 'changes_or_trailer' ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ expect='start_changes'
+ blank_lines=
+ elif [ "${line# -- }" != "${line}" ]; then
+ if [ "${expect}" != 'changes_or_trailer' ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_found_trailer' \
- "$(_ob_get_changelog_expect_str "${_obpch_expect}")"
+ "$(_ob_get_changelog_expect_str "${expect}")"
fi
- _obpch_line="${_obpch_line# -- }"
- _obpch_maintainer="${_obpch_line%% *}"
- _obpch_date="${_obpch_line#* }"
- if [ -z "${_obpch_maintainer}" -o -z "${_obpch_date}" -o \
- "${_obpch_maintainer}" = "${_obpch_date}" ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ line="${line# -- }"
+ maintainer="${line%% *}"
+ date="${line#* }"
+ if [ -z "${maintainer}" -o -z "${date}" -o \
+ "${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="${_obpch_maintainer}"
- OB_CHANGELOG_DATE="${_obpch_date}"
- "${_obpch_entry_cb}"
+ OB_CHANGELOG_MAINTAINER="${maintainer}"
+ OB_CHANGELOG_DATE="${date}"
+ "${entry_cb}"
if [ ${?} -ne 0 ]; then
- _ob_return 0
- return ${?}
+ return 0
fi
fi
- _obpch_expect='next_or_eof'
- _obpch_blank_lines=
- elif [ "${_obpch_line# --}" != "${_obpch_line}" ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ expect='next_or_eof'
+ blank_lines=
+ elif [ "${line# --}" != "${line}" ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_bad_trailer'
- elif [ "${_obpch_line## }" != "${_obpch_line}" ]; then
- if [ "${_obpch_expect}" != 'start_changes' -a \
- "${_obpch_expect}" != 'changes_or_trailer' ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ elif [ "${line## }" != "${line}" ]; then
+ if [ "${expect}" != 'start_changes' -a \
+ "${expect}" != 'changes_or_trailer' ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_found_change' \
- "$(_ob_get_changelog_expect_str "${_obpch_expect}")"
+ "$(_ob_get_changelog_expect_str "${expect}")"
fi
OB_CHANGELOG_CHANGES="${OB_CHANGELOG_CHANGES}
-${_obpch_blank_lines}${_obpch_line}"
- _obpch_expect='changes_or_trailer'
- _obpch_blank_lines=
+${blank_lines}${line}"
+ expect='changes_or_trailer'
+ blank_lines=
else
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_bad_line'
- _obpch_blank_lines=
+ blank_lines=
fi
done <<-EOF
- $(cat "${_obpch_file}")
+ $(cat "${file}")
EOF
- if [ "${_obpch_expect}" != 'next_or_eof' ]; then
- _ob_parse_changelog_error "${_obpch_file}" "${_obpch_line_nr}" \
+ if [ "${expect}" != 'next_or_eof' ]; then
+ _ob_parse_changelog_error "${file}" "${line_nr}" \
'changelog_found_eof' \
- "$(_ob_get_changelog_expect_str "${_obpch_expect}")"
+ "$(_ob_get_changelog_expect_str "${expect}")"
fi
- _ob_return 0
- return ${?}
+ return 0
}
_ob_parse_changelog_error()
{
- _ob_local _obpche_file _obpche_line_nr _obpche_msg_id \
- _obpche_file_info _obpche_orig_text_domain
-
- _obpche_file="${1}"
- _obpche_line_nr="${2}"
- _obpche_msg_id="${3}"
+ local file=
+ local line_nr=
+ local msg_id=
+ local file_info=
+ local orig_text_domain=
+
+ file="${1}"
+ line_nr="${2}"
+ msg_id="${3}"
shift 3
- _obpche_file_info="$(printf '%20s(l%d):' "${_obpche_file}" \
- "${_obpche_line_nr}")"
+ file_info="$(printf '%20s(l%d):' "${file}" "${line_nr}")"
- _obpche_orig_text_domain="$(ob_get_text_domain)"
+ orig_text_domain="$(ob_get_text_domain)"
ob_set_text_domain "${_OB_INTERNAL_TEXT_DOMAIN}"
- ob_warn "${_obpche_file_info} $(ob_get_msg "${_obpche_msg_id}")" "${@}"
+ ob_warn "${file_info} $(ob_get_msg "${msg_id}")" "${@}"
- ob_set_text_domain "${_obpche_orig_text_domain}"
+ ob_set_text_domain "${orig_text_domain}"
- _ob_return 0
- return ${?}
+ return 0
}
_ob_get_changelog_expect_str()
{
- _ob_local _obgces_orig_text_domain
+ local orig_text_domain=
- _obgces_orig_text_domain="$(ob_get_text_domain)"
+ orig_text_domain="$(ob_get_text_domain)"
ob_set_text_domain "${_OB_INTERNAL_TEXT_DOMAIN}"
echo "$(ob_get_msg "changelog_expect_${1}")"
- ob_set_text_domain "${_obgces_orig_text_domain}"
+ ob_set_text_domain "${orig_text_domain}"
- _ob_return 0
- return ${?}
+ return 0
}