From fd53afd70ca44948017eebe11d4a3464f7692fcb Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 8 Nov 2022 12:23:22 +0800 Subject: [PATCH] fix: add installation folder to system path (#17943) * fix: add installation folder to system path * fix: add c:\tdengine in env path to issc setup --- packaging/release.bat | 2 +- packaging/tools/make_install.bat | 97 ++++++++++++++++++++++---------- packaging/tools/tdengine.iss | 23 ++++++++ 3 files changed, 91 insertions(+), 31 deletions(-) diff --git a/packaging/release.bat b/packaging/release.bat index 4c82c5ead5..4ab7297f03 100644 --- a/packaging/release.bat +++ b/packaging/release.bat @@ -39,7 +39,7 @@ if not exist %work_dir%\debug\ver-%2-x86 ( md %work_dir%\debug\ver-%2-x86 ) cd %work_dir%\debug\ver-%2-x64 -call vcvarsall.bat x64 +rem #call vcvarsall.bat x64 cmake ../../ -G "NMake Makefiles JOM" -DCMAKE_MAKE_PROGRAM=jom -DBUILD_TOOLS=true -DWEBSOCKET=true -DBUILD_HTTP=false -DBUILD_TEST=false -DVERNUMBER=%2 -DCPUTYPE=x64 cmake --build . rd /s /Q C:\TDengine diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index f5d1e45690..c19519f9a1 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -1,4 +1,7 @@ @echo off + +for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a" + goto %1 :needAdmin @@ -11,60 +14,94 @@ set binary_dir=%3 set binary_dir=%binary_dir:/=\\% set osType=%4 set verNumber=%5 -set tagert_dir=C:\\TDengine +set target_dir=C:\\TDengine -if not exist %tagert_dir% ( - mkdir %tagert_dir% +if not exist %target_dir% ( + mkdir %target_dir% ) -if not exist %tagert_dir%\\cfg ( - mkdir %tagert_dir%\\cfg +if not exist %target_dir%\\cfg ( + mkdir %target_dir%\\cfg ) -if not exist %tagert_dir%\\include ( - mkdir %tagert_dir%\\include +if not exist %target_dir%\\include ( + mkdir %target_dir%\\include ) -if not exist %tagert_dir%\\driver ( - mkdir %tagert_dir%\\driver +if not exist %target_dir%\\driver ( + mkdir %target_dir%\\driver ) if not exist C:\\TDengine\\cfg\\taos.cfg ( - copy %source_dir%\\packaging\\cfg\\taos.cfg %tagert_dir%\\cfg\\taos.cfg > nul + copy %source_dir%\\packaging\\cfg\\taos.cfg %target_dir%\\cfg\\taos.cfg > nul ) if exist %binary_dir%\\test\\cfg\\taosadapter.toml ( - if not exist %tagert_dir%\\cfg\\taosadapter.toml ( - copy %binary_dir%\\test\\cfg\\taosadapter.toml %tagert_dir%\\cfg\\taosadapter.toml > nul + if not exist %target_dir%\\cfg\\taosadapter.toml ( + copy %binary_dir%\\test\\cfg\\taosadapter.toml %target_dir%\\cfg\\taosadapter.toml > nul ) ) -copy %source_dir%\\include\\client\\taos.h %tagert_dir%\\include > nul -copy %source_dir%\\include\\util\\taoserror.h %tagert_dir%\\include > nul -copy %source_dir%\\include\\libs\\function\\taosudf.h %tagert_dir%\\include > nul -copy %binary_dir%\\build\\lib\\taos.lib %tagert_dir%\\driver > nul -copy %binary_dir%\\build\\lib\\taos_static.lib %tagert_dir%\\driver > nul -copy %binary_dir%\\build\\lib\\taos.dll %tagert_dir%\\driver > nul -copy %binary_dir%\\build\\bin\\taos.exe %tagert_dir% > nul -copy %binary_dir%\\build\\bin\\taosd.exe %tagert_dir% > nul -copy %binary_dir%\\build\\bin\\udfd.exe %tagert_dir% > nul +copy %source_dir%\\include\\client\\taos.h %target_dir%\\include > nul +copy %source_dir%\\include\\util\\taoserror.h %target_dir%\\include > nul +copy %source_dir%\\include\\libs\\function\\taosudf.h %target_dir%\\include > nul +copy %binary_dir%\\build\\lib\\taos.lib %target_dir%\\driver > nul +copy %binary_dir%\\build\\lib\\taos_static.lib %target_dir%\\driver > nul +copy %binary_dir%\\build\\lib\\taos.dll %target_dir%\\driver > nul +copy %binary_dir%\\build\\bin\\taos.exe %target_dir% > nul if exist %binary_dir%\\build\\bin\\taosBenchmark.exe ( - copy %binary_dir%\\build\\bin\\taosBenchmark.exe %tagert_dir% > nul + copy %binary_dir%\\build\\bin\\taosBenchmark.exe %target_dir% > nul ) if exist %binary_dir%\\build\\lib\\taosws.dll.lib ( - copy %binary_dir%\\build\\lib\\taosws.dll.lib %tagert_dir%\\driver > nul + copy %binary_dir%\\build\\lib\\taosws.dll.lib %target_dir%\\driver > nul ) if exist %binary_dir%\\build\\lib\\taosws.dll ( - copy %binary_dir%\\build\\lib\\taosws.dll %tagert_dir%\\driver > nul - copy %source_dir%\\tools\\taosws-rs\\target\\release\\taosws.h %tagert_dir%\\include > nul + copy %binary_dir%\\build\\lib\\taosws.dll %target_dir%\\driver > nul + copy %source_dir%\\tools\\taosws-rs\\target\\release\\taosws.h %target_dir%\\include > nul ) if exist %binary_dir%\\build\\bin\\taosdump.exe ( - copy %binary_dir%\\build\\bin\\taosdump.exe %tagert_dir% > nul -) -if exist %binary_dir%\\build\\bin\\taosadapter.exe ( - copy %binary_dir%\\build\\bin\\taosadapter.exe %tagert_dir% > nul + copy %binary_dir%\\build\\bin\\taosdump.exe %target_dir% > nul ) -mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close)&& echo To start/stop TDengine with administrator privileges: sc start/stop taosd &goto :eof +copy %binary_dir%\\build\\bin\\taosd.exe %target_dir% > nul +copy %binary_dir%\\build\\bin\\udfd.exe %target_dir% > nul + +if exist %binary_dir%\\build\\bin\\taosadapter.exe ( + copy %binary_dir%\\build\\bin\\taosadapter.exe %target_dir% > nul +) + +mshta vbscript:createobject("shell.application").shellexecute("%~s0",":hasAdmin","","runas",1)(window.close) + +echo. +echo Please manually remove C:\TDengine from your system PATH environment after you remove TDengine software +echo. +echo To start/stop TDengine with administrator privileges: %ESC%[92msc start/stop taosd %ESC%[0m + +if exist %binary_dir%\\build\\bin\\taosadapter.exe ( + echo To start/stop taosAdapter with administrator privileges: %ESC%[92msc start/stop taosadapter %ESC%[0m +) + +goto :eof + :hasAdmin + +sc query "taosd" && sc stop taosd && sc delete taosd +sc query "taosadapter" && sc stop taosadapter && sc delete taosd + copy /y C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 > nul if exist C:\\TDengine\\driver\\taosws.dll ( copy /y C:\\TDengine\\driver\\taosws.dll C:\\Windows\\System32 > nul ) + sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND sc query "taosadapter" >nul || sc create "taosadapter" binPath= "C:\\TDengine\\taosadapter.exe" start= DEMAND + +set "env=HKLM\System\CurrentControlSet\Control\Session Manager\Environment" +for /f "tokens=2*" %%I in ('reg query "%env%" /v Path ^| findstr /i "\"') do ( + + rem // make addition persistent through reboots + reg add "%env%" /f /v Path /t REG_EXPAND_SZ /d "%%J;C:\TDengine" + + rem // apply change to the current process + for %%a in ("%%J;C:\TDengine") do path %%~a +) + +rem // use setx to set a temporary throwaway value to trigger a WM_SETTINGCHANGE +rem // applies change to new console windows without requiring a reboot +(setx /m foo bar & reg delete "%env%" /f /v foo) >NUL 2>NUL + diff --git a/packaging/tools/tdengine.iss b/packaging/tools/tdengine.iss index ec9c432092..981bee91b8 100644 --- a/packaging/tools/tdengine.iss +++ b/packaging/tools/tdengine.iss @@ -60,6 +60,29 @@ Source: {#MyAppSourceDir}{#MyAppIncludeName}; DestDir: "{app}\include"; Flags: i Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExcludeSource} ; Flags: igNoreversion recursesubdirs createallsubdirs Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs + +[Registry] +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ + ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\TDengine"; \ + Check: NeedsAddPath('C:\TDengine') + +[Code] +function NeedsAddPath(Param: string): boolean; +var + OrigPath: string; +begin + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, + 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', + 'Path', OrigPath) + then begin + Result := True; + exit; + end; + { look for the path with leading and trailing semicolon } + { Pos() returns 0 if not found } + Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0; +end; + [UninstallDelete] Name: {app}\driver; Type: filesandordirs Name: {app}\connector; Type: filesandordirs