package.sh 6.9 KB

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