From: Brian Warner Date: Tue, 18 Aug 2009 19:05:27 +0000 (-0700) Subject: new approach for debian packaging, sharing pieces across distributions. Still experim... X-Git-Tag: trac-4100~46 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/FOOURL?a=commitdiff_plain;h=7dc17aa078aa36a82579d048cb234688103c78df;p=tahoe-lafs%2Ftahoe-lafs.git new approach for debian packaging, sharing pieces across distributions. Still experimental, still only works for sid. --- diff --git a/Makefile b/Makefile index 87895614..4cb82b1b 100644 --- a/Makefile +++ b/Makefile @@ -404,7 +404,7 @@ deb-jaunty-head: # new experimental debian-packaging-building target .PHONY: EXPERIMENTAL-deb EXPERIMENTAL-deb: is-known-debian-arch - misc/build-deb.sh + $(PYTHON) misc/build-deb.py $(ARCH) # These targets provide for windows native builds diff --git a/misc/build-deb.py b/misc/build-deb.py new file mode 100644 index 00000000..7c0015d9 --- /dev/null +++ b/misc/build-deb.py @@ -0,0 +1,110 @@ +# invoke this with a specific python + +import sys, shutil, os.path +from subprocess import Popen, PIPE + +PYTHON = sys.executable +ARCH = sys.argv[1] + +class SubprocessError(Exception): + pass + +def get_output(*cmd, **kwargs): + tolerate_stderr = kwargs.get("tolerate_stderr", False) + print " " + " ".join(cmd) + p = Popen(cmd, stdout=PIPE) + (out,err) = p.communicate() + rc = p.returncode + if rc != 0: + print >>sys.stderr, err + raise SubprocessError("command %s exited with rc=%s", (cmd, rc)) + if err and not tolerate_stderr: + print >>sys.stderr, "stderr:", err + raise SubprocessError("command emitted unexpected stderr") + print " =>", out, + return out + +def run(*cmd, **kwargs): + print " " + " ".join(cmd) +# if "stdin" in kwargs: +# stdin = kwargs.pop("stdin") +# p = Popen(cmd, stdin=PIPE, **kwargs) +# p.stdin.write(stdin) +# p.stdin.close() +# else: +# p = Popen(cmd, **kwargs) + p = Popen(cmd, **kwargs) + rc = p.wait() + if rc != 0: + raise SubprocessError("command %s exited with rc=%s", (cmd, rc)) + +# the very first time you run setup.py, it will download+build darcsver and +# whatnot, emitting noise to stdout. Run it once (and throw away that junk) +# to avoid treating that noise as the package name. +run(PYTHON, "setup.py", "--name") + +NAME = get_output(PYTHON, "setup.py", "--name").strip() +VERSION = get_output(PYTHON, "setup.py", "--version").strip() + +TARBALL = "%s-%s.tar.gz" % (NAME, VERSION) +DEBIAN_TARBALL = "%s_%s.orig.tar.gz" % (NAME, VERSION) +BUILDDIR = "build/debian/%s-%s" % (NAME, VERSION) + +run(PYTHON, "setup.py", "sdist", "--formats=gztar") +if os.path.exists("build/debian"): + shutil.rmtree("build/debian") +os.makedirs("build/debian") +shutil.copyfile("dist/%s" % TARBALL, "build/debian/%s" % DEBIAN_TARBALL) +run("tar", "xf", DEBIAN_TARBALL, cwd="build/debian") + +# now modify the tree for debian packaging. This is an algorithmic way of +# applying the debian .diff, which factors out some of the similarities +# between various debian/ubuntu releases. Everything we do after this point +# will show up in the generated .diff, and thus form the debian-specific part +# of the source package. +DEBDIR = os.path.join(BUILDDIR, "debian") +os.makedirs(DEBDIR) + +# The 'aliases' section in setup.cfg causes problems, so get rid of it. We +# could get rid of the whole file, but 1: find_links is still sort of useful, +# and 2: dpkg-buildpackage prefers to ignore file removal (as opposed to +# file-modification) + +#os.unlink(os.path.join(BUILDDIR, "setup.cfg")) +SETUPCFG = os.path.join(BUILDDIR, "setup.cfg") +lines = open(SETUPCFG, "r").readlines() +f = open(SETUPCFG, "w") +for l in lines: + if l.startswith("[aliases]"): + break + f.write(l) +f.close() + +for n in ["compat", "control", "copyright", "pycompat", "rules"]: + fn = "misc/debian/%s.%s" % (n, ARCH) + if not os.path.exists(fn): + fn = "misc/debian/%s" % n + assert os.path.exists(fn) + + shutil.copyfile(fn, os.path.join(DEBDIR, n)) + if n == "rules": + os.chmod(os.path.join(DEBDIR, n), 0755) # +x + +# We put "local package" on the first line of the changelog entry to suppress +# the lintian NMU warnings (since debchange's new entry's "author" will +# probably be different than the what the debian/control Maintainer: field +# says) + +DISTRIBUTION_MAP = {"sid": "unstable"} + +run("debchange", "--create", + "--package", NAME, + "--newversion", VERSION+"-1", + "--distribution", DISTRIBUTION_MAP.get(ARCH, ARCH), + "local package: 'make deb' build", cwd=BUILDDIR) + +# the package is ready to build. 'debuild' will produce the source package +# (.dsc+.diff.gz), then build the .deb and produce a .changes file ready for +# upload to an APT archive. The build log will go into a .build file. + +run("debuild", "-uc", "-us", cwd=BUILDDIR) diff --git a/misc/build-deb.sh b/misc/build-deb.sh deleted file mode 100644 index e15d4287..00000000 --- a/misc/build-deb.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -e - -# $PYTHON and $ARCH must be set - -if [ -z "$PYTHON" ]; then - PYTHON=python -fi -if [ -z "$ARCH" ]; then - echo "must set ARCH= before running this script" - exit 1 -fi - -NAME=$($PYTHON setup.py --name) -VERSION=$($PYTHON setup.py --version) - -# actually, it's the debchange using a different author than the -# debian/control Maintainer: entry that makes lintian think this is an NMU. -# Put "local package" on the first line of the changelog entry to supress -# this warning. -TARBALL=${NAME}-${VERSION}.tar.gz -DEBTARBALL=${NAME}_${VERSION}.orig.tar.gz -DEBDIR=build/debian/${NAME}-${VERSION} -$PYTHON setup.py sdist --formats=gztar -rm -rf build/debian -mkdir -p build/debian -cp dist/$TARBALL build/debian/$DEBTARBALL -(cd build/debian && tar xf $DEBTARBALL) -zcat misc/debian/$ARCH.diff.gz | (cd $DEBDIR && patch -p1) -chmod +x $DEBDIR/debian/rules -# We put "local package" on the first line of the changelog entry to suppress -# the lintian NMU warnings (since debchange's new entry's "author" will -# probably be different than the what the debian/control Maintainer: field -# says) -echo "updating version to $VERSION-1" -(cd $DEBDIR && debchange --newversion $VERSION-1 "local package: 'make deb' build") -(cd $DEBDIR && debuild -uc -us) - diff --git a/misc/debian/compat b/misc/debian/compat new file mode 100644 index 00000000..b8626c4c --- /dev/null +++ b/misc/debian/compat @@ -0,0 +1 @@ +4 diff --git a/misc/debian/compat.sid b/misc/debian/compat.sid new file mode 100644 index 00000000..7f8f011e --- /dev/null +++ b/misc/debian/compat.sid @@ -0,0 +1 @@ +7 diff --git a/misc/debian/control.sid b/misc/debian/control.sid new file mode 100644 index 00000000..ecdbee1a --- /dev/null +++ b/misc/debian/control.sid @@ -0,0 +1,17 @@ +Source: allmydata-tahoe +Section: python +Priority: optional +Maintainer: Brian Warner +Homepage: http://allmydata.org/trac/tahoe +Build-Depends: debhelper (>= 5.0.37.2), cdbs (>= 0.4.43), python-central (>= 0.5), python-setuptools, python, python-dev, debhelper (>= 7) +Build-Depends-Indep: python-twisted-core +XS-Python-Version: 2.4,2.5,2.6 +Standards-Version: 3.8.3 + +Package: allmydata-tahoe +Architecture: all +Depends: ${python:Depends}, python-twisted-core, python-twisted-names, python-twisted-web, python-foolscap (>= 0.4.1), python-openssl, python-nevow, python-simplejson (>= 1.4), python-zfec (>= 1.1), python-pycryptopp (>= 0.5.15), python-setuptools, ${misc:Depends} +Recommends: +XB-Python-Version: 2.4,2.5,2.6 +Description: A secure distributed filesystem + Allmydata Tahoe diff --git a/misc/debian/copyright b/misc/debian/copyright new file mode 100644 index 00000000..d5834e65 --- /dev/null +++ b/misc/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Brian Warner + +The upstream source of this project is http://allmydata.org . + +Copyright (c) 2006-2009 +AllMyData, Inc. + +You may use this package under the GNU General Public License, version 2 or, at +your option, any later version. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +This licence also comes with the added permission that you may link this +program with the OpenSSL library and distribute executables, as long as you +follow the requirements of this licence in regard to all of the software in +the executable aside from OpenSSL. + +You may use this package under the Transitive Grace Period Public Licence, +version 1 or, at your option, any later version. The Transitive Grace Period +Public Licence has requirements similar to the GPL except that it allows you to +wait for up to twelve months after you redistribute a derived work before +releasing the source code of your derived work. See the file COPYING.TGPPL.html +for the terms of the Transitive Grace Period Public Licence, version 1. + +(You may choose to use this package under the terms of either licence, at your +option.) diff --git a/misc/debian/pycompat b/misc/debian/pycompat new file mode 100644 index 00000000..0cfbf088 --- /dev/null +++ b/misc/debian/pycompat @@ -0,0 +1 @@ +2 diff --git a/misc/debian/rules.sid b/misc/debian/rules.sid new file mode 100644 index 00000000..7f12edf6 --- /dev/null +++ b/misc/debian/rules.sid @@ -0,0 +1,34 @@ +#! /usr/bin/make -f +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +DEB_PYTHON_SYSTEM=pycentral + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/python-distutils.mk + +# this ought to be the name of the package that we're building, which is +# different on each tahoe branch. debian/control is the master: whatever +# package is listed in there will be built. +DEBNAME := $(firstword $(DEB_PACKAGES)) + +STAGING_DIR := $(CURDIR)/debian/$(DEBNAME) + +DEB_INSTALL_DOCS_ALL := COPYING.TGPPL.html CREDITS NEWS README relnotes.txt \ + docs misc/spacetime misc/cpu-watcher.tac +DEB_COMPRESS_EXCLUDE := .tac + +install/$(DEBNAME):: + dh_install misc/munin/* usr/share/$(DEBNAME)/munin + chmod +x $(STAGING_DIR)/usr/share/$(DEBNAME)/munin/* + chmod -x $(STAGING_DIR)/usr/share/$(DEBNAME)/munin/*-conf + +# the base rules do "python setup.py clean", which spuriously downloads and +# builds several setuptools-extensions eggs. The tahoe 'setup.py clean' +# leaves those and many other files in place, but its "make clean" does the +# right thing. Putting this double-colon rule after the 'include' statements +# above should ensure that it runs after the base rules. + +clean:: + $(MAKE) clean +