build_installer.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. #
  3. # Setup script to build Windows tool installer with Inno Setup
  4. #
  5. # Designed to be run on Linux (with wine) but could be adapted to run under MSYS2 on Windows
  6. # pretty easily...
  7. #
  8. # - Downloads (if necessary) all tools to install to the "dl/" directory
  9. # - Deletes the "input" directory contains and copies everything under there
  10. # - Runs ISCC under wine to compile the installer itself
  11. set -e
  12. if [ -z "${KEYPASSWORD}" ]; then
  13. echo "KEYPASSWORD should be set"
  14. exit 1
  15. fi
  16. if [ "$1" != "--no-download" ]; then
  17. mkdir -p dl input
  18. cd `dirname $0`
  19. pushd dl
  20. wget --continue "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip"
  21. wget --continue "https://github.com/espressif/binutils-esp32ulp/releases/download/v2.28.51-esp32ulp-20180809/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip"
  22. wget --continue "https://github.com/espressif/openocd-esp32/releases/download/v0.10.0-esp32-20180920/openocd-esp32-win32-0.10.0-esp32-20180920.zip"
  23. wget --continue "https://github.com/espressif/kconfig-frontends/releases/download/v4.6.0.0-idf-20180525/mconf-v4.6.0.0-idf-20180525-win32.zip"
  24. wget --continue "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip"
  25. popd
  26. rm -rf input/*
  27. pushd input
  28. unzip ../dl/xtensa-esp32-elf-win32-1.22.0-97-gc752ad5-5.2.0.zip
  29. unzip ../dl/mconf-v4.6.0.0-idf-20180525-win32.zip
  30. unzip ../dl/binutils-esp32ulp-win32-2.28.51-esp32ulp-20180809.zip
  31. unzip ../dl/openocd-esp32-win32-0.10.0-esp32-20180920.zip
  32. unzip ../dl/ninja-win.zip
  33. popd
  34. fi
  35. wine "C:\Program Files\Inno Setup 5\ISCC.exe" "`winepath -w ./idf_tool_setup.iss`"
  36. # sign the installer with osslsigncode, parsing the version number out of the
  37. # installer config
  38. VERSION=`grep "^AppVersion=" idf_tool_setup.iss | cut -d'=' -f2`
  39. echo "Signing installer..."
  40. # Note: The cert chain passed to -certs needs to contain the intermediate
  41. # cert(s) as well, appended after the code signing cert, or Windows may see
  42. # it as "Unknown Publisher"
  43. #
  44. # See https://stackoverflow.com/a/52637050 for full details
  45. #
  46. umask 770 # for the process substitution FIFO
  47. osslsigncode -certs ./keys/certchain.pem -key ./keys/key.pem \
  48. -readpass <(echo "$KEYPASSWORD") \
  49. -in Output/esp-idf-tools-setup-unsigned.exe \
  50. -out Output/esp-idf-tools-setup-${VERSION}.exe \
  51. -h sha256 \
  52. -n "Espressif Systems (Shanghai) Pte. Ltd." \
  53. -i "https://www.espressif.com/" \
  54. -ts http://timestamp.digicert.com
  55. chmod 644 Output/esp-idf-tools-setup-${VERSION}.exe # make up for the umask