diff options
author | P. J. McDermott <pjm@nac.net> | 2013-08-17 22:12:44 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-08-17 22:12:44 (EDT) |
commit | 68cd3755e18c5eb0937acf977dbcdb7f409ab827 (patch) | |
tree | 8abd0489dc542d510321d1cc255a2d2f16dfdae0 /src | |
parent | 93dda971787afd1eba6fd3684520a077d74108b5 (diff) |
ob-genchanges: Implement, finally.
Diffstat (limited to 'src')
-rw-r--r-- | src/local.mk | 2 | ||||
-rw-r--r-- | src/ob-genchanges.sh | 106 |
2 files changed, 107 insertions, 1 deletions
diff --git a/src/local.mk b/src/local.mk index 06eeb4b..630b72c 100644 --- a/src/local.mk +++ b/src/local.mk @@ -26,4 +26,4 @@ bin_srcs = \ src/ob-installdocs.sh \ src/ob-gencontrol.sh \ src/ob-buildopk.sh \ -# src/ob-genchanges.sh + src/ob-genchanges.sh diff --git a/src/ob-genchanges.sh b/src/ob-genchanges.sh new file mode 100644 index 0000000..c24d9c8 --- /dev/null +++ b/src/ob-genchanges.sh @@ -0,0 +1,106 @@ +#!@@SH@@ +# +# opkbuild +# src/ob-genchanges +# Generates a changes file to describe binary packages and their changes. +# +# Copyright (C) 2013 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 2 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/>. + +. '@@PKGLIBDIR@@/load.sm' + +ob_use locale +ob_use output +ob_use package + +main() +{ + ob_set_text_domain 'opkbuild' + + ob_init_package '..' || exit 1 + ob_parse_package_metadata -c '.opkbuild.cache' || exit 1 + + if [ -n "${OB_DO_SOURCE}" ]; then + changes="${OPK_SOURCE}_${OPK_SOURCE_VERSION}_src_all.changes" + exec 3>"../../${changes}" + write_changes "${OPK_SOURCE_VERSION}" 'src' 'all' + write_files_src + exec 3>&- + else + changes="${OPK_SOURCE}_${OPK_SOURCE_VERSION}" + changes="${changes}_${OPK_HOST_ARCH}_${OPK_HOST_PLAT}.changes" + exec 3>"../../${changes}" + write_changes "${OPK_BINARY_VERSION}" \ + "${OPK_HOST_ARCH}" "${OPK_HOST_PLAT}" + write_files_bin + exec 3>&- + fi +} + +write_changes() +{ + version="${1}" + arch="${2}" + plat="${3}" + + printf 'Format: 1.0\n' >&3 + + printf 'Source: %s\n' "${OPK_SOURCE}" >&3 + printf 'Binary: %s\n' "$(ob_get_binary_packages)" >&3 + printf 'Version: %s\n' "${version}" >&3 + printf 'Architecture: %s\n' "${arch}" >&3 + printf 'Platform: %s\n' "${plat}" >&3 + + printf 'Distribution: %s\n' \ + "$(ob_get_source_parameter 'Distribution')" >&3 + printf 'Maintainer: %s\n' "$(ob_get_source_parameter 'Maintainer')" >&3 + printf 'Changed-By: %s\n' "$(ob_get_source_parameter 'Uploader')" >&3 + printf 'Date: %s\n' "$(ob_get_source_parameter 'Date')" >&3 + + printf 'Description:\n' >&3 + for pkg in $(ob_get_binary_packages); do + printf ' %s - %s\n' "${pkg}" "$(ob_get_binary_parameter \ + "${pkg}" 'Description' | head -n 1)" >&3 + done + + printf 'Changes:\n%s\n' "$(ob_get_source_parameter 'Changes' | \ + sed 's/^$/./; s/^/ /;')" >&3 +} + +write_files_src() +{ + printf 'Files:\n' >&3 + file="src-${OPK_SOURCE}_${OPK_SOURCE_VERSION}_src_all.opk" + printf ' %s %s %s\n' \ + "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ + 'base' "${file}" >&3 +} + +write_files_bin() +{ + printf 'Files:\n' >&3 + for pkg in $(ob_get_binary_packages); do + arch="$(ob_get_binary_parameter "${pkg}" 'Architecture')" + [ "${arch}" != 'all' ] && arch="${OPK_HOST_ARCH}" + plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" + [ "${plat}" != 'all' ] && plat="${OPK_HOST_PLAT}" + file="${pkg}_${version}_${arch}_${plat}.opk" + printf ' %s %s %s\n' \ + "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ + 'base' "${file}" >&3 + done +} + +main "${@}" |