From 623d82a1302ecdad33b61864de1ebaf34bb0d959 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Thu, 10 Apr 2008 16:29:59 -0700
Subject: [PATCH] debian: use our own /usr/bin/tahoe, remove runtime dependency
 on setuptools (since it required egg-aware versions of all dependencies too)

---
 misc/feisty/debian/control |  2 +-
 misc/feisty/debian/rules   | 16 ++++++++++++++++
 misc/sid/debian/control    |  2 +-
 misc/sid/debian/rules      | 16 ++++++++++++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/misc/feisty/debian/control b/misc/feisty/debian/control
index 8e779e32..0b86abc4 100644
--- a/misc/feisty/debian/control
+++ b/misc/feisty/debian/control
@@ -9,7 +9,7 @@ Standards-Version: 3.7.2
 
 Package: allmydata-tahoe
 Architecture: all
-Depends: ${python:Depends}, python-twisted, python-foolscap (>= 0.2.5), python-pyopenssl, python-nevow, python-simplejson (>= 1.4), python-zfec (>= 1.1), python-pycryptopp (>= 0.2.8), python-pkg-resources | python-setuptools
+Depends: ${python:Depends}, python-twisted, python-foolscap (>= 0.2.5), python-pyopenssl, python-nevow, python-simplejson (>= 1.4), python-zfec (>= 1.1), python-pycryptopp (>= 0.2.8)
 Recommends:
 XB-Python-Version: 2.4,2.5
 Description: A secure distributed filestore
diff --git a/misc/feisty/debian/rules b/misc/feisty/debian/rules
index 5abfddcb..0966bf75 100644
--- a/misc/feisty/debian/rules
+++ b/misc/feisty/debian/rules
@@ -9,10 +9,26 @@ include /usr/share/cdbs/1/class/python-distutils.mk
 
 STAGING_DIR=$(CURDIR)/debian/allmydata-tahoe
 
+# we overwrite the setuptools-generated /usr/bin/tahoe (located in
+# support/bin/tahoe after a 'make build') with a different version, because
+# the setuptools form (using "entry points") insists upon .egg-info -visible
+# forms of dependent packages to be installed. For a debian package, we rely
+# upon the dependencies that are declared in debian/control .
+#
+# To make sure the #! line matches the version of python that we're using for
+# this build, we copy it from the setuptools-generated /usr/bin/tahoe, then
+# add other code to the generated file.
+
 install/allmydata-tahoe::
 	mkdir -pm755 $(STAGING_DIR)
 	python setup.py install --root=$(STAGING_DIR)
 
+	head -1 $(STAGING_DIR)/usr/bin/tahoe >$(STAGING_DIR)/usr/bin/tahoe.new
+	echo "from allmydata.scripts import runner" >>$(STAGING_DIR)/usr/bin/tahoe.new
+	echo "runner.run()" >>$(STAGING_DIR)/usr/bin/tahoe.new
+	chmod +x $(STAGING_DIR)/usr/bin/tahoe.new
+	mv $(STAGING_DIR)/usr/bin/tahoe.new $(STAGING_DIR)/usr/bin/tahoe
+
 	dh_pycentral
 
 clean::
diff --git a/misc/sid/debian/control b/misc/sid/debian/control
index cca142c8..ac542d01 100644
--- a/misc/sid/debian/control
+++ b/misc/sid/debian/control
@@ -9,7 +9,7 @@ Standards-Version: 3.7.2
 
 Package: allmydata-tahoe
 Architecture: all
-Depends: ${python:Depends}, python-twisted-core, python-foolscap (>= 0.2.5), python-pyopenssl, python-twisted-names, python-nevow, python-simplejson (>= 1.4), python-zfec (>= 1.1), python-pycryptopp (>= 0.2.8), python-pkg-resources | python-setuptools
+Depends: ${python:Depends}, python-twisted-core, python-foolscap (>= 0.2.5), python-pyopenssl, python-twisted-names, python-nevow, python-simplejson (>= 1.4), python-zfec (>= 1.1), python-pycryptopp (>= 0.2.8)
 Recommends:
 XB-Python-Version: 2.4
 Description: A secure distributed filestore
diff --git a/misc/sid/debian/rules b/misc/sid/debian/rules
index 5abfddcb..0966bf75 100644
--- a/misc/sid/debian/rules
+++ b/misc/sid/debian/rules
@@ -9,10 +9,26 @@ include /usr/share/cdbs/1/class/python-distutils.mk
 
 STAGING_DIR=$(CURDIR)/debian/allmydata-tahoe
 
+# we overwrite the setuptools-generated /usr/bin/tahoe (located in
+# support/bin/tahoe after a 'make build') with a different version, because
+# the setuptools form (using "entry points") insists upon .egg-info -visible
+# forms of dependent packages to be installed. For a debian package, we rely
+# upon the dependencies that are declared in debian/control .
+#
+# To make sure the #! line matches the version of python that we're using for
+# this build, we copy it from the setuptools-generated /usr/bin/tahoe, then
+# add other code to the generated file.
+
 install/allmydata-tahoe::
 	mkdir -pm755 $(STAGING_DIR)
 	python setup.py install --root=$(STAGING_DIR)
 
+	head -1 $(STAGING_DIR)/usr/bin/tahoe >$(STAGING_DIR)/usr/bin/tahoe.new
+	echo "from allmydata.scripts import runner" >>$(STAGING_DIR)/usr/bin/tahoe.new
+	echo "runner.run()" >>$(STAGING_DIR)/usr/bin/tahoe.new
+	chmod +x $(STAGING_DIR)/usr/bin/tahoe.new
+	mv $(STAGING_DIR)/usr/bin/tahoe.new $(STAGING_DIR)/usr/bin/tahoe
+
 	dh_pycentral
 
 clean::
-- 
2.45.2