buildinstaller.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. targ="zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install"
  46. if [ -e /usr/bin/clang ]; then
  47. clang -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
  48. else
  49. gcc -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
  50. fi
  51. strip --strip-all $targ
  52. ls -l $targ
  53. ;;
  54. Darwin)
  55. echo "Assembling mac installer for x86/x64 (combined) and ZT1 version $vmajor.$vminor.$revision"
  56. ./file2lz4c ext/installfiles/mac/uninstall.sh uninstall_sh >installer-build/uninstall_sh.h
  57. ./file2lz4c ext/installfiles/mac/launch.sh mac__launch_sh >installer-build/mac__launch_sh.h
  58. ./file2lz4c ext/installfiles/mac/com.zerotier.one.plist mac__com_zerotier_one_plist >installer-build/mac__com_zerotier_one_plist.h
  59. ./file2lz4c ext/bin/tap-mac/tap.kext/Contents/Info.plist tap_mac__Info_plist >installer-build/tap_mac__Info_plist.h
  60. ./file2lz4c ext/bin/tap-mac/tap.kext/Contents/MacOS/tap tap_mac__tap >installer-build/tap_mac__tap.h
  61. ./file2lz4c "build-ZeroTierUI-release/ZeroTier One.app/Contents/Info.plist" mac_ui__contents_info_plist >installer-build/mac_ui__contents_info_plist.h
  62. ./file2lz4c "build-ZeroTierUI-release/ZeroTier One.app/Contents/PkgInfo" mac_ui__contents_pkginfo >installer-build/mac_ui__contents_pkginfo.h
  63. ./file2lz4c "build-ZeroTierUI-release/ZeroTier One.app/Contents/MacOS/ZeroTier One" mac_ui__contents_macos_zerotier_one >installer-build/mac_ui__contents_macos_zerotier_one.h
  64. ./file2lz4c "build-ZeroTierUI-release/ZeroTier One.app/Contents/Resources/empty.lproj" mac_ui__contents_resources_empty_lproj >installer-build/mac_ui__contents_resources_empty_lproj.h
  65. ./file2lz4c "build-ZeroTierUI-release/ZeroTier One.app/Contents/Resources/zt1icon.icns" mac_ui__contents_resources_zt1icon_icns >installer-build/mac_ui__contents_resources_zt1icon_icns.h
  66. targ="zt1-${vmajor}_${vminor}_${revision}-mac-combined-install"
  67. # Installer can be i386-only to save space, but installs combined
  68. # x86/x64 binaries for ZT1 itself.
  69. clang -Os -arch i386 -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
  70. strip $targ
  71. ls -l $targ
  72. ;;
  73. *)
  74. echo "Unsupported platform: $system"
  75. exit 2
  76. esac
  77. exit 0