package.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/sh
  2. # Copyright 2004-2005 Nick Mathewson.
  3. # Copyright 2005-2007 Andrew Lewman
  4. # Copyright 2008 The Tor Project, Inc.
  5. # See LICENSE in Tor distribution for licensing information.
  6. # This script builds a Macintosh OS X metapackage containing 2 packages:
  7. # - One for Tor.
  8. # - One for Startup script for Tor.
  9. #
  10. # This script expects to be run from the toplevel makefile, with VERSION
  11. # set to the latest Tor version, and Tor already built.
  12. #
  13. # Read the documentation located in tor/doc/tor-osx-dmg-creation.txt on
  14. # how to build Tor for OSX
  15. ###
  16. # Helpful info on OS X packaging:
  17. # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
  18. # man packagemaker
  19. # Make sure VERSION is set, so we don't name the package
  20. # "Tor--$ARCH-Bundle.dmg"
  21. if [ "XX$VERSION" = 'XX' ]; then
  22. echo "VERSION not set."
  23. exit 1
  24. fi
  25. ## Determine OSX Version
  26. # map version to name
  27. if [ -x /usr/bin/sw_vers ]; then
  28. # This is poor, yet functional. We don't care about the 3rd number in
  29. # the OS version
  30. OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
  31. case "$OSVER" in
  32. "10.6") ARCH="i386";;
  33. "10.5") ARCH="i386";;
  34. "10.4") ARCH="i386";;
  35. "10.3") ARCH="ppc";;
  36. "10.2") ARCH="ppc";;
  37. "10.1") ARCH="ppc";;
  38. "10.0") ARCH="ppc";;
  39. *) ARCH="unknown";;
  40. esac
  41. else
  42. ARCH="unknown"
  43. fi
  44. # Where will we put our temporary files?
  45. BUILD_DIR=/tmp/tor-osx-$$
  46. # Path to PackageMaker app.
  47. PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
  48. umask 022
  49. echo I might ask you for your password now, so you can sudo.
  50. sudo rm -rf $BUILD_DIR
  51. mkdir $BUILD_DIR || exit 1
  52. for subdir in tor_packageroot tor_resources \
  53. torstartup_packageroot \
  54. torbundle_resources \
  55. output; do
  56. mkdir $BUILD_DIR/$subdir
  57. done
  58. ### Make Tor package.
  59. make install DESTDIR=$BUILD_DIR/tor_packageroot
  60. cp contrib/osx/ReadMe.rtf $BUILD_DIR/tor_resources
  61. chmod 755 contrib/osx/TorPostflight
  62. cp contrib/osx/TorPostflight $BUILD_DIR/tor_resources/postflight
  63. cp contrib/osx/addsysuser $BUILD_DIR/tor_resources/addsysuser
  64. cp contrib/osx/Tor_Uninstaller.applescript $BUILD_DIR/tor_resources/Tor_Uninstaller.applescript
  65. cp contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/uninstall_tor_bundle.sh
  66. cp contrib/osx/package_list.txt $BUILD_DIR/tor_resources/package_list.txt
  67. cp contrib/osx/tor_logo.gif $BUILD_DIR/tor_resources/background.gif
  68. cp src/config/geoip $BUILD_DIR/tor_resources/geoip
  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. ### Assemble documentation
  75. DOC=$BUILD_DIR/tor_resources/documents
  76. mkdir $DOC
  77. mkdir $DOC/howto
  78. cp AUTHORS $DOC/AUTHORS.txt
  79. groff doc/tor.1.in -T ps -m man | pstopdf -i -o $DOC/tor-reference.pdf
  80. groff doc/tor-resolve.1 -T ps -m man | pstopdf -i -o $DOC/tor-resolve.pdf
  81. mkdir $DOC/Advanced
  82. cp doc/spec/*.txt $DOC/Advanced
  83. cp doc/HACKING $DOC/Advanced/HACKING.txt
  84. cp ChangeLog $DOC/Advanced/ChangeLog.txt
  85. find $BUILD_DIR/tor_packageroot -print0 |sudo xargs -0 chown root:wheel
  86. $PACKAGEMAKER -build \
  87. -p $BUILD_DIR/output/Tor.pkg \
  88. -f $BUILD_DIR/tor_packageroot \
  89. -r $BUILD_DIR/tor_resources \
  90. -i contrib/osx/TorInfo.plist \
  91. -d contrib/osx/TorDesc.plist
  92. ### Make Startup Script package
  93. mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  94. cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
  95. $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
  96. find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
  97. $PACKAGEMAKER -build \
  98. -p $BUILD_DIR/output/torstartup.pkg \
  99. -f $BUILD_DIR/torstartup_packageroot \
  100. -i contrib/osx/TorStartupInfo.plist \
  101. -d contrib/osx/TorStartupDesc.plist
  102. ### Assemble the metapackage. Packagemaker won't buld metapackages from
  103. # the command line, so we need to do it by hand.
  104. MPKG=$BUILD_DIR/output/Tor-$VERSION-$ARCH-Bundle.mpkg
  105. mkdir -p "$MPKG/Contents/Resources"
  106. echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo"
  107. cp contrib/osx/ReadMe.rtf "$MPKG/Contents/Resources"
  108. cp contrib/osx/TorBundleInfo.plist "$MPKG/Contents/Info.plist"
  109. cp contrib/osx/TorBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf"
  110. cp contrib/osx/TorBundleDesc.plist "$MPKG/Contents/Resources/Description.plist"
  111. cp contrib/osx/tor_logo.gif "$MPKG/Contents/Resources/background.gif"
  112. # Move all the subpackages into place.
  113. mkdir $BUILD_DIR/output/.contained_packages
  114. mv $BUILD_DIR/output/*.pkg $BUILD_DIR/OUTPUT/.contained_packages
  115. ( cd $BUILD_DIR/output/.contained_packages )
  116. ### Copy readmes and licenses into toplevel.
  117. cp contrib/osx/ReadMe.rtf $BUILD_DIR/output/Tor\ ReadMe.rtf
  118. cp LICENSE $BUILD_DIR/output/Tor\ License.txt
  119. ### Package it all into a DMG
  120. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  121. mv $BUILD_DIR/output "$BUILD_DIR/Tor-$VERSION-$ARCH-Bundle"
  122. rm -f "Tor-$VERSION-$ARCH-Bundle.dmg"
  123. USER="`whoami`"
  124. sudo hdiutil create -format UDZO -imagekey zlib-level=9 -srcfolder "$BUILD_DIR/Tor-$VERSION-$ARCH-Bundle" "Tor-$VERSION-$ARCH-Bundle.dmg"
  125. sudo chown "$USER" "Tor-$VERSION-$ARCH-Bundle.dmg"
  126. sudo rm -rf $BUILD_DIR