[Build-common-hackers] Bug#290940: Improvements for updating config.* files

Robert Millan Robert Millan <rmh@debian.org>, 290940@bugs.debian.org
Mon, 17 Jan 2005 22:19:47 +0100


This is a multi-part MIME message sent by reportbug.

--===============0071373087==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: cdbs
Version: 0.4.26-1.1
Severity: wishlist
Tags: patch

  - Move auto-update config.{guess,sub} code to buildcore.mk
  - If config.{guess,sub} are found in source dir, and debian/control
    autogeneration is enabled, add autotools-dev to build-depends.
  - Ditto for config.rpath and gnulib.
  - Move part of the tarball logic to buildcore.mk.  Find out if config.*
    files that need updating are in the tarball (during clean target before
    it is unpacked) and add autotools-dev/gnulib dependencies if this is so.
  - In tarball.mk, use the precached location of config.* files to update them
    rapidly.
  - Detect if the package we're building is autotools-dev or gnulib, in which
    case avoid recursive braindamage (gnulib is cdbs'ed, autotools-dev not yet)

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: kfreebsd-i386 (i386)
Kernel: GNU/kFreeBSD 5.3+1-1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)

-- no debconf information

--===============0071373087==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="config_update.diff"

diff -ur cdbs-0.4.26.old/1/class/autotools-files.mk.in cdbs-0.4.26/1/class/autotools-files.mk.in
--- cdbs-0.4.26.old/1/class/autotools-files.mk.in	2004-09-05 19:56:36.000000000 +0200
+++ cdbs-0.4.26/1/class/autotools-files.mk.in	2005-01-17 20:41:59.000000000 +0100
@@ -68,14 +68,6 @@
 	if test -n "$(DEB_AUTO_UPDATE_AUTOMAKE)" ; then \
 		if test -e $(DEB_SRCDIR)/Makefile.am ; then cd $(DEB_SRCDIR) && automake-$(DEB_AUTO_UPDATE_AUTOMAKE) ; fi ; \
 	fi
-	for ext in guess sub ; do \
-		if test -e /usr/share/misc/config.$$ext ; then \
-			for i in `find $(DEB_SRCDIR) -type f -name config.$$ext` ; do \
-				mv $$i $$i.cdbs-orig ; \
-				cp -f /usr/share/misc/config.$$ext $$i ; \
-			done ; \
-		fi ; \
-	done
 	touch debian/stamp-autotools-files
 
 clean::
diff -ur cdbs-0.4.26.old/1/rules/buildcore.mk.in cdbs-0.4.26/1/rules/buildcore.mk.in
--- cdbs-0.4.26.old/1/rules/buildcore.mk.in	2004-09-24 19:42:07.000000000 +0200
+++ cdbs-0.4.26/1/rules/buildcore.mk.in	2005-01-17 21:58:22.000000000 +0100
@@ -49,12 +49,75 @@
 $(patsubst %,cleanbuilddir/%,$(DEB_PACKAGES)) :: cleanbuilddir/% : 
 	-if test -n "$(DEB_BUILDDIR_$(cdbs_curpkg))" && test "$(DEB_BUILDDIR_$(cdbs_curpkg))" != "$(DEB_SRCDIR)"; then rmdir "$(DEB_BUILDDIR_$(cdbs_curpkg))"; fi
 
+
+# This variable is used by tarball.mk, but we want it here in order to check
+# tarball contents before unpacking.  tarball.mk imports this file anyway.
+DEB_TARBALL ?= $(wildcard *.tar *.tgz *.tar.gz *.tar.bz *.tar.bz2 *.zip)
+
+ifneq (, $(findstring .bz2, $(DEB_TARBALL)))
+CDBS_BUILD_DEPENDS    := $(CDBS_BUILD_DEPENDS), bzip2
+endif
+ifneq (, $(findstring .zip, $(DEB_TARBALL)))
+CDBS_BUILD_DEPENDS    := $(CDBS_BUILD_DEPENDS), unzip
+endif
+
+# make is dumb
+close_parenthesis := )
+
+# Avoid recursive braindamage if we're building autotools-dev
+ifeq (, $(shell grep -x 'Package: autotools-dev' debian/control))
+config_guess		:= $(shell find $(DEB_SRCDIR) -type f -name config.guess)
+config_sub		:= $(shell find $(DEB_SRCDIR) -type f -name config.sub)
+ifneq (, $(DEB_TARBALL))
+config_guess_tar	:= $(shell for i in $(DEB_TARBALL) ; do case $$i in *.tar$(close_parenthesis) tar -tf $$i | grep /config.guess ;; *.tgz|*.tar.gz$(close_parenthesis) tar -tzf $$i | grep /config.guess ;; *.tar.bz|*.tar.bz2$(close_parenthesis) tar -tjf $$i | grep /config.guess ;; *.zip$(close_parenthesis) unzip -l $$i | grep /config.guess ;; esac ; done)
+config_sub_tar		:= $(shell for i in $(DEB_TARBALL) ; do case $$i in *.tar$(close_parenthesis) tar -tf $$i | grep /config.sub ;; *.tgz|*.tar.gz$(close_parenthesis) tar -tzf $$i | grep /config.sub ;; *.tar.bz|*.tar.bz2$(close_parenthesis) tar -tjf $$i | grep /config.sub ;; *.zip$(close_parenthesis) unzip -l $$i | grep /config.sub ;; esac ; done)
+endif
+endif
+# Ditto for gnulib
+ifeq (, $(shell grep -x 'Package: gnulib' debian/control))
+config_rpath		:= $(shell find $(DEB_SRCDIR) -type f -name config.rpath)
+ifneq (, $(DEB_TARBALL))
+config_rpath_tar	:= $(shell for i in $(DEB_TARBALL) ; do case $$i in *.tar$(close_parenthesis) tar -tf $$i | grep /config.rpath ;; *.tgz|*.tar.gz$(close_parenthesis) tar -tzf $$i | grep /config.rpath ;; *.tar.bz|*.tar.bz2$(close_parenthesis) tar -tjf $$i | grep /config.rpath ;; *.zip$(close_parenthesis) unzip -l $$i | grep /config.rpath ;; esac ; done)
+endif
+endif
+
+ifneq (, $(config_guess)$(config_sub)$(config_guess_tar)$(config_sub_tar))
+CDBS_BUILD_DEPENDS	:= $(CDBS_BUILD_DEPENDS), autotools-dev
+endif
+ifneq (, $(config_rpath)$(config_rpath_tar))
+CDBS_BUILD_DEPENDS	:= $(CDBS_BUILD_DEPENDS), gnulib (>= 0.0.20041014-2)
+endif
+
 # This target is called before almost anything else happens.  It's a good place
 # to do stuff like unpack extra source tarballs, apply patches, and stuff.  In
 # the future it will be a good place to generate debian/control, but right
 # now we don't support that very well.
 pre-build:: testdir makebuilddir
 	$(foreach x,$(_cdbs_deprecated_vars),$(warning "$x is a deprecated variable"))
+ifneq (, $(config_guess))
+	if test -e /usr/share/misc/config.guess ; then \
+		for i in $(config_guess) ; do \
+			mv $$i $$i.cdbs-orig ; \
+			cp -f /usr/share/misc/config.guess $$i ; \
+		done ; \
+	fi
+endif
+ifneq (, $(config_sub))
+	if test -e /usr/share/misc/config.sub ; then \
+		for i in $(config_sub) ; do \
+			mv $$i $$i.cdbs-orig ; \
+			cp -f /usr/share/misc/config.sub $$i ; \
+		done ; \
+	fi
+endif
+ifneq (, $(config_rpath))
+	if test -e /usr/share/gnulib/config/config.rpath ; then \
+		for i in $(config_rpath) ; do \
+			mv $$i $$i.cdbs-orig ; \
+			cp -f /usr/share/gnulib/config/config.rpath $$i ; \
+		done ; \
+	fi
+endif
 
 # This target is called after patches are applied.  Right now it's only used
 # by the patch system.
@@ -103,9 +166,10 @@
 
 debian/control::
 ifneq ($(DEB_AUTO_UPDATE_DEBIAN_CONTROL),)
-	cat debian/control.in \
-	| sed "s/@cdbs@/$(CDBS_BUILD_DEPENDS)/g" \
-	> debian/control
+	sed -e "s/@cdbs@/$(CDBS_BUILD_DEPENDS)/g" \
+	< debian/control.in > debian/control
+	# make sure new build-depends (if any) are installed
+	dpkg-checkbuilddeps -B
 endif
 
 # This rule is called before the common-install target.  It's currently only
diff -ur cdbs-0.4.26.old/1/rules/tarball.mk.in cdbs-0.4.26/1/rules/tarball.mk.in
--- cdbs-0.4.26.old/1/rules/tarball.mk.in	2005-01-17 18:08:11.000000000 +0100
+++ cdbs-0.4.26/1/rules/tarball.mk.in	2005-01-17 21:56:54.000000000 +0100
@@ -32,15 +32,6 @@
 # The user developper may override this variable to choose which tarballs
 # to unpack.
 
-DEB_TARBALL ?= $(wildcard *.tgz *.tar.gz *.tar.bz *.tar.bz2 *.zip)
-
-ifneq (, $(findstring .bz2, $(DEB_TARBALL)))
-CDBS_BUILD_DEPENDS    := $(CDBS_BUILD_DEPENDS), bzip2
-endif
-ifneq (, $(findstring .zip, $(DEB_TARBALL)))
-CDBS_BUILD_DEPENDS    := $(CDBS_BUILD_DEPENDS), unzip
-endif
-
 ifeq ($(DEB_TAR_SRCDIR),)
 $(error You must specify DEB_TAR_SRCDIR)
 endif
@@ -77,6 +68,30 @@
 		find $(DEB_SRCDIR) -type f -name $$i | xargs rm -f ; \
 	done
 endif
+ifneq (, $(config_guess_tar))
+	if test -e /usr/share/misc/config.guess ; then \
+		for i in $(config_guess_tar) ; do \
+			cp -f /usr/share/misc/config.guess \
+			$(_cdbs_tarball_dir)/$$i ; \
+		done ; \
+	fi
+endif
+ifneq (, $(config_sub_tar))
+	if test -e /usr/share/misc/config.sub ; then \
+		for i in $(config_sub_tar) ; do \
+			cp -f /usr/share/misc/config.sub \
+			$(_cdbs_tarball_dir)/$$i ; \
+		done ; \
+	fi
+endif
+ifneq (, $(config_rpath_tar))
+	if test -e /usr/share/gnulib/config/config.rpath ; then \
+		for i in $(config_rpath_tar) ; do \
+			cp -f /usr/share/gnulib/config/config.rpath \
+			$(_cdbs_tarball_dir)/$$i ; \
+		done ; \
+	fi
+endif
 
 $(addsuffix .gz,$(_cdbs_tarball_stamp_base)) $(addsuffix .tgz,$(_cdbs_tarball_stamp_base)):
 	tar -C $(_cdbs_tarball_dir) $(_cdbs_tar_verbose) -xzf $(patsubst stamp-%,%,$(notdir $@))

--===============0071373087==--