📄 colinux.nsi
字号:
Call StrStr Pop $R0 IntCmp $5 0 +1 tapcontrol_check_error tapcontrol_check_error IntCmp $R0 -1 tapinstall ;tapupdate: DetailPrint "TAP-Win32 UPDATE (please confirm Windows-Logo-Test)" nsExec::ExecToLog '"$INSTDIR\netdriver\tapcontrol.exe" update \ "$INSTDIR\netdriver\OemWin2k.inf" TAP0801co' Pop $R0 # return value/error/timeout IntOp $5 $5 | $R0 DetailPrint "tapcontrol update returned: $R0" Goto tapcontrol_check_error tapinstall: DetailPrint "TAP-Win32 INSTALL (please confirm Windows-Logo-Test)" nsExec::ExecToLog '"$INSTDIR\netdriver\tapcontrol.exe" install \ "$INSTDIR\netdriver\OemWin2k.inf" TAP0801co' Pop $R0 # return value/error/timeout IntOp $5 $5 | $R0 DetailPrint "tapcontrol install returned: $R0" tapcontrol_check_error: IntCmp $5 +1 notap MessageBox MB_OK "An error occurred installing the TAP-Win32 device driver." notap:SectionEnd;--------------------;Post-install sectionSection -post nsExec::ExecToStack '"$INSTDIR\colinux-daemon.exe" --remove-driver' Pop $R0 # return value/error/timeout Pop $R1 # Log nsExec::ExecToLog '"$INSTDIR\colinux-daemon.exe" --install-driver' Pop $R0 # return value/error/timeoutSectionEnd;--------------------------------;Descriptions LangString DESC_SecGrpcoLinux ${LANG_ENGLISH} "Install or upgrade coLinux. Install coLinux basics, driver, Linux kernel, Linux modules and docs" LangString DESC_SecNTConsole ${LANG_ENGLISH} "Native Windows (NT) coLinux console views Linux console in an NT DOS Command-line console" LangString DESC_SecFLTKConsole ${LANG_ENGLISH} "FLTK Cross-platform coLinux console to view Linux console and manage coLinux from a GUI program" LangString DESC_SeccoLinuxNet ${LANG_ENGLISH} "TAP Virtual Ethernet Driver as private network link between Linux and Windows" LangString DESC_SeccoLinuxNetSLiRP ${LANG_ENGLISH} "SLiRP Ethernet Driver as virtual Gateway for outgoings TCP and UDP connections - Simplest to use" LangString DESC_SeccoLinuxBridgedNet ${LANG_ENGLISH} "Bridge Ethernet support allows to join the coLinux machine to an existing network" LangString DESC_SeccoLinuxSerial ${LANG_ENGLISH} "Virtual Serial Driver allows to use serial Devices between Linux and Windows" LangString DESC_SeccoLinuxDebug ${LANG_ENGLISH} "Debugging allows to create extensive debug log for troubleshooting problems" LangString DESC_SecImage ${LANG_ENGLISH} "Download an image from sourceforge. Also provide useful links on how to use it" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecGrpcoLinux} $(DESC_SecGrpcoLinux) !insertmacro MUI_DESCRIPTION_TEXT ${SecNTConsole} $(DESC_SecNTConsole) !insertmacro MUI_DESCRIPTION_TEXT ${SecFLTKConsole} $(DESC_SecFLTKConsole) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxNet} $(DESC_SeccoLinuxNet) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxNetSLiRP} $(DESC_SeccoLinuxNetSLiRP) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxBridgedNet} $(DESC_SeccoLinuxBridgedNet) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxSerial} $(DESC_SeccoLinuxSerial) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxDebug} $(DESC_SeccoLinuxDebug) !insertmacro MUI_DESCRIPTION_TEXT ${SeccoLinuxImage} $(DESC_SecImage) !insertmacro MUI_FUNCTION_DESCRIPTION_END;--------------------------------;Uninstaller Section;--------------------------------Section "Uninstall" DetailPrint "TAP-Win32 REMOVE" nsExec::ExecToLog '"$INSTDIR\netdriver\tapcontrol.exe" remove TAP0801co' Pop $R0 # return value/error/timeout DetailPrint "tapcontrol remove returned: $R0" nsExec::ExecToLog '"$INSTDIR\colinux-daemon.exe" --remove-driver' Pop $R0 # return value/error/timeout ;---------------------------------------------------------------FILES-- ;---------------------------------------------------------------------- ; Delete "$INSTDIR\coLinux-console-fltk.exe" Delete "$INSTDIR\coLinux-console-nt.exe" Delete "$INSTDIR\coLinux-debug-daemon.exe" Delete "$INSTDIR\coLinux-serial-daemon.exe" Delete "$INSTDIR\coLinux-slirp-net-daemon.exe" Delete "$INSTDIR\coLinux-daemon.exe" Delete "$INSTDIR\coLinux-net-daemon.exe" Delete "$INSTDIR\coLinux-bridged-net-daemon.exe" Delete "$INSTDIR\linux.sys" Delete "$INSTDIR\vmlinux" Delete "$INSTDIR\initrd.gz" Delete "$INSTDIR\vmlinux-modules.tar.gz" Delete "$INSTDIR\README.txt" Delete "$INSTDIR\news.txt" Delete "$INSTDIR\cofs.txt" Delete "$INSTDIR\colinux-daemon.txt" Delete "$INSTDIR\debugging.txt" Delete "$INSTDIR\example.conf" Delete "$INSTDIR\netdriver\OemWin2k.inf" Delete "$INSTDIR\netdriver\tap0801co.sys" Delete "$INSTDIR\netdriver\tapcontrol.exe" Delete "$INSTDIR\netdriver\tap.cat" ;--------------------------------------------------------------/FILES-- ;---------------------------------------------------------------------- Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR\netdriver" RMDir "$INSTDIR" ; Cleanup registry DeleteRegKey HKLM ${REGUNINSTAL} DeleteRegKey HKLM ${REGEVENTS} DeleteRegKey /ifempty HKCU "Software\coLinux"SectionEnd# Functions #######################################;====================================================; StrStr - Finds a given string in another given string.; Returns -1 if not found and the pos if found.; Input: head of the stack - string to find; second in the stack - string to find in; Output: head of the stack;====================================================Function StrStr Push $0 Exch Pop $0 ; $0 now have the string to find Push $1 Exch 2 Pop $1 ; $1 now have the string to find in Exch Push $2 Push $3 Push $4 Push $5 StrCpy $2 -1 StrLen $3 $0 StrLen $4 $1 IntOp $4 $4 - $3 StrStr_loop: IntOp $2 $2 + 1 IntCmp $2 $4 0 0 StrStrReturn_notFound StrCpy $5 $1 $3 $2 StrCmp $5 $0 StrStr_done StrStr_loop StrStrReturn_notFound: StrCpy $2 -1 StrStr_done: Pop $5 Pop $4 Pop $3 Exch $2 Exch 2 Pop $0 Pop $1FunctionEnd##################################################### Downloads a file from a list of mirrors# (the fist mirror is selected at random)## Usage:# Push Mirror1# Push [Mirror2]# ...# Push [Mirror10]# Push NumMirrors # 10 Max# Push FileName# Call DownloadFromRandomMirror# Pop Return## Returns the NSISdl resultFunction DownloadFromRandomMirror Exch $R1 #File name Exch Exch $R0 #Number of Mirros Push $0 Exch 3 Pop $0 #Mirror 1 IntCmpU "2" $R0 0 0 +4 Push $1 Exch 4 Pop $1 #Mirror 2 IntCmpU "3" $R0 0 0 +4 Push $2 Exch 5 Pop $2 #Mirror 3 IntCmpU "4" $R0 0 0 +4 Push $3 Exch 6 Pop $3 #Mirror 4 IntCmpU "5" $R0 0 0 +4 Push $4 Exch 7 Pop $4 #Mirror 5 IntCmpU "6" $R0 0 0 +4 Push $5 Exch 8 Pop $5 #Mirror 6 IntCmpU "7" $R0 0 0 +4 Push $6 Exch 9 Pop $6 #Mirror 7 IntCmpU "8" $R0 0 0 +4 Push $7 Exch 10 Pop $7 #Mirror 8 IntCmpU "9" $R0 0 0 +4 Push $8 Exch 11 Pop $8 #Mirror 9 IntCmpU "10" $R0 0 0 +4 Push $9 Exch 12 Pop $9 #Mirror 10 Push $R4 Push $R2 Push $R3 Push $R5 Push $R6 # If you don't want a random mirror, replace this block with: # StrCpy $R3 "0" # ----------------------------------------------------------- StrCmp $RandomSeed "" 0 +2 StrCpy $RandomSeed $HWNDPARENT #init RandomSeed Push $RandomSeed Push $R0 Call LimitedRandomNumber Pop $R3 Pop $RandomSeed # ----------------------------------------------------------- StrCpy $R5 "0"MirrorsStart: IntOp $R5 $R5 + "1" StrCmp $R3 "0" 0 +3 StrCpy $R2 $0 Goto MirrorsEnd StrCmp $R3 "1" 0 +3 StrCpy $R2 $1 Goto MirrorsEnd StrCmp $R3 "2" 0 +3 StrCpy $R2 $2 Goto MirrorsEnd StrCmp $R3 "3" 0 +3 StrCpy $R2 $3 Goto MirrorsEnd StrCmp $R3 "4" 0 +3 StrCpy $R2 $4 Goto MirrorsEnd StrCmp $R3 "5" 0 +3 StrCpy $R2 $5 Goto MirrorsEnd StrCmp $R3 "6" 0 +3 StrCpy $R2 $6 Goto MirrorsEnd StrCmp $R3 "7" 0 +3 StrCpy $R2 $7 Goto MirrorsEnd StrCmp $R3 "8" 0 +3 StrCpy $R2 $8 Goto MirrorsEnd StrCmp $R3 "9" 0 +3 StrCpy $R2 $9 Goto MirrorsEnd StrCmp $R3 "10" 0 +3 StrCpy $R2 $10 Goto MirrorsEndMirrorsEnd: IntOp $R6 $R3 + "1" DetailPrint "Downloading from mirror $R6: $R2" NSISdl::download "$R2" "$R1" Pop $R4 StrCmp $R4 "success" Success StrCmp $R4 "cancel" DownloadCanceled IntCmp $R5 $R0 NoSuccess DetailPrint "Download failed (error $R4), trying with other mirror" IntOp $R3 $R3 + "1" IntCmp $R3 $R0 0 MirrorsStart StrCpy $R3 "0" Goto MirrorsStartDownloadCanceled: DetailPrint "Download Canceled: $R2" Goto EndNoSuccess: DetailPrint "Download Failed: $R1" Goto EndSuccess: DetailPrint "Download completed."End: Pop $R6 Pop $R5 Pop $R3 Pop $R2 Push $R4 Exch Pop $R4 Exch 2 Pop $R1 Exch 2 Pop $0 Exch IntCmpU "2" $R0 0 0 +4 Exch 2 Pop $1 Exch IntCmpU "3" $R0 0 0 +4 Exch 2 Pop $2 Exch IntCmpU "4" $R0 0 0 +4 Exch 2 Pop $3 Exch IntCmpU "5" $R0 0 0 +4 Exch 2 Pop $4 Exch IntCmpU "6" $R0 0 0 +4 Exch 2 Pop $5 Exch IntCmpU "7" $R0 0 0 +4 Exch 2 Pop $6 Exch IntCmpU "8" $R0 0 0 +4 Exch 2 Pop $7 Exch IntCmpU "9" $R0 0 0 +4 Exch 2 Pop $8 Exch IntCmpU "10" $R0 0 0 +4 Exch 2 Pop $9 Exch Pop $R0FunctionEnd################################################################# Returns a random number## Usage:# Push Seed (or previously generated number)# Call RandomNumber# Pop Generated Random NumberFunction RandomNumber Exch $R0 IntOp $R0 $R0 * "13" IntOp $R0 $R0 + "3" IntOp $R0 $R0 % "1048576" # Values goes from 0 to 1048576 (2^20) Exch $R0FunctionEnd###################################################### Returns a random number between 0 and Max-1## Usage:# Push Seed (or previously generated number)# Push MaxValue# Call RandomNumber# Pop Generated Random Number# Pop NewSeedFunction LimitedRandomNumber Exch $R0 Exch Exch $R1 Push $R2 Push $R3 StrLen $R2 $R0 Push $R1RandLoop: Call RandomNumber Pop $R1 #Random Number IntCmp $R1 $R0 0 NewRnd StrLen $R3 $R1 IntOp $R3 $R3 - $R2 IntOp $R3 $R3 / "2" StrCpy $R3 $R1 $R2 $R3 IntCmp $R3 $R0 0 RndEndNewRnd: Push $R1 Goto RandLoopRndEnd: StrCpy $R0 $R3 IntOp $R0 $R0 + "0" #removes initial 0's Pop $R3 Pop $R2 Exch $R1 Exch Exch $R0FunctionEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -