package.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. # $Id: package.sh 8992 2006-12-23 03:12:09Z phobos $
  3. # Copyright 2004-2005 Nick Mathewson & Andrew Lewman.
  4. # Copyright 2005-2007 Andrew Lewman
  5. # See LICENSE in Polipo distribution for licensing information.
  6. ###
  7. # Helpful info on OS X packaging:
  8. # http://developer.apple.com/documentation/DeveloperTools/Conceptual/SoftwareDistribution/index.html
  9. # man packagemaker
  10. VERSION="1.0.3"
  11. ## Determine OSX Version
  12. # map version to name
  13. if [ -x /usr/bin/sw_vers ]; then
  14. # This is poor, yet functional. We don't care about the 3rd number in
  15. # the OS version
  16. OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
  17. case "$OSVER" in
  18. "10.5") OS="leopard" ARCH="universal";;
  19. "10.4") OS="tiger" ARCH="universal";;
  20. "10.3") OS="panther" ARCH="ppc";;
  21. "10.2") OS="jaguar" ARCH="ppc";;
  22. "10.1") OS="puma" ARCH="ppc";;
  23. "10.0") OS="cheetah" ARCH="ppc";;
  24. *) OS="unknown";;
  25. esac
  26. else
  27. OS="unknown"
  28. fi
  29. # Where will we put our temporary files?
  30. BUILD_DIR=/tmp/polipo-osx-$$
  31. # Path to PackageMaker app.
  32. PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
  33. umask 022
  34. echo I might ask you for your password now, so you can sudo.
  35. sudo rm -rf $BUILD_DIR
  36. mkdir $BUILD_DIR || exit 1
  37. for subdir in polipo_packageroot output; do
  38. mkdir $BUILD_DIR/$subdir
  39. done
  40. ### Make Polipo package.
  41. chmod 755 contrib/PolipoPostflight
  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-$OS-$ARCH"
  65. rm -f "Polipo-$VERSION-$OS-$ARCH-Bundle.dmg"
  66. USER="`whoami`"
  67. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Polipo-$VERSION-$OS-$ARCH" "Polipo-$VERSION-$OS-$ARCH.dmg"
  68. sudo chown "$USER" "Polipo-$VERSION-$OS-$ARCH.dmg"
  69. #sudo rm -rf $BUILD_DIR