Skip to content

Commit

Permalink
Leave dokan running during update if it's not changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Sanders committed Jan 29, 2016
1 parent b11c8c4 commit 00ed29c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 50 deletions.
1 change: 1 addition & 0 deletions go/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Only restart driver if necessary when upgrading on Windows (PR: keybase/client#1842)
- Fix formatting for certain errors (PR: keybase/client#1830)
- Cache InputCanceled from SecretUI from KBFS crypto ops (PR: keybase/client#1795)
- New `keybase status` command, previous one moved to `keybase dump-keyfamily`
Expand Down
12 changes: 8 additions & 4 deletions packaging/windows/build_prerelease.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ for /f %%i in ('winresource.exe -cb') do set KEYBASE_BUILD=%%i
echo %KEYBASE_BUILD%
go build -a -tags "prerelease production" -ldflags="-X github.com/keybase/client/go/libkb.CustomBuild=%KEYBASE_BUILD%"

:: Then build kbfsdokan with go build -tags "production prerelease"
:: Then build kbfsdokan
:: cd %GOPATH%\src\github.com\keybase\kbfs\kbfsdokan
:: go build -tags "production prerelease"

:: Then the desktop:
:: client\react-native\react>npm i
:: client\desktop>npm i
:: client\desktop>node package.js --arch ia32 --platform win32
:: cd %GOPATH%\src\github.com\keybase\client\react-native\react
:: npm i
:: cd %GOPATH%\src\github.com\keybase\client\desktop
:: npm i
:: node package.js --arch ia32 --platform win32
8 changes: 7 additions & 1 deletion packaging/windows/doinstaller_gui.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ echo %BUILDVER%
for /f "tokens=3" %%i in ('%1 -version') do set SEMVER=%%i
echo %SEMVER%

for /f %%i in ('PowerShell "(Get-Item %Folder%..\..\..\..\dokan-dev\dokany\Win32\Win10Release\dokan.sys).VersionInfo.FileVersion"') do set DOKANVER=%%i

This comment has been minimized.

Copy link
@taruti

taruti Jan 29, 2016

Contributor

Is the \Win10Release correct here? Or does the correct version vary depending on the Windows version running on the install machine?

This comment has been minimized.

Copy link
@zanderz

zanderz Jan 29, 2016

Contributor

This is just where I put the source components, kind of arbitrarily. Install target is a different location. I'll add a comment.
Also arbitrary is the choice of the 32 bit Win10 driver. There are 8 (4 windows versions times 32/64 bit) but they all seem to have the same version.

echo %DOKANVER%
IF %DOKANVER%=="" (
EXIT /B 1
)

:: Other alternate time servers:
:: http://timestamp.verisign.com/scripts/timstamp.dll
:: http://timestamp.globalsign.com/scripts/timestamp.dll
Expand All @@ -31,7 +37,7 @@ SignTool.exe sign /a /tr http://timestamp.digicert.com %Folder%..\..\desktop\rel
IF %ERRORLEVEL% NEQ 0 (
EXIT /B 1
)
"%ProgramFiles(x86)%\Inno Setup 5\iscc.exe" /DMyExePathName=%1 /DMyAppVersion=%BUILDVER% /DMySemVersion=%SEMVER% "/sSignCommand=signtool.exe sign /tr http://timestamp.digicert.com $f" setup_windows_gui.iss
"%ProgramFiles(x86)%\Inno Setup 5\iscc.exe" /DMyExePathName=%1 /DMyAppVersion=%BUILDVER% /DMySemVersion=%SEMVER% /DNewDokanVersion=%DOKANVER% "/sSignCommand=signtool.exe sign /tr http://timestamp.digicert.com $f" setup_windows_gui.iss

:: Afterwards, do:
:: powershell Get-FileHash -Algorithm sha256
Expand Down
106 changes: 61 additions & 45 deletions packaging/windows/setup_windows_gui.iss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#define MyExePathName MyGoPath + "\src\github.com\keybase\client\go\keybase\" + MyExeName
#endif
#define MyGoArch GetEnv('GOARCH')
#ifndef MyGoArch
#define MyGoArch "amd64"

#ifndef NewDokanVersion
#define NewDokanVersion ""
#endif

[Setup]
Expand Down Expand Up @@ -55,7 +56,6 @@ ArchitecturesInstallIn64BitMode=x64 ia64
; (there doesn't seem to be a way to make it conditional)
SignTool=SignCommand


[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

Expand All @@ -66,20 +66,20 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Source: "{#MyExePathName}"; DestDir: "{app}"; Flags: replacesameversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: "..\..\desktop\release\win32-ia32\Keybase-win32-ia32\*"; DestDir: "{app}\gui"; Flags: createallsubdirs recursesubdirs replacesameversion
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win7Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows7
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win8Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows8
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win8.1Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows8_1
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win10Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows10
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokan.dll"; DestDir: "{sys}"; Flags: 32bit
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokannp.dll"; DestDir: "{sys}"; Flags: 32bit
Source: "..\..\..\..\dokan-dev\dokany\x64\Win7Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows7
Source: "..\..\..\..\dokan-dev\dokany\x64\Win8Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows8
Source: "..\..\..\..\dokan-dev\dokany\x64\Win8.1Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows8_1
Source: "..\..\..\..\dokan-dev\dokany\x64\Win10Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows10
Source: "..\..\..\..\dokan-dev\dokany\x64\Release\dokan.dll"; DestDir: "{sys}"; Flags: 64bit; Check: IsX64
Source: "..\..\..\..\dokan-dev\dokany\x64\Release\dokannp.dll"; DestDir: "{sys}"; Flags: 64bit; Check: IsX64
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokanctl.exe"; DestDir: "{pf32}\Dokan\DokanLibrary"
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\mounter.exe"; DestDir: "{pf32}\Dokan\DokanLibrary"
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win7Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows7 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win8Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows8 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win8.1Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows8_1 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Win10Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsOtherArch and IsWindows10 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokan.dll"; DestDir: "{sys}"; Flags: 32bit; Check: IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokannp.dll"; DestDir: "{sys}"; Flags: 32bit; Check: IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Win7Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows7 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Win8Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows8 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Win8.1Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows8_1 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Win10Release\dokan.sys"; DestDir: "{sys}\drivers"; Check: IsX64 and IsWindows10 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Release\dokan.dll"; DestDir: "{sys}"; Flags: 64bit; Check: IsX64 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\x64\Release\dokannp.dll"; DestDir: "{sys}"; Flags: 64bit; Check: IsX64 and IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\dokanctl.exe"; DestDir: "{pf32}\Dokan\DokanLibrary"; Check: IsDokanBeingUpdated
Source: "..\..\..\..\dokan-dev\dokany\Win32\Release\mounter.exe"; DestDir: "{pf32}\Dokan\DokanLibrary"; Check: IsDokanBeingUpdated
Source: "..\..\..\..\..\..\bin\vc_redist.x86.exe"; DestDir: "{tmp}"
Source: "..\..\..\kbfs\kbfsdokan\kbfsdokan.exe"; DestDir: "{app}"; Flags: replacesameversion

Expand All @@ -98,8 +98,7 @@ WelcomeLabel2=This will install [name/ver] on your computer.
[Run]
Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/quiet /Q:a /c:""msiexec /qb /i vcredist.msi"""; StatusMsg: "Installing VisualStudio 2015 RunTime..."
Filename: "{app}\{#MyExeName}"; Parameters: "ctl watchdog"; Flags: runasoriginaluser runhidden nowait
Filename: "{pf32}\Dokan\DokanLibrary\dokanctl.exe"; Parameters: "/i a"; WorkingDir: "{pf32}\Dokan\DokanLibrary"; Flags: runhidden; Description: "Install Dokan Service"
Filename: "{app}\kbfsdokan.exe"; Parameters: "k:"; Flags: nowait runasoriginaluser runhidden
Filename: "{pf32}\Dokan\DokanLibrary\dokanctl.exe"; Parameters: "/i a"; WorkingDir: "{pf32}\Dokan\DokanLibrary"; Flags: runhidden; Description: "Install Dokan Service"; Check: IsDokanBeingUpdated
Filename: "{app}\gui\Keybase.exe"; WorkingDir: "{app}\gui"; Flags: nowait runasoriginaluser

[UninstallDelete]
Expand All @@ -109,14 +108,14 @@ Type: files; Name: "{userstartup}\{#MyAppName}.vbs"
Type: files; Name: "{userstartup}\{#MyAppName}.vbs"

[UninstallRun]
Filename: "{app}\{#MyExePathName}"; Parameters: "ctl stop"; WorkingDir: "{app}"; Flags: skipifdoesntexist
Filename: "{pf32}\Dokan\DokanLibrary\dokanctl.exe"; Parameters: "/r a"
Filename: "taskkill"; Parameters: "/f /im Keybase.exe"
Filename: "taskkill"; Parameters: "/f /im kbfsdokan.exe"
Filename: "{app}\{#MyExePathName}"; Parameters: "ctl stop"; WorkingDir: "{app}"; Flags: skipifdoesntexist
Filename: "{pf32}\Dokan\DokanLibrary\dokanctl.exe"; Parameters: "/r a"

[Code]
var
g_driverVer: String;
g_currentDokanVer: String;
// Simply invoking "Keybase.exe service" at startup results in an unsightly
// extra console window, so we'll emit this bit of script instead.
Expand All @@ -137,7 +136,6 @@ begin
lines[3] := ExpandConstant('WinScriptHost.Run Chr(34) & "{app}\kbfsdokan.exe" & Chr(34) & " k:", 0');
lines[4] := 'Set WinScriptHost = Nothing';
Result := SaveStringsToFile(filename,lines,true);
exit;
end;
Expand All @@ -152,43 +150,56 @@ begin
begin
CreateStartupScript();
end
else if CurStep=ssDone then
begin
Sleep(500);
ExecAsOriginalUser(ExpandConstant('{app}\kbfsdokan.exe'), 'K:\', '', SW_HIDE,
ewNoWait, ResultCode);
end
end;
function IsDokanBeingUpdated(): Boolean;
var
newVer: String;
begin
newVer := ExpandConstant('{#NewDokanVersion}');
Log('Old driver ver: ' + g_currentDokanVer);
Log('New driver ver: ' + newVer);
Result := not (CompareStr(g_currentDokanVer, newVer) = 0)
end;
// Restart if the driver got changed
function NeedRestart(): Boolean;
begin
Result := (Length(g_currentDokanVer) > 0) and IsDokanBeingUpdated();
end;
procedure StopKeybaseService();
var
ResultCode: Integer;
CommandName: string;
begin
// kill any electron UI instances
Exec('taskkill.exe', '/f /im Keybase.exe', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
// Launch Keybase ctl stop and wait for it to terminate
CommandName := ExpandConstant('{app}\{#MyExeName}');
Exec(CommandName, 'ctl stop', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
Sleep(100);
Exec('{pf32}\Dokan\DokanLibrary\dokanctl.exe', '/r a', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
// Now kill any electron UI instances
Exec('taskkill.exe', '/f /im Keybase.exe', '', SW_HIDE,
Exec('{pf32}\Dokan\DokanLibrary\dokanctl.exe', '/m K', '', SW_HIDE,

This comment has been minimized.

Copy link
@taruti

taruti Jan 29, 2016

Contributor

Is it '/m K' or '/u' 'K'?

This comment has been minimized.

Copy link
@zanderz

zanderz Jan 29, 2016

Contributor

Whoops, you are right. Should work even better after that!

ewWaitUntilTerminated, ResultCode);
Sleep(500);
Exec('taskkill.exe', '/f /im kbfsdokan.exe', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
Sleep(100);
end;
// Restart if the driver got changed
function NeedRestart(): Boolean;
var
newVer: String;
fileName: String;
begin
fileName := ExpandConstant('{sys}\drivers\dokan.sys');
GetVersionNumbersString(fileName, newVer);
Log('Old driver ver: ' + g_driverVer);
Log('New driver ver: ' + newVer);
Result := (Length(g_driverVer) > 0 ) and not (CompareStr(g_driverVer, newVer) = 0)
if IsDokanBeingUpdated() then
begin
Exec('{pf32}\Dokan\DokanLibrary\dokanctl.exe', '/r a', '', SW_HIDE,
ewWaitUntilTerminated, ResultCode);
end
end;
function UninstallNeedRestart(): Boolean;
Expand All @@ -198,12 +209,17 @@ begin
end;
function PrepareToInstall(var Needs: Boolean): String;
var
fileName: String;
begin
StopKeybaseService();
end;
function InitializeSetup(): Boolean;
var
fileName: string;
begin
fileName := ExpandConstant('{sys}\drivers\dokan.sys');
GetVersionNumbersString(fileName, g_driverVer);
GetVersionNumbersString(fileName, g_currentDokanVer);
Result := true;
end;
function IsX64: Boolean;
Expand Down

0 comments on commit 00ed29c

Please sign in to comment.