From 3bc002a39d7ec61ee5f143bb338a425f0ddc5753 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 16 Jun 2019 18:26:15 -0400 Subject: ob-gencontrol: Generate different fields for source packages --- diff --git a/TODO b/TODO index a0406a1..6b91171 100644 --- a/TODO +++ b/TODO @@ -4,8 +4,6 @@ Near Term Functional Changes ------------------ - * ob-gencontrol: For source packages, remove `Source` and add `Binary` and - `Build-Depends` fields. * ob-installplatconf: Match version directory as a pattern against package version. diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index 49fecf4..175e275 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -62,15 +62,63 @@ calc_inst_size() printf '%d' $(((${inst_size} + 1023) / 1024)) } -gen_control() +gen_control_src() +{ + local binary= + local name= + local value= + local homepage= + + binary="src-${OPK_SOURCE}" + + mkdir -p -- "${binary}.control" + + # TODO: If OPK_PACKAGES_REDUCED is renamed to OPK_PACKAGES, use + # ob_get_binary_packages(). See comment and code in opkbuild + # setup_build(). + cat >"${binary}.control/control" <<-EOF + Package: ${OPK_SOURCE} + Binary:$(printf ' %s' ${OPK_PACKAGES}) + Version: ${OPK_SOURCE_VERSION} + Architecture: src + Platform: all + Maintainer: $(ob_get_source_parameter 'Maintainer' | \ + tr '\n' ' ') + EOF + + for name in Build-Depends; do + value="$(ob_get_source_parameter "${name}")" + if [ -z "${value}" ]; then + continue + fi + value="$(ob_substvars "${value}")" + printf '%s: %s\n' "${name}" "${value}" | \ + sed 's/[, ]*$//' \ + >>"${binary}.control/control" + done + + cat >>"${binary}.control/control" <<-EOF + Installed-Size: $(calc_inst_size "src-${OPK_SOURCE}") + Description: ${OPK_SOURCE} source package + EOF + + homepage="$(ob_get_source_parameter 'Homepage')" + if [ -n "${homepage}" ]; then + printf '%s: %s\n' 'Homepage' "${homepage}" \ + >>"${binary}.control/control" + fi + + return 0 +} + +gen_control_bin() { local binary="${1}" local version="${2}" local arch="${3}" local plat="${4}" local desc="${5}" - local gen_rel="${6}" - shift 6 + shift 5 local name= local value= local homepage= @@ -87,7 +135,7 @@ gen_control() tr '\n' ' ') EOF - if ${gen_rel}; then + if :; then for name in Essential Depends Recommends Suggests Pre-Depends \ Conflicts Provides Replaces; do value="$(ob_get_binary_parameter "${binary}" "${name}")" @@ -222,8 +270,7 @@ main() if [ x"${OB_DO_SOURCE:+set}" = x'set' ]; then ob_info "$(ob_get_msg 'gen_control')" "src-${OPK_SOURCE}" - gen_control "src-${OPK_SOURCE}" "${OPK_SOURCE_VERSION}" \ - 'src' 'all' "${OPK_SOURCE} source package" 'false' + gen_control_src gen_md5sums "src-${OPK_SOURCE}" else for pkg in ${OPK_PACKAGES_REDUCED}; do @@ -236,8 +283,8 @@ main() [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" desc="$(ob_get_binary_parameter "${pkg}" 'Description')" desc="$(ob_substvars "${desc}" "${pkg}")" - gen_control "${pkg}" "${OPK_BINARY_VERSION}" \ - "${arch}" "${plat}" "${desc}" 'true' + gen_control_bin "${pkg}" "${OPK_BINARY_VERSION}" \ + "${arch}" "${plat}" "${desc}" install_maintainer_scripts "${pkg}" gen_conffiles "${pkg}" gen_md5sums "${pkg}" -- cgit v0.9.1