From 824797b55596d45589e5ca49ac906639f6e49f53 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 08 Dec 2020 01:29:23 -0500 Subject: ob-gencontrol: Use an FD for control files --- (limited to 'src') diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index b54c4b3..5a8aa40 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -72,8 +72,9 @@ gen_control_src() binary="src:${OPK_SOURCE}" mkdir -p -- "${binary}.control" + exec 3>"${binary}.control/control" - cat >"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Package: src:${OPK_SOURCE} Source: ${OPK_SOURCE} Binary:$(printf '%s\n' $(ob_get_binary_packages) | \ @@ -91,12 +92,10 @@ gen_control_src() continue fi value="$(ob_substvars "${value}")" - printf '%s: %s\n' "${name}" "${value}" | \ - sed 's/[, ]*$//' \ - >>"${binary}.control/control" + printf '%s: %s\n' "${name}" "${value}" | sed 's/[, ]*$//' >&3 done - cat >>"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Installed-Size: $(calc_inst_size "src:${OPK_SOURCE}") Format: $(ob_get_source_parameter 'Format') Description: ${OPK_SOURCE} source package @@ -104,10 +103,11 @@ gen_control_src() homepage="$(ob_get_source_parameter 'Homepage')" if [ -n "${homepage}" ]; then - printf '%s: %s\n' 'Homepage' "${homepage}" \ - >>"${binary}.control/control" + printf '%s: %s\n' 'Homepage' "${homepage}" >&3 fi + exec 3>&- + return 0 } @@ -124,8 +124,9 @@ gen_control_bin() local homepage= mkdir -p -- "${binary}.control" + exec 3>"${binary}.control/control" - cat >"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Package: $(ob_qualify_package_name "${binary}" \ "${OPK_HOST_ARCH}") Source: ${OPK_SOURCE} @@ -135,11 +136,11 @@ gen_control_bin() EOF value="$(ob_get_binary_parameter "${binary}" 'Section')" if [ -n "${value}" ]; then - cat >>"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Section: ${value} EOF fi - cat >>"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Maintainer: $(ob_get_source_parameter 'Maintainer' | \ tr '\n' ' ') EOF @@ -168,21 +169,21 @@ gen_control_bin() value="$(ob_substvars "${value}" "${binary}")" ;; esac - printf '%s: %s\n' "${name}" "${value}" | sed 's/[, ]*$//' \ - >>"${binary}.control/control" + printf '%s: %s\n' "${name}" "${value}" | sed 's/[, ]*$//' >&3 done - cat >>"${binary}.control/control" <<-EOF + cat >&3 <<-EOF Installed-Size: $(calc_inst_size "${binary}") Description:$(printf '%s' "${desc}" | sed 's/^/ /') EOF homepage="$(ob_get_source_parameter 'Homepage')" if [ -n "${homepage}" ]; then - printf '%s: %s\n' 'Homepage' "${homepage}" \ - >>"${binary}.control/control" + printf '%s: %s\n' 'Homepage' "${homepage}" >&3 fi + exec 3>&- + return 0 } -- cgit v0.9.1