Subject: Bug#738470: graphviz: Patch to bootstrap without Gtk+, PHP, Ruby 1.8

From: Daniel Schepler <[email-masked]>
Date: Sun, 09 Feb 2014 13:26:12 -0800

Source: graphviz
Version: 2.26.3-16.1
Severity: wishlist
Tags: patch

As the subject says: the attached patch adds a build profile which allows for 
bootstrapping graphviz at a point in the bootstrap process where certain 
dependencies are not yet available.
-- 
Daniel Schepler
diff -urN graphviz-2.26.3.old/debian/rules graphviz-2.26.3/debian/rules
--- graphviz-2.26.3.old/debian/rules	2014-01-12 08:09:27.000000000 -0800
+++ graphviz-2.26.3/debian/rules	2014-02-09 13:08:03.667161061 -0800
@@ -44,6 +44,17 @@
 # See: https://wiki.debian.org/HardeningWalkthrough#dpkg-buildflags
 dpkg_buildflags = DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed" dpkg-buildflags
 
+ifneq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
+WITH_GNOMEUI = --without-gnomeui
+ENABLE_PHP = --disable-php
+ENABLE_RUBY = --disable-ruby
+DH_BOOTSTRAP_EXCLUDES = -Nlibgv-php5 -Nlibgv-ruby -Nlibgvc5-plugins-gtk
+else
+WITH_GNOMEUI = --with-gnomeui
+ENABLE_PHP = --enable-php
+ENABLE_RUBY = --enable-ruby
+endif
+
 configure: configure-stamp
 configure-stamp:
 	dh_testdir
@@ -64,15 +75,15 @@
 	--with-pangocairo \
 	--with-x \
 	--with-gdk-pixbuf \
-	--with-gnomeui \
+	$(WITH_GNOMEUI) \
 	--with-gtk \
 	--without-gts \
 	--without-ipsepcola \
 	--without-rsvg \
 	--enable-guile \
 	--enable-lua \
-	--enable-php \
-	--enable-ruby \
+	$(ENABLE_PHP) \
+	$(ENABLE_RUBY) \
 	--enable-tcl \
 	--disable-java \
 	--disable-r \
@@ -164,10 +175,11 @@
 		$(CURDIR)/debian/tmp/usr/lib/*.so
 
 	# Move from debian/tmp to the appropriate packages, rename one binary
-	dh_install --sourcedir=debian/tmp --list-missing
+	dh_install --sourcedir=debian/tmp --list-missing $(DH_BOOTSTRAP_EXCLUDES)
 	mv $(CURDIR)/debian/libgvc$(SONAME)/usr/sbin/dot \
 		$(CURDIR)/debian/libgvc$(SONAME)/usr/sbin/libgvc$(SONAME)-config-update
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 	# Some additional work for libgv-php5
 	install -d $(PHP_PACKAGE)/$(PHP_EXTENSION_DIR)
 	mv $(PHP_PACKAGE)/usr/lib/graphviz/php/libgv_php.so \
@@ -177,6 +189,7 @@
 		$(PHP_PACKAGE)/usr/share/php/libgv-php5
 	rm -rf $(PHP_PACKAGE)/usr/lib/graphviz
 	echo "php:Depends=phpapi-`php-config5 --phpapi`" >> $(PHP_PACKAGE).substvars
+endif
 
 	# Some additional work for libgv-lua
 	# 1. Rename using the LUA_VERSION
@@ -205,11 +218,13 @@
 	dh_installman -plibgvc$(SONAME)      \
 		$(CURDIR)/debian/libgvc$(SONAME)-config-update.8
 
+ifeq (,$(filter stage1,$(DEB_BUILD_PROFILES)))
 	# Some additional work for libgv-ruby
 	install -d $(RUBY_PACKAGE)/usr/lib/ruby/$(RUBY_VERSION)
 	mv $(RUBY_PACKAGE)/usr/lib/graphviz/ruby/libgv_ruby.so \
 		$(RUBY_PACKAGE)/usr/lib/ruby/$(RUBY_VERSION)/gv.so
 	rm -rf $(RUBY_PACKAGE)/usr/lib/graphviz
+endif
 
 # Build architecture-independent files here.
 binary-indep: build install
@@ -234,27 +249,27 @@
 # Build architecture-dependent files here.
 # Pass -a to all debhelper commands in this target to reduce clutter.
 binary-arch: build install
-	dh_testdir -a
-	dh_testroot -a
-	dh_installdocs -a -XMakefile
-	dh_installexamples -a
-	dh_installmenu -a
-	dh_installman -a
-	dh_installchangelogs ChangeLog -a
-	dh_perl -a
-	dh_pysupport -a
-	dh_link -a usr/share/man/man1/gxl2gv.1 usr/share/man/man1/gxl2dot.1 usr/share/man/man1/gxl2gv.1 usr/share/man/man1/dot2gxl.1
-	dh_strip -a
-	dh_lintian -a
-	dh_compress -a
-	dh_fixperms -a
+	dh_testdir -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_testroot -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_installdocs -a $(DH_BOOTSTRAP_EXCLUDES) -XMakefile
+	dh_installexamples -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_installmenu -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_installman -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_installchangelogs ChangeLog -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_perl -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_pysupport -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_link -a $(DH_BOOTSTRAP_EXCLUDES) usr/share/man/man1/gxl2gv.1 usr/share/man/man1/gxl2dot.1 usr/share/man/man1/gxl2gv.1 usr/share/man/man1/dot2gxl.1
+	dh_strip -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_lintian -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_compress -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_fixperms -a $(DH_BOOTSTRAP_EXCLUDES)
 	dh_makeshlibs -plibgvc$(SONAME) -plibgraph$(OTHER_SONAME) -plibcgraph$(SONAME) -plibcdt$(OTHER_SONAME) \
 		-plibpathplan$(OTHER_SONAME) -plibxdot$(OTHER_SONAME) -plibgvpr1 
-	dh_installdeb -a
-	dh_shlibdeps -a
-	dh_gencontrol -a
-	dh_md5sums -a
-	dh_builddeb -a
+	dh_installdeb -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_shlibdeps -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_gencontrol -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_md5sums -a $(DH_BOOTSTRAP_EXCLUDES)
+	dh_builddeb -a $(DH_BOOTSTRAP_EXCLUDES)
 
 binary: binary-indep binary-arch
 .PHONY: build clean binary-indep binary-arch binary install configure