3 # Copyright 2004-2005 Nick Mathewson.
4 # See LICENSE in Tor distribution for licensing information.
6 # This script builds a Macintosh OS X metapackage containing 4 packages:
9 # - One for a tor-specific privoxy configuration script.
10 # - One for Startup scripts for Tor.
12 # This script expects to be run from the toplevel makefile, with VERSION
13 # set to the latest Tor version, and Tor already built.
15 # Building Tor for OSX in 3 easy steps:
16 # 1) Make sure PRIVOXY_PKG_ZIP= is set to the correct path to find privoxyosx_setup_3.0.3.zip
17 # 2) In the top level, this means ~/tor, not tor/contrib/osx, do a configure with these parameters:
18 # configure --prefix=/Library/Tor --bindir=/Library/Tor --sysconfdir=/Library
19 # 3) In same top level dir, make dist-osx. You'll have a .dmg file when complete.
21 # Where have we put the zip file containing Privoxy? Edit this if your
22 # privoxy lives somewhere else.
23 PRIVOXY_PKG_ZIP
=~
/src
/privoxy-setup
/privoxyosx_setup_3.0
.3.
zip
26 # Helpful info on OS X packaging:
27 # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
30 # Make sure VERSION is set, so we don't name the package "Tor Bundle.dmg"
31 if [ "XX$VERSION" = 'XX' ]; then
32 echo "VERSION not set."
36 # Where will we put our temporary files?
37 BUILD_DIR
=/tmp
/tor-osx-$$
38 # Path to PackageMaker app.
39 PACKAGEMAKER
=/Developer
/Applications
/Utilities
/PackageMaker.app
/Contents
/MacOS
/PackageMaker
43 echo I might ask you
for your password now
, so you can sudo.
45 sudo
rm -rf $BUILD_DIR
46 mkdir
$BUILD_DIR ||
exit 1
47 for subdir
in tor_packageroot tor_resources \
48 torstartup_packageroot \
49 privoxyconf_packageroot \
52 mkdir
$BUILD_DIR/$subdir
56 make install DESTDIR
=$BUILD_DIR/tor_packageroot
57 #mv $BUILD_DIR/tor_packageroot/Library/Tor/torrc.sample $BUILD_DIR/tor_packageroot/Library/Tor/torrc
58 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/tor_resources
59 #cp contrib/osx/License.rtf $BUILD_DIR/tor_resources
60 chmod 755 contrib
/osx
/TorPostflight
61 cp contrib
/osx
/TorPostflight
$BUILD_DIR/tor_resources
/postflight
62 cp contrib
/osx
/addsysuser
$BUILD_DIR/tor_resources
/addsysuser
63 cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
64 Tor: an anonymous Internet communication system
66 Tor is a system for using the internet anonymously, and allowing
70 find $BUILD_DIR/tor_packageroot
-print0 |sudo
xargs -0 chown root
:wheel
72 $PACKAGEMAKER -build \
73 -p $BUILD_DIR/output
/Tor.pkg \
74 -f $BUILD_DIR/tor_packageroot \
75 -r $BUILD_DIR/tor_resources \
76 -i contrib
/osx
/TorInfo.plist \
77 -d contrib
/osx
/TorDesc.plist
79 ### Put privoxy configuration package in place.
80 mkdir
-p $BUILD_DIR/privoxyconf_packageroot
/Library
/Privoxy
81 cp contrib
/osx
/privoxy.config
$BUILD_DIR/privoxyconf_packageroot
/Library
/Privoxy
/config
83 find $BUILD_DIR/privoxyconf_packageroot
-print0 |sudo
xargs -0 chown root
:wheel
85 $PACKAGEMAKER -build \
86 -p $BUILD_DIR/output
/privoxyconf.pkg \
87 -f $BUILD_DIR/privoxyconf_packageroot \
88 -i contrib
/osx
/PrivoxyConfInfo.plist \
89 -d contrib
/osx
/PrivoxyConfDesc.plist
91 ### Make Startup Script package
93 mkdir
-p $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
94 cp contrib
/osx
/Tor contrib
/osx
/StartupParameters.plist \
95 $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
97 find $BUILD_DIR/torstartup_packageroot
-print0 | sudo
xargs -0 chown root
:wheel
98 $PACKAGEMAKER -build \
99 -p $BUILD_DIR/output
/torstartup.pkg \
100 -f $BUILD_DIR/torstartup_packageroot \
101 -i contrib
/osx
/TorStartupInfo.plist \
102 -d contrib
/osx
/TorStartupDesc.plist
104 ### Assemble the metapackage. Packagemaker won't buld metapackages from
105 # the command line, so we need to do it by hand.
107 MPKG
=$BUILD_DIR/output
/Tor\ Bundle.mpkg
108 mkdir
-p "$MPKG/Contents/Resources"
109 echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
110 cp contrib
/osx
/ReadMe.rtf
"$MPKG/Contents/Resources"
111 #cp contrib/osx/License.rtf "$MPKG/Contents/Resources"
112 cp contrib
/osx
/TorBundleInfo.plist
"$MPKG/Contents/Info.plist"
113 cp contrib
/osx
/TorBundleWelcome.rtf
"$MPKG/Contents/Resources/Welcome.rtf"
114 cp contrib
/osx
/TorBundleDesc.plist
"$MPKG/Contents/Resources/Description.plist"
116 # Move all the subpackages into place. unzip Privoxy.pkg into place,
117 # and fix its file permissions so we can rm -rf it later.
118 mkdir
$BUILD_DIR/output
/.contained_packages
119 mv $BUILD_DIR/output
/*.pkg
$BUILD_DIR/OUTPUT
/.contained_packages
120 ( cd $BUILD_DIR/output
/.contained_packages
&& unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg
-type d
-print0 |
xargs -0 chmod u
+w
)
122 ### Copy readmes and licenses into toplevel.
123 PRIVOXY_RESDIR
=$BUILD_DIR/output
/.contained_packages
/Privoxy.pkg
/Contents
/Resources
124 cp $PRIVOXY_RESDIR/License.html
$BUILD_DIR/output
/Privoxy\ License.html
125 cp $PRIVOXY_RESDIR/ReadMe.txt
$BUILD_DIR/output
/Privoxy\ ReadMe.txt
126 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/output
/Tor\ ReadMe.rtf
127 cp LICENSE
$BUILD_DIR/output
/Tor\ License.txt
129 ### Assemble documentation
131 DOC
=$BUILD_DIR/output
/Documents
133 cp doc
/tor-doc.html
doc
/tor-doc.css
$DOC
134 cp AUTHORS
$DOC/AUTHORS.txt
135 groff doc
/tor
.1 -T ps
-m man | ps2pdf
- $DOC/tor-reference.pdf
136 groff doc
/tor-resolve
.1 -T ps
-m man | ps2pdf
- $DOC/tor-resolve.pdf
139 cp doc
/tor-spec.txt
doc
/rend-spec.txt
doc
/control-spec.txt
doc
/socks-extensions.txt
doc
/version-spec.txt
$DOC/Advanced
140 cp doc
/HACKING
$DOC/Advanced
/HACKING.txt
141 cp ChangeLog
$DOC/Advanced
/ChangeLog.txt
143 ### Package it all into a DMG
145 find $BUILD_DIR/output
-print0 | sudo
xargs -0 chown root
:wheel
147 mv $BUILD_DIR/output
"$BUILD_DIR/Tor $VERSION Bundle"
148 rm -f "Tor $VERSION Bundle.dmg"
150 sudo hdiutil create
-format UDZO
-srcfolder "$BUILD_DIR/Tor $VERSION Bundle" "Tor $VERSION Bundle.dmg"
151 sudo chown
"$USER" "Tor $VERSION Bundle.dmg"
153 sudo
rm -rf $BUILD_DIR