package.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. mkdir -p $BUILD_DIR/polipo_packageroot/Library/Polipo/
  43. cp polipo $BUILD_DIR/polipo_packageroot/polipo
  44. cp config.sample $BUILD_DIR/polipo_packageroot/config
  45. cp contrib/PolipoPostflight $BUILD_DIR/polipo_packageroot/postflight
  46. cp contrib/addsysuser $BUILD_DIR/polipo_packageroot/addsysuser
  47. cp contrib/uninstall_polipo_bundle.sh $BUILD_DIR/polipo_packageroot/uninstall_polipo_bundle.sh
  48. cp localindex.html $BUILD_DIR/polipo_packageroot/index.html
  49. cat <<EOF > $BUILD_DIR/polipo_packageroot/Welcome.txt
  50. Polipo: a caching web proxy
  51. Polipo is a small and fast caching web proxy (a web cache, an HTTP
  52. proxy, a proxy server).
  53. EOF
  54. ### Assemble documentation
  55. groff polipo.man -T ps -m man | pstopdf -i -o $BUILD_DIR/polipo_packageroot/polipo.pdf
  56. texi2html polipo.texi && cp polipo.html $BUILD_DIR/polipo_packageroot/polipo.html
  57. find $BUILD_DIR/polipo_packageroot -print0 |sudo xargs -0 chown root:wheel
  58. $PACKAGEMAKER -build \
  59. -p $BUILD_DIR/output/Polipo.pkg \
  60. -f $BUILD_DIR/polipo_packageroot \
  61. -i contrib/PolipoInfo.plist \
  62. -d contrib/PolipoDesc.plist
  63. ### Package it all into a DMG
  64. find $BUILD_DIR/output -print0 | sudo xargs -0 chown root:wheel
  65. mv $BUILD_DIR/output "$BUILD_DIR/Polipo-$VERSION-$OS-$ARCH"
  66. rm -f "Polipo-$VERSION-$OS-$ARCH-Bundle.dmg"
  67. USER="`whoami`"
  68. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Polipo-$VERSION-$OS-$ARCH" "Polipo-$VERSION-$OS-$ARCH.dmg"
  69. sudo chown "$USER" "Polipo-$VERSION-$OS-$ARCH.dmg"
  70. #sudo rm -rf $BUILD_DIR