from __future__ import print_function import os def write_installer(bits, version, debug): try: os.makedirs('build/platform/windows') except: pass f = open('build/platform/windows/installer.%d.nsi' % bits, 'w') print('!include "MUI2.nsh"', file=f) if bits == 64: print('!include "x64.nsh"', file=f) if debug: print('Name "DCP-o-matic Debug"', file=f) else: print('Name "DCP-o-matic"', file=f) print('RequestExecutionLevel admin', file=f) if debug: print('outFile "DCP-o-matic Debug %s %d-bit Installer.exe"' % (version, bits), file=f) else: print('outFile "DCP-o-matic %s %d-bit Installer.exe"' % (version, bits), file=f) print(""" !define MUI_ICON "%resources%/dcpomatic.ico" !define MUI_UNICON "%resources%/dcpomatic.ico" !define MUI_SPECIALBITMAP "%resources%/dcpomatic.bmp" !include "Sections.nsh" """, file=f) if debug: print('InstallDir "$PROGRAMFILES\\DCP-o-matic 2 Debug"', file=f) else: print('InstallDir "$PROGRAMFILES\\DCP-o-matic 2"', file=f) print(""" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "../../../COPYING" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_COMPONENTS Section "Common files (required)" SEC_COMMON SectionIn RO """, file=f) if bits == 64: print(""" ${If} ${RunningX64} DetailPrint "Installer running on 64-bit host" ; disable registry redirection (enable access to 64-bit portion of registry) SetRegView 64 ; change install dir StrCpy $INSTDIR "$PROGRAMFILES64\DCP-o-matic 2" ${EndIf} """, file=f) print(""" SetOutPath "$INSTDIR\\bin" WriteUninstaller "$INSTDIR\Uninstall.exe" File "%static_deps%/bin/libintl-8.dll" File "%static_deps%/bin/libboost_chrono-mt.dll" File "%static_deps%/bin/libboost_filesystem-mt.dll" File "%static_deps%/bin/libboost_system-mt.dll" File "%static_deps%/bin/libboost_thread_win32-mt.dll" File "%static_deps%/bin/libboost_date_time-mt.dll" File "%static_deps%/bin/libboost_locale-mt.dll" File "%static_deps%/bin/libeay32.dll" File "%static_deps%/bin/libgcc_s_sjlj-1.dll" File "%static_deps%/bin/libgio-2.0-0.dll" File "%static_deps%/bin/libglib-2.0-0.dll" File "%static_deps%/bin/libgobject-2.0-0.dll" File "%static_deps%/bin/libiconv-2.dll" File "%static_deps%/bin/libjpeg-8.dll" File "%static_deps%/bin/libMagick++-6.Q16-3.dll" File "%static_deps%/bin/libMagickCore-6.Q16-1.dll" File "%static_deps%/bin/libMagickWand-6.Q16-1.dll" File "%static_deps%/bin/libpng15-15.dll" File "%static_deps%/bin/libsigc-2.0-0.dll" File "%static_deps%/bin/libsndfile-1.dll" File "%static_deps%/bin/libssh.dll" File "%static_deps%/bin/libstdc++-6.dll" File "%static_deps%/bin/zlib1.dll" File "%static_deps%/bin/libjpeg-8.dll" File "%static_deps%/bin/wxbase30u_gcc_custom.dll" File "%static_deps%/bin/wxmsw30u_core_gcc_custom.dll" File "%static_deps%/bin/wxmsw30u_adv_gcc_custom.dll" File "%static_deps%/bin/wxmsw30u_richtext_gcc_custom.dll" File "%static_deps%/bin/wxmsw30u_html_gcc_custom.dll" File "%static_deps%/bin/wxbase30u_xml_gcc_custom.dll" File "%static_deps%/bin/libcairo-2.dll" File "%static_deps%/bin/libfreetype-6.dll" File "%static_deps%/bin/libgthread-2.0-0.dll" File "%static_deps%/bin/libpango-1.0-0.dll" File "%static_deps%/bin/libgmodule-2.0-0.dll" File "%static_deps%/bin/libpangocairo-1.0-0.dll" File "%static_deps%/bin/libpangowin32-1.0-0.dll" File "%static_deps%/bin/libtiff-5.dll" File "%static_deps%/bin/libglibmm-2.4-1.dll" File "%static_deps%/bin/libxml++-2.6-2.dll" File "%static_deps%/bin/libxml2-2.dll" File "%static_deps%/bin/libpixman-1-0.dll" File "%static_deps%/bin/libfontconfig-1.dll" File "%static_deps%/bin/libexpat-1.dll" File "%static_deps%/bin/libbz2.dll" File "%static_deps%/bin/libxmlsec1.dll" File "%static_deps%/bin/libxmlsec1-openssl.dll" File "%static_deps%/bin/libexslt-0.dll" File "%static_deps%/bin/libxslt-1.dll" File "%static_deps%/bin/libffi-6.dll" File "%static_deps%/bin/openssl.exe" File "%static_deps%/bin/libcurl-4.dll" File "%static_deps%/bin/ssleay32.dll" File "%static_deps%/bin/libzip-2.dll" File "%static_deps%/bin/libcairomm-1.0-1.dll" File "%static_deps%/bin/libpangomm-1.4-1.dll" File "%static_deps%/bin/pango-querymodules.exe" File "%cdist_deps%/bin/asdcp-libdcp-1.0.dll" File "%cdist_deps%/bin/kumu-libdcp-1.0.dll" File "%cdist_deps%/bin/avcodec-56.dll" File "%cdist_deps%/bin/avfilter-5.dll" File "%cdist_deps%/bin/avformat-56.dll" File "%cdist_deps%/bin/avutil-54.dll" File "%cdist_deps%/bin/avdevice-56.dll" File "%cdist_deps%/bin/postproc-53.dll" File "%cdist_deps%/bin/dcp-1.0.dll" File "%cdist_deps%/bin/libopenjpeg-1.dll" File "%cdist_deps%/bin/swresample-1.dll" File "%cdist_deps%/bin/swscale-3.dll" File "%cdist_deps%/bin/cxml-0.dll" File "%cdist_deps%/bin/sub.dll" File "%cdist_deps%/bin/ffprobe.exe" """, file=f) if debug: print('File "%resources%/gdb_script"', file=f) print('File "%resources%/debug.bat"', file=f) print('File "%mingw%/gdb.exe"', file=f) print('File "%mingw%/addr2line.exe"', file=f) else: print('File "%binaries%/src/wx/dcpomatic2-wx.dll"', file=f) print('File "%binaries%/src/lib/dcpomatic2.dll"', file=f) print(""" SetOutPath "$INSTDIR\\lib\\pango\\1.8.0\\modules" File "%static_deps%/lib/pango/1.8.0/modules/pango-arabic-lang.dll" File "%static_deps%/lib/pango/1.8.0/modules/pango-basic-win32.dll" File "%static_deps%/lib/pango/1.8.0/modules/pango-indic-lang.dll" SetOutPath "$INSTDIR\\bin" # I don't know why, but sometimes it seems that # delegates.xml must be in with the binaries, and # sometimes in the $PROFILE. Meh. File "%static_deps%/etc/ImageMagick-6/delegates.xml" SetOutPath "$PROFILE\\.magick" File "%static_deps%/etc/ImageMagick-6/delegates.xml" SetOutPath "$INSTDIR\\locale\\fr\\LC_MESSAGES" File "%binaries%/src/lib/mo/fr_FR/libdcpomatic2.mo" File "%binaries%/src/wx/mo/fr_FR/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/fr_FR/dcpomatic2.mo" File "%static_deps%/share/locale/fr/LC_MESSAGES/wxstd.mo" SetOutPath "$INSTDIR\\locale\\it\\LC_MESSAGES" File "%binaries%/src/lib/mo/it_IT/libdcpomatic2.mo" File "%binaries%/src/wx/mo/it_IT/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/it_IT/dcpomatic2.mo" File "%static_deps%/share/locale/it/LC_MESSAGES/wxstd.mo" SetOutPath "$INSTDIR\\locale\\es\\LC_MESSAGES" File "%binaries%/src/lib/mo/es_ES/libdcpomatic2.mo" File "%binaries%/src/wx/mo/es_ES/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/es_ES/dcpomatic2.mo" File "%static_deps%/share/locale/es/LC_MESSAGES/wxstd.mo" SetOutPath "$INSTDIR\\locale\\sv\\LC_MESSAGES" File "%binaries%/src/lib/mo/sv_SE/libdcpomatic2.mo" File "%binaries%/src/wx/mo/sv_SE/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/sv_SE/dcpomatic2.mo" File "%static_deps%/share/locale/sv/LC_MESSAGES/wxstd.mo" SetOutPath "$INSTDIR\\locale\\de\\LC_MESSAGES" File "%binaries%/src/lib/mo/de_DE/libdcpomatic2.mo" File "%binaries%/src/wx/mo/de_DE/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/de_DE/dcpomatic2.mo" File "%static_deps%/share/locale/de/LC_MESSAGES/wxstd.mo" SetOutPath "$INSTDIR\\locale\\nl\\LC_MESSAGES" File "%binaries%/src/lib/mo/nl_NL/libdcpomatic2.mo" File "%binaries%/src/wx/mo/nl_NL/libdcpomatic2-wx.mo" File "%binaries%/src/tools/mo/nl_NL/dcpomatic2.mo" File "%static_deps%/share/locale/nl/LC_MESSAGES/wxstd.mo" """, file=f) if debug: print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f) else: print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f) print(""" WriteUninstaller "$INSTDIR\\Uninstall.exe" CreateDirectory "$INSTDIR\etc\pango" ReadEnvStr $0 COMSPEC SetOutPath "$INSTDIR" nsExec::ExecToLog '$0 /C bin\pango-querymodules.exe > etc\pango\pango.modules' SectionEnd """, file=f) if debug: print('Section "DCP-o-matic 2 Debug" SEC_MASTER', file=f) else: print('Section "DCP-o-matic 2" SEC_MASTER', file=f) print('SetOutPath "$INSTDIR\\bin"', file=f) if debug: print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2 Debug"', file=f) else: print('CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2"', file=f) print(""" File "%binaries%/src/tools/dcpomatic2.exe" File "%binaries%/src/tools/dcpomatic2_batch.exe" File "%binaries%/src/tools/dcpomatic2_cli.exe" """, file=f) if debug: print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat" ""', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2 Debug\\DCP-o-matic 2 Debug.lnk" "$INSTDIR\\bin\\debug.bat"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2 Debug.lnk" "$INSTDIR\\Uninstall.exe"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "DisplayName" "DCP-o-matic 2 Debug (remove only)"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f) else: print('CreateShortCut "$DESKTOP\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe" ""', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f) print('CreateShortCut "$DESKTOP\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2_batch.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 batch converter.lnk" "$INSTDIR\\bin\\dcpomatic2.exe"', file=f) print('CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "DisplayName" "DCP-o-matic 2 (remove only)"', file=f) print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic2" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f) print(""" WriteUninstaller "$INSTDIR\\Uninstall.exe" SectionEnd """, file=f) if not debug: print(""" Section "Encode server" SEC_SERVER SetOutPath "$INSTDIR\\bin" CreateDirectory "$SMPROGRAMS\\DCP-o-matic 2" File "%binaries%/src/tools/dcpomatic2_server_cli.exe" File "%binaries%/src/tools/dcpomatic2_server.exe" CreateShortCut "$DESKTOP\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic2_server.exe" "" CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\DCP-o-matic 2 encode server.lnk" "$INSTDIR\\bin\\dcpomatic_server.exe" "" "$INSTDIR\\bin\\dcpomatic2_server.exe" 0 CreateShortCut "$SMPROGRAMS\\DCP-o-matic 2\\Uninstall DCP-o-matic 2.lnk" "$INSTDIR\\Uninstall.exe" "" "$INSTDIR\\Uninstall.exe" 0 SectionEnd """, file=f) if debug: print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2 Debug"', file=f) else: print('LangString DESC_SEC_MASTER ${LANG_ENGLISH} "DCP-o-matic 2"', file=f) print('LangString DESC_SEC_SERVER ${LANG_ENGLISH} "DCP-o-matic 2 encode server"', file=f) print(""" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SEC_MASTER} $(DESC_SEC_MASTER) !insertmacro MUI_DESCRIPTION_TEXT ${SEC_SERVER} $(DESC_SEC_SERVER) !insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_LANGUAGE "English" """, file=f) if debug: print(""" Section "Uninstall" RMDir /r "$INSTDIR\\*.*" RMDir "$INSTDIR" Delete "$DESKTOP\\DCP-o-matic 2 Debug.lnk" Delete "$SMPROGRAMS\\DCP-o-matic 2 Debug\\*.*" RmDir "$SMPROGRAMS\\DCP-o-matic 2 Debug" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2 Debug" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2 Debug" SectionEnd """, file=f) else: print(""" Section "Uninstall" RMDir /r "$INSTDIR\\*.*" RMDir "$INSTDIR" Delete "$DESKTOP\\DCP-o-matic 2.lnk" Delete "$DESKTOP\\DCP-o-matic 2 batch converter.lnk" Delete "$DESKTOP\\DCP-o-matic 2 encode server.lnk" Delete "$SMPROGRAMS\\DCP-o-matic 2\\*.*" RmDir "$SMPROGRAMS\\DCP-o-matic 2" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\DCP-o-matic 2" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\DCP-o-matic 2" SectionEnd """, file=f) def build(bld): write_installer(32, bld.env.VERSION, bld.env.DEBUG) write_installer(64, bld.env.VERSION, bld.env.DEBUG)