On 2/26/26 1:01 AM, Ihar Hrachyshka via dev wrote:
> Move the generation of debian/control and debian/copyright from inline
> Makefile recipes into a standalone build-aux/prepare-debian.sh script.
> 
> This may be helpful for power users who want to generate debian/
> packaging files without going through the full autotools configuration
> process (./boot.sh, ./configure, make), e.g. when building in an
> isolated environment like pbuilder.
> 
> Signed-off-by: Ihar Hrachyshka <[email protected]>
> 
> ---
> v1: initial version.
> v2: fix debian-deb not triggering script after cleanup.
> ---
>  build-aux/automake.mk       |  1 +
>  build-aux/prepare-debian.sh | 22 ++++++++++++++++++++++
>  debian/automake.mk          | 37 +++++++++----------------------------
>  3 files changed, 32 insertions(+), 28 deletions(-)
>  create mode 100755 build-aux/prepare-debian.sh
> 
> diff --git a/build-aux/automake.mk b/build-aux/automake.mk
> index d65b6da6c..2fd28e5ad 100644
> --- a/build-aux/automake.mk
> +++ b/build-aux/automake.mk
> @@ -15,6 +15,7 @@ EXTRA_DIST += \
>       build-aux/gen_ofp_field_decoders \
>       build-aux/generate-dhparams-c \
>       build-aux/initial-tab-allowed-files \
> +     build-aux/prepare-debian.sh \
>       build-aux/sodepends.py \
>       build-aux/soexpand.py \
>       build-aux/text2c \
> diff --git a/build-aux/prepare-debian.sh b/build-aux/prepare-debian.sh
> new file mode 100755
> index 000000000..76d8b0b7b
> --- /dev/null
> +++ b/build-aux/prepare-debian.sh
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +set -e
> +
> +srcdir=$(dirname "$0")/..
> +
> +# Generate debian/control from control.in.
> +# With --dpdk, uncomment DPDK_NETDEV lines; without, strip them.
> +if [ "$1" = "--dpdk" ]; then
> +    sed -e 's/^# DPDK_NETDEV //' \
> +        < "$srcdir/debian/control.in" > "$srcdir/debian/control"
> +else
> +    grep -v '^# DPDK_NETDEV' \
> +        "$srcdir/debian/control.in" > "$srcdir/debian/control"

Producing files in the source directory is not nice.  While this
target will probabaly never be used with separate build directory.
it's still a little awkward to explicitly produce things in the
source directory.  Might be good if the directories can be passed
into the script.  For your manual runs there can be a fallback
if the directories are not provided.

> +fi
> +
> +# Generate debian/copyright from copyright.in and AUTHORS.rst.
> +{ sed -n -e '/%AUTHORS%/q' -e p < "$srcdir/debian/copyright.in"
> +  tail -n +28 "$srcdir/AUTHORS.rst" | sed '1,/^$/d' |
> +    sed -n -e '/^$/q' -e 's/^/  /p'
> +  sed -e '1,/%AUTHORS%/d' "$srcdir/debian/copyright.in"
> +} > "$srcdir/debian/copyright"
> diff --git a/debian/automake.mk b/debian/automake.mk
> index 7ae4e00e5..892effc2b 100644
> --- a/debian/automake.mk
> +++ b/debian/automake.mk
> @@ -80,42 +80,24 @@ check-debian-changelog-version:
>  ALL_LOCAL += check-debian-changelog-version
>  DIST_HOOKS += check-debian-changelog-version
>  
> -
> -update_deb_copyright = \
> -     $(AM_V_GEN) \
> -     { sed -n -e '/%AUTHORS%/q' -e p < $(srcdir)/debian/copyright.in;   \
> -       tail -n +28 $(srcdir)/AUTHORS.rst | sed '1,/^$$/d' |             \
> -             sed -n -e '/^$$/q' -e 's/^/  /p';                          \
> -       sed -e '1,/%AUTHORS%/d' $(srcdir)/debian/copyright.in;           \
> -     } > debian/copyright
> -
> -debian/copyright: AUTHORS.rst debian/copyright.in
> -     $(update_deb_copyright)
> -
> -CLEANFILES += debian/copyright
> -
> -
> +debian/control: $(srcdir)/debian/control.in Makefile

I wonder why it's an explicit source directory dependency...

> +debian/copyright: AUTHORS.rst debian/copyright.in debian/control
>  if DPDK_NETDEV
> -update_deb_control = \
> -     $(AM_V_GEN) sed -e 's/^\# DPDK_NETDEV //' \
> -             < $(srcdir)/debian/control.in > debian/control
> +PREPARE_DEBIAN_FLAGS = --dpdk
>  DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc`
>  else
> -update_deb_control = \
> -     $(AM_V_GEN) grep -v '^\# DPDK_NETDEV' \
> -             < $(srcdir)/debian/control.in > debian/control
> +PREPARE_DEBIAN_FLAGS =
>  DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc` nodpdk
>  endif
>  
> -debian/control: $(srcdir)/debian/control.in Makefile
> -     $(update_deb_control)
> -
> -CLEANFILES += debian/control
> -
> +debian/control debian/copyright:
> +     ./build-aux/prepare-debian.sh $(PREPARE_DEBIAN_FLAGS)

This script will be executed twice.  Once per target file.  And in
parallel if the make is running with -j, potentially corrupting the
output.

A standard portable way to solve this problem is to create a "stamp"
target, e.g. "debian.stamp", make both control and copyright depend
on the stamp, and make the stamp target have all the real dependencies
and run the script.  And create the stamp file, of course.  it will
also need to be added to gitignore, if not already covered.

>  
>  debian: debian/copyright debian/control
>  .PHONY: debian
>  
> +CLEANFILES += debian/copyright
> +CLEANFILES += debian/control

These are in the build directory, while script explicitly creates
them in the source directory.

>  
>  debian-deb: debian
>       @if test X"$(srcdir)" != X"$(top_builddir)"; then                       
> \
> @@ -123,8 +105,7 @@ debian-deb: debian
>               exit 1;                                                         
> \
>       fi
>       $(MAKE) distclean
> -     $(update_deb_copyright)
> -     $(update_deb_control)
> +     ./build-aux/prepare-debian.sh $(PREPARE_DEBIAN_FLAGS)
>       $(AM_V_GEN) fakeroot debian/rules clean
>       $(AM_V_GEN) DEB_BUILD_OPTIONS="$(DEB_BUILD_OPTIONS)" \
>               fakeroot debian/rules binary

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to