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.
16 # Read the documentation located in tor/doc/tor-osx-dmg-creation.txt on
17 # how to build Tor for OSX
19 # Where have we put the zip file containing Privoxy? Edit this if your
20 # privoxy lives somewhere else.
21 PRIVOXY_PKG_ZIP
=~
/tmp
/privoxyosx_setup_3.0
.6.
zip
24 # Helpful info on OS X packaging:
25 # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
28 # Make sure VERSION is set, so we don't name the package
29 # "Tor--$OS-$ARCH-Bundle.dmg"
30 if [ "XX$VERSION" = 'XX' ]; then
31 echo "VERSION not set."
35 ## Determine OSX Version
37 if [ -x /usr
/bin
/sw_vers
]; then
38 # This is poor, yet functional. We don't care about the 3rd number in
40 OSVER
=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
42 "10.5") OS
="leopard" ARCH
="universal";;
43 "10.4") OS
="tiger" ARCH
="universal";;
44 "10.3") OS
="panther" ARCH
="ppc";;
45 "10.2") OS
="jaguar" ARCH
="ppc";;
46 "10.1") OS
="puma" ARCH
="ppc";;
47 "10.0") OS
="cheetah" ARCH
="ppc";;
54 # Where will we put our temporary files?
55 BUILD_DIR
=/tmp
/tor-osx-$$
56 # Path to PackageMaker app.
57 PACKAGEMAKER
=/Developer
/Applications
/Utilities
/PackageMaker.app
/Contents
/MacOS
/PackageMaker
61 echo I might ask you
for your password now
, so you can sudo.
63 sudo
rm -rf $BUILD_DIR
64 mkdir
$BUILD_DIR ||
exit 1
65 for subdir
in tor_packageroot tor_resources \
66 torstartup_packageroot \
67 privoxyconf_packageroot \
70 mkdir
$BUILD_DIR/$subdir
74 make install DESTDIR
=$BUILD_DIR/tor_packageroot
75 #mv $BUILD_DIR/tor_packageroot/Library/Tor/torrc.sample $BUILD_DIR/tor_packageroot/Library/Tor/torrc
76 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/tor_resources
77 #cp contrib/osx/License.rtf $BUILD_DIR/tor_resources
78 chmod 755 contrib
/osx
/TorPostflight
79 cp contrib
/osx
/TorPostflight
$BUILD_DIR/tor_resources
/postflight
80 cp contrib
/osx
/addsysuser
$BUILD_DIR/tor_resources
/addsysuser
81 cp contrib
/osx
/Tor_Uninstaller.applescript
$BUILD_DIR/tor_resources
/Tor_Uninstaller.applescript
82 cp contrib
/osx
/uninstall_tor_bundle.sh
$BUILD_DIR/tor_resources
/uninstall_tor_bundle.sh
83 cp contrib
/osx
/package_list.txt
$BUILD_DIR/tor_resources
/package_list.txt
84 cp contrib
/osx
/tor_logo.gif
$BUILD_DIR/tor_resources
/background.gif
85 cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
86 Tor: an anonymous Internet communication system
88 Tor is a system for using the internet anonymously, and allowing
92 ### Assemble documentation
94 DOC
=$BUILD_DIR/tor_resources
/documents
97 #cp doc/website/stylesheet.css doc/website/tor-doc-osx.html.* $DOC/howto
98 #cp doc/website/tor-doc-server.html.* $DOC/howto
99 #cp doc/website/tor-hidden-service.html.* $DOC/howto
100 #cp doc/website/tor-switchproxy.html.* $DOC/howto
102 #cp doc/img/screenshot-osx* $DOC/img
103 cp AUTHORS
$DOC/AUTHORS.txt
104 groff doc
/tor
.1.
in -T ps
-m man | pstopdf
-i -o $DOC/tor-reference.pdf
105 groff doc
/tor-resolve
.1 -T ps
-m man | pstopdf
-i -o $DOC/tor-resolve.pdf
107 cp doc
/spec
/tor-spec.txt \
108 doc
/spec
/rend-spec.txt \
109 doc
/spec
/control-spec.txt \
110 doc
/spec
/socks-extensions.txt \
111 doc
/spec
/version-spec.txt \
112 doc
/spec
/address-spec.txt \
113 doc
/spec
/path-spec.txt \
116 cp doc
/HACKING
$DOC/Advanced
/HACKING.txt
117 cp ChangeLog
$DOC/Advanced
/ChangeLog.txt
119 find $BUILD_DIR/tor_packageroot
-print0 |sudo
xargs -0 chown root
:wheel
121 $PACKAGEMAKER -build \
122 -p $BUILD_DIR/output
/Tor.pkg \
123 -f $BUILD_DIR/tor_packageroot \
124 -r $BUILD_DIR/tor_resources \
125 -i contrib
/osx
/TorInfo.plist \
126 -d contrib
/osx
/TorDesc.plist
128 ### Put privoxy configuration package in place.
129 mkdir
-p $BUILD_DIR/privoxyconf_packageroot
/Library
/Privoxy
130 cp contrib
/osx
/privoxy.config
$BUILD_DIR/privoxyconf_packageroot
/Library
/Privoxy
/config
132 find $BUILD_DIR/privoxyconf_packageroot
-print0 |sudo
xargs -0 chown root
:wheel
134 $PACKAGEMAKER -build \
135 -p $BUILD_DIR/output
/privoxyconf.pkg \
136 -f $BUILD_DIR/privoxyconf_packageroot \
137 -i contrib
/osx
/PrivoxyConfInfo.plist \
138 -d contrib
/osx
/PrivoxyConfDesc.plist
140 ### Make Startup Script package
142 mkdir
-p $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
143 cp contrib
/osx
/Tor contrib
/osx
/StartupParameters.plist \
144 $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
146 find $BUILD_DIR/torstartup_packageroot
-print0 | sudo
xargs -0 chown root
:wheel
147 $PACKAGEMAKER -build \
148 -p $BUILD_DIR/output
/torstartup.pkg \
149 -f $BUILD_DIR/torstartup_packageroot \
150 -i contrib
/osx
/TorStartupInfo.plist \
151 -d contrib
/osx
/TorStartupDesc.plist
153 ### Assemble the metapackage. Packagemaker won't buld metapackages from
154 # the command line, so we need to do it by hand.
156 MPKG
=$BUILD_DIR/output
/Tor-
$VERSION-$OS-$ARCH-Bundle.mpkg
157 mkdir
-p "$MPKG/Contents/Resources"
158 echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
159 cp contrib
/osx
/ReadMe.rtf
"$MPKG/Contents/Resources"
160 #cp contrib/osx/License.rtf "$MPKG/Contents/Resources"
161 cp contrib
/osx
/TorBundleInfo.plist
"$MPKG/Contents/Info.plist"
162 cp contrib
/osx
/TorBundleWelcome.rtf
"$MPKG/Contents/Resources/Welcome.rtf"
163 cp contrib
/osx
/TorBundleDesc.plist
"$MPKG/Contents/Resources/Description.plist"
164 cp contrib
/osx
/tor_logo.gif
"$MPKG/Contents/Resources/background.gif"
166 # Move all the subpackages into place. unzip Privoxy.pkg into place,
167 # and fix its file permissions so we can rm -rf it later.
168 mkdir
$BUILD_DIR/output
/.contained_packages
169 mv $BUILD_DIR/output
/*.pkg
$BUILD_DIR/OUTPUT
/.contained_packages
170 ( cd $BUILD_DIR/output
/.contained_packages
&& unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg
-type d
-print0 |
xargs -0 chmod u
+w
)
172 ### Copy readmes and licenses into toplevel.
173 PRIVOXY_RESDIR
=$BUILD_DIR/output
/.contained_packages
/Privoxy.pkg
/Contents
/Resources
174 cp $PRIVOXY_RESDIR/License.html
$BUILD_DIR/output
/Privoxy\ License.html
175 cp $PRIVOXY_RESDIR/ReadMe.txt
$BUILD_DIR/output
/Privoxy\ ReadMe.txt
176 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/output
/Tor\ ReadMe.rtf
177 cp LICENSE
$BUILD_DIR/output
/Tor\ License.txt
179 ### Package it all into a DMG
181 find $BUILD_DIR/output
-print0 | sudo
xargs -0 chown root
:wheel
183 mv $BUILD_DIR/output
"$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle"
184 rm -f "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
186 sudo hdiutil create
-format UDZO
-srcfolder "$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
187 sudo chown
"$USER" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
189 sudo
rm -rf $BUILD_DIR