📄 colinux.nsi
字号:
;Cooperative Linux installer;Written by NEBOR Regis;Modified by Dan Aloni (c) 2004;Modified 8/20/2004,2/4/2004 by George P Boutwell;Modified 11/2/2007 by Henry Nestler;------------------------------------- !include "MUI.nsh" !include Sections.nsh !include "coLinux_def.inc" !define PUBLISHER "www.colinux.org" ;General Name "Cooperative Linux ${VERSION}" OutFile "coLinux.exe" ShowInstDetails show ShowUninstDetails show ;Folder selection page InstallDir "$PROGRAMFILES\coLinux" ;Get install folder from registry if available InstallDirRegKey HKCU "Software\coLinux" "" BrandingText "${PUBLISHER}" VIAddVersionKey ProductName "Cooperative Linux" VIAddVersionKey CompanyName "${PUBLISHER}" VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey FileVersion "${VERSION}" VIAddVersionKey FileDescription "An optimized virtual Linux system for Windows" VIAddVersionKey LegalCopyright "Copyright @ 2004-2007 ${PUBLISHER}" VIProductVersion "${LONGVERSION}" XPStyle on; For priority Unpack ReserveFile "iDl.ini" ReserveFile "WinpcapRedir.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS;--------------------------------;Interface Settings !define MUI_ABORTWARNING !define MUI_FINISHPAGE_NOAUTOCLOSE;--------------------------------;Pages !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "header.bmp" !define MUI_SPECIALBITMAP "startlogo.bmp" !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_WELCOMEPAGE_TITLE "Welcome to the coLinux ${VERSION} Setup Wizard" !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cooperative Linux ${VERSION}\r\n\r\n$_CLICK" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "..\..\..\..\..\..\COPYING" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY Page custom WinpcapRedir WinpcapRedirLeave Page custom StartDlImageFunc EndDlImageFunc !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_LINK "Visit the Cooperative Linux website" !define MUI_FINISHPAGE_LINK_LOCATION "http://www.colinux.org/" !define MUI_FINISHPAGE_SHOWREADME "README.TXT" !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES;--------------------------------;Languages !insertmacro MUI_LANGUAGE "English";------------------------------------------------------------------------;------------------------------------------------------------------------;Custom Setup for image download;Variables used to track user choice Var LOCATION Var RandomSeed; StartDlImageFunc down for reference resolutionFunction EndDlImageFuncFunctionEndFunction WinpcapRedirLeaveFunctionEndFunction .onInit !insertmacro MUI_INSTALLOPTIONS_EXTRACT "iDl.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "WinpcapRedir.ini"FunctionEnd;------------------------------------------------------------------------;------------------------------------------------------------------------;Installer SectionsSectionGroup "coLinux" SecGrpcoLinuxSection ;-------------------------------------------Uninstall with old driver-- ;---------------------------------------------------------------------- ;get the old install folder ReadRegStr $R2 HKCU "Software\coLinux" "" StrCmp $R2 "" no_old_linux_sys ;path without "" StrCpy $R1 $R2 1 StrCmp $R1 '"' 0 +2 StrCpy $R2 $R2 -1 1 ;Check old daemon for removing driver IfFileExists "$R2\colinux-daemon.exe" 0 no_old_linux_sys ;Runs any monitor?check_running_monitors: DetailPrint "Check running monitors" nsExec::ExecToStack '"$R2\colinux-daemon.exe" --status-driver' Pop $R0 # return value/error/timeout Pop $R1 # Log ;Remove, if no monitor is running Push $R1 Push "current number of monitors: 0" Call StrStr Pop $R0 Pop $R1 IntCmp $R0 -1 0 remove_linux_sys remove_linux_sys ;remove anyway, if no can detect running status Push $R1 Push "current number of monitors:" Call StrStr Pop $R0 Pop $R1 IntCmp $R0 -1 remove_linux_sys MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION \ "Any coLinux is running.$\nPlease stop it, before continue" \ IDRETRY check_running_monitors DetailPrint "Abort" Abortremove_linux_sys: DetailPrint "Uninstall old linux driver" nsExec::ExecToLog '"$R2\colinux-daemon.exe" --remove-driver' Pop $R0 # return value/error/timeoutno_old_linux_sys: ;------------------------------------------------------------REGISTRY-- ;---------------------------------------------------------------------- !define REGUNINSTAL "Software\Microsoft\Windows\CurrentVersion\Uninstall\coLinux" !define REGEVENTS "SYSTEM\CurrentControlSet\Services\Eventlog\Application\coLinux" WriteRegStr HKLM ${REGUNINSTAL} "DisplayName" "coLinux ${VERSION}" WriteRegStr HKLM ${REGUNINSTAL} "UninstallString" '"$INSTDIR\Uninstall.exe"' WriteRegStr HKLM ${REGUNINSTAL} "DisplayIcon" "$INSTDIR\colinux-daemon.exe,0" WriteRegDWORD HKLM ${REGUNINSTAL} "NoModify" "1" WriteRegDWORD HKLM ${REGUNINSTAL} "NoRepair" "1" ; plain text in event log view WriteRegStr HKLM ${REGEVENTS} "EventMessageFile" "$INSTDIR\colinux-daemon.exe" WriteRegDWORD HKLM ${REGEVENTS} "TypesSupported" "4" ;EVENTLOG_INFORMATION_TYPE ;---------------------------------------------------------------FILES-- ;---------------------------------------------------------------------- ; Our Files . If you adds something here, Remember to delete it in ; the uninstall section SetOutPath "$INSTDIR" File "premaid\coLinux-daemon.exe" File "premaid\linux.sys" File "premaid\README.txt" File "premaid\news.txt" File "premaid\cofs.txt" File "premaid\colinux-daemon.txt" File "premaid\vmlinux" File "premaid\vmlinux-modules.tar.gz" ; initrd installs modules vmlinux-modules.tar.gz over cofs31 on first start File "premaid\initrd.gz" ;Backup config file if present IfFileExists "$INSTDIR\example.conf" 0 +2 CopyFiles /SILENT "$INSTDIR\example.conf" "$INSTDIR\example.conf.old" File "premaid\example.conf" ; Remove kludge from older installations Delete "$INSTDIR\packet.dll" Delete "$INSTDIR\wpcap.dll" ;--------------------------------------------------------------/FILES-- ;---------------------------------------------------------------------- ;Store install folder WriteRegStr HKCU "Software\coLinux" "" "$INSTDIR" ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe"SectionEndSection "Native Windows Linux Console (NT)" SecNTConsole File "premaid\coLinux-console-nt.exe"SectionEndSection "Cross-platform Linux Console (FLTK)" SecFLTKConsole File "premaid\coLinux-console-fltk.exe"SectionEndSection "Virtual Ethernet Driver (coLinux TAP-Win32)" SeccoLinuxNet SetOutPath "$INSTDIR\netdriver" File "premaid\netdriver\OemWin2k.inf" File "premaid\netdriver\tap0801co.sys" File "premaid\netdriver\tapcontrol.exe" File "premaid\netdriver\tap.cat" SetOutPath "$INSTDIR" File "premaid\coLinux-net-daemon.exe"SectionEndSection "Virtual Network Daemon (SLiRP)" SeccoLinuxNetSLiRP File "premaid\coLinux-slirp-net-daemon.exe"SectionEndSection "Bridged Ethernet (WinPcap)" SeccoLinuxBridgedNet File "premaid\coLinux-bridged-net-daemon.exe"SectionEndSection "Virtual Serial Device (ttyS)" SeccoLinuxSerial File "premaid\coLinux-serial-daemon.exe"SectionEndSection "Debugging" SeccoLinuxDebug File "premaid\coLinux-debug-daemon.exe" File "premaid\debugging.txt"SectionEndSectionGroupEnd# Defines must sync with entries in file iDl.ini!define IDL_NOTHING 1!define IDL_ARCHLINUX 2!define IDL_DEBIAN 3!define IDL_FEDORA 4!define IDL_GENTOO 5!define IDL_UBUNTU 6!define IDL_LOCATION 7Section "Root Filesystem image Download" SeccoLinuxImage ;---------------------------------------------------------- ; Random sourceforge download ;Read a value from an InstallOptions INI file and set the filenames !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_NOTHING}" "State" StrCmp $R1 "1" End !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_ARCHLINUX}" "State" StrCpy $R0 "ArchLinux-0.7.2-ext3-512mb.7z" StrCmp $R1 "1" tryDownload !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_DEBIAN}" "State" StrCpy $R0 "Debian-4.0r0-etch.ext3.1gb.bz2" StrCmp $R1 "1" tryDownload !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_FEDORA}" "State" StrCpy $R0 "Fedora-7-20070906.exe" StrCmp $R1 "1" tryDownload !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_GENTOO}" "State" StrCpy $R0 "Gentoo-colinux-i686-2007-03-03.7z" StrCmp $R1 "1" tryDownload !insertmacro MUI_INSTALLOPTIONS_READ $R1 "iDl.ini" "Field ${IDL_UBUNTU}" "State" StrCpy $R0 "Ubuntu-6.06.1.ext3.1gb.bz2" StrCmp $R1 "1" tryDownload GoTo End tryDownload: StrCpy $R1 "colinux" ; project !insertmacro MUI_INSTALLOPTIONS_READ $LOCATION "iDl.ini" "Field ${IDL_LOCATION}" "State" StrCmp $LOCATION "SourceForge defaults" SFdefault ;This is the preferred way and counts the stats StrCmp $LOCATION "Asia" Asia StrCmp $LOCATION "Australia" Australia StrCmp $LOCATION "Europe" Europe StrCmp $LOCATION "North America" NorthAmerica StrCmp $LOCATION "South America" SouthAmerica ;Random: ;MessageBox MB_OK "Random" Push "http://belnet.dl.sourceforge.net/sourceforge/$R1/$R0" ;Europe Push "http://heanet.dl.sourceforge.net/sourceforge/$R1/$R0" ;Europe Push "http://easynews.dl.sourceforge.net/sourceforge/$R1/$R0" ;NorthAmerica Push "http://twtelecom.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? NorthAmerika Push "http://flow.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push "http://aleron.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? NorthAmerika Push "http://umn.dl.sourceforge.net/sourceforge/$R1/$R0" ;NorthAmerika Push "http://jaist.dl.sourceforge.net/sourceforge/$R1/$R0" ;Asia Push "http://optusnet.dl.sourceforge.net/sourceforge/$R1/$R0" ;Australia Push "http://mesh.dl.sourceforge.net/sourceforge/$R1/$R0" ;Europe Push 10 Goto DownloadRandom Asia: ;MessageBox MB_OK "Asia" Push "http://jaist.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://nchc.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://keihanna.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push 3 Goto DownloadRandom Australia: Push "http://optusnet.dl.sourceforge.net/sourceforge/$R1/$R0" Push 1 Goto DownloadRandom Europe: ;MessageBox MB_OK "Europe" Push "http://belnet.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://puzzle.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://switch.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://mesh.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://ohv.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://heanet.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://surfnet.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://kent.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://cesnet.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push 9 Goto DownloadRandom NorthAmerica: ;MessageBox MB_OK "NorthAmerica" Push "http://easynews.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://superb-west.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://superb-east.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://umn.dl.sourceforge.net/sourceforge/$R1/$R0" Push "http://twtelecom.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push "http://aleron.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push "http://unc.dl.sourceforge.net/sourceforge/$R1/$R0" ;?? Push 7 Goto DownloadRandom SouthAmerica: Push "http://ufpr.dl.sourceforge.net/sourceforge/$R1/$R0" Push 1 Goto DownloadRandom SFdefault: Push "http://downloads.sourceforge.net/$R1/$R0?download" Push 1 DownloadRandom: Push "$INSTDIR\$R0" Call DownloadFromRandomMirror Pop $0 End: SectionEndFunction StartDlImageFunc SectionGetFlags ${SeccoLinuxImage} $R0 IntOp $R0 $R0 & ${SF_SELECTED} IntCmp $R0 ${SF_SELECTED} "" ImageEnd ImageEnd !insertmacro MUI_HEADER_TEXT "Obtain a coLinux root file system image" "Choose a location" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "iDl.ini" ImageEnd:FunctionEndFunction WinpcapRedir SectionGetFlags ${SeccoLinuxBridgedNet} $R0 IntOp $R0 $R0 & ${SF_SELECTED} IntCmp $R0 ${SF_SELECTED} "" WinpcapEnd WinpcapEnd !insertmacro MUI_HEADER_TEXT "Get WinPCAP" "Install Bridged Ethernet WinPCAP dependency" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "WinpcapRedir.ini" WinpcapEnd:FunctionEnd;--------------------;Post-install sectionSection -post;---- Directly from OpenVPN install script , some minor mods SectionGetFlags ${SeccoLinuxNet} $R0 IntOp $R0 $R0 & ${SF_SELECTED} IntCmp $R0 ${SF_SELECTED} "" notap notap ; TAP install/update was selected. ; Should we install or update? ; If tapcontrol error occurred, $5 will ; be nonzero. IntOp $5 0 & 0 nsExec::ExecToStack '"$INSTDIR\netdriver\tapcontrol.exe" hwids TAP0801co' Pop $R0 # return value/error/timeout # leave Log in stack IntOp $5 $5 | $R0 DetailPrint "tapcontrol hwids returned: $R0" ; If tapcontrol output string contains "TAP" we assume ; that TAP device has been previously installed, ; therefore we will update, not install. Push "TAP"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -