1 | #!/bin/sh |
---|
2 | |
---|
3 | VERSION=`sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3" | sed "s/\"//g"` |
---|
4 | PWD=`pwd` |
---|
5 | TARGET="/Applications/tahoe.app" |
---|
6 | |
---|
7 | # Clean up any test garbage that might be left over from a recent test run. |
---|
8 | rm -rvf _trial_temp |
---|
9 | |
---|
10 | virtualenv osx-venv |
---|
11 | osx-venv/bin/pip install . |
---|
12 | |
---|
13 | # The virtualenv contains all the dependencies we need, but the bin/python |
---|
14 | # itself is not useful, nor is having it as the shbang line in the generated |
---|
15 | # bin/tahoe executable. Replace bin/tahoe with a form that explicitly sets |
---|
16 | # sys.path to the target directory (/Applications/tahoe.app). This isn't as |
---|
17 | # isolated as a proper virtualenv would be (the system site-packages |
---|
18 | # directory will still appear later in sys.path), but I think it ought to |
---|
19 | # work. |
---|
20 | |
---|
21 | rm osx-venv/bin/* |
---|
22 | cat >osx-venv/bin/tahoe <<EOF |
---|
23 | #!/usr/bin/env python |
---|
24 | import sys, os.path |
---|
25 | up = os.path.dirname |
---|
26 | bintahoe = os.path.abspath(__file__) |
---|
27 | appdir = up(up(bintahoe)) |
---|
28 | sitedir = os.path.join(appdir, "lib", "python2.7", "site-packages") |
---|
29 | # usually "/Applications/tahoe.app/lib/python2.7/site-packages" |
---|
30 | sys.path.insert(0, sitedir) |
---|
31 | from allmydata.scripts.runner import run |
---|
32 | run() |
---|
33 | EOF |
---|
34 | chmod +x osx-venv/bin/tahoe |
---|
35 | |
---|
36 | # The venv has a .pth file which allows "import zope.interface" to work even |
---|
37 | # though "zope" isn't really a package (it has no __init__.py). The venv's |
---|
38 | # python has this site-packages/ on sys.path early enough to process the .pth |
---|
39 | # file, and running tahoe with PYTHONPATH=...site-packages would also process |
---|
40 | # it, but a simple sys.path.insert doesn't. This is the simplest hack I could |
---|
41 | # find to fix it. |
---|
42 | |
---|
43 | touch osx-venv/lib/python2.7/site-packages/zope/__init__.py |
---|
44 | |
---|
45 | cp -r $PWD/misc/build_helpers/osx/Contents osx-venv/Contents |
---|
46 | |
---|
47 | # create component pkg |
---|
48 | pkgbuild --root osx-venv \ |
---|
49 | --identifier com.leastauthority.tahoe \ |
---|
50 | --version "$VERSION" \ |
---|
51 | --ownership recommended \ |
---|
52 | --install-location $TARGET \ |
---|
53 | --scripts "$PWD/misc/build_helpers/osx/scripts" \ |
---|
54 | tahoe-lafs.pkg |
---|
55 | |
---|
56 | # create product archive |
---|
57 | productbuild --distribution "$PWD/misc/build_helpers/osx/Distribution.xml" \ |
---|
58 | --package-path . \ |
---|
59 | "tahoe-lafs-$VERSION-osx.pkg" |
---|
60 | |
---|
61 | # remove intermediate pkg |
---|
62 | rm -f tahoe-lafs.pkg |
---|