<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Build on bramp.net</title>
    <link>https://blog.bramp.net/</link>
    <description>Recent content in Build on bramp.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Tue, 22 Nov 2011 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bramp.net/tags/build/" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Building PHP’s Debian package nightmare</title>
      <link>https://blog.bramp.net/post/2011/11/22/building-phps-debian-package-nightmare/</link>
      <pubDate>Tue, 22 Nov 2011 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2011/11/22/building-phps-debian-package-nightmare/</guid>
      <description><p>I just tried to compile the Debian PHP packages, so I could make some <a href="http://www.howtoforge.com/recompiling-php5-with-bundled-support-for-gd-on-ubuntu">minor tweaks</a> to the source, to fix a bug I’m hopefully going to document shortly. This turned out to be very problematic, mainly due to the testing phase!</p>
<p>To build the Debian packages you typically do the following:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mkdir php
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> php
</span></span><span class="line"><span class="cl">apt-get <span class="nb">source</span> php5
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> php5-*
</span></span><span class="line"><span class="cl">debuild -us -uc -j4
</span></span></code></pre></div><p>While testing, the debian/setup_mysql.sh script is called, to create a temporary MySQL database. This however failed to execute correctly because I had some custom options in my <a href="http://dev.mysql.com/doc/refman/5.1/en/option-files.html">~/.my.cnf</a>. Thus it failed like so:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># start our own mysql server for the tests</span>
</span></span><span class="line"><span class="cl">/bin/sh debian/setup-mysql.sh <span class="m">1029</span> /home/bramp/vendor/php/php5-5.3.8.0/mysql_db
</span></span><span class="line"><span class="cl">mysqladmin: connect to server at <span class="s1">&#39;localhost&#39;</span> failed
</span></span><span class="line"><span class="cl">error: <span class="s1">&#39;Access denied for user &#39;</span>root<span class="s1">&#39;@&#39;</span>localhost<span class="s1">&#39; (using password: YES)&#39;</span>
</span></span><span class="line"><span class="cl">make: *** <span class="o">[</span>test-results.txt<span class="o">]</span> Error <span class="m">1</span>
</span></span><span class="line"><span class="cl">dpkg-buildpackage: error: debian/rules build gave error <span class="nb">exit</span> status <span class="m">2</span>
</span></span><span class="line"><span class="cl">debuild: fatal error at line 1348:
</span></span><span class="line"><span class="cl">dpkg-buildpackage -rfakeroot -D -us -uc -j8 failed
</span></span></code></pre></div><p>After removing the my.cnf things were ok. The below patch fixes it in a more general way:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"><span class="gd">-- debian/setup-mysql.sh.org	2011-11-21 21:57:07.244481175 -0500
</span></span></span><span class="line"><span class="cl"><span class="gi">+++ debian/setup-mysql.sh	2011-11-21 21:40:39.384455880 -0500
</span></span></span><span class="line"><span class="cl"><span class="gu">@@ -16,7 +16,7 @@
</span></span></span><span class="line"><span class="cl"> 
</span></span><span class="line"><span class="cl"> socket=$datadir/mysql.sock
</span></span><span class="line"><span class="cl"> # Commands:
</span></span><span class="line"><span class="cl"><span class="gd">-mysqladmin=&#34;mysqladmin -u root -P $port -h localhost --socket=$socket&#34;
</span></span></span><span class="line"><span class="cl"><span class="gi">+mysqladmin=&#34;mysqladmin --no-defaults -u root -P $port -h localhost --socket=$socket&#34;
</span></span></span><span class="line"><span class="cl"> mysqld=&#34;/usr/sbin/mysqld --no-defaults --bind-address=localhost --port=$port --socket=$socket --datadir=$datadir&#34;
</span></span><span class="line"><span class="cl"> 
</span></span><span class="line"><span class="cl"> # Main code #
</span></span></code></pre></div><p>The next problem I encountered is that all the automated PHP unit tests were failing, and they would eventually get stuck and use all my RAM and swap space (at least 16GiB of it) :( I’m not sure what made the machine run out of RAM, but the tests were failing because the version of PHP that was running the tests was incorrectly loading extensions from my system. The quick fix for this was to disable any extensions I had installed to my system. I just</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo mv /etc/php5/conf.d /etc/php5/conf.d.tmp
</span></span></code></pre></div><p>to do that.</p>
<p>This made me think that in future I should perhaps find a cleaner environment to build these packages. In fact, it makes me wonder if the builds are just broken if my environment clearly impacts the successful run of tests.</p>
<p>One trick I found while building again and again, is that you can pass “-nc” to debuild so that it does not clean, and thus reuses the existing build materials for a faster build. Either way, I now have my own version of PHP built and installed! Next time I might just ignore the .deb files and build direct from source.</p>
</description>
    </item>
    
  </channel>
</rss>
