diff options
author | rahulp13 | 2020-03-03 14:06:08 +0530 |
---|---|---|
committer | rahulp13 | 2020-03-03 14:06:08 +0530 |
commit | 13bda1ef3163f24f063b6209d523f536121adce6 (patch) | |
tree | ba6739878b92c4726aaa5b127b5d10879dc59fe0 /Windows | |
parent | 388995b3472ad42780ea43af7ac30cc43d869743 (diff) | |
download | eSim-13bda1ef3163f24f063b6209d523f536121adce6.tar.gz eSim-13bda1ef3163f24f063b6209d523f536121adce6.tar.bz2 eSim-13bda1ef3163f24f063b6209d523f536121adce6.zip |
packaging with pyinstaller
Diffstat (limited to 'Windows')
-rw-r--r-- | Windows/esim-setup-script.nsi | 364 |
1 files changed, 221 insertions, 143 deletions
diff --git a/Windows/esim-setup-script.nsi b/Windows/esim-setup-script.nsi index 9821a847..9804ee50 100644 --- a/Windows/esim-setup-script.nsi +++ b/Windows/esim-setup-script.nsi @@ -1,6 +1,6 @@ ;NSIS Modern User Interface ;Start Menu Folder Selection Example Script -;Modified by Fahim Khan, Saurabh Bansode, Rahul Paknikar - 20_08_2019 +;Modified by Fahim Khan, Saurabh Bansode, Rahul Paknikar - 01_03_2020 ;Made by eSim Team, FOSSEE, IIT Bombay ;-------------------------------- @@ -12,34 +12,99 @@ !include "x64.nsh" ;-------------------------------- -;General +;-------------------------------- +; StrContains +; This function does a case sensitive searches for an occurrence of a substring in a string. +; It returns the substring if it is found. +; Otherwise it returns null(""). +; Written by kenglish_hi +; Adapted from StrReplace written by dandaman32 + + +Var STR_HAYSTACK +Var STR_NEEDLE +Var STR_CONTAINS_VAR_1 +Var STR_CONTAINS_VAR_2 +Var STR_CONTAINS_VAR_3 +Var STR_CONTAINS_VAR_4 +Var STR_RETURN_VAR + +Function StrContains + Exch $STR_NEEDLE + Exch 1 + Exch $STR_HAYSTACK + ; Uncomment to debug + ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK ' + StrCpy $STR_RETURN_VAR "" + StrCpy $STR_CONTAINS_VAR_1 -1 + StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE + StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK + loop: + IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1 + StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1 + StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found + StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done + Goto loop + found: + StrCpy $STR_RETURN_VAR $STR_NEEDLE + Goto done + done: + Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the + Exch $STR_RETURN_VAR +FunctionEnd + +!macro _StrContainsConstructor OUT NEEDLE HAYSTACK + Push `${HAYSTACK}` + Push `${NEEDLE}` + Call StrContains + Pop `${OUT}` +!macroend + +!define StrContains '!insertmacro "_StrContainsConstructor"' + +;-------------------------------- -!define PRODUCT_NAME "eSim" -!define PRODUCT_VERSION "1.1.2.0" -!define VERSION "1.1.2.0" -!define PRODUCT_PUBLISHER "FOSSEE" -!define PRODUCT_WEB_SITE "http://fossee.in" + +;General + +!define PRODUCT_NAME "eSim" +!define PRODUCT_VERSION "2.0" +!define VERSION "2.0.0.0" +!define PRODUCT_PUBLISHER "FOSSEE, IIT Bombay" +!define PRODUCT_WEB_SITE "https://esim.fossee.in/" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" - + VIAddVersionKey "ProductName" "eSim" -VIProductVersion "${PRODUCT_VERSION}" +VIProductVersion "${VERSION}" VIFileVersion "${VERSION}" VIAddVersionKey "FileVersion" "${VERSION}" -VIAddVersionKey "CompanyName" "FOSSEE @ IIT-B" +VIAddVersionKey "CompanyName" "FOSSEE, IIT Bombay" VIAddVersionKey "LegalCopyright" "Copyright (C) 2007 Free Software Foundation, Inc." -VIAddVersionKey "FileDescription" "eSim Installer" - +VIAddVersionKey "FileDescription" "Installer for eSim EDA Suite" + ;Default installation folder - InstallDir "C:\" + InstallDir "C:\FOSSEE" +;Request application privileges for Admin Rights + RequestExecutionLevel admin + ;Get installation folder from registry if available InstallDirRegKey HKLM "Software\eSim" "" -;Request application privileges for Windows Vista - RequestExecutionLevel user +!include LogicLib.nsh + +Function .onInit +UserInfo::GetAccountType +pop $0 +${If} $0 != "admin" ;Require admin rights on NT4+ + MessageBox mb_iconstop "Administrator rights required!" + SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + Quit +${EndIf} +FunctionEnd ;-------------------------------- ;Variables @@ -48,13 +113,11 @@ VIAddVersionKey "FileDescription" "eSim Installer" ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING - !define Python_HOME "C:\Python27" ;-------------------------------- ;Pages - + !insertmacro MUI_PAGE_LICENSE "LICENSE.rtf" - !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY ;Start Menu Folder Page Configuration @@ -78,145 +141,156 @@ VIAddVersionKey "FileDescription" "eSim Installer" ;-------------------------------- Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" -OutFile "eSim-Installer.exe" +OutFile "eSim-2.0_install.exe" + + +Function .onVerifyInstDir + ${StrContains} $0 "Program Files" $INSTDIR + StrCmp $0 "" notfound + MessageBox MB_ICONSTOP|MB_OK \ + "Installation in 'Program Files' is not allowed, choose another directory." + Abort + notfound: + ${StrContains} $0 " " $INSTDIR + StrCmp $0 "" PathGood + MessageBox MB_ICONSTOP|MB_OK \ + "Installation path containing spaces is not allowed, choose another directory." + Abort + PathGood: +FunctionEnd ;Installer Sections -Section "Ngspice circuit simulator" SecDummy +Section -NgspiceSim + + ;Current section needs an additional "size_kb" kilobytes of disk space + AddSize 2726298 + + SetOutPath "$EXEDIR" + + File "spice.zip" + File "eSim.zip" + File "logo.ico" + SetOutPath "$INSTDIR" -;ADD YOUR OWN FILES HERE... -ZipDLL::extractall "$EXEDIR\spice.zip" "C:\" -ZipDLL::extractall "$EXEDIR\eSim.zip" "$INSTDIR\" -;Copying Folder to install directory -SetOutPath "$INSTDIR\eSim" -;File /nonfatal /a /r "eSim\" + ;ADD YOUR OWN FILES HERE... + ZipDLL::extractall "$EXEDIR\spice.zip" "$INSTDIR\" + ZipDLL::extractall "$EXEDIR\eSim.zip" "$INSTDIR\" + ;Setting Env Variable for Ngspice + ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\spice\bin" + ;Copying Folder to install directory + SetOutPath "$INSTDIR\eSim" + ;File /nonfatal /a /r "eSim\" -;Store installation folder + ;Store installation folder WriteRegStr HKLM "Software\eSim" "" $INSTDIR - - + + ;Create eSim config directory + CreateDirectory $PROFILE\.esim + CopyFiles "$EXEDIR\logo.ico" "$PROFILE\.esim" + FileOpen $0 "$PROFILE\.esim\config.ini" w + FileWrite $0 `[eSim]$\n` + FileWrite $0 `eSim_HOME = $INSTDIR\eSim$\n` + FileWrite $0 `LICENSE = %(eSim_HOME)s\LICENSE.rtf$\n` + FileWrite $0 `KicadLib = %(eSim_HOME)s\library\kicadLibrary.zip$\n` + FileWrite $0 `IMAGES = %(eSim_HOME)s\images$\n` + FileWrite $0 `VERSION = %(eSim_HOME)s\VERSION$\n` + FileWrite $0 `MODELICA_MAP_JSON = %(eSim_HOME)s\library\ngspicetoModelica\Mapping.json$\n` + FileClose $0 + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application -;Create shortcuts + ;Create shortcuts ;create desktop shortcut - CreateShortCut "$DESKTOP\eSim.lnk" "$INSTDIR\eSim\esim.bat" "" "$EXEDIR\logo.ico" "" SW_SHOWMINIMIZED + CreateShortCut "$DESKTOP\eSim.lnk" "$INSTDIR\eSim\eSim" "" "$PROFILE\.esim\logo.ico" "" SW_SHOWMINIMIZED + + ;Remove not required files + Delete "$EXEDIR\spice.zip" + Delete "$EXEDIR\eSim.zip" + Delete "$EXEDIR\logo.ico" !insertmacro MUI_STARTMENU_WRITE_END - -CreateDirectory "$PROFILE\AppData\Roaming\kicad" -; will replace the kicad folder. If there is not one, it will create -CopyFiles "$PROFILE\AppData\Roaming\kicad\fp-lib-table" "$PROFILE\AppData\Roaming\kicad\fp-lib-table-backup" -CopyFiles "$PROFILE\AppData\Roaming\kicad\fp-lib-table-online" "$PROFILE\AppData\Roaming\kicad\fp-lib-table-online-backup" -CopyFiles "$EXEDIR\dependencies\OfflineFiles\fp-lib-table" "$PROFILE\AppData\Roaming\kicad\" -CopyFiles "$EXEDIR\dependencies\OfflineFiles\fp-lib-table-online" "$PROFILE\AppData\Roaming\kicad\" + SectionEnd -Section -Prerequisites - ;SetOutPath $INSTDIR\Prerequisites - - MessageBox MB_OK "Installing Python" - ExecWait '"msiexec" /i "$EXEDIR\dependencies\python-2.7.10.msi"' - - ;Setting Environment Variable for Python - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "C:\Python27" - - - MessageBox MB_OK "Installing PyQT4" - ExecWait "$EXEDIR\dependencies\PyQt4-4.10.4-gpl-Py2.7-Qt4.8.6-x32" - - MessageBox MB_OK "Installing Numpy" - ExecWait "$EXEDIR\dependencies\numpy-1.9.0-win32-superpack-python2.7.exe" - - MessageBox MB_OK "Installing Matplotlib" - ExecWait "$EXEDIR\dependencies\matplotlib-1.4.0.win32-py2.7.exe" - - MessageBox MB_OK "Installing dateutil for matplotlib" - ExecWait "$EXEDIR\dependencies\python-dateutil-2.2.win32-py2.7.exe" - - MessageBox MB_OK "Installing six for matplotlib" - ExecWait "$EXEDIR\dependencies\six-1.8.0.win32-py2.7.exe" - - MessageBox MB_OK "Installing pyparsing for matplotlib" - ExecWait "$EXEDIR\dependencies\pyparsing-2.0.2.win32-py2.7.exe" - - - - MessageBox MB_OK "Installing KiCad" - ExecWait "$EXEDIR\dependencies\kicad-4.0.7-i686.exe" +Section -InstallKiCad + + SetOutPath "$EXEDIR" + File "kicad-4.0.7-i686.exe" + SetOutPath "$INSTDIR" + SetDetailsPrint both + DetailPrint "Installing: KiCad......" + SetDetailsPrint listonly + ExecWait '"$EXEDIR\kicad-4.0.7-i686.exe" /S /D=$INSTDIR\KiCad' + SetDetailsPrint both + Goto endActiveSync endActiveSync: + ;Remove not required files + Delete "$EXEDIR\kicad-4.0.7-i686.exe" + + ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\KiCad\bin" + + ZipDLL::extractall "$INSTDIR\eSim\library\kicadLibrary.zip" "$INSTDIR\eSim\library\" - ${If} ${RunningX64} + ;CopyFiles "$INSTDIR\eSim\library\kicadLibrary\library\*" "$INSTDIR\KiCad\share\kicad\library\" + + ;Copy KiCad library made for eSim + CopyFiles "$INSTDIR\eSim\library\kicadLibrary\kicad_eSim-Library\*" "$INSTDIR\KiCad\share\kicad\library\" - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "C:\Program Files (x86)\KiCad\bin" - CopyFiles "$EXEDIR\dependencies\library\*.lib" "C:\Program Files (x86)\KiCad\share\library" - CopyFiles "$EXEDIR\dependencies\library\*.dcm" "C:\Program Files (x86)\KiCad\share\library" - CopyFiles "$EXEDIR\dependencies\template\kicad.pro" "C:\Program Files (x86)\KiCad\share\template" + CopyFiles "$INSTDIR\eSim\library\kicadLibrary\modules\*" "$INSTDIR\KiCad\share\kicad\modules\" - CopyFiles "$EXEDIR\dependencies\library\*.lib" "C:\Program Files (x86)\KiCad\share\kicad\library" - CopyFiles "$EXEDIR\dependencies\library\*.dcm" "C:\Program Files (x86)\KiCad\share\kicad\library" - CopyFiles "$EXEDIR\dependencies\template\kicad.pro" "C:\Program Files (x86)\KiCad\share\kicad\template" + CopyFiles "$INSTDIR\eSim\library\kicadLibrary\template\*" "$INSTDIR\KiCad\share\kicad\template\" + - CopyFiles "$EXEDIR\dependencies\OfflineFiles\TerminalBlock_Altech_AK300-2_P5.00mm.kicad_mod" "C:\Program Files (x86)\KiCad\share\kicad\modules\Connectors_Terminal_Blocks.pretty\" - CopyFiles "$EXEDIR\dependencies\OfflineFiles\TO-220-3_Vertical.kicad_mod" "C:\Program Files (x86)\KiCad\share\kicad\modules\TO_SOT_Packages_THT.pretty\" + ;Remove older KiCad config files (if any). + RMDir /r "$PROFILE\AppData\Roaming\kicad" + CreateDirectory "$PROFILE\AppData\Roaming\kicad" + CopyFiles "$INSTDIR\eSim\library\supportFiles\fp-lib-table" "$PROFILE\AppData\Roaming\kicad\" + CopyFiles "$INSTDIR\eSim\library\supportFiles\fp-lib-table-online" "$PROFILE\AppData\Roaming\kicad\" - MessageBox MB_OK "Setting Permissions..." - ExecWait "$EXEDIR\dependencies\permission (x86).bat" + FileOpen $0 "$INSTDIR\eSim\library\supportFiles\kicad_config_path.txt" w + FileWrite $0 `$PROFILE\AppData\Roaming\kicad$\n` + FileClose $0 - ${Else} - - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "C:\Program Files\KiCad\bin" - CopyFiles "$EXEDIR\dependencies\library\*.lib" "C:\Program Files\KiCad\share\library" - CopyFiles "$EXEDIR\dependencies\library\*.dcm" "C:\Program Files\KiCad\share\library" - CopyFiles "$EXEDIR\dependencies\template\kicad.pro" "C:\Program Files\KiCad\share\template" - - CopyFiles "$EXEDIR\dependencies\library\*.lib" "C:\Program Files\KiCad\share\kicad\library" - CopyFiles "$EXEDIR\dependencies\library\*.dcm" "C:\Program Files\KiCad\share\kicad\library" - CopyFiles "$EXEDIR\dependencies\template\kicad.pro" "C:\Program Files\KiCad\share\kicad\template" - - CopyFiles "$EXEDIR\dependencies\OfflineFiles\TerminalBlock_Altech_AK300-2_P5.00mm.kicad_mod" "C:\Program Files\KiCad\share\kicad\modules\Connectors_Terminal_Blocks.pretty\" - CopyFiles "$EXEDIR\dependencies\OfflineFiles\TO-220-3_Vertical.kicad_mod" "C:\Program Files\KiCad\share\kicad\modules\TO_SOT_Packages_THT.pretty\" - - - MessageBox MB_OK "Setting Permissions..." - ExecWait "$EXEDIR\dependencies\permission.bat" - - ${EndIf} - - ;Setting Env Variable for ngspice - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "C:\spice\bin" - - + ;Remove extracted KiCad Library - not needed anymore + RMDir /r "$INSTDIR\eSim\library\kicadLibrary" + +SectionEnd - SectionEnd - Section -AdditionalIcons - SetOutPath $INSTDIR +Section -AdditionalIcons + + SetOutPath "$INSTDIR" CreateDirectory "$SMPROGRAMS\eSim" - CreateShortCut "$SMPROGRAMS\eSim\Uninstall.lnk" "$INSTDIR\uninst.exe" + CreateShortCut "$SMPROGRAMS\eSim\Uninstall.lnk" "$INSTDIR\eSim\uninst-eSim.exe" + SectionEnd + Section -Post - WriteUninstaller "$INSTDIR\uninst.exe" + + WriteUninstaller "$INSTDIR\eSim\uninst-eSim.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" - WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" + WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\eSim\uninst-eSim.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" + SectionEnd -Function un.onUninstSuccess - HideWindow - MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." -FunctionEnd +;Function un.onUninstSuccess +; HideWindow +; MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." +;FunctionEnd Function un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 @@ -225,45 +299,49 @@ FunctionEnd Section Uninstall + ;Note that in uninstaller code, $INSTDIR contains the directory where the uninstaller lies + Delete "$INSTDIR\uninst-eSim.exe" + Delete "$SMPROGRAMS\eSim\Uninstall.lnk" + + ;Removing Env Variable for KiCad + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\..\KiCad\bin" - + ;Remove KiCad config + RMDir /r "$PROFILE\AppData\Roaming\kicad" + + ;Removing KiCad + ExecWait '"$INSTDIR\..\KiCad\uninstaller.exe" /S' - Delete "$INSTDIR\uninst.exe" - ;Delete "$INSTDIR\eSim" - + Goto endActiveSync + endActiveSync: - Delete "$SMPROGRAMS\eSim\Uninstall.lnk" - - ${If} ${RunningX64} - ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "C:\Program Files (x86)\KiCad\bin" - - ${Else} - ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "C:\Program Files\KiCad\bin" - - ${EndIf} - - ;Setting Env Variable for ngspice - ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "C:\spice\bin" + ;Removing Env Variable for Ngspice + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\..\spice\bin" + + ;Removing Ngspice + RMDir /r "$INSTDIR\..\spice" - RMDir "$SMPROGRAMS\eSim" - ;RMDir "$INSTDIR\eSim" - ;RMDir /r "$INSTDIR\" - RMDir /r "$INSTDIR\eSim" - Delete "$DESKTOP\eSim.lnk" + ;Removing eSim + RMDir /r "$PROFILE\.esim" + RMDir "$SMPROGRAMS\eSim" + RMDir /r "$INSTDIR\..\eSim" + Delete "$DESKTOP\eSim.lnk" + + DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" + ;SetAutoClose true - DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" - SetAutoClose true SectionEnd - ;Descriptions + +;Descriptions-------------------- ;Language strings - ;LangString DESC_SecDummy ${LANG_ENGLISH} "Ngspice is a mixed-level/mixed-signal circuit simulator. Its code is based on three open source software packages: Spice3f5, Cider1b1 and Xspice. Ngspice is part of gEDA project, a full GPL'd suite of Electronic Design Automation tools." + ;LangString DESC_NgspiceSim ${LANG_ENGLISH} "Ngspice is a mixed-level/mixed-signal circuit simulator. Its code is based on three open source software packages: Spice3f5, Cider1b1 and Xspice. Ngspice is part of gEDA project, a full GPL'd suite of Electronic Design Automation tools." ;Assign language strings to sections ;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - ; !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy) - ; !insertmacro MUI_FUNCTION_DESCRIPTION_END + ;!insertmacro MUI_DESCRIPTION_TEXT ${NgspiceSim} $(DESC_NgspiceSim) + ;!insertmacro MUI_FUNCTION_DESCRIPTION_END ;--------------------------------
\ No newline at end of file |