package.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 "Tor Bundle.dmg"
  24. if [ "XX$VERSION" = 'XX' ]; then
  25. echo "VERSION not set."
  26. exit 1
  27. fi
  28. # Where will we put our temporary files?
  29. BUILD_DIR=/tmp/tor-osx-$$
  30. # Path to PackageMaker app.
  31. PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
  32. umask 022
  33. echo I might ask you for your password now, so you can sudo.
  34. sudo rm -rf $BUILD_DIR
  35. mkdir $BUILD_DIR || exit 1
  36. for subdir in tor_packageroot tor_resources \
  37. torstartup_packageroot \
  38. privoxyconf_packageroot \
  39. torbundle_resources \
  40. output; do
  41. mkdir $BUILD_DIR/$subdir
  42. done
  43. ### Make Tor package.
  44. make install DESTDIR=$BUILD_DIR/tor_packageroot
  45. #mv $BUILD_DIR/tor_packageroot/Library/Tor/torrc.sample $BUILD_DIR/tor_packageroot/Library/Tor/torrc
  46. cp contrib/osx/ReadMe.rtf $BUILD_DIR/tor_resources
  47. #cp contrib/osx/License.rtf $BUILD_DIR/tor_resources
  48. chmod 755 contrib/osx/TorPostflight
  49. cp contrib/osx/TorPostflight $BUILD_DIR/tor_resources/postflight
  50. cp contrib/osx/addsysuser $BUILD_DIR/tor_resources/addsysuser
  51. cp contrib/osx/Tor_Uninstaller.applescript $BUILD_DIR/tor_resources/Tor_Uninstaller.applescript
  52. cp contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/uninstall_tor_bundle.sh
  53. cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
  54. Tor: an anonymous Internet communication system
  55. Tor is a system for using the internet anonymously, and allowing
  56. others to do so.
  57. EOF
  58. find $BUILD_DIR/tor_packageroot -print0 |sudo xargs -0 chown root:wheel
  59. $PACKAGEMAKER -build \
  60. -p $BUILD_DIR/output/Tor.pkg \
  61. -f $BUILD_DIR/tor_packageroot \
  62. -r $BUILD_DIR/tor_resources \
  63. -i contrib/osx/TorInfo.plist \
  64. -d contrib/osx/TorDesc.plist
  65. ### Put privoxy configuration package in place.
  66. mkdir -p $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy
  67. cp contrib/osx/privoxy.config $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/config
  68. find $BUILD_DIR/privoxyconf_packageroot -print0 |sudo xargs -0 chown root:wheel
  69. $PACKAGEMAKER -build \
  70. -p $BUILD_DIR/output/privoxyconf.pkg \
  71. -f $BUILD_DIR/privoxyconf_packageroot \
  72. -i contrib/osx/PrivoxyConfInfo.plist \
  73. -d contrib/osx/PrivoxyConfDesc.plist
  74. ### Make Startup Script package
  75. mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  76. cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
  77. $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  78. find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
  79. $PACKAGEMAKER -build \
  80. -p $BUILD_DIR/output/torstartup.pkg \
  81. -f $BUILD_DIR/torstartup_packageroot \
  82. -i contrib/osx/TorStartupInfo.plist \
  83. -d contrib/osx/TorStartupDesc.plist
  84. ### Assemble the metapackage. Packagemaker won't buld metapackages from
  85. # the command line, so we need to do it by hand.
  86. MPKG=$BUILD_DIR/output/Tor\ Bundle.mpkg
  87. mkdir -p "$MPKG/Contents/Resources"
  88. echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
  89. cp contrib/osx/ReadMe.rtf "$MPKG/Contents/Resources"
  90. #cp contrib/osx/License.rtf "$MPKG/Contents/Resources"
  91. cp contrib/osx/TorBundleInfo.plist "$MPKG/Contents/Info.plist"
  92. cp contrib/osx/TorBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf"
  93. cp contrib/osx/TorBundleDesc.plist "$MPKG/Contents/Resources/Description.plist"
  94. # Move all the subpackages into place. unzip Privoxy.pkg into place,
  95. # and fix its file permissions so we can rm -rf it later.
  96. mkdir $BUILD_DIR/output/.contained_packages
  97. mv $BUILD_DIR/output/*.pkg $BUILD_DIR/OUTPUT/.contained_packages
  98. ( cd $BUILD_DIR/output/.contained_packages && unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg -type d -print0 | xargs -0 chmod u+w )
  99. ### Copy readmes and licenses into toplevel.
  100. PRIVOXY_RESDIR=$BUILD_DIR/output/.contained_packages/Privoxy.pkg/Contents/Resources
  101. cp $PRIVOXY_RESDIR/License.html $BUILD_DIR/output/Privoxy\ License.html
  102. cp $PRIVOXY_RESDIR/ReadMe.txt $BUILD_DIR/output/Privoxy\ ReadMe.txt
  103. cp contrib/osx/ReadMe.rtf $BUILD_DIR/output/Tor\ ReadMe.rtf
  104. cp LICENSE $BUILD_DIR/output/Tor\ License.txt
  105. ### Assemble documentation
  106. DOC=$BUILD_DIR/output/Documents
  107. mkdir $DOC
  108. cp doc/tor-doc.html doc/tor-doc.css $DOC
  109. cp AUTHORS $DOC/AUTHORS.txt
  110. groff doc/tor.1 -T ps -m man | pstopdf - $DOC/tor-reference.pdf
  111. groff doc/tor-resolve.1 -T ps -m man | pstopdf - $DOC/tor-resolve.pdf
  112. mkdir $DOC/Advanced
  113. cp doc/tor-spec.txt doc/rend-spec.txt doc/control-spec.txt doc/socks-extensions.txt doc/version-spec.txt $DOC/Advanced
  114. cp doc/HACKING $DOC/Advanced/HACKING.txt
  115. cp ChangeLog $DOC/Advanced/ChangeLog.txt
  116. ### Package it all into a DMG
  117. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  118. mv $BUILD_DIR/output "$BUILD_DIR/Tor $VERSION Bundle"
  119. rm -f "Tor $VERSION Bundle.dmg"
  120. USER="`whoami`"
  121. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Tor $VERSION Bundle" "Tor $VERSION Bundle.dmg"
  122. sudo chown "$USER" "Tor $VERSION Bundle.dmg"
  123. sudo rm -rf $BUILD_DIR