From 050bee8fdcc6d7b1c25f2eb0f7508e2b1838e1b0 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Wed, 17 Sep 2008 16:07:56 -0700
Subject: [PATCH] setup.py,Makefile: move the 'chmod +x bin/tahoe' into
 setup.py

---
 Makefile |  1 -
 setup.py | 10 +++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 18a5f5ee..09a98ad8 100644
--- a/Makefile
+++ b/Makefile
@@ -72,7 +72,6 @@ build: src/allmydata/_version.py
 # setuptools.
 build-once:
 	$(PYTHON) setup.py build_tahoe
-	chmod +x bin/tahoe
 	touch .built
 
 # 'make install' will do the following:
diff --git a/setup.py b/setup.py
index 2aff99fc..825760a6 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@
 #
 # See the docs/about.html file for licensing information.
 
-import os, re, sys, subprocess
+import os, re, sys, stat, subprocess
 
 ##### sys.path management
 
@@ -284,6 +284,14 @@ class BuildTahoe(Command):
     def finalize_options(self):
         pass
     def run(self):
+        # chmod +x bin/tahoe
+        bin_tahoe = os.path.join("bin", "tahoe")
+        old_mode = stat.S_IMODE(os.stat(bin_tahoe)[stat.ST_MODE])
+        new_mode = old_mode | (stat.S_IXUSR | stat.S_IRUSR |
+                               stat.S_IXGRP | stat.S_IRGRP |
+                               stat.S_IXOTH | stat.S_IROTH )
+        os.chmod(bin_tahoe, new_mode)
+
         # 'setup.py develop --prefix SUPPORT' will complain if SUPPORTLIB is
         # not on PYTHONPATH, because it thinks you are installing to a place
         # that will not be searched at runtime (which is true, except that we
-- 
2.45.2