package.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. # Copyright 2004-2005 Nick Mathewson & Andrew Lewman.
  3. # Copyright 2005-2008 Andrew Lewman
  4. # This is licensed under the Modified BSD License.
  5. ###
  6. # Helpful info on OS X packaging:
  7. # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
  8. # man packagemaker
  9. VERSION="1.0.4"
  10. ## Determine OSX Version
  11. # map version to name
  12. if [ -x /usr/bin/sw_vers ]; then
  13. # This is poor, yet functional. We don't care about the 3rd number in
  14. # the OS version
  15. OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
  16. case "$OSVER" in
  17. "10.5") ARCH="universal";;
  18. "10.4") ARCH="universal";;
  19. "10.3") ARCH="ppc";;
  20. "10.2") ARCH="ppc";;
  21. "10.1") ARCH="ppc";;
  22. "10.0") ARCH="ppc";;
  23. *) ARCH="unknown";;
  24. esac
  25. else
  26. ARCH="unknown"
  27. fi
  28. # Where will we put our temporary files?
  29. BUILD_DIR=/tmp/polipo-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 polipo_packageroot output; do
  37. mkdir $BUILD_DIR/$subdir
  38. done
  39. ### Make Polipo package.
  40. chmod 755 contrib/PolipoPostflight
  41. mkdir -p $BUILD_DIR/polipo_packageroot/Library/Polipo/
  42. cp polipo $BUILD_DIR/polipo_packageroot/polipo
  43. cp config.sample $BUILD_DIR/polipo_packageroot/config
  44. cp contrib/PolipoPostflight $BUILD_DIR/polipo_packageroot/postflight
  45. cp contrib/addsysuser $BUILD_DIR/polipo_packageroot/addsysuser
  46. cp contrib/uninstall_polipo_bundle.sh $BUILD_DIR/polipo_packageroot/uninstall_polipo_bundle.sh
  47. cp localindex.html $BUILD_DIR/polipo_packageroot/index.html
  48. cat <<EOF > $BUILD_DIR/polipo_packageroot/Welcome.txt
  49. Polipo: a caching web proxy
  50. Polipo is a small and fast caching web proxy (a web cache, an HTTP
  51. proxy, a proxy server).
  52. EOF
  53. ### Assemble documentation
  54. groff polipo.man -T ps -m man | pstopdf -i -o $BUILD_DIR/polipo_packageroot/polipo.pdf
  55. texi2html polipo.texi && cp polipo.html $BUILD_DIR/polipo_packageroot/polipo.html
  56. find $BUILD_DIR/polipo_packageroot -print0 |sudo xargs -0 chown root:wheel
  57. $PACKAGEMAKER -build \
  58. -p $BUILD_DIR/output/Polipo.pkg \
  59. -f $BUILD_DIR/polipo_packageroot \
  60. -i contrib/PolipoInfo.plist \
  61. -d contrib/PolipoDesc.plist
  62. ### Package it all into a DMG
  63. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  64. mv $BUILD_DIR/output "$BUILD_DIR/Polipo-$VERSION-$ARCH"
  65. rm -f "Polipo-$VERSION-$ARCH-Bundle.dmg"
  66. USER="`whoami`"
  67. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Polipo-$VERSION-$ARCH" "Polipo-$VERSION-$ARCH.dmg"
  68. sudo chown "$USER" "Polipo-$VERSION-$ARCH.dmg"
  69. #sudo rm -rf $BUILD_DIR