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]>
---
 build-aux/automake.mk       |  1 +
 build-aux/prepare-debian.sh | 22 ++++++++++++++++++++++
 debian/automake.mk          | 35 ++++++-----------------------------
 3 files changed, 29 insertions(+), 29 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"
+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..f62281f5b 100644
--- a/debian/automake.mk
+++ b/debian/automake.mk
@@ -80,42 +80,21 @@ 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
+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
+       ./build-aux/prepare-debian.sh --dpdk
 DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc`
 else
-update_deb_control = \
-       $(AM_V_GEN) grep -v '^\# DPDK_NETDEV' \
-               < $(srcdir)/debian/control.in > debian/control
+       ./build-aux/prepare-debian.sh
 DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc` nodpdk
 endif
 
-debian/control: $(srcdir)/debian/control.in Makefile
-       $(update_deb_control)
-
-CLEANFILES += debian/control
-
-
 debian: debian/copyright debian/control
 .PHONY: debian
 
+CLEANFILES += debian/copyright
+CLEANFILES += debian/control
 
 debian-deb: debian
        @if test X"$(srcdir)" != X"$(top_builddir)"; then                       
\
@@ -123,8 +102,6 @@ debian-deb: debian
                exit 1;                                                         
\
        fi
        $(MAKE) distclean
-       $(update_deb_copyright)
-       $(update_deb_control)
        $(AM_V_GEN) fakeroot debian/rules clean
        $(AM_V_GEN) DEB_BUILD_OPTIONS="$(DEB_BUILD_OPTIONS)" \
                fakeroot debian/rules binary
-- 
2.52.0

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

Reply via email to