package.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.6") ARCH="i386";;
  18. "10.5") ARCH="i386";;
  19. "10.4") ARCH="i386";;
  20. "10.3") ARCH="ppc";;
  21. "10.2") ARCH="ppc";;
  22. "10.1") ARCH="ppc";;
  23. "10.0") ARCH="ppc";;
  24. *) ARCH="unknown";;
  25. esac
  26. else
  27. ARCH="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 | /usr/bin/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. sudo mv $BUILD_DIR/output "$BUILD_DIR/Polipo-$VERSION-$ARCH"
  66. sudo rm -f "Polipo-$VERSION-$ARCH-Bundle.dmg"
  67. USER="`whoami`"
  68. sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/Polipo-$VERSION-$ARCH" "Polipo-$VERSION-$ARCH.dmg"
  69. sudo chown "$USER" "Polipo-$VERSION-$ARCH.dmg"
  70. #sudo rm -rf $BUILD_DIR