Introducing Torbutton integration to the Tor-Privoxy OSX bundle.
[tor/rransom.git] / contrib / osx / package.sh
blobd36216e8fb081a40eb27e3344a6b658689c14c02
1 #!/bin/sh
2 # $Id$
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:
7 # - One for Tor.
8 # - One for Privoxy.
9 # - One for a tor-specific privoxy configuration script.
10 # - One for Startup scripts for Tor.
11 # - One for Torbutton, an extension for FireFox
13 # This script expects to be run from the toplevel makefile, with VERSION
14 # set to the latest Tor version, and Tor already built.
17 # Read the documentation located in tor/doc/tor-osx-dmg-creation.txt on
18 # how to build Tor for OSX
20 # Where have we put the zip file containing Privoxy? Edit this if your
21 # privoxy lives somewhere else.
22 PRIVOXY_PKG_ZIP=~/tmp/privoxyosx_setup_3.0.6.zip
24 # Where have we put the xpi and license for Torbutton? Edit this if your
25 # torbutton and torbutton license live somewhere else.
26 TORBUTTON_PATH=~/tmp/torbutton-1.1.8-alpha.xpi
27 TORBUTTON_LIC_PATH=~/tmp/LICENSE
29 ###
30 # Helpful info on OS X packaging:
31 # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
32 # man packagemaker
34 # Make sure VERSION is set, so we don't name the package
35 # "Tor--$OS-$ARCH-Bundle.dmg"
36 if [ "XX$VERSION" = 'XX' ]; then
37 echo "VERSION not set."
38 exit 1
41 ## Determine OSX Version
42 # map version to name
43 if [ -x /usr/bin/sw_vers ]; then
44 # This is poor, yet functional. We don't care about the 3rd number in
45 # the OS version
46 OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
47 case "$OSVER" in
48 "10.5") OS="leopard" ARCH="universal";;
49 "10.4") OS="tiger" ARCH="universal";;
50 "10.3") OS="panther" ARCH="ppc";;
51 "10.2") OS="jaguar" ARCH="ppc";;
52 "10.1") OS="puma" ARCH="ppc";;
53 "10.0") OS="cheetah" ARCH="ppc";;
54 *) OS="unknown";;
55 esac
56 else
57 OS="unknown"
60 # Where will we put our temporary files?
61 BUILD_DIR=/tmp/tor-osx-$$
62 # Path to PackageMaker app.
63 PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
65 umask 022
67 echo I might ask you for your password now, so you can sudo.
69 sudo rm -rf $BUILD_DIR
70 mkdir $BUILD_DIR || exit 1
71 for subdir in tor_packageroot tor_resources \
72 torstartup_packageroot \
73 privoxyconf_packageroot \
74 torbundle_resources \
75 torbutton_packageroot \
76 output; do
77 mkdir $BUILD_DIR/$subdir
78 done
80 ### Make Tor package.
82 make install DESTDIR=$BUILD_DIR/tor_packageroot
83 #mv $BUILD_DIR/tor_packageroot/Library/Tor/torrc.sample $BUILD_DIR/tor_packageroot/Library/Tor/torrc
84 cp contrib/osx/ReadMe.rtf $BUILD_DIR/tor_resources
85 #cp contrib/osx/License.rtf $BUILD_DIR/tor_resources
86 chmod 755 contrib/osx/TorPostflight
87 cp contrib/osx/TorPostflight $BUILD_DIR/tor_resources/postflight
88 cp contrib/osx/addsysuser $BUILD_DIR/tor_resources/addsysuser
89 cp contrib/osx/Tor_Uninstaller.applescript $BUILD_DIR/tor_resources/Tor_Uninstaller.applescript
90 cp contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/uninstall_tor_bundle.sh
91 cp contrib/osx/package_list.txt $BUILD_DIR/tor_resources/package_list.txt
92 cp contrib/osx/tor_logo.gif $BUILD_DIR/tor_resources/background.gif
93 cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
94 Tor: an anonymous Internet communication system
96 Tor is a system for using the internet anonymously, and allowing
97 others to do so.
98 EOF
100 ### Assemble documentation
102 DOC=$BUILD_DIR/tor_resources/documents
103 mkdir $DOC
104 mkdir $DOC/howto
105 #cp doc/website/stylesheet.css doc/website/tor-doc-osx.html.* $DOC/howto
106 #cp doc/website/tor-doc-server.html.* $DOC/howto
107 #cp doc/website/tor-hidden-service.html.* $DOC/howto
108 #cp doc/website/tor-switchproxy.html.* $DOC/howto
109 #mkdir $DOC/img
110 #cp doc/img/screenshot-osx* $DOC/img
111 cp AUTHORS $DOC/AUTHORS.txt
112 groff doc/tor.1.in -T ps -m man | pstopdf -i -o $DOC/tor-reference.pdf
113 groff doc/tor-resolve.1 -T ps -m man | pstopdf -i -o $DOC/tor-resolve.pdf
114 mkdir $DOC/Advanced
115 cp doc/spec/tor-spec.txt \
116 doc/spec/rend-spec.txt \
117 doc/spec/control-spec.txt \
118 doc/spec/socks-extensions.txt \
119 doc/spec/version-spec.txt \
120 doc/spec/address-spec.txt \
121 doc/spec/path-spec.txt \
122 $DOC/Advanced
124 cp doc/HACKING $DOC/Advanced/HACKING.txt
125 cp ChangeLog $DOC/Advanced/ChangeLog.txt
127 find $BUILD_DIR/tor_packageroot -print0 |sudo xargs -0 chown root:wheel
129 $PACKAGEMAKER -build \
130 -p $BUILD_DIR/output/Tor.pkg \
131 -f $BUILD_DIR/tor_packageroot \
132 -r $BUILD_DIR/tor_resources \
133 -i contrib/osx/TorInfo.plist \
134 -d contrib/osx/TorDesc.plist
136 ### Put privoxy configuration package in place.
137 mkdir -p $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy
138 cp contrib/osx/privoxy.config $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/config
140 find $BUILD_DIR/privoxyconf_packageroot -print0 |sudo xargs -0 chown root:wheel
142 $PACKAGEMAKER -build \
143 -p $BUILD_DIR/output/privoxyconf.pkg \
144 -f $BUILD_DIR/privoxyconf_packageroot \
145 -i contrib/osx/PrivoxyConfInfo.plist \
146 -d contrib/osx/PrivoxyConfDesc.plist
148 ### Make Startup Script package
150 mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
151 cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
152 $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
154 find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
156 $PACKAGEMAKER -build \
157 -p $BUILD_DIR/output/torstartup.pkg \
158 -f $BUILD_DIR/torstartup_packageroot \
159 -i contrib/osx/TorStartupInfo.plist \
160 -d contrib/osx/TorStartupDesc.plist
162 ### Make Torbutton Installation package
164 mkdir -p $BUILD_DIR/torbutton_packageroot/Library/Torbutton
165 cp $TORBUTTON_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/
166 cp $TORBUTTON_LIC_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/Torbutton-LICENSE.txt
168 find $BUILD_DIR/torbutton_packageroot -print0 | sudo xargs -0 chown root:wheel
170 $PACKAGEMAKER -build \
171 -p $BUILD_DIR/output/torbutton.pkg \
172 -f $BUILD_DIR/torbutton_packageroot \
173 -i contrib/osx/TorbuttonInfo.plist \
174 -d contrib/osx/TorbuttonDesc.plist
176 ### Assemble the metapackage. Packagemaker won't buld metapackages from
177 # the command line, so we need to do it by hand.
179 MPKG=$BUILD_DIR/output/Tor-$VERSION-$OS-$ARCH-Bundle.mpkg
180 mkdir -p "$MPKG/Contents/Resources"
181 echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
182 cp contrib/osx/ReadMe.rtf "$MPKG/Contents/Resources"
183 #cp contrib/osx/License.rtf "$MPKG/Contents/Resources"
184 cp contrib/osx/TorBundleInfo.plist "$MPKG/Contents/Info.plist"
185 cp contrib/osx/TorBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf"
186 cp contrib/osx/TorBundleDesc.plist "$MPKG/Contents/Resources/Description.plist"
187 cp contrib/osx/tor_logo.gif "$MPKG/Contents/Resources/background.gif"
189 # Move all the subpackages into place. unzip Privoxy.pkg into place,
190 # and fix its file permissions so we can rm -rf it later.
191 mkdir $BUILD_DIR/output/.contained_packages
192 mv $BUILD_DIR/output/*.pkg $BUILD_DIR/OUTPUT/.contained_packages
193 ( cd $BUILD_DIR/output/.contained_packages && unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg -type d -print0 | xargs -0 chmod u+w )
195 ### Copy readmes and licenses into toplevel.
196 PRIVOXY_RESDIR=$BUILD_DIR/output/.contained_packages/Privoxy.pkg/Contents/Resources
197 cp $PRIVOXY_RESDIR/License.html $BUILD_DIR/output/Privoxy\ License.html
198 cp $PRIVOXY_RESDIR/ReadMe.txt $BUILD_DIR/output/Privoxy\ ReadMe.txt
199 cp contrib/osx/ReadMe.rtf $BUILD_DIR/output/Tor\ ReadMe.rtf
200 cp LICENSE $BUILD_DIR/output/Tor\ License.txt
201 cp $TORBUTTON_LIC_PATH $BUILD_DIR/output/Torbutton_LICENSE.txt
203 ### Package it all into a DMG
205 find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
207 mv $BUILD_DIR/output "$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle"
208 rm -f "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
209 USER="`whoami`"
210 sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
211 sudo chown "$USER" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
213 sudo rm -rf $BUILD_DIR