tags 592086 +patch
thanks

On Sat, Aug 07, 2010 at 03:18:58PM +0200, Lionel Elie Mamane wrote:

> The "clean" target does not undo all that binary / build targets do,
> leading to:

>  1) rebuilding yields a _different_ source package

>  2) (...) that "new" source package fails  to build from source
>     when built twice in a row.

> In other words, openvpn fails to build from source when built *three*
> times in a row.

> I expected AM_MAINTAINER_MODE (in a debian/patches/ patch) would solve
> the problem, but it seems it doesn't. That may be because patches are
> unapplied _before_ running "distclean", not _after_, and
> AM_MAINTAINTER_MODE is not active then?

That was exactly why it was not working. Here is a patch that works:
it makes sure patches are applied before clean, and unpatches at the
end of clean.

One could apply _only_ the am_maintainer_mode patch before clean (and
still unapply all patches at the end of clean). Something like
(untested):

clean::
        dh_testdir
        dh_testroot
        rm -f build-stamp 

        QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null push 
am_maintainer_mode || test $$? = 2
        # Add here commands to clean up after the build process.
        [ ! -f Makefile ] || $(MAKE) distclean

        #clean plugins
        $(MAKE) -C plugin/auth-pam/ clean
        $(MAKE) -C plugin/down-root/ clean

clean:: unpatch
        dh_clean


-- 
Lionel
diff -Nru openvpn-2.1.0/debian/patches/am_maintainer_mode openvpn-2.1.0/debian/patches/am_maintainer_mode
--- openvpn-2.1.0/debian/patches/am_maintainer_mode	1970-01-01 01:00:00.000000000 +0100
+++ openvpn-2.1.0/debian/patches/am_maintainer_mode	2010-08-07 17:18:17.000000000 +0200
@@ -0,0 +1,298 @@
+Index: openvpn-2.1.0/configure.ac
+===================================================================
+--- openvpn-2.1.0.orig/configure.ac	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/configure.ac	2010-08-07 17:17:29.000000000 +0200
+@@ -33,6 +33,7 @@
+ dnl Guess host type.
+ AC_CANONICAL_HOST
+ AC_CANONICAL_SYSTEM
++AM_MAINTAINER_MODE
+ AM_INIT_AUTOMAKE(openvpn, [$PACKAGE_VERSION])
+ 
+ AC_ARG_WITH(cygwin-native,
+Index: openvpn-2.1.0/Makefile.in
+===================================================================
+--- openvpn-2.1.0.orig/Makefile.in	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/Makefile.in	2010-08-07 17:17:47.000000000 +0200
+@@ -184,6 +184,7 @@
+ LIBOBJS = @LIBOBJS@
+ LIBS = @LIBS@
+ LTLIBOBJS = @LTLIBOBJS@
++MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MAN2HTML = @MAN2HTML@
+ MKDIR_P = @MKDIR_P@
+@@ -379,7 +380,7 @@
+ .SUFFIXES: .c .o .obj
+ am--refresh:
+ 	@:
+-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
++$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+ 	@for dep in $?; do \
+ 	  case '$(am__configure_deps)' in \
+ 	    *$$dep*) \
+@@ -406,9 +407,9 @@
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ 	$(SHELL) ./config.status --recheck
+ 
+-$(top_srcdir)/configure:  $(am__configure_deps)
++$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ 	cd $(srcdir) && $(AUTOCONF)
+-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
++$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+ 
+ config.h: stamp-h1
+@@ -420,7 +421,7 @@
+ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+ 	@rm -f stamp-h1
+ 	cd $(top_builddir) && $(SHELL) ./config.status config.h
+-$(srcdir)/config.h.in:  $(am__configure_deps) 
++$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+ 	cd $(top_srcdir) && $(AUTOHEADER)
+ 	rm -f stamp-h1
+ 	touch $@
+Index: openvpn-2.1.0/aclocal.m4
+===================================================================
+--- openvpn-2.1.0.orig/aclocal.m4	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/aclocal.m4	2010-08-07 17:17:45.000000000 +0200
+@@ -543,6 +543,35 @@
+ rmdir .tst 2>/dev/null
+ AC_SUBST([am__leading_dot])])
+ 
++# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
++# From Jim Meyering
++
++# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
++# Free Software Foundation, Inc.
++#
++# This file is free software; the Free Software Foundation
++# gives unlimited permission to copy and/or distribute it,
++# with or without modifications, as long as this notice is preserved.
++
++# serial 4
++
++AC_DEFUN([AM_MAINTAINER_MODE],
++[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
++  dnl maintainer-mode is disabled by default
++  AC_ARG_ENABLE(maintainer-mode,
++[  --enable-maintainer-mode  enable make rules and dependencies not useful
++			  (and sometimes confusing) to the casual installer],
++      USE_MAINTAINER_MODE=$enableval,
++      USE_MAINTAINER_MODE=no)
++  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
++  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
++  MAINT=$MAINTAINER_MODE_TRUE
++  AC_SUBST(MAINT)dnl
++]
++)
++
++AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
++
+ # Check to see how 'make' treats includes.	            -*- Autoconf -*-
+ 
+ # Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+Index: openvpn-2.1.0/configure
+===================================================================
+--- openvpn-2.1.0.orig/configure	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/configure	2010-08-07 17:17:46.000000000 +0200
+@@ -664,6 +664,9 @@
+ target_cpu
+ target_vendor
+ target_os
++MAINTAINER_MODE_TRUE
++MAINTAINER_MODE_FALSE
++MAINT
+ INSTALL_PROGRAM
+ INSTALL_SCRIPT
+ INSTALL_DATA
+@@ -1311,6 +1314,8 @@
+ Optional Features:
+   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
++  --enable-maintainer-mode  enable make rules and dependencies not useful
++			  (and sometimes confusing) to the casual installer
+   --disable-lzo           Disable LZO compression support
+   --disable-crypto        Disable OpenSSL crypto support
+   --disable-ssl           Disable OpenSSL SSL support for TLS-based key exchange
+@@ -1957,6 +1962,28 @@
+   test "$program_prefix$program_suffix$program_transform_name" = \
+     NONENONEs,x,x, &&
+   program_prefix=${target_alias}-
++{ echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
++echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6; }
++    # Check whether --enable-maintainer-mode was given.
++if test "${enable_maintainer_mode+set}" = set; then
++  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
++else
++  USE_MAINTAINER_MODE=no
++fi
++
++  { echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
++echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6; }
++   if test $USE_MAINTAINER_MODE = yes; then
++  MAINTAINER_MODE_TRUE=
++  MAINTAINER_MODE_FALSE='#'
++else
++  MAINTAINER_MODE_TRUE='#'
++  MAINTAINER_MODE_FALSE=
++fi
++
++  MAINT=$MAINTAINER_MODE_TRUE
++
++
+ am__api_version='1.10'
+ 
+ # Find a good install program.  We prefer a C program (faster),
+@@ -13202,6 +13229,13 @@
+ LTLIBOBJS=$ac_ltlibobjs
+ 
+ 
++if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
++  { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
++Usually this means the macro was only invoked conditionally." >&5
++echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
++Usually this means the macro was only invoked conditionally." >&2;}
++   { (exit 1); exit 1; }; }
++fi
+ if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+   { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+ Usually this means the macro was only invoked conditionally." >&5
+@@ -13810,6 +13844,9 @@
+ target_cpu!$target_cpu$ac_delim
+ target_vendor!$target_vendor$ac_delim
+ target_os!$target_os$ac_delim
++MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim
++MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim
++MAINT!$MAINT$ac_delim
+ INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+ INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+ INSTALL_DATA!$INSTALL_DATA$ac_delim
+@@ -13855,9 +13892,6 @@
+ GREP!$GREP$ac_delim
+ EGREP!$EGREP$ac_delim
+ MAN2HTML!$MAN2HTML$ac_delim
+-LIBOBJS!$LIBOBJS$ac_delim
+-PTHREAD_CC!$PTHREAD_CC$ac_delim
+-PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
+ _ACEOF
+ 
+   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+@@ -13899,6 +13933,9 @@
+ ac_delim='%!_!# '
+ for ac_last_try in false false false false false :; do
+   cat >conf$$subs.sed <<_ACEOF
++LIBOBJS!$LIBOBJS$ac_delim
++PTHREAD_CC!$PTHREAD_CC$ac_delim
++PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
+ PTHREAD_CFLAGS!$PTHREAD_CFLAGS$ac_delim
+ TAP_ID!$TAP_ID$ac_delim
+ TAP_WIN32_MIN_MAJOR!$TAP_WIN32_MIN_MAJOR$ac_delim
+@@ -13909,7 +13946,7 @@
+ LTLIBOBJS!$LTLIBOBJS$ac_delim
+ _ACEOF
+ 
+-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 8; then
++  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 11; then
+     break
+   elif $ac_last_try; then
+     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+Index: openvpn-2.1.0/images/Makefile.in
+===================================================================
+--- openvpn-2.1.0.orig/images/Makefile.in	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/images/Makefile.in	2010-08-07 17:17:47.000000000 +0200
+@@ -113,6 +113,7 @@
+ LIBOBJS = @LIBOBJS@
+ LIBS = @LIBS@
+ LTLIBOBJS = @LTLIBOBJS@
++MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MAN2HTML = @MAN2HTML@
+ MKDIR_P = @MKDIR_P@
+@@ -200,7 +201,7 @@
+ all: all-am
+ 
+ .SUFFIXES:
+-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
++$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+ 	@for dep in $?; do \
+ 	  case '$(am__configure_deps)' in \
+ 	    *$$dep*) \
+@@ -225,9 +226,9 @@
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ 
+-$(top_srcdir)/configure:  $(am__configure_deps)
++$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
++$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ install-dist_imageDATA: $(dist_image_DATA)
+ 	@$(NORMAL_INSTALL)
+Index: openvpn-2.1.0/install-win32/Makefile.in
+===================================================================
+--- openvpn-2.1.0.orig/install-win32/Makefile.in	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/install-win32/Makefile.in	2010-08-07 17:17:47.000000000 +0200
+@@ -127,6 +127,7 @@
+ LIBOBJS = @LIBOBJS@
+ LIBS = @LIBS@
+ LTLIBOBJS = @LTLIBOBJS@
++MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MAN2HTML = @MAN2HTML@
+ MKDIR_P = @MKDIR_P@
+@@ -231,7 +232,7 @@
+ all: all-am
+ 
+ .SUFFIXES:
+-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
++$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+ 	@for dep in $?; do \
+ 	  case '$(am__configure_deps)' in \
+ 	    *$$dep*) \
+@@ -256,9 +257,9 @@
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ 
+-$(top_srcdir)/configure:  $(am__configure_deps)
++$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
++$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ settings: $(top_builddir)/config.status $(srcdir)/settings.in
+ 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Index: openvpn-2.1.0/service-win32/Makefile.in
+===================================================================
+--- openvpn-2.1.0.orig/service-win32/Makefile.in	2010-08-07 17:17:11.000000000 +0200
++++ openvpn-2.1.0/service-win32/Makefile.in	2010-08-07 17:17:47.000000000 +0200
+@@ -123,6 +123,7 @@
+ LIBOBJS = @LIBOBJS@
+ LIBS = @LIBS@
+ LTLIBOBJS = @LTLIBOBJS@
++MAINT = @MAINT@
+ MAKEINFO = @MAKEINFO@
+ MAN2HTML = @MAN2HTML@
+ MKDIR_P = @MKDIR_P@
+@@ -212,7 +213,7 @@
+ 
+ .SUFFIXES:
+ .SUFFIXES: .c .o .obj
+-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
++$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+ 	@for dep in $?; do \
+ 	  case '$(am__configure_deps)' in \
+ 	    *$$dep*) \
+@@ -237,9 +238,9 @@
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ 
+-$(top_srcdir)/configure:  $(am__configure_deps)
++$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
++$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+ install-sbinPROGRAMS: $(sbin_PROGRAMS)
+ 	@$(NORMAL_INSTALL)
diff -Nru openvpn-2.1.0/debian/patches/series openvpn-2.1.0/debian/patches/series
--- openvpn-2.1.0/debian/patches/series	2010-07-09 12:44:02.000000000 +0200
+++ openvpn-2.1.0/debian/patches/series	2010-08-07 17:17:07.000000000 +0200
@@ -1,3 +1,4 @@
+am_maintainer_mode
 auth-pam_libpam_so_filename.patch
 close_socket_before_scripts.patch
 manpage_dash_escaping.patch
diff -Nru openvpn-2.1.0/debian/rules openvpn-2.1.0/debian/rules
--- openvpn-2.1.0/debian/rules	2009-12-11 12:08:49.000000000 +0100
+++ openvpn-2.1.0/debian/rules	2010-08-07 17:25:01.000000000 +0200
@@ -40,7 +40,7 @@
 
 	touch build-stamp
 
-clean: unpatch
+clean:: patch
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp 
@@ -52,6 +52,7 @@
 	$(MAKE) -C plugin/auth-pam/ clean
 	$(MAKE) -C plugin/down-root/ clean
 
+clean:: unpatch
 	dh_clean
 
 install: build

Reply via email to