Patchwork [4,of,6,packaging] builddeb: new script for building a deb package

login
register
mail settings
Submitter Augie Fackler
Date May 8, 2015, 5:10 p.m.
Message ID <25e90eb8e6dd9a142d52.1431105007@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8973/
State Accepted
Headers show

Comments

Augie Fackler - May 8, 2015, 5:10 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1430932434 14400
#      Wed May 06 13:13:54 2015 -0400
# Node ID 25e90eb8e6dd9a142d52128d13584d2d99147d7f
# Parent  0232c9960ca7e5506ab1ec1c73e1c245de547edc
builddeb: new script for building a deb package

Future work will allow us to use docker to build debs.

Right now this doesn't install any config files. I plan to do that as
a followup, but getting something basic and working checked in seems
like more of a priority than getting everything done in one big step.

This also does not create a source deb yet. I haven't looked into that
process.

Note that this declares incompatibility with the `mercurial-common`
package. It's typical for debian packages to be split between
architecture-independent bits and native bits, meaning the python bits
downstream live in mercurial-common and the c extension bits live in
mercurial. We don't do that because we want to (ideally) give users a
single deb file to install.
Pierre-Yves David - May 8, 2015, 9:33 p.m.
On 05/08/2015 10:10 AM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1430932434 14400
> #      Wed May 06 13:13:54 2015 -0400
> # Node ID 25e90eb8e6dd9a142d52128d13584d2d99147d7f
> # Parent  0232c9960ca7e5506ab1ec1c73e1c245de547edc
> builddeb: new script for building a deb package
>
> Future work will allow us to use docker to build debs.
>
> Right now this doesn't install any config files. I plan to do that as
> a followup, but getting something basic and working checked in seems
> like more of a priority than getting everything done in one big step.
>
> This also does not create a source deb yet. I haven't looked into that
> process.

not that the centos rules are apparently nice enough to build package 
-and- produce a valid package repositories that can be used as a source. 
That would be nice to have that for debian too.

> Note that this declares incompatibility with the `mercurial-common`
> package. It's typical for debian packages to be split between
> architecture-independent bits and native bits, meaning the python bits
> downstream live in mercurial-common and the c extension bits live in
> mercurial. We don't do that because we want to (ideally) give users a
> single deb file to install.

This sounds like a bad goal. Ideally, we should be able to produce 
package compatible with what Debian is doing, and gracefully integrating 
in there naming scheme.

I do not believe downloading multiple .deb will be a show stopped. I've 
doing that on a regular basis from other project nightly build.

The patch are accepted anyway to move the topic forward. I'll lets 
people who know something about debian packaging make comment for follow up.
Pierre-Yves David - May 8, 2015, 9:39 p.m.
On 05/08/2015 10:10 AM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1430932434 14400
> #      Wed May 06 13:13:54 2015 -0400
> # Node ID 25e90eb8e6dd9a142d52128d13584d2d99147d7f
> # Parent  0232c9960ca7e5506ab1ec1c73e1c245de547edc
> builddeb: new script for building a deb package
>
> Future work will allow us to use docker to build debs.
>
> Right now this doesn't install any config files. I plan to do that as
> a followup, but getting something basic and working checked in seems
> like more of a priority than getting everything done in one big step.
>
> This also does not create a source deb yet. I haven't looked into that
> process.
>
> Note that this declares incompatibility with the `mercurial-common`
> package. It's typical for debian packages to be split between
> architecture-independent bits and native bits, meaning the python bits
> downstream live in mercurial-common and the c extension bits live in
> mercurial. We don't do that because we want to (ideally) give users a
> single deb file to install.
>
> diff --git a/Makefile b/Makefile
> --- a/Makefile
> +++ b/Makefile
> @@ -157,6 +157,12 @@ osx:
>   	N=`cd dist && echo mercurial-*.mpkg | sed 's,\.mpkg$$,,'` && hdiutil create -srcfolder dist/$$N.mpkg/ -scrub -volname "$$N" -ov packages/osx/$$N.dmg
>   	rm -rf dist/mercurial-*.mpkg
>
> +debian-jessie:

Note that we could call that debian8.

Any plan to add -testing, -unstable or -experimental flags?
Augie Fackler - May 9, 2015, 10:15 p.m.
On May 8, 2015, at 5:33 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:

>> Note that this declares incompatibility with the `mercurial-common`
>> package. It's typical for debian packages to be split between
>> architecture-independent bits and native bits, meaning the python bits
>> downstream live in mercurial-common and the c extension bits live in
>> mercurial. We don't do that because we want to (ideally) give users a
>> single deb file to install.
> 
> This sounds like a bad goal. Ideally, we should be able to produce package compatible with what Debian is doing, and gracefully integrating in there naming scheme.
> 
> I do not believe downloading multiple .deb will be a show stopped. I've doing that on a regular basis from other project nightly build.

Yeah, in the perfect future when the rules create a directory that’s a valid apt sources.list directory, this will make more sense. :)

> 
> The patch are accepted anyway to move the topic forward. I'll lets people who know something about debian packaging make comment for follow up.
Augie Fackler - May 9, 2015, 10:15 p.m.
On May 8, 2015, at 5:39 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:

>> +debian-jessie:
> 
> Note that we could call that debian8.

I’ve never once in my life before this point heard people use version numbers talking about debian.

> 
> Any plan to add -testing, -unstable or -experimental flags?

Not really, since those are moving targets (albeit slowly.)

Patch

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -157,6 +157,12 @@  osx:
 	N=`cd dist && echo mercurial-*.mpkg | sed 's,\.mpkg$$,,'` && hdiutil create -srcfolder dist/$$N.mpkg/ -scrub -volname "$$N" -ov packages/osx/$$N.dmg
 	rm -rf dist/mercurial-*.mpkg
 
+debian-jessie:
+	mkdir -p packages/debian-jessie
+	contrib/builddeb
+	mv debbuild/*.deb packages/debian-jessie
+	rm -rf debbuild
+
 fedora20:
 	mkdir -p packages/fedora20
 	contrib/buildrpm
diff --git a/contrib/builddeb b/contrib/builddeb
new file mode 100755
--- /dev/null
+++ b/contrib/builddeb
@@ -0,0 +1,76 @@ 
+#!/bin/sh -e
+#
+# Build a Mercurial debian package from the current repo
+#
+# Tested on Jessie (stable as of original script authoring.)
+
+BUILD=1
+DEBBUILDDIR="$PWD/debbuild"
+while [ "$1" ]; do
+    case "$1" in
+    --prepare )
+        shift
+        BUILD=
+        ;;
+    --debbuilddir )
+        shift
+        DEBBUILDDIR="$1"
+        shift
+        ;;
+    * )
+        echo "Invalid parameter $1!" 1>&2
+        exit 1
+        ;;
+    esac
+done
+
+set -u
+
+rm -rf $DEBBUILDDIR
+mkdir -p $DEBBUILDDIR
+
+if [ ! -d .hg ]; then
+    echo 'You are not inside a Mercurial repository!' 1>&2
+    exit 1
+fi
+
+# build local hg and use it
+python setup.py build_py -c -d .
+HG="$PWD/hg"
+
+$HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
+
+hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
+
+if echo $hgversion | grep -- '-' > /dev/null 2>&1; then
+    # nightly build case, version is like 1.3.1+250-20b91f91f9ca
+    version=`echo $hgversion | cut -d- -f1`
+    release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'`
+else
+    # official tag, version is like 1.3.1
+    version=`echo $hgversion | sed -e 's/+.*//'`
+    release='0'
+fi
+
+cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN
+chmod -R 0755 $DEBBUILDDIR/DEBIAN
+
+control=$DEBBUILDDIR/DEBIAN/control
+
+# This looks like sed -i, but sed -i behaves just differently enough
+# between BSD and GNU sed that I gave up and did the dumb thing.
+sed "s/__VERSION__/$version/" < $control > $control.tmp
+mv $control.tmp $control
+
+if [ "$BUILD" ]; then
+    dpkg-deb --build $DEBBUILDDIR
+    mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb
+    if [ $? = 0 ]; then
+        echo
+        echo "Built packages for $version-$release:"
+        find $DEBBUILDDIR/ -type f -newer $control
+    fi
+else
+    echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:"
+    echo "dpkg-deb --build $DEBBUILDDIR"
+fi
diff --git a/contrib/debian/control b/contrib/debian/control
new file mode 100644
--- /dev/null
+++ b/contrib/debian/control
@@ -0,0 +1,9 @@ 
+Package: mercurial
+Version: __VERSION__
+Section: vcs
+Priority: optional
+Architecture: all
+Depends: python
+Conflicts: mercurial-common
+Maintainer: Mercurial Developers <mercurial-devel@selenic.com>
+Description: Mercurial (probably nightly) package built by upstream.