;Copyright (c) 2010, Tom Schoonjans ;All rights reserved. ;Redistribution and use in source and binary forms, with or without ;modification, are permitted provided that the following conditions are met: ; * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. ; * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. ;THIS SOFTWARE IS PROVIDED BY Tom Schoonjans ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Tom Schoonjans BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;Written by Tom Schoonjans !define PRODUCT_NAME "xraylib-cli" !define VERSION @VERSION@ !define PRODUCT_VERSION @VERSION@ !define PRODUCT_WEB_SITE "http://github.com/tschoonj/xraylib" !define PRODUCT_DIR_REGKEY "Software\xraylib-cli" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define abs_top_srcdir_win "C:\MinGW\msys\1.0\@abs_top_srcdir_win@" !define abs_top_builddir_win "C:\MinGW\msys\1.0\@abs_top_builddir_win@" !define DLLTOOL "i686-pc-mingw32-dlltool" !addincludedir "${abs_top_srcdir_win}\windows\python\cli_py2exe" !include "MUI2.nsh" !include "EnvVarUpdate.nsh" !include "Sections.nsh" ;!define MUI_LANGDLL_REGISTRY_ROOT "HKLM" ;!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}" ;!define MUI_LANGDLL_REGISTRY_VALUENAME "Language" Name "xraylib-cli" OutFile xraylib-${VERSION}-win32-cli.exe RequestExecutionLevel none InstallDir "$PROGRAMFILES\xraylib-cli" !ifdef NSIS_LZMA_COMPRESS_WHOLE SetCompressor lzma !else SetCompressor /SOLID lzma !endif SetOverwrite ifnewer CRCCheck on !define MUI_ABORTWARNING ;!define MUI_WELCOMEPAGE_TITLE "xraylib: an open-source library for X-ray -- matter interactions" !define MUI_WELCOMEPAGE_TEXT "Thank you for downloading version ${VERSION} of xraylib. This wizard will assist you in installing the command-line interface of xraylib and its depencies. If you want to install the full version of xraylib, download either the source code or the Windows 32-bit SDK." !define MUI_WELCOMEPAGE_TITLE_3LINES !insertmacro MUI_PAGE_WELCOME !define MUI_LICENSEPAGE_CHECKBOX !insertmacro MUI_PAGE_LICENSE "${abs_top_srcdir_win}\windows\License.rtf" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_TEXT "Thank you for installing xraylib. Remember: the latest version of xraylib can be obtained from the development repository on github" !define MUI_FINISHPAGE_LINK "xraylib development link" !define MUI_FINISHPAGE_LINK_LOCATION "http://github.com/tschoonj/xraylib" !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt" !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH Section "-xraylib core files" SecDummy SetOutPath "$INSTDIR" ;Readme etc File ${abs_top_srcdir_win}\README Push "$INSTDIR\README" Push "$INSTDIR\README.txt" Call unix2dos File ${abs_top_srcdir_win}\AUTHORS Push "$INSTDIR\AUTHORS" Push "$INSTDIR\AUTHORS.txt" Call unix2dos File ${abs_top_srcdir_win}\BUGS Push "$INSTDIR\BUGS" Push "$INSTDIR\BUGS.txt" Call unix2dos File ${abs_top_srcdir_win}\Changelog Push "$INSTDIR\Changelog" Push "$INSTDIR\Changelog.txt" Call unix2dos File ${abs_top_srcdir_win}\TODO Push "$INSTDIR\TODO" Push "$INSTDIR\TODO.txt" Call unix2dos ;Documentation SetOutPath "$INSTDIR\Doc" File ${abs_top_srcdir_win}\doc\xraybanner.txt Push "$INSTDIR\Doc\xraybanner.txt" Push "$INSTDIR\Doc\xraybanner.txt.fix" Call unix2dos Rename xraybanner.txt.fix xraybanner.txt File ${abs_top_srcdir_win}\doc\xraydoc.txt Push "$INSTDIR\Doc\xraydoc.txt" Push "$INSTDIR\Doc\xraydoc.txt.fix" Call unix2dos Rename xraydoc.txt.fix xraydoc.txt File ${abs_top_srcdir_win}\doc\xrayfunc.txt Push "$INSTDIR\Doc\xrayfunc.txt" Push "$INSTDIR\Doc\xrayfunc.txt.fix" Call unix2dos Rename xrayfunc.txt.fix xrayfunc.txt File ${abs_top_srcdir_win}\doc\xrayhelp.txt Push "$INSTDIR\Doc\xrayhelp.txt" Push "$INSTDIR\Doc\xrayhelp.txt.fix" Call unix2dos Rename xrayhelp.txt.fix xrayhelp.txt SetOutPath "$INSTDIR\Bin" File ${abs_top_builddir_win}\windows\python\cli_py2exe\dist\xraylib.exe SetOutPath "$INSTDIR\temp" File "${abs_top_srcdir_win}\windows\msvcrt\vcredist_x86_90.exe" ExecWait "$INSTDIR\temp\vcredist_x86_90.exe /q" SetOutPath "$INSTDIR" RMDir /r "$INSTDIR\temp" ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\Bin" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" $INSTDIR WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayName" "xraylib-cli ${VERSION}" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayVersion" "${VERSION}" WriteRegDWORD HKLM ${PRODUCT_UNINST_KEY} "NoModify" 1 WriteRegDWORD HKLM ${PRODUCT_UNINST_KEY} "NoRepair" 1 WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd Section "Uninstall" Delete "$INSTDIR\Doc\xraybanner.txt" Delete "$INSTDIR\Doc\xraydoc.txt" Delete "$INSTDIR\Doc\xrayfunc.txt" Delete "$INSTDIR\Doc\xrayhelp.txt" RMDir "$INSTDIR\Doc" Delete "$INSTDIR\Bin\xraylib.exe" RMDir "$INSTDIR\Bin" Delete "$INSTDIR\README.txt" Delete "$INSTDIR\AUTHORS.txt" Delete "$INSTDIR\BUGS.txt" Delete "$INSTDIR\Changelog.txt" Delete "$INSTDIR\TODO.txt" Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\Bin" DeleteRegKey /ifempty HKLM "${PRODUCT_DIR_REGKEY}" DeleteRegKey HKLM ${PRODUCT_UNINST_KEY} SectionEnd Function unix2dos ; strips all CRs ; ; and then converts all LFs into CRLFs ; ; (this is roughly equivalent to "cat file | dos2unix | unix2dos") ; ; ; ; usage: ; ; Push "infile" ; ; Push "outfile" ; ; Call unix2dos ; ; ; ; beware that this function destroys $0 $1 $2 ClearErrors Pop $2 FileOpen $1 $2 w Pop $2 FileOpen $0 $2 r Push $2 ; save name for deleting IfErrors unix2dos_done ; $0 = file input (opened for reading) ; $1 = file output (opened for writing) unix2dos_loop: ; read a byte (stored in $2) FileReadByte $0 $2 IfErrors unix2dos_done ; EOL ; skip CR StrCmp $2 13 unix2dos_loop ; if LF write an extra CR StrCmp $2 10 unix2dos_cr unix2dos_write unix2dos_cr: FileWriteByte $1 13 unix2dos_write: ; write byte FileWriteByte $1 $2 ; read next byte Goto unix2dos_loop unix2dos_done: ; close files FileClose $0 FileClose $1 ; delete original Pop $0 Delete $0 FunctionEnd Function .onInit ReadRegStr $R0 HKLM ${PRODUCT_UNINST_KEY} "UninstallString" StrCmp $R0 "" done MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is already installed. $\n$\nClick `OK` to remove the previous version or `Cancel` to cancel this upgrade." IDOK uninst Abort uninst: ClearErrors Exec $INSTDIR\Uninstall.exe done: FunctionEnd !insertmacro MUI_LANGUAGE "English"