package.sh 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #!/bin/sh
  2. # $Id$
  3. # Copyright 2004-2005 Nick Mathewson.
  4. # Copyright 2005-2007 Andrew Lewman
  5. # 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
  12. #
  13. # This script expects to be run from the toplevel makefile, with VERSION
  14. # set to the latest Tor version, and Tor already built.
  15. #
  16. # Read the documentation located in tor/doc/tor-osx-dmg-creation.txt on
  17. # how to build Tor for OSX
  18. # Where have we put the zip file containing Privoxy? Edit this if your
  19. # privoxy lives somewhere else.
  20. PRIVOXY_PKG_ZIP=~/tmp/privoxyosx_setup_3.0.6.zip
  21. # Where have we put the xpi and license for Torbutton? Edit this if your
  22. # torbutton and torbutton license live somewhere else.
  23. TORBUTTON_PATH=~/tmp/torbutton-1.2.0rc1.xpi
  24. TORBUTTON_LIC_PATH=~/tmp/LICENSE
  25. ###
  26. # Helpful info on OS X packaging:
  27. # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
  28. # man packagemaker
  29. # Make sure VERSION is set, so we don't name the package
  30. # "Tor--$OS-$ARCH-Bundle.dmg"
  31. if [ "XX$VERSION" = 'XX' ]; then
  32. echo "VERSION not set."
  33. exit 1
  34. fi
  35. ## Determine OSX Version
  36. # map version to name
  37. if [ -x /usr/bin/sw_vers ]; then
  38. # This is poor, yet functional. We don't care about the 3rd number in
  39. # the OS version
  40. OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
  41. case "$OSVER" in
  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";;
  48. *) OS="unknown";;
  49. esac
  50. else
  51. OS="unknown"
  52. fi
  53. # Where will we put our temporary files?
  54. BUILD_DIR=/tmp/tor-osx-$$
  55. # Path to PackageMaker app.
  56. PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
  57. umask 022
  58. echo I might ask you for your password now, so you can sudo.
  59. sudo rm -rf $BUILD_DIR
  60. mkdir $BUILD_DIR || exit 1
  61. for subdir in tor_packageroot tor_resources \
  62. torstartup_packageroot \
  63. privoxyconf_packageroot \
  64. torbundle_resources \
  65. torbutton_packageroot \
  66. output; do
  67. mkdir $BUILD_DIR/$subdir
  68. done
  69. ### Make Tor package.
  70. make install DESTDIR=$BUILD_DIR/tor_packageroot
  71. cp contrib/osx/ReadMe.rtf $BUILD_DIR/tor_resources
  72. chmod 755 contrib/osx/TorPostflight
  73. cp contrib/osx/TorPostflight $BUILD_DIR/tor_resources/postflight
  74. cp contrib/osx/addsysuser $BUILD_DIR/tor_resources/addsysuser
  75. cp contrib/osx/Tor_Uninstaller.applescript $BUILD_DIR/tor_resources/Tor_Uninstaller.applescript
  76. cp contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/uninstall_tor_bundle.sh
  77. cp contrib/osx/package_list.txt $BUILD_DIR/tor_resources/package_list.txt
  78. cp contrib/osx/tor_logo.gif $BUILD_DIR/tor_resources/background.gif
  79. cp src/config/geoip $BUILD_DIR/tor_resources/geoip
  80. cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
  81. Tor: an anonymous Internet communication system
  82. Tor is a system for using the internet anonymously, and allowing
  83. others to do so.
  84. EOF
  85. ### Assemble documentation
  86. DOC=$BUILD_DIR/tor_resources/documents
  87. mkdir $DOC
  88. mkdir $DOC/howto
  89. cp AUTHORS $DOC/AUTHORS.txt
  90. groff doc/tor.1.in -T ps -m man | pstopdf -i -o $DOC/tor-reference.pdf
  91. groff doc/tor-resolve.1 -T ps -m man | pstopdf -i -o $DOC/tor-resolve.pdf
  92. mkdir $DOC/Advanced
  93. cp doc/spec/tor-spec.txt \
  94. doc/spec/rend-spec.txt \
  95. doc/spec/control-spec.txt \
  96. doc/spec/socks-extensions.txt \
  97. doc/spec/version-spec.txt \
  98. doc/spec/address-spec.txt \
  99. doc/spec/path-spec.txt \
  100. $DOC/Advanced
  101. cp doc/HACKING $DOC/Advanced/HACKING.txt
  102. cp ChangeLog $DOC/Advanced/ChangeLog.txt
  103. find $BUILD_DIR/tor_packageroot -print0 |sudo xargs -0 chown root:wheel
  104. $PACKAGEMAKER -build \
  105. -p $BUILD_DIR/output/Tor.pkg \
  106. -f $BUILD_DIR/tor_packageroot \
  107. -r $BUILD_DIR/tor_resources \
  108. -i contrib/osx/TorInfo.plist \
  109. -d contrib/osx/TorDesc.plist
  110. ### Put privoxy configuration package in place.
  111. mkdir -p $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy
  112. cp contrib/osx/privoxy.config $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/config
  113. find $BUILD_DIR/privoxyconf_packageroot -print0 |sudo xargs -0 chown root:wheel
  114. $PACKAGEMAKER -build \
  115. -p $BUILD_DIR/output/privoxyconf.pkg \
  116. -f $BUILD_DIR/privoxyconf_packageroot \
  117. -i contrib/osx/PrivoxyConfInfo.plist \
  118. -d contrib/osx/PrivoxyConfDesc.plist
  119. ### Make Startup Script package
  120. mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  121. cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
  122. $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  123. find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
  124. $PACKAGEMAKER -build \
  125. -p $BUILD_DIR/output/torstartup.pkg \
  126. -f $BUILD_DIR/torstartup_packageroot \
  127. -i contrib/osx/TorStartupInfo.plist \
  128. -d contrib/osx/TorStartupDesc.plist
  129. ### Make Torbutton Installation package
  130. mkdir -p $BUILD_DIR/torbutton_packageroot/Library/Torbutton
  131. cp $TORBUTTON_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/
  132. cp $TORBUTTON_LIC_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/Torbutton-LICENSE.txt
  133. find $BUILD_DIR/torbutton_packageroot -print0 | sudo xargs -0 chown root:wheel
  134. $PACKAGEMAKER -build \
  135. -p $BUILD_DIR/output/torbutton.pkg \
  136. -f $BUILD_DIR/torbutton_packageroot \
  137. -i contrib/osx/TorbuttonInfo.plist \
  138. -d contrib/osx/TorbuttonDesc.plist
  139. ### Assemble the metapackage. Packagemaker won't buld metapackages from
  140. # the command line, so we need to do it by hand.
  141. MPKG=$BUILD_DIR/output/Tor-$VERSION-$OS-$ARCH-Bundle.mpkg
  142. mkdir -p "$MPKG/Contents/Resources"
  143. echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
  144. cp contrib/osx/ReadMe.rtf "$MPKG/Contents/Resources"
  145. cp contrib/osx/TorBundleInfo.plist "$MPKG/Contents/Info.plist"
  146. cp contrib/osx/TorBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf"
  147. cp contrib/osx/TorBundleDesc.plist "$MPKG/Contents/Resources/Description.plist"
  148. cp contrib/osx/tor_logo.gif "$MPKG/Contents/Resources/background.gif"
  149. # Move all the subpackages into place. unzip Privoxy.pkg into place,
  150. # and fix its file permissions so we can rm -rf it later.
  151. mkdir $BUILD_DIR/output/.contained_packages
  152. mv $BUILD_DIR/output/*.pkg $BUILD_DIR/OUTPUT/.contained_packages
  153. ( cd $BUILD_DIR/output/.contained_packages && unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg -type d -print0 | xargs -0 chmod u+w )
  154. ### Copy readmes and licenses into toplevel.
  155. PRIVOXY_RESDIR=$BUILD_DIR/output/.contained_packages/Privoxy.pkg/Contents/Resources
  156. cp $PRIVOXY_RESDIR/License.html $BUILD_DIR/output/Privoxy\ License.html
  157. cp $PRIVOXY_RESDIR/ReadMe.txt $BUILD_DIR/output/Privoxy\ ReadMe.txt
  158. cp contrib/osx/ReadMe.rtf $BUILD_DIR/output/Tor\ ReadMe.rtf
  159. cp LICENSE $BUILD_DIR/output/Tor\ License.txt
  160. cp $TORBUTTON_LIC_PATH $BUILD_DIR/output/Torbutton_LICENSE.txt
  161. ### Package it all into a DMG
  162. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  163. mv $BUILD_DIR/output "$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle"
  164. rm -f "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
  165. USER="`whoami`"
  166. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Tor-$VERSION-$OS-$ARCH-Bundle" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
  167. sudo chown "$USER" "Tor-$VERSION-$OS-$ARCH-Bundle.dmg"
  168. sudo rm -rf $BUILD_DIR