Page 1 of 1

[SOLVED] dpkg-buildpackage overwrites my control changes

Posted: 2018-07-04 07:48
by Talkless
Hi,

We have a bug 778596 about php-gd not providing antialiasing.

To solve that I have this patch for Debian Jessie:

Code: Select all

--- a/debian/rules
+++ b/debian/rules
@@ -297,7 +297,7 @@
 		--with-curl=shared,/usr \
 		--with-enchant=shared,/usr \
 		--with-zlib-dir=/usr \
-		--with-gd=shared,/usr --enable-gd-native-ttf \
+		--with-gd=shared --enable-gd-native-ttf \
 		--with-gmp=shared,/usr \
 		--with-jpeg-dir=shared,/usr \
 		--with-xpm-dir=shared,/usr/X11R6 \
--- a/debian/control
+++ b/debian/control
@@ -317,7 +317,7 @@
  for web development and can be embedded into HTML.
 
 Package: php5-dbg
-Depends: ${misc:Depends}, php5-common (= ${binary:Version}), libapache2-mod-php5 (= ${binary:Version}) | libapache2-mod-php5filter (= ${binary:Version}) | php5-cgi (= ${binary:Version}) | php5-cli (= ${binary:Version}) | php5-fpm (= ${binary:Version}) | libphp5-embed (= ${binary:Version}) | php5-curl (= ${binary:Version}) | php5-enchant (= ${binary:Version}) | php5-gd (= ${binary:Version}) | php5-gmp (= ${binary:Version}) | php5-imap (= ${binary:Version}) | php5-interbase (= ${binary:Version}) | php5-intl (= ${binary:Version}) | php5-ldap (= ${binary:Version}) | php5-mcrypt (= ${binary:Version}) | php5-readline (= ${binary:Version}) | php5-mysql (= ${binary:Version}) | php5-mysqlnd (= ${binary:Version}) | php5-odbc (= ${binary:Version}) | php5-pgsql (= ${binary:Version}) | php5-pspell (= ${binary:Version}) | php5-recode (= ${binary:Version}) | php5-snmp (= ${binary:Version}) | php5-sqlite (= ${binary:Version}) | php5-sybase (= ${binary:Version}) | php5-tidy (= ${binary:Version}) | php5-xmlrpc (= ${binary:
Version}) | php5-xsl (= ${binary:Version})
+Depends: ${misc:Depends}, php5-common (= ${binary:Version}), libapache2-mod-php5 (= ${binary:Version}) | libapache2-mod-php5filter (= ${binary:Version}) | php5-cgi (= ${binary:Version}) | php5-cli (= ${binary:Version}) | php5-fpm (= ${binary:Version}) | libphp5-embed (= ${binary:Version}) | php5-curl (= ${binary:Version}) | php5-enchant (= ${binary:Version}) | php5-gd (>= 5.6) | php5-gmp (= ${binary:Version}) | php5-imap (= ${binary:Version}) | php5-interbase (= ${binary:Version}) | php5-intl (= ${binary:Version}) | php5-ldap (= ${binary:Version}) | php5-mcrypt (= ${binary:Version}) | php5-readline (= ${binary:Version}) | php5-mysql (= ${binary:Version}) | php5-mysqlnd (= ${binary:Version}) | php5-odbc (= ${binary:Version}) | php5-pgsql (= ${binary:Version}) | php5-pspell (= ${binary:Version}) | php5-recode (= ${binary:Version}) | php5-snmp (= ${binary:Version}) | php5-sqlite (= ${binary:Version}) | php5-sybase (= ${binary:Version}) | php5-tidy (= ${binary:Version}) | php5-xmlrpc (= ${binary:Version}) | 
php5-xsl (= ${binary:Version})
 Recommends: gdb
 Section: debug
 Priority: extra
@@ -374,7 +374,7 @@
 
 Package: php5-gd
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${php:Depends}, php5-common (= ${binary:Version}), ucf
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${php:Depends}, php5-common (>= 5.6), ucf
 Pre-Depends: ${misc:Pre-Depends}
 Description: GD module for php5
  This package provides a module for handling graphics directly from PHP
I apply it and make local release:

Code: Select all

dch --force-distribution --distribution jessie-mycompany-php5 --local +mycompany8u0+ 'Rebuild with bundled GD library'
I modify control file so that recompiled php5-gd does not depend on php5-...+mycompany package, it is enough to use default Debian php5-common package (no suffix). I just install single package php5-gd..+mycompany8u0 and I have antialiasing.

Now I need to do the same for Stretch php7.0-gd, and I have the problem that package is compiled apparently without `debian/control` changes applied.

I have tried multiplies times to make various changes for php7.0-gd debian/control entry, latest patch is this:

Code: Select all

Index: php7.0-7.0.27/debian/rules
===================================================================
--- php7.0-7.0.27.orig/debian/rules
+++ php7.0-7.0.27/debian/rules
@@ -195,6 +195,7 @@ COMMON_CONFIG := \
 		--with-system-tzdata \
 		--with-zlib=/usr \
 		  --with-zlib-dir=/usr \
+		--with-gd=shared \
 		$(CONFIGURE_ZTS) \
 		$(CONFIGURE_DTRACE_ARGS)
 
Index: php7.0-7.0.27/debian/control
===================================================================
--- php7.0-7.0.27.orig/debian/control
+++ php7.0-7.0.27/debian/control
@@ -460,12 +460,7 @@ Package: php7.0
 Architecture: any
 Depends: php-common (>= 1:35),
          ucf,
-         ${misc:Depends},
-         ${php:Depends},
-	 ${php-gd:Depends},
-         ${shlibs:Depends}
-Pre-Depends: ${misc:Pre-Depends},
-	     ${php-gd:Pre-Depends}
+         libc6 (>= 2.14), libpng16-16 (>= 1.6.2-1), zlib1g (>= 1:1.1.4)
 Built-Using: ${php:Built-Using}
 Replaces: ${php-gd:Replaces}
 Breaks: ${php-gd:Breaks}
I just remove as much as I can, to avoid php7.0-common+mycompany dependency. But after `dpkg-buildpackage` is run, all these changes are lost and problem is not fixed.

Here's `quilt diff` after running `DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -nc -j$(nproc)`:

Code: Select all

ndex: php7.0-7.0.27/debian/rules
===================================================================
--- php7.0-7.0.27.orig/debian/rules
+++ php7.0-7.0.27/debian/rules
@@ -195,6 +195,7 @@ COMMON_CONFIG := \
 		--with-system-tzdata \
 		--with-zlib=/usr \
 		  --with-zlib-dir=/usr \
+		--with-gd=shared \
 		$(CONFIGURE_ZTS) \
 		$(CONFIGURE_DTRACE_ARGS)
 
Index: php7.0-7.0.27/debian/control
===================================================================
--- php7.0-7.0.27.orig/debian/control
+++ php7.0-7.0.27/debian/control
@@ -410,29 +410,6 @@ Description: DOM, SimpleXML, WDDX, XML,
  open source general-purpose scripting language that is especially suited
  for web development and can be embedded into HTML.
 
-Package: php7.0-zip
-Architecture: any
-Depends: php-common (>= 1:35),
-         ucf,
-         ${misc:Depends},
-         ${php:Depends},
-	 ${php-zip:Depends},
-         ${shlibs:Depends}
-Pre-Depends: ${misc:Pre-Depends},
-	     ${php-zip:Pre-Depends}
-Built-Using: ${php:Built-Using}
-Replaces: ${php-zip:Replaces}
-Breaks: ${php-zip:Breaks}
-Conflicts: ${php-zip:Conflicts}
-Provides: ${php-zip:Provides}
-Recommends: ${php-zip:Recommends}
-Description: Zip module for PHP
- This package provides the Zip module(s) for PHP.
- .
- PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
- open source general-purpose scripting language that is especially suited
- for web development and can be embedded into HTML.
-
 Package: php7.0-sybase
 Architecture: any
 Depends: php-common (>= 1:35),
@@ -502,24 +479,24 @@ Description: GMP module for PHP
  open source general-purpose scripting language that is especially suited
  for web development and can be embedded into HTML.
 
-Package: php7.0-ldap
+Package: php7.0-zip
 Architecture: any
 Depends: php-common (>= 1:35),
          ucf,
          ${misc:Depends},
          ${php:Depends},
-	 ${php-ldap:Depends},
+	 ${php-zip:Depends},
          ${shlibs:Depends}
 Pre-Depends: ${misc:Pre-Depends},
-	     ${php-ldap:Pre-Depends}
+	     ${php-zip:Pre-Depends}
 Built-Using: ${php:Built-Using}
-Replaces: ${php-ldap:Replaces}
-Breaks: ${php-ldap:Breaks}
-Conflicts: ${php-ldap:Conflicts}
-Provides: ${php-ldap:Provides}
-Recommends: ${php-ldap:Recommends}
-Description: LDAP module for PHP
- This package provides the LDAP module(s) for PHP.
+Replaces: ${php-zip:Replaces}
+Breaks: ${php-zip:Breaks}
+Conflicts: ${php-zip:Conflicts}
+Provides: ${php-zip:Provides}
+Recommends: ${php-zip:Recommends}
+Description: Zip module for PHP
+ This package provides the Zip module(s) for PHP.
  .
  PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
  open source general-purpose scripting language that is especially suited
@@ -983,4 +960,27 @@ Description: CURL module for PHP
  .
  PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
  open source general-purpose scripting language that is especially suited
+ for web development and can be embedded into HTML.
+
+Package: php7.0-ldap
+Architecture: any
+Depends: php-common (>= 1:35),
+         ucf,
+         ${misc:Depends},
+         ${php:Depends},
+	 ${php-ldap:Depends},
+         ${shlibs:Depends}
+Pre-Depends: ${misc:Pre-Depends},
+	     ${php-ldap:Pre-Depends}
+Built-Using: ${php:Built-Using}
+Replaces: ${php-ldap:Replaces}
+Breaks: ${php-ldap:Breaks}
+Conflicts: ${php-ldap:Conflicts}
+Provides: ${php-ldap:Provides}
+Recommends: ${php-ldap:Recommends}
+Description: LDAP module for PHP
+ This package provides the LDAP module(s) for PHP.
+ .
+ PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
+ open source general-purpose scripting language that is especially suited
  for web development and can be embedded into HTML.

`debian/rules` file does have changes I need, but `debian/control` is changed in different way now for some reason..?

What I am doing wrong?

If anyone cares to reproduce, you can try this scenario:

Code: Select all

sudo cowbuilder --create --distribution stretch --basepath /var/cache/pbuilder/base-stretch.cow
sudo cowbuilder --update --basepath /var/cache/pbuilder/base-stretch.cow
mkdir /tmp/build
cp antialiasing.patch /tmp/build/
sudo cowbuilder --login --bindmounts=/tmp/build  --basepath /var/cache/pbuilder/base-stretch.cow
Now we do work within cowbuilder chroot:

Code: Select all

echo -e "deb-src http://httpredir.debian.org/debian stretch main" >> /etc/apt/sources.list.d/src.list
echo -e "deb-src http://httpredir.debian.org/debian stretch-updates main" >> /etc/apt/sources.list.d/src.list
echo -e "deb-src http://security.debian.org stretch/updates main" >> /etc/apt/sources.list.d/src.list
apt update
apt install devscripts less libdistro-info-perl quilt -y
apt build-dep php7.0 -y
cd /tmp/build
apt source --only-source php7.0
cd php7.0*/
quilt import /tmp/build/antialiasing.patch 
quilt push antialiasing.patch
dch --force-distribution --distribution stretch-mycompany-php7.0 --local +mycompany9u0+ 'Rebuild with bundled GD library'
Now, after this is done, double-check:

Code: Select all

quilt diff
Index: php7.0-7.0.27/debian/rules
===================================================================
--- php7.0-7.0.27.orig/debian/rules
+++ php7.0-7.0.27/debian/rules
@@ -195,6 +195,7 @@ COMMON_CONFIG := \
 		--with-system-tzdata \
 		--with-zlib=/usr \
 		  --with-zlib-dir=/usr \
+		--with-gd=shared \
 		$(CONFIGURE_ZTS) \
 		$(CONFIGURE_DTRACE_ARGS)
 
Index: php7.0-7.0.27/debian/control
===================================================================
--- php7.0-7.0.27.orig/debian/control
+++ php7.0-7.0.27/debian/control
@@ -460,12 +460,7 @@ Package: php7.0-gd
 Architecture: any
 Depends: php-common (>= 1:35),
          ucf,
-         ${misc:Depends},
-         ${php:Depends},
-	 ${php-gd:Depends},
-         ${shlibs:Depends}
-Pre-Depends: ${misc:Pre-Depends},
-	     ${php-gd:Pre-Depends}
+         libc6 (>= 2.14), libpng16-16 (>= 1.6.2-1), zlib1g (>= 1:1.1.4)
 Built-Using: ${php:Built-Using}
 Replaces: ${php-gd:Replaces}
 Breaks: ${php-gd:Breaks}
Changes are as expected. Now start building (still inside chroot):

Code: Select all

DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -nc -j$(nproc)
After waiting (yet another) ~30 minutes, calling `quilt diff` shows irrelevant changes that I have pasted above, and my local `debian/control` changes are discarded.

Checking control file within `php7.0-gd` packages shows this:

Code: Select all

cd /tmp
dpkg -e build/php7.0-gd_7.0.27-0+deb9u1+mycompany9u0+1_amd64.deb
fgrep php7.0-gd -A 6 DEBIAN/control 
Package: php7.0-gd
Source: php7.0
Version: 7.0.27-0+deb9u1+mycompany9u0+1
Architecture: amd64
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Installed-Size: 387
Depends: php-common (>= 1:35), ucf, php7.0-common (= 7.0.27-0+deb9u1+mycompany9u0+1), libc6 (>= 2.14), libpng16-16 (>= 1.6.2-1), zlib1g (>= 1:1.1.4)
It still depends on 7.0.27-0+deb9u1+mycompany9u0+1, which I wanted to avoid, as I did successfully on Jessie. I guess I could install all "mycompany9u0" php7.0 packages from local repository, but my previous solution was more preferable for me.

Re: dpkg-buildpackage overwrites my debian/control changes

Posted: 2018-07-04 09:57
by Talkless
Looks like there's some script that rebuilds `debian/control` file (output of dpkg-buildpackage):

Code: Select all

touch prepared-stamp
sed -e "s/@PHP_VERSION@/7.0/g" >debian/source.lintian-overrides <debian/source.lintian-overrides.in
sed -e "s/@PHP_VERSION@/7.0/g" -e "s/@BUILT_USING@//g" >debian/control <debian/control.in
for ext in odbc readline recode sqlite3 xml sybase gd gmp zip common intl mysql mcrypt snmp json pgsql mbstring enchant opcache imap bz2 bcmath tidy soap dba interbase xmlrpc pspell curl ldap; do \
  package=php7.0-${ext}; \
  description=$(eval echo \${${ext}_DESCRIPTION}); \
  echo >>debian/control; \
  sed -e "s|@ext@|${ext}|" -e "s|@package@|${package}|" -e "s|@description@|${description}|" >>debian/control <debian/php-module.control.in; \
done

Re: dpkg-buildpackage overwrites my debian/control changes

Posted: 2018-07-04 12:00
by Talkless
I've found the solution. I re-apply my patch during `debian/rules` run:

Code: Select all

Index: php7.0-7.0.27/debian/rules
===================================================================
--- php7.0-7.0.27.orig/debian/rules
+++ php7.0-7.0.27/debian/rules
@@ -195,6 +195,7 @@ COMMON_CONFIG := \
 		--with-system-tzdata \
 		--with-zlib=/usr \
 		  --with-zlib-dir=/usr \
+		--with-gd=shared \
 		$(CONFIGURE_ZTS) \
 		$(CONFIGURE_DTRACE_ARGS)
 
@@ -604,6 +605,8 @@ debian/control: debian/control.in debian
 	  echo >>$@; \
 	  $(SED) -e "s|@ext@|$${ext}|" -e "s|@package@|$${package}|" -e "s|@description@|$${description}|" >>$@ <debian/php-module.control.in; \
 	done
+	# re-apply patch after debian/control file is changed by debian/rules script
+	patch -p1 debian/control debian/patches/antialiasing.patch || true
 	mkdir -p debian/tests
 	for f in debian/tests.in/*; do \
 	  t=$$(basename $${f}); \
Index: php7.0-7.0.27/debian/control
===================================================================
--- php7.0-7.0.27.orig/debian/control
+++ php7.0-7.0.27/debian/control
@@ -460,12 +460,9 @@ Package: php7.0-gd
 Architecture: any
 Depends: php-common (>= 1:35),
          ucf,
-         ${misc:Depends},
-         ${php:Depends},
-	 ${php-gd:Depends},
+         php7.0-common (>= 7.0.27),
+         ${php-gd:Depends},
          ${shlibs:Depends}
-Pre-Depends: ${misc:Pre-Depends},
-	     ${php-gd:Pre-Depends}
 Built-Using: ${php:Built-Using}
 Replaces: ${php-gd:Replaces}
 Breaks: ${php-gd:Breaks}
Now my pachage dependencies are as expected:

Code: Select all

 apt show php7.0-gd
Package: php7.0-gd
Version: 7.0.27-0+deb9u1+mycompany9u0+1
Status: install ok installed
Priority: optional
Section: php
Source: php7.0
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Installed-Size: 396 kB
Provides: php-gd
Depends: php-common (>= 1:35), ucf, php7.0-common (>= 7.0.27), libc6 (>= 2.14), libpng16-16 (>= 1.6.2-1), zlib1g (>= 1:1.1.4)