Browse Source

Make the clean target work

Christoph Biedl 4 years ago
parent
commit
538f5fd2e8

+ 15 - 0
debian/Makefile.am

@@ -0,0 +1,15 @@
+ACLOCAL_AMFLAGS	= -I m4
+
+noinst_LTLIBRARIES		= libbgpdump.la
+libbgpdump_la_SOURCES	= bgpdump-config.h bgpdump_attr.h bgpdump_formats.h bgpdump_lib.c bgpdump_lib.h bgpdump_mstream.c bgpdump_mstream.h cfile_tools.c cfile_tools.h inet_ntop.c util.c util.h
+
+bin_PROGRAMS 	= bgpdump
+bgpdump_SOURCES	= bgpdump.c
+bgpdump_LDADD 	= libbgpdump.la
+
+check-clean:
+	rm -f test_out/*.bgp.gz
+
+test: check-clean bgpdump
+	./test.sh debian/tests/
+	@[ -d test_data ] && ./test.sh || echo "Skipping upstream tests as they are huge (see README.Debian)"

+ 43 - 0
debian/configure.ac

@@ -0,0 +1,43 @@
+AC_REVISION([m4_esyscmd_s([dpkg-parsechangelog -SVersion])])
+
+AC_INIT([libbgpdump], 1.5.0, [ris@ripe.net])
+
+AM_INIT_AUTOMAKE([foreign])
+
+AC_CONFIG_SRCDIR([bgpdump_lib.c])
+AC_CONFIG_HEADERS([bgpdump-config.h])
+
+# Checks for programs.
+AC_PROG_CC
+
+AC_PROG_LIBTOOL
+AC_CONFIG_MACRO_DIRS([m4])
+
+# Checks for header files.
+AC_CHECK_HEADERS([arpa/inet.h netinet/in.h syslog.h])
+AC_STRUCT_TM
+
+# Check for u_*_t
+AC_CHECK_TYPE(u_char_t, , AC_DEFINE(u_char_t, uchar_t, [Define if system headers do not define u_char_t]))
+AC_CHECK_TYPE(u_int8_t, , AC_DEFINE(u_int8_t, uint8_t, [Define if system headers do not define u_int8_t]))
+AC_CHECK_TYPE(u_int16_t, , AC_DEFINE(u_int16_t, uint16_t, [Define if system headers do not define u_int16_t]))
+AC_CHECK_TYPE(u_int32_t, , AC_DEFINE(u_int32_t, uint32_t, [Define if system headers do not define u_int32_t]))
+
+AC_CHECK_LIB(z, gzopen, [], AC_DEFINE(DONT_HAVE_GZ, 1, Define if libz not present))
+AC_CHECK_LIB(bz2, BZ2_bzReadOpen, [], AC_DEFINE(DONT_HAVE_BZ2, 1, Define if libbzip2 not present))
+AC_CHECK_LIB(bsd, strlcat)
+
+# Check for inet_ntoa in -lnsl if not found (Solaris)
+AC_CHECK_FUNCS(inet_ntoa, [], AC_CHECK_LIB(nsl, inet_ntoa, [], AC_MSG_ERROR([inet_ntoa not found],1)))
+AC_CHECK_FUNCS(inet_ntop, [], AC_CHECK_LIB(nsl, inet_ntop, [], AC_MSG_ERROR([inet_ntop not found],1)))
+
+case `uname` in
+	Darwin*) LDFLAGS="$LDFLAGS -dynamiclib" ;;
+	*)       LDFLAGS="$LDFLAGS -shared" ;;
+esac
+
+AC_SUBST(CFLAGS)
+AC_SUBST(LDFLAGS)
+AC_SUBST(LIBS)
+
+AC_OUTPUT([bgpdump.spec Makefile])

+ 0 - 8
debian/patches/enhance-test-script.patch

@@ -59,11 +59,3 @@ Last-Update: 2014-07-22
      if [ $? = 0 ]; then
          echo "success"
      else
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -11,4 +11,5 @@
- 	rm -f test_out/*.bgp.gz
- 
- test: check-clean bgpdump
-+	./test.sh debian/tests/
- 	@[ -d test_data ] && ./test.sh || echo "Skipping upstream tests as they are huge (see README.Debian)"

+ 0 - 68
debian/patches/re-autoconfig.patch

@@ -1,68 +0,0 @@
-Description: Redo autoconfig stuff
-Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
-Forwarded: No
-Last-Update: 2016-07-20
-
---- /dev/null
-+++ b/Makefile.am
-@@ -0,0 +1,14 @@
-+ACLOCAL_AMFLAGS	= -I m4
-+
-+noinst_LTLIBRARIES		= libbgpdump.la
-+libbgpdump_la_SOURCES	= bgpdump-config.h bgpdump_attr.h bgpdump_formats.h bgpdump_lib.c bgpdump_lib.h bgpdump_mstream.c bgpdump_mstream.h cfile_tools.c cfile_tools.h inet_ntop.c util.c util.h
-+
-+bin_PROGRAMS 	= bgpdump
-+bgpdump_SOURCES	= bgpdump.c
-+bgpdump_LDADD 	= libbgpdump.la
-+
-+check-clean:
-+	rm -f test_out/*.bgp.gz
-+
-+test: check-clean bgpdump
-+	@[ -d test_data ] && ./test.sh || echo "Skipping upstream tests as they are huge (see README.Debian)"
---- /dev/null
-+++ b/configure.ac
-@@ -0,0 +1,43 @@
-+AC_REVISION([m4_esyscmd_s([dpkg-parsechangelog -SVersion])])
-+
-+AC_INIT([libbgpdump], 1.4.99.15, [ris@ripe.net])
-+
-+AM_INIT_AUTOMAKE([foreign])
-+
-+AC_CONFIG_SRCDIR([bgpdump_lib.c])
-+AC_CONFIG_HEADERS([bgpdump-config.h])
-+
-+# Checks for programs.
-+AC_PROG_CC
-+
-+AC_PROG_LIBTOOL
-+AC_CONFIG_MACRO_DIRS([m4])
-+
-+# Checks for header files.
-+AC_CHECK_HEADERS([arpa/inet.h netinet/in.h syslog.h])
-+AC_STRUCT_TM
-+
-+# Check for u_*_t
-+AC_CHECK_TYPE(u_char_t, , AC_DEFINE(u_char_t, uchar_t, [Define if system headers do not define u_char_t]))
-+AC_CHECK_TYPE(u_int8_t, , AC_DEFINE(u_int8_t, uint8_t, [Define if system headers do not define u_int8_t]))
-+AC_CHECK_TYPE(u_int16_t, , AC_DEFINE(u_int16_t, uint16_t, [Define if system headers do not define u_int16_t]))
-+AC_CHECK_TYPE(u_int32_t, , AC_DEFINE(u_int32_t, uint32_t, [Define if system headers do not define u_int32_t]))
-+
-+AC_CHECK_LIB(z, gzopen, [], AC_DEFINE(DONT_HAVE_GZ, 1, Define if libz not present))
-+AC_CHECK_LIB(bz2, BZ2_bzReadOpen, [], AC_DEFINE(DONT_HAVE_BZ2, 1, Define if libbzip2 not present))
-+AC_CHECK_LIB(bsd, strlcat)
-+
-+# Check for inet_ntoa in -lnsl if not found (Solaris)
-+AC_CHECK_FUNCS(inet_ntoa, [], AC_CHECK_LIB(nsl, inet_ntoa, [], AC_MSG_ERROR([inet_ntoa not found],1)))
-+AC_CHECK_FUNCS(inet_ntop, [], AC_CHECK_LIB(nsl, inet_ntop, [], AC_MSG_ERROR([inet_ntop not found],1)))
-+
-+case `uname` in
-+	Darwin*) LDFLAGS="$LDFLAGS -dynamiclib" ;;
-+	*)       LDFLAGS="$LDFLAGS -shared" ;;
-+esac
-+
-+AC_SUBST(CFLAGS)
-+AC_SUBST(LDFLAGS)
-+AC_SUBST(LIBS)
-+
-+AC_OUTPUT([bgpdump.spec Makefile])

+ 0 - 3
debian/patches/series

@@ -1,6 +1,3 @@
-# packaging
-re-autoconfig.patch
-
 # upstream code cleanup
 disable-cfr_strerror.patch
 fix-crash-on-huge-prefix-lists.patch

+ 38 - 3
debian/rules

@@ -8,10 +8,45 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 override_dh_clean:
 	dh_clean
 	-rm debian/bgpdump.1
+	-rm -rf debian/tests/test_out/
 
-override_dh_autoreconf:
-	-rm configure.in Makefile.in
-	dh_autoreconf
+override_dh_auto_clean:
+	# some extra loops for cleanup *after* build
+	if [ -d m4 ] ; then \
+		cp -v debian/Makefile.am debian/configure.ac . ; \
+	fi
+	dh_auto_clean
+	-rm Makefile.am configure.ac
+
+override_dh_autoreconf_clean:
+	dh_autoreconf_clean
+	# restore upstream files
+	for file in Makefile.in configure.in ; do \
+		if [ -f $$file.orig ] ; then \
+			mv -v $$file.orig $$file ; \
+		fi ; \
+	done
+
+override_dh_update_autotools_config:
+	cp -v debian/Makefile.am debian/configure.ac .
+	mkdir -p m4
+	# move upstream files out of the way
+	for file in Makefile.in configure.in ; do \
+		if [ -f $$file ] && [ ! -f $$file.orig ] ; then \
+			mv -v $$file $$file.orig ; \
+		fi ; \
+	done
+	dh_update_autotools_config
+
+override_dh_auto_configure:
+	dh_auto_configure
+	VERSION_AC="$$(awk '($$2=="VERSION"){print $$3}' bgpdump-config.h | cut -d'"' -f2)" ; \
+	VERSION_DEB="$$(dpkg-parsechangelog -SVersion | cut -d- -f1)" ; \
+	if [ "$$VERSION_AC" != "$$VERSION_DEB" ] ; then \
+		echo "Mismatch! Debian: $$VERSION_DEB, AC: $$VERSION_AC" ; \
+		echo "Fix debian/configure.ac to match debian/changelog" ; \
+		false ; \
+	fi
 
 override_dh_install:
 	dh_install