package.sh 7.8 KB

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