package.sh
上传用户:awang829
上传日期:2019-07-14
资源大小:2356k
文件大小:5k
源码类别:

网络

开发平台:

Unix_Linux

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