From 445e3d6e43c55ddeb19322918e016c63f91c1958 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 13 Jun 2020 11:27:33 -0400 Subject: ob-gencontrol: Generate a "Format" field And add the needed support to ob_get_source_parameter(). --- diff --git a/NEWS b/NEWS index 765c135..6710d47 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,13 @@ Utilities: * ob-buildopk now correctly checks for the BusyBox tar reverse ordering bug. + * ob-gencontrol now generates a "Format" field to indicate the source + package formate version. + +libopkbuild: + + * ob_get_source_parameter() now supports a "Format" field to get the + source package formate version. opkbuild version 4.1.4 ---------------------- diff --git a/lib/package.sh b/lib/package.sh index 27ea8cb..8ed6645 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -18,6 +18,7 @@ # along with opkbuild. If not, see . _ob_package_dir= +_ob_package_format_full= _ob_package_format= _ob_binary_packages= _ob_got_binary_packages=false @@ -50,8 +51,9 @@ ob_init_package() _ob_package_dir="$(cd -- "${dir}" && pwd)" + _ob_package_format_full="$(cat -- "${_ob_package_dir}/format")" if [ -r "${_ob_package_dir}/format" ]; then - case "$(cat -- "${_ob_package_dir}/format")" in + case "${_ob_package_format_full}" in 2.0) _ob_package_format='2' ;; @@ -184,6 +186,10 @@ ob_get_source_parameter() EOF )" + case "${name}" in 'FORMAT') + printf '%s' "${_ob_package_format_full}" + esac + # TODO: Return error on no such field? eval "printf '%s' \"\${_OB_SRCFIELD_${name}-}\"" diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index 172f50f..be42c32 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -98,6 +98,7 @@ gen_control_src() cat >>"${binary}.control/control" <<-EOF Installed-Size: $(calc_inst_size "src-${OPK_SOURCE}") + Format: $(ob_get_source_parameter 'Format') Description: ${OPK_SOURCE} source package EOF diff --git a/tests/exe/ob-gencontrol.sh b/tests/exe/ob-gencontrol.sh index a619856..6f29d9b 100755 --- a/tests/exe/ob-gencontrol.sh +++ b/tests/exe/ob-gencontrol.sh @@ -36,6 +36,7 @@ cmd_is 'source package control file' cat 'src-foo.control/control' <<-EOF Maintainer: "J. Random Hacker" Build-Depends: build-all-runes Installed-Size: 0 + Format: 2.0 Description: foo source package EOF -- cgit v0.9.1