3 # Copyright 2004-2005 Nick Mathewson.
4 # Copyright 2005-2007 Andrew Lewman
5 # Copyright 2008 The Tor Project, Inc.
6 # See LICENSE in Tor distribution for licensing information.
8 # This script builds a Macintosh OS X metapackage containing 2 packages:
10 # - One for Startup script 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
20 # Helpful info on OS X packaging:
21 # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
24 # Make sure VERSION is set, so we don't name the package
25 # "Tor--$ARCH-Bundle.dmg"
26 if [ "XX$VERSION" = 'XX' ]; then
27 echo "VERSION not set."
31 ## Determine OSX Version
33 if [ -x /usr
/bin
/sw_vers
]; then
34 # This is poor, yet functional. We don't care about the 3rd number in
36 OSVER
=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
38 "10.6") ARCH
="universal";;
39 "10.5") ARCH
="universal";;
40 "10.4") ARCH
="universal";;
51 # Where will we put our temporary files?
52 BUILD_DIR
=/tmp
/tor-osx-$$
53 # Path to PackageMaker app.
54 PACKAGEMAKER
=/Developer
/Applications
/Utilities
/PackageMaker.app
/Contents
/MacOS
/PackageMaker
58 echo I might ask you
for your password now
, so you can sudo.
60 sudo
rm -rf $BUILD_DIR
61 mkdir
$BUILD_DIR ||
exit 1
62 for subdir
in tor_packageroot tor_resources \
63 torstartup_packageroot \
66 mkdir
$BUILD_DIR/$subdir
71 make install DESTDIR
=$BUILD_DIR/tor_packageroot
72 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/tor_resources
73 chmod 755 contrib
/osx
/TorPostflight
74 cp contrib
/osx
/TorPostflight
$BUILD_DIR/tor_resources
/postflight
75 cp contrib
/osx
/addsysuser
$BUILD_DIR/tor_resources
/addsysuser
76 cp contrib
/osx
/Tor_Uninstaller.applescript
$BUILD_DIR/tor_resources
/Tor_Uninstaller.applescript
77 cp contrib
/osx
/uninstall_tor_bundle.sh
$BUILD_DIR/tor_resources
/uninstall_tor_bundle.sh
78 cp contrib
/osx
/package_list.txt
$BUILD_DIR/tor_resources
/package_list.txt
79 cp contrib
/osx
/tor_logo.gif
$BUILD_DIR/tor_resources
/background.gif
80 cp src
/config
/geoip
$BUILD_DIR/tor_resources
/geoip
81 cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
82 Tor: an anonymous Internet communication system
84 Tor is a system for using the internet anonymously, and allowing
88 ### Assemble documentation
90 DOC
=$BUILD_DIR/tor_resources
/documents
93 cp AUTHORS
$DOC/AUTHORS.txt
94 groff doc
/tor
.1.
in -T ps
-m man | pstopdf
-i -o $DOC/tor-reference.pdf
95 groff doc
/tor-resolve
.1 -T ps
-m man | pstopdf
-i -o $DOC/tor-resolve.pdf
97 cp doc
/spec
/*.txt
$DOC/Advanced
98 cp doc
/HACKING
$DOC/Advanced
/HACKING.txt
99 cp ChangeLog
$DOC/Advanced
/ChangeLog.txt
101 find $BUILD_DIR/tor_packageroot
-print0 |sudo
xargs -0 chown root
:wheel
103 $PACKAGEMAKER -build \
104 -p $BUILD_DIR/output
/Tor.pkg \
105 -f $BUILD_DIR/tor_packageroot \
106 -r $BUILD_DIR/tor_resources \
107 -i contrib
/osx
/TorInfo.plist \
108 -d contrib
/osx
/TorDesc.plist
110 ### Make Startup Script package
112 mkdir
-p $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
113 cp contrib
/osx
/Tor contrib
/osx
/StartupParameters.plist \
114 $BUILD_DIR/torstartup_packageroot
/Library
/StartupItems
/Tor
116 find $BUILD_DIR/torstartup_packageroot
-print0 | sudo
xargs -0 chown root
:wheel
118 $PACKAGEMAKER -build \
119 -p $BUILD_DIR/output
/torstartup.pkg \
120 -f $BUILD_DIR/torstartup_packageroot \
121 -i contrib
/osx
/TorStartupInfo.plist \
122 -d contrib
/osx
/TorStartupDesc.plist
124 ### Assemble the metapackage. Packagemaker won't buld metapackages from
125 # the command line, so we need to do it by hand.
127 MPKG
=$BUILD_DIR/output
/Tor-
$VERSION-$ARCH-Bundle.mpkg
128 mkdir
-p "$MPKG/Contents/Resources"
129 echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
130 cp contrib
/osx
/ReadMe.rtf
"$MPKG/Contents/Resources"
131 cp contrib
/osx
/TorBundleInfo.plist
"$MPKG/Contents/Info.plist"
132 cp contrib
/osx
/TorBundleWelcome.rtf
"$MPKG/Contents/Resources/Welcome.rtf"
133 cp contrib
/osx
/TorBundleDesc.plist
"$MPKG/Contents/Resources/Description.plist"
134 cp contrib
/osx
/tor_logo.gif
"$MPKG/Contents/Resources/background.gif"
136 # Move all the subpackages into place.
137 mkdir
$BUILD_DIR/output
/.contained_packages
138 mv $BUILD_DIR/output
/*.pkg
$BUILD_DIR/OUTPUT
/.contained_packages
139 ( cd $BUILD_DIR/output
/.contained_packages
)
141 ### Copy readmes and licenses into toplevel.
142 cp contrib
/osx
/ReadMe.rtf
$BUILD_DIR/output
/Tor\ ReadMe.rtf
143 cp LICENSE
$BUILD_DIR/output
/Tor\ License.txt
145 ### Package it all into a DMG
147 find $BUILD_DIR/output
-print0 | sudo
xargs -0 chown root
:wheel
149 mv $BUILD_DIR/output
"$BUILD_DIR/Tor-$VERSION-$ARCH-Bundle"
150 rm -f "Tor-$VERSION-$ARCH-Bundle.dmg"
152 sudo hdiutil create
-format UDZO
-imagekey zlib-level
=9 -srcfolder "$BUILD_DIR/Tor-$VERSION-$ARCH-Bundle" "Tor-$VERSION-$ARCH-Bundle.dmg"
153 sudo chown
"$USER" "Tor-$VERSION-$ARCH-Bundle.dmg"
155 sudo
rm -rf $BUILD_DIR