"Fossies" - the Fresh Open Source Software Archive

Member "scm/scm.nsi" (16 Feb 2020, 13204 Bytes) of package /linux/privat/scm-5f3.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) NSIS source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "scm.nsi": 5f2_vs_5f3.

    1 ; Install SCM on Windows for current user
    2 ; Basic script generated by the HM NIS Edit Script Wizard.
    3 ; Augmented by Jerry van Dijk, february 2007
    4 ; placed in the public domain
    5 
    6 ; *** version numbers ***
    7 !define PRODUCT_VERSION "5f3-1"
    8 !define REQ_SLIB_VERSION "3b6-1"
    9 
   10 ; ----------------[ NO CHANGES BELOW ]----------------
   11 
   12 ; *** unless files are added or removed ***
   13 ; *** remember to edit both 'file' and 'delete' sections!
   14 
   15 ; *** registry settings ***
   16 !define KEY_VERSION "version"
   17 !define SCM_KEY "Software\Voluntocracy\scm"
   18 !define SLIB_KEY "Software\Voluntocracy\slib"
   19 
   20 ; HM NIS Edit Wizard helper defines
   21 !define PRODUCT_NAME "SCM"
   22 !define PRODUCT_COMPANY "Voluntocracy"
   23 !define PRODUCT_PUBLISHER "Aubrey Jaffer"
   24 !define PRODUCT_WEB_SITE "http://people.csail.mit.edu/jaffer/SCM.html"
   25 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\scm-${PRODUCT_VERSION}.exe"
   26 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
   27 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
   28 !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
   29 
   30 ; MUI 1.67 compatible ------
   31 !include "MUI.nsh"
   32 
   33 ; MUI Settings
   34 !define MUI_ABORTWARNING
   35 !define MUI_ICON "SCM.ico"
   36 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
   37 
   38 ; Welcome page
   39 !insertmacro MUI_PAGE_WELCOME
   40 
   41 ; License page
   42 !insertmacro MUI_PAGE_LICENSE "COPYING"
   43 
   44 ; Directory page
   45 !insertmacro MUI_PAGE_DIRECTORY
   46 
   47 ; Start menu page
   48 var ICONS_GROUP
   49 !define MUI_STARTMENUPAGE_NODISABLE
   50 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "scm"
   51 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
   52 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
   53 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
   54 !insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
   55 
   56 ; Instfiles page
   57 !insertmacro MUI_PAGE_INSTFILES
   58 
   59 ; Finish page
   60 !insertmacro MUI_PAGE_FINISH
   61 
   62 ; Uninstaller pages
   63 !insertmacro MUI_UNPAGE_INSTFILES
   64 
   65 ; Language files
   66 !insertmacro MUI_LANGUAGE "English"
   67 
   68 ; MUI end ------
   69 
   70 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
   71 OutFile "scm-${PRODUCT_VERSION}.exe"
   72 InstallDir "$PROGRAMFILES\scm"
   73 InstallDirRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" ""
   74 ShowInstDetails show
   75 ShowUnInstDetails show
   76 
   77 ; Check that the correct slib is installed, and no other scm version is present
   78 Function .onInit
   79 ; Check that slib is installed
   80   ClearErrors
   81   ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${SLIB_KEY}" "${KEY_VERSION}"
   82   IfErrors 0 +3
   83   MessageBox MB_OK|MB_ICONSTOP "No SLIB found. Please install SLIB before installing SCM."
   84   Abort
   85 
   86 ; Check that the correct slib is installed
   87   StrCmp $0 ${REQ_SLIB_VERSION} +3 0
   88   MessageBox MB_OK|MB_ICONSTOP "Found SLIB version $0. SCM ${PRODUCT_VERSION} requires SLIB ${REQ_SLIB_VERSION}. Please install this SLIB version first."
   89   Abort
   90 
   91 ; Check for older scm installed
   92   ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${SCM_KEY}" "${KEY_VERSION}"
   93   StrCmp $0 '' +4 0
   94   StrCmp $0 ${PRODUCT_VERSION} +3 0
   95   MessageBox MB_OK|MB_ICONSTOP "You already have SCM version $0 installed. Please uninstall this SCM first."
   96   Abort
   97 
   98 FunctionEnd
   99 
  100 Section "MainSection" SEC01
  101   SetOutPath "$INSTDIR"
  102   SetOverwrite try
  103   File "scm.exe"
  104   File "scm.html"
  105   File "SCM.ico"
  106   File "Init5f3.scm"
  107   File "Tscript.scm"
  108   File "Transcen.scm"
  109   File "mkimpcat.scm"
  110   File "hobbit.scm"
  111   File "scmhob.scm"
  112   File "hobbit.html"
  113   File "wbtab.scm"
  114   File "rwb-isam.scm"
  115   File "r4rstest.scm"
  116   File "pi.scm"
  117 
  118 ; Shortcuts
  119   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  120   CreateShortCut "$DESKTOP\SCM.lnk" "$INSTDIR\scm.exe" "" "$INSTDIR\SCM.ico"
  121   CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
  122   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\SCM Manual.lnk" "$INSTDIR\scm.html"
  123   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\SCM.lnk" "$INSTDIR\scm.exe" "" "$INSTDIR\SCM.ico"
  124   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Hobbit Manual.lnk" "$INSTDIR\hobbit.html"
  125   !insertmacro MUI_STARTMENU_WRITE_END
  126 
  127 ; Jaffer scm registry settings
  128   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${SCM_KEY}" "${KEY_VERSION}" "${PRODUCT_VERSION}"
  129 
  130 ; Jaffer scm path settings
  131   Push "$INSTDIR\"
  132   Call AddToPath
  133 
  134 SectionEnd
  135 
  136 Section -AdditionalIcons
  137   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  138   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  139   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  140   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
  141   !insertmacro MUI_STARTMENU_WRITE_END
  142 SectionEnd
  143 
  144 Section -Post
  145   WriteUninstaller "$INSTDIR\uninst.exe"
  146   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\scm-${PRODUCT_VERSION}.exe"
  147   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  148   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  149   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\scm-${PRODUCT_VERSION}.exe"
  150   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  151   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  152   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  153 SectionEnd
  154 
  155 Function .onInstSuccess
  156   IfRebootFlag 0 noreboot
  157     MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON1 "A reboot is required to finish the installation. Do you wish to reboot now?" IDNO noreboot
  158       Reboot
  159   noreboot:
  160 FunctionEnd
  161 
  162 Function un.onUninstSuccess
  163   HideWindow
  164   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
  165 FunctionEnd
  166 
  167 Function un.onInit
  168   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
  169   Abort
  170 FunctionEnd
  171 
  172 Section Uninstall
  173   !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
  174   Delete "$INSTDIR\${PRODUCT_NAME}.url"
  175   Delete "$INSTDIR\uninst.exe"
  176   Delete "$INSTDIR\pi.scm"
  177   Delete "$INSTDIR\r4rstest.scm"
  178   Delete "$INSTDIR\rwb-isam.scm"
  179   Delete "$INSTDIR\wbtab.scm"
  180   Delete "$INSTDIR\hobbit.html"
  181   Delete "$INSTDIR\scmhob.scm"
  182   Delete "$INSTDIR\hobbit.scm"
  183   Delete "$INSTDIR\mkimpcat.scm"
  184   Delete "$INSTDIR\Transcen.scm"
  185   Delete "$INSTDIR\Tscript.scm"
  186   Delete "$INSTDIR\Init5f3.scm"
  187   Delete "$INSTDIR\SCM.ico"
  188   Delete "$INSTDIR\scm.html"
  189   Delete "$INSTDIR\scm.exe"
  190   Delete "$INSTDIR\scmlit.exe"
  191   Delete "$INSTDIR\implcat"
  192   Delete "$INSTDIR\slibcat"
  193   Delete "$INSTDIR\tmp1"
  194   Delete "$INSTDIR\tmp2"
  195   Delete "$INSTDIR\tmp3"
  196 
  197   Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
  198   Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
  199   Delete "$SMPROGRAMS\$ICONS_GROUP\SCM.lnk"
  200   Delete "$SMPROGRAMS\$ICONS_GROUP\SCM Manual.lnk"
  201   Delete "$SMPROGRAMS\$ICONS_GROUP\Hobbit Manual.lnk"
  202   Delete "$DESKTOP\SCM.lnk"
  203 
  204   RMDir "$SMPROGRAMS\$ICONS_GROUP"
  205   RMDir "$INSTDIR"
  206 
  207   # remove from the path
  208   Push "$INSTDIR\"
  209   Call un.RemoveFromPath
  210 
  211   ; remove Jaffer registry entries
  212   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${SCM_KEY}"
  213 
  214   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  215   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}"
  216   SetAutoClose true
  217 
  218 SectionEnd
  219 
  220 ; ----------------[ ENVIRONMENT MANIPULATION ]----------------
  221 
  222 !ifndef WriteEnvStr_RegKey
  223   !ifdef ALL_USERS
  224     !define WriteEnvStr_RegKey \
  225        'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  226   !else
  227     !define WriteEnvStr_RegKey 'HKCU "Environment"'
  228   !endif
  229 !endif
  230 
  231 
  232 ; ----------------[ EXECUTABLE PATH MANIPULATION ]----------------
  233 
  234 ; AddToPath - Adds the given dir to the search path.
  235 ;        Input - head of the stack
  236 ;        Note - Win9x systems requires reboot
  237 
  238 Function AddToPath
  239   Exch $0
  240   Push $1
  241   Push $2
  242   Push $3
  243 
  244   # don't add if the path doesn't exist
  245   IfFileExists "$0\*.*" "" AddToPath_done
  246 
  247   ReadEnvStr $1 PATH
  248   Push "$1;"
  249   Push "$0;"
  250   Call StrStr
  251   Pop $2
  252   StrCmp $2 "" "" AddToPath_done
  253   Push "$1;"
  254   Push "$0\;"
  255   Call StrStr
  256   Pop $2
  257   StrCmp $2 "" "" AddToPath_done
  258   GetFullPathName /SHORT $3 $0
  259   Push "$1;"
  260   Push "$3;"
  261   Call StrStr
  262   Pop $2
  263   StrCmp $2 "" "" AddToPath_done
  264   Push "$1;"
  265   Push "$3\;"
  266   Call StrStr
  267   Pop $2
  268   StrCmp $2 "" "" AddToPath_done
  269 
  270   Call IsNT
  271   Pop $1
  272   StrCmp $1 1 AddToPath_NT
  273     ; Not on NT
  274     StrCpy $1 $WINDIR 2
  275     FileOpen $1 "$1\autoexec.bat" a
  276     FileSeek $1 -1 END
  277     FileReadByte $1 $2
  278     IntCmp $2 26 0 +2 +2 # DOS EOF
  279       FileSeek $1 -1 END # write over EOF
  280     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
  281     FileClose $1
  282     SetRebootFlag true
  283     Goto AddToPath_done
  284 
  285   AddToPath_NT:
  286     ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
  287     StrCmp $1 "" AddToPath_NTdoIt
  288       Push $1
  289       Call Trim
  290       Pop $1
  291       StrCpy $0 "$1;$0"
  292     AddToPath_NTdoIt:
  293       WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0
  294       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  295 
  296   AddToPath_done:
  297     Pop $3
  298     Pop $2
  299     Pop $1
  300     Pop $0
  301 FunctionEnd
  302 
  303 ; RemoveFromPath - Remove a given dir from the path
  304 ;     Input: head of the stack
  305 
  306 Function un.RemoveFromPath
  307   Exch $0
  308   Push $1
  309   Push $2
  310   Push $3
  311   Push $4
  312   Push $5
  313   Push $6
  314 
  315   IntFmt $6 "%c" 26 # DOS EOF
  316 
  317   Call un.IsNT
  318   Pop $1
  319   StrCmp $1 1 unRemoveFromPath_NT
  320     ; Not on NT
  321     StrCpy $1 $WINDIR 2
  322     FileOpen $1 "$1\autoexec.bat" r
  323     GetTempFileName $4
  324     FileOpen $2 $4 w
  325     GetFullPathName /SHORT $0 $0
  326     StrCpy $0 "SET PATH=%PATH%;$0"
  327     Goto unRemoveFromPath_dosLoop
  328 
  329     unRemoveFromPath_dosLoop:
  330       FileRead $1 $3
  331       StrCpy $5 $3 1 -1 # read last char
  332       StrCmp $5 $6 0 +2 # if DOS EOF
  333         StrCpy $3 $3 -1 # remove DOS EOF so we can compare
  334       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
  335       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
  336       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
  337       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  338       FileWrite $2 $3
  339       Goto unRemoveFromPath_dosLoop
  340       unRemoveFromPath_dosLoopRemoveLine:
  341         SetRebootFlag true
  342         Goto unRemoveFromPath_dosLoop
  343 
  344     unRemoveFromPath_dosLoopEnd:
  345       FileClose $2
  346       FileClose $1
  347       StrCpy $1 $WINDIR 2
  348       Delete "$1\autoexec.bat"
  349       CopyFiles /SILENT $4 "$1\autoexec.bat"
  350       Delete $4
  351       Goto unRemoveFromPath_done
  352 
  353   unRemoveFromPath_NT:
  354     ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
  355     StrCpy $5 $1 1 -1 # copy last char
  356     StrCmp $5 ";" +2 # if last char != ;
  357       StrCpy $1 "$1;" # append ;
  358     Push $1
  359     Push "$0;"
  360     Call un.StrStr ; Find `$0;` in $1
  361     Pop $2 ; pos of our dir
  362     StrCmp $2 "" unRemoveFromPath_done
  363       ; else, it is in path
  364       # $0 - path to add
  365       # $1 - path var
  366       StrLen $3 "$0;"
  367       StrLen $4 $2
  368       StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
  369       StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
  370       StrCpy $3 $5$6
  371 
  372       StrCpy $5 $3 1 -1 # copy last char
  373       StrCmp $5 ";" 0 +2 # if last char == ;
  374         StrCpy $3 $3 -1 # remove last char
  375 
  376       WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3
  377       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  378 
  379   unRemoveFromPath_done:
  380     Pop $6
  381     Pop $5
  382     Pop $4
  383     Pop $3
  384     Pop $2
  385     Pop $1
  386     Pop $0
  387 FunctionEnd
  388 
  389 ; ----------------[ OS TYPE DETERMINATION ]----------------
  390 
  391 #
  392 # [un.]IsNT - Pushes 1 if running on NT, 0 if not
  393 #
  394 # Example:
  395 #   Call IsNT
  396 #   Pop $0
  397 #   StrCmp $0 1 +3
  398 #     MessageBox MB_OK "Not running on NT!"
  399 #     Goto +2
  400 #     MessageBox MB_OK "Running on NT!"
  401 #
  402 !macro IsNT UN
  403 Function ${UN}IsNT
  404   Push $0
  405   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  406   StrCmp $0 "" 0 IsNT_yes
  407   ; we are not NT.
  408   Pop $0
  409   Push 0
  410   Return
  411 
  412   IsNT_yes:
  413     ; NT!!!
  414     Pop $0
  415     Push 1
  416 FunctionEnd
  417 !macroend
  418 !insertmacro IsNT ""
  419 !insertmacro IsNT "un."
  420 
  421 ; ----------------[ STRING MANIPULATION ]----------------
  422 
  423 ; StrStr
  424 ; input, top of stack = string to search for
  425 ;        top of stack-1 = string to search in
  426 ; output, top of stack (replaces with the portion of the string remaining)
  427 ; modifies no other variables.
  428 ;
  429 ; Usage:
  430 ;   Push "this is a long ass string"
  431 ;   Push "ass"
  432 ;   Call StrStr
  433 ;   Pop $R0
  434 ;  ($R0 at this point is "ass string")
  435 
  436 !macro StrStr un
  437 Function ${un}StrStr
  438 Exch $R1 ; st=haystack,old$R1, $R1=needle
  439   Exch    ; st=old$R1,haystack
  440   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
  441   Push $R3
  442   Push $R4
  443   Push $R5
  444   StrLen $R3 $R1
  445   StrCpy $R4 0
  446   ; $R1=needle
  447   ; $R2=haystack
  448   ; $R3=len(needle)
  449   ; $R4=cnt
  450   ; $R5=tmp
  451   loop:
  452     StrCpy $R5 $R2 $R3 $R4
  453     StrCmp $R5 $R1 done
  454     StrCmp $R5 "" done
  455     IntOp $R4 $R4 + 1
  456     Goto loop
  457 done:
  458   StrCpy $R1 $R2 "" $R4
  459   Pop $R5
  460   Pop $R4
  461   Pop $R3
  462   Pop $R2
  463   Exch $R1
  464 FunctionEnd
  465 !macroend
  466 !insertmacro StrStr ""
  467 !insertmacro StrStr "un."
  468 
  469 Function Trim ; Added by Pelaca
  470     Exch $R1
  471     Push $R2
  472 Loop:
  473     StrCpy $R2 "$R1" 1 -1
  474     StrCmp "$R2" " " RTrim
  475     StrCmp "$R2" "$\n" RTrim
  476     StrCmp "$R2" "$\r" RTrim
  477     StrCmp "$R2" ";" RTrim
  478     GoTo Done
  479 RTrim:
  480     StrCpy $R1 "$R1" -1
  481     Goto Loop
  482 Done:
  483     Pop $R2
  484     Exch $R1
  485 FunctionEnd