#!@@SH@@ # # opkbuild # src/ob-genchanges.sh # 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 . . '@@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" 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 } 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' | \ 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}")" printf ' %s - %s\n' "${pkg}" "${desc}" >&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 ${OPK_PACKAGES_REDUCED}; 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 "${@}"