build_osx_release.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # Generate an OSX universal binary (32+64b intel) DMG with Installer & DMG
  3. #
  4. # This script is supposed to be run from the aria2 source directory.
  5. # It has to be run on an OSX 10.6 host with Developer Tools installed.
  6. #
  7. # Additionally, Macports must be installed with the following packages:
  8. #
  9. # autoconf autoconf213 autogen +universal automake coreutils +universal
  10. # gettext +universal gmake +universal icu +universal
  11. # libgcrypt +universal libxml2 +universal m4 +universal
  12. # openssl +universal pkgconfig +universal c-ares +universal zlib +universal
  13. #
  14. # Author: renaud gaudin
  15. # path definitions.
  16. A2_VERSION=`cat config.h |grep "define VERSION" | cut -f 2 -d '"' -`
  17. CURRENT_DIR=`pwd`
  18. PACKAGE_ROOT=${CURRENT_DIR}/aria_build
  19. BUILD_TARGET=${PACKAGE_ROOT}/usr
  20. PACKAGE_RESOURCES=${CURRENT_DIR}/osx_resources
  21. TARGET_NAME=aria2-${A2_VERSION}
  22. PKG_NAME=${TARGET_NAME}.pkg
  23. DMG_NAME=${TARGET_NAME}.dmg
  24. UNINST_NAME="Uninstall aria2.applescript"
  25. DMG_SKEL=aria2_dmg
  26. # build aria2 mostly static
  27. mkdir -p $BUILD_TARGET
  28. export ZLIB_LIBS="/opt/local/lib/libz.a"
  29. export OPENSSL_LIBS="-L/usr/lib -lssl -L/usr/lib -lcrypto"
  30. export LIBCARES_LIBS="/opt/local/lib/libcares.a"
  31. export CPPFLAGS="-I/opt/local/include"
  32. export LDFLAGS="-static-libstdc++"
  33. export LIBS="/opt/local/lib/libintl.a /opt/local/lib/libcrypto.a /opt/local/lib/libiconv.a"
  34. CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch x86_64" CPP="gcc -E" CXXCPP="g++ -E" ./configure --without-libxml2 --without-gnutls --prefix=$BUILD_TARGET --without-libgcrypt --without-libnettle --without-libgmp --enable-bittorrent --enable-metalink --enable-epoll --with-libexpat --with-openssl
  35. make
  36. # install into our target
  37. make install
  38. # create pkg installer
  39. mkdir -p ${PACKAGE_RESOURCES}
  40. cp -av README.html ${PACKAGE_RESOURCES}/Welcome.html
  41. cp -av COPYING ${PACKAGE_RESOURCES}/License.txt
  42. cp -av NEWS ${PACKAGE_RESOURCES}/ReadMe.txt
  43. rm -rf ${PKG_NAME}
  44. /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker --root ${PACKAGE_ROOT} --id aria2 --version ${A2_VERSION} --title "aria2" --domain system --resources ${PACKAGE_RESOURCES} --out ${PKG_NAME}
  45. # create uninstaller tool
  46. DEL_STR=`find ${PACKAGE_ROOT}/ -type f | sed -e "s,$PACKAGE_ROOT,sudo rm -f ," | tr '\n' ' ; '`
  47. echo "(do shell script \"mkdir -p /var/db/sudo/$USER; touch /var/db/sudo/$USER\" with administrator privileges) & (do shell script \"${DEL_STR}\")" > "$UNINST_NAME"
  48. # create dmg with installer and uninstall inside
  49. rm -rf ${DMG_SKEL}
  50. mkdir -p ${DMG_SKEL}
  51. cp -av ${PKG_NAME} ${DMG_SKEL}/
  52. cp -av "${UNINST_NAME}" ${DMG_SKEL}/
  53. rm -f ${DMG_NAME}
  54. hdiutil create -megabytes 20 -fs HFS+ -volname aria2 -nospotlight -srcfolder ${DMG_SKEL} ${DMG_NAME}