package.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. ######################
  15. # The following steps are the exact steps used to produce the "official" OSX build of tor
  16. #
  17. # Summary:
  18. # 1) Compile and install the latest release of libevent
  19. # 2) Acquire privoxyosx_setup_3.0.3.zip. Remember where you put this file.
  20. # 3) Acquire and install your preferred version of tor via "make dist-osx"
  21. #
  22. # Details:
  23. # 1) You need to download the latest libevent from http://www.monkey.org/~provos/libevent/
  24. # 1a) At a shell prompt, export CFLAGS="-march=powerpc -mtune=powerpc"
  25. # 1b) The first step of compiling libevent is to configure it as follows:
  26. # configure --enable-static --disable-shared
  27. # 1c) Complete the "make" and "make install".
  28. # 2) Get your preferred version of the tor source from tor.eff.org
  29. # 2a) Edit /path/to/tor/contrib/osx/package.sh (the file you are reading) and confirm PRIVOXY_PKG_ZIP= is set
  30. # to the correct path to find the file privoxyosx_setup_3.0.3.zip
  31. # 2b) In the top level, this means /path/to/tor/, not tor/contrib/osx, do a configure with these parameters:
  32. # configure --prefix=/Library/Tor --bindir=/Library/Tor --sysconfdir=/Library
  33. # 2c) In same top level dir, do a "make dist-osx". You'll have a .dmg file when complete. Install from this dmg.
  34. # Where have we put the zip file containing Privoxy? Edit this if your
  35. # privoxy lives somewhere else.
  36. PRIVOXY_PKG_ZIP=~/tmp/privoxyosx_setup_3.0.3.zip
  37. ###
  38. # Helpful info on OS X packaging:
  39. # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
  40. # man packagemaker
  41. # Make sure VERSION is set, so we don't name the package "Tor Bundle.dmg"
  42. if [ "XX$VERSION" = 'XX' ]; then
  43. echo "VERSION not set."
  44. exit 1
  45. fi
  46. # Where will we put our temporary files?
  47. BUILD_DIR=/tmp/tor-osx-$$
  48. # Path to PackageMaker app.
  49. PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
  50. umask 022
  51. echo I might ask you for your password now, so you can sudo.
  52. sudo rm -rf $BUILD_DIR
  53. mkdir $BUILD_DIR || exit 1
  54. for subdir in tor_packageroot tor_resources \
  55. torstartup_packageroot \
  56. privoxyconf_packageroot \
  57. torbundle_resources \
  58. output; do
  59. mkdir $BUILD_DIR/$subdir
  60. done
  61. ### Make Tor package.
  62. make install DESTDIR=$BUILD_DIR/tor_packageroot
  63. #mv $BUILD_DIR/tor_packageroot/Library/Tor/torrc.sample $BUILD_DIR/tor_packageroot/Library/Tor/torrc
  64. cp contrib/osx/ReadMe.rtf $BUILD_DIR/tor_resources
  65. #cp contrib/osx/License.rtf $BUILD_DIR/tor_resources
  66. chmod 755 contrib/osx/TorPostflight
  67. cp contrib/osx/TorPostflight $BUILD_DIR/tor_resources/postflight
  68. cp contrib/osx/addsysuser $BUILD_DIR/tor_resources/addsysuser
  69. cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
  70. Tor: an anonymous Internet communication system
  71. Tor is a system for using the internet anonymously, and allowing
  72. others to do so.
  73. EOF
  74. find $BUILD_DIR/tor_packageroot -print0 |sudo xargs -0 chown root:wheel
  75. $PACKAGEMAKER -build \
  76. -p $BUILD_DIR/output/Tor.pkg \
  77. -f $BUILD_DIR/tor_packageroot \
  78. -r $BUILD_DIR/tor_resources \
  79. -i contrib/osx/TorInfo.plist \
  80. -d contrib/osx/TorDesc.plist
  81. ### Put privoxy configuration package in place.
  82. mkdir -p $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy
  83. cp contrib/osx/privoxy.config $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/config
  84. find $BUILD_DIR/privoxyconf_packageroot -print0 |sudo xargs -0 chown root:wheel
  85. $PACKAGEMAKER -build \
  86. -p $BUILD_DIR/output/privoxyconf.pkg \
  87. -f $BUILD_DIR/privoxyconf_packageroot \
  88. -i contrib/osx/PrivoxyConfInfo.plist \
  89. -d contrib/osx/PrivoxyConfDesc.plist
  90. ### Make Startup Script package
  91. mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  92. cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
  93. $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  94. find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
  95. $PACKAGEMAKER -build \
  96. -p $BUILD_DIR/output/torstartup.pkg \
  97. -f $BUILD_DIR/torstartup_packageroot \
  98. -i contrib/osx/TorStartupInfo.plist \
  99. -d contrib/osx/TorStartupDesc.plist
  100. ### Assemble the metapackage. Packagemaker won't buld metapackages from
  101. # the command line, so we need to do it by hand.
  102. MPKG=$BUILD_DIR/output/Tor\ Bundle.mpkg
  103. mkdir -p "$MPKG/Contents/Resources"
  104. echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
  105. cp contrib/osx/ReadMe.rtf "$MPKG/Contents/Resources"
  106. #cp contrib/osx/License.rtf "$MPKG/Contents/Resources"
  107. cp contrib/osx/TorBundleInfo.plist "$MPKG/Contents/Info.plist"
  108. cp contrib/osx/TorBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf"
  109. cp contrib/osx/TorBundleDesc.plist "$MPKG/Contents/Resources/Description.plist"
  110. # Move all the subpackages into place. unzip Privoxy.pkg into place,
  111. # and fix its file permissions so we can rm -rf it later.
  112. mkdir $BUILD_DIR/output/.contained_packages
  113. mv $BUILD_DIR/output/*.pkg $BUILD_DIR/OUTPUT/.contained_packages
  114. ( cd $BUILD_DIR/output/.contained_packages && unzip $PRIVOXY_PKG_ZIP && find Privoxy.pkg -type d -print0 | xargs -0 chmod u+w )
  115. ### Copy readmes and licenses into toplevel.
  116. PRIVOXY_RESDIR=$BUILD_DIR/output/.contained_packages/Privoxy.pkg/Contents/Resources
  117. cp $PRIVOXY_RESDIR/License.html $BUILD_DIR/output/Privoxy\ License.html
  118. cp $PRIVOXY_RESDIR/ReadMe.txt $BUILD_DIR/output/Privoxy\ ReadMe.txt
  119. cp contrib/osx/ReadMe.rtf $BUILD_DIR/output/Tor\ ReadMe.rtf
  120. cp LICENSE $BUILD_DIR/output/Tor\ License.txt
  121. ### Assemble documentation
  122. DOC=$BUILD_DIR/output/Documents
  123. mkdir $DOC
  124. cp doc/tor-doc.html doc/tor-doc.css $DOC
  125. cp AUTHORS $DOC/AUTHORS.txt
  126. groff doc/tor.1 -T ps -m man | pstopdf - $DOC/tor-reference.pdf
  127. groff doc/tor-resolve.1 -T ps -m man | pstopdf - $DOC/tor-resolve.pdf
  128. mkdir $DOC/Advanced
  129. cp doc/tor-spec.txt doc/rend-spec.txt doc/control-spec.txt doc/socks-extensions.txt doc/version-spec.txt $DOC/Advanced
  130. cp doc/HACKING $DOC/Advanced/HACKING.txt
  131. cp ChangeLog $DOC/Advanced/ChangeLog.txt
  132. ### Package it all into a DMG
  133. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  134. mv $BUILD_DIR/output "$BUILD_DIR/Tor $VERSION Bundle"
  135. rm -f "Tor $VERSION Bundle.dmg"
  136. USER="`whoami`"
  137. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Tor $VERSION Bundle" "Tor $VERSION Bundle.dmg"
  138. sudo chown "$USER" "Tor $VERSION Bundle.dmg"
  139. sudo rm -rf $BUILD_DIR