package.sh 5.5 KB

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