buildinstaller.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # This script builds the installer for *nix systems. Windows must do everything
  3. # completely differently, as usual.
  4. if [ ! -f zerotier-one ]; then
  5. echo "Could not find 'zerotier-one' binary, please build before running this script."
  6. exit 2
  7. fi
  8. make -j 2 file2lz4c
  9. if [ ! -f file2lz4c ]; then
  10. echo "Build of file2lz4c utility failed, aborting installer build."
  11. exit 2
  12. fi
  13. machine=`uname -m`
  14. system=`uname -s`
  15. vmajor=`cat version.h | grep -F ZEROTIER_ONE_VERSION_MAJOR | cut -d ' ' -f 3`
  16. vminor=`cat version.h | grep -F ZEROTIER_ONE_VERSION_MINOR | cut -d ' ' -f 3`
  17. revision=`cat version.h | grep -F ZEROTIER_ONE_VERSION_REVISION | cut -d ' ' -f 3`
  18. if [ -z "$vmajor" -o -z "$vminor" -o -z "$revision" ]; then
  19. echo "Unable to extract version info from version.h, aborting installer build."
  20. exit 2
  21. fi
  22. echo "Packaging common files: zerotier-one"
  23. rm -rf installer-build
  24. mkdir installer-build
  25. ./file2lz4c zerotier-one zerotier_one >installer-build/zerotier_one.h
  26. case "$system" in
  27. Linux)
  28. # Canonicalize $machine for some architectures... we use x86
  29. # and x64 for Intel stuff. ARM and others should be fine if
  30. # we ever ship officially for those.
  31. case "$machine" in
  32. i386|i486|i586|i686)
  33. machine="x86"
  34. ;;
  35. x86_64|amd64|x64)
  36. machine="x64"
  37. ;;
  38. *)
  39. echo "Unsupported machine type: $machine"
  40. exit 2
  41. esac
  42. echo "Assembling Linux installer for $machine and ZT1 version $vmajor.$vminor.$revision"
  43. ./file2lz4c ext/installfiles/linux/uninstall.sh uninstall_sh >installer-build/uninstall_sh.h
  44. ./file2lz4c ext/installfiles/linux/init.d/zerotier-one linux__init_d__zerotier_one >installer-build/linux__init_d__zerotier_one.h
  45. g++ -Os -o "zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install" installer.cpp ext/lz4/lz4.o ext/lz4/lz4hc.o
  46. ls -l zt1-*-install
  47. ;;
  48. Darwin)
  49. echo "Assembling OSX installer for x86/x64 (combined) and ZT1 version $vmajor.$vminor.$revision"
  50. ./file2lz4c ext/installfiles/linux/uninstall.sh uninstall_sh >installer-build/uninstall_sh.h
  51. ./file2lz4c ext/bin/tap-mac/tap.kext/Contents/Info.plist tap_mac__Info_plist >installer-build/tap_mac__Info_plist.h
  52. ./file2lz4c ext/bin/tap-mac/tap.kext/Contents/MacOS/tap tap_mac__tap >installer-build/tap_mac__tap.h
  53. g++ -Os -arch i386 -o "zt1-${vmajor}_${vminor}_${revision}-mac-combined-install" installer.cpp ext/lz4/lz4.o ext/lz4/lz4hc.o
  54. ls -l zt1-*-install
  55. ;;
  56. *)
  57. echo "Unsupported platform: $system"
  58. exit 2
  59. esac
  60. exit 0