wkhtmltox.nsi 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. !include "MUI2.nsh"
  2. !include "x64.nsh"
  3. Name "wkhtmltox ${VERSION}"
  4. OutFile "static-build\wkhtmltox-${VERSION}_${TARGET}.exe"
  5. !if "${ARCH}" == "win64"
  6. InstallDir "$PROGRAMFILES64\wkhtmltopdf"
  7. !else
  8. InstallDir "$PROGRAMFILES\wkhtmltopdf"
  9. !endif
  10. VIProductVersion "${SIMPLE_VERSION}"
  11. VIAddVersionKey "ProductName" "wkhtmltox"
  12. VIAddVersionKey "FileDescription" "wkhtmltox ${VERSION}"
  13. VIAddVersionKey "LegalCopyright" "wkhtmltopdf authors"
  14. VIAddVersionKey "FileVersion" "${VERSION}"
  15. CRCCheck force
  16. SetCompressor /SOLID lzma
  17. SetCompressorDictSize 64
  18. RequestExecutionLevel admin
  19. !insertmacro MUI_PAGE_LICENSE "LICENSE"
  20. !insertmacro MUI_PAGE_DIRECTORY
  21. !insertmacro MUI_PAGE_INSTFILES
  22. !insertmacro MUI_UNPAGE_CONFIRM
  23. !insertmacro MUI_UNPAGE_INSTFILES
  24. !insertmacro MUI_LANGUAGE "English"
  25. !macro DeleteFiles un
  26. Function ${un}DeleteFiles
  27. ; remove as per old installer layout
  28. Delete "$INSTDIR\libgcc_s_dw2-1.dll"
  29. Delete "$INSTDIR\mingwm10.dll"
  30. Delete "$INSTDIR\ssleay32.dll"
  31. Delete "$INSTDIR\libeay32.dll"
  32. Delete "$INSTDIR\wkhtmltopdf.exe"
  33. Delete "$INSTDIR\wkhtmltoimage.exe"
  34. Delete "$INSTDIR\bin\libgcc_s_sjlj-1.dll"
  35. Delete "$INSTDIR\bin\libgcc_s_seh-1.dll"
  36. Delete "$INSTDIR\bin\libstdc++-6.dll"
  37. Delete "$INSTDIR\bin\libwinpthread-1.dll"
  38. ; remove as per current installer layout
  39. Delete "$INSTDIR\bin\wkhtmltoimage.exe"
  40. Delete "$INSTDIR\bin\wkhtmltopdf.exe"
  41. Delete "$INSTDIR\bin\wkhtmltox.dll"
  42. Delete "$INSTDIR\lib\wkhtmltox.lib"
  43. Delete "$INSTDIR\include\wkhtmltox\dllbegin.inc"
  44. Delete "$INSTDIR\include\wkhtmltox\dllend.inc"
  45. Delete "$INSTDIR\include\wkhtmltox\pdf.h"
  46. Delete "$INSTDIR\include\wkhtmltox\image.h"
  47. Delete "$INSTDIR\uninstall.exe"
  48. RMDir "$INSTDIR\bin"
  49. RMDir "$INSTDIR\include\wkhtmltox"
  50. RMDir "$INSTDIR\include"
  51. RMDir "$INSTDIR\lib"
  52. RMDir "$INSTDIR"
  53. FunctionEnd
  54. !macroend
  55. !macro CheckVCRedist
  56. !ifdef MSVC
  57. InitPluginsDir
  58. ClearErrors
  59. ReadRegDWORD $R0 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\${MSVC}\RuntimeMinimum" "Install"
  60. IfErrors need_vcruntime
  61. IntCmp $R0 1 skip_vcruntime need_vcruntime need_vcruntime
  62. need_vcruntime:
  63. File /oname=$PLUGINSDIR\vcredist.exe static-build\${TARGET}\vcredist.exe
  64. skip_vcruntime:
  65. !endif
  66. !macroend
  67. !insertmacro DeleteFiles ""
  68. !insertmacro DeleteFiles "un."
  69. Section "Install"
  70. !ifdef MSVC
  71. IfFileExists "$PLUGINSDIR\vcredist.exe" 0 skip_vcruntime
  72. ExecWait '"$PLUGINSDIR\vcredist.exe" /install /quiet /norestart' $R9
  73. skip_vcruntime:
  74. !endif
  75. Call DeleteFiles
  76. SetOutPath "$INSTDIR"
  77. SetOutPath "$INSTDIR\bin"
  78. File static-build\${TARGET}\app\bin\wkhtmltoimage.exe
  79. File static-build\${TARGET}\app\bin\wkhtmltopdf.exe
  80. File static-build\${TARGET}\app\bin\wkhtmltox.dll
  81. SetOutPath "$INSTDIR\lib"
  82. File static-build\${TARGET}\app\bin\wkhtmltox.lib
  83. SetOutPath "$INSTDIR\include\wkhtmltox"
  84. File include\wkhtmltox\dllbegin.inc
  85. File include\wkhtmltox\dllend.inc
  86. File include\wkhtmltox\pdf.h
  87. File include\wkhtmltox\image.h
  88. WriteRegStr HKLM "Software\wkhtmltopdf" "InstallPath" "$INSTDIR"
  89. WriteRegStr HKLM "Software\wkhtmltopdf" "Version" "${VERSION}"
  90. WriteRegStr HKLM "Software\wkhtmltopdf" "DllPath" "$INSTDIR\bin\wkhtmltox.dll"
  91. WriteRegStr HKLM "Software\wkhtmltopdf" "PdfPath" "$INSTDIR\bin\wkhtmltopdf.exe"
  92. WriteRegStr HKLM "Software\wkhtmltopdf" "ImagePath" "$INSTDIR\bin\wkhtmltoimage.exe"
  93. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wkhtmltopdf" \
  94. "DisplayName" "wkhtmltox ${VERSION}"
  95. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wkhtmltopdf" \
  96. "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
  97. WriteUninstaller "$INSTDIR\uninstall.exe"
  98. SectionEnd
  99. Section "Uninstall"
  100. ${If} ${RunningX64}
  101. SetRegView 64
  102. ${EndIf}
  103. Call un.DeleteFiles
  104. DeleteRegKey HKLM "Software\wkhtmltopdf"
  105. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wkhtmltopdf"
  106. SectionEnd
  107. Function .onInit
  108. !if "${ARCH}" == "win32"
  109. !insertmacro CheckVCRedist
  110. ${If} ${RunningX64}
  111. SetRegView 64
  112. ${EndIf}
  113. !endif
  114. !if "${ARCH}" == "win64"
  115. ${If} ${RunningX64}
  116. SetRegView 64
  117. !insertmacro CheckVCRedist
  118. ${Else}
  119. Abort "Cannot install 64-bit binaries on a 32-bit OS"
  120. ${EndIf}
  121. !endif
  122. FunctionEnd