# Generate a changes file to describe binary packages and their changes # # Copyright (C) 2013 Patrick McDermott # # This file is part of opkbuild. # # opkbuild 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. # # opkbuild 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 opkbuild. If not, see . set -eu write_changes() { local version="${1}" local arch="${2}" local plat="${3}" shift 3 local pkg= local desc= printf 'Format: 1.0\n' >&3 printf 'Source: %s\n' "${OPK_SOURCE}" >&3 printf 'Binary:' >&3 printf '%s\n' $(ob_get_binary_packages) | LC_ALL='C' sort | \ xargs printf ' %s' >&3 printf '\n' >&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' | \ tr '\n' ' ')" >&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 ob_set_package_substvars "${pkg}" desc="$(ob_get_binary_parameter "${pkg}" 'Description' | \ head -n 1)" desc="$(ob_substvars "${desc}" "${pkg}")" printf ' %s - %s\n' "${pkg}" "${desc}" >&3 done printf 'Changes:\n%s\n' "$(ob_get_source_parameter 'Changes' | \ sed 's/^$/./; s/^/ /;')" >&3 return 0 } write_files_src() { local file= 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)" \ 'src' "${file}" >&3 return 0 } write_files_bin() { local pkg= local arch= local plat= local sect= local file= printf 'Files:\n' >&3 for pkg in ${OPK_PACKAGES_REDUCED}; do arch="$(ob_get_binary_parameter "${pkg}" 'Architecture')" [ x"${arch}" != x'all' ] && arch="${OPK_HOST_ARCH}" plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" sect="$(ob_get_binary_parameter "${pkg}" 'Section')" [ x"${sect}" = x'' ] && sect='base' file="$(ob_qualify_package_name "${pkg}" "${OPK_HOST_ARCH}")" file="${file}_${OPK_BINARY_VERSION}_${arch}_${plat}.opk" printf ' %s %s %s\n' \ "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ "${sect}" "${file}" >&3 done return 0 } main() { local changes= if ! ob_set_text_domain 'opkbuild'; then printf '%s: Error: Failed to load locale messages\n' \ "${0##*/}" >&2 return 1 fi ob_init_package '..' || return 1 if [ x"${OB_DO_SOURCE:+set}" = x'set' ]; then changes="${OPK_SOURCE}_${OPK_SOURCE_VERSION}_src_all.changes" ob_info "$(ob_get_msg 'gen_changes')" "${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" ob_info "$(ob_get_msg 'gen_changes')" "${changes}" exec 3>"../../${changes}" write_changes "${OPK_BINARY_VERSION}" \ "${OPK_HOST_ARCH}" "${OPK_HOST_PLAT}" write_files_bin exec 3>&- fi return 0 }