Skip to content

Commit

Permalink
msi: support path which contains space
Browse files Browse the repository at this point in the history
When installing fluent-package to c:\Program Files, it must be
escaped correctly.

* sources.wxs
  * For xml, double quote (") must be "
  * to escape double quote in literal, you must escape with ^&quote;
    it is treated as ^", so it intended to execute:

  "cmd" /c "fsutil ... "c:\Program Files .." "c:\Program Files...""

* .bat
  * set FOO="..." assign extra double quote, it's not intended
    * use set "FOO=..." to assign without extra double quote
  * to get RUBY_VERSION, disable delimiter with delims= and escape
    command explicitly.
     passed '^""C:\..." ....^"' literal are evaluated ^""C:\..."^".

Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys committed Sep 15, 2023
1 parent 2964ab2 commit 425c6b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions fluent-package/msi/assets/fluent-gem.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@echo off
if "%~nx0" == "td-agent-gem.bat" (
set FLUENT_PACKAGE_TOPDIR=%~dp0..\
set "FLUENT_PACKAGE_TOPDIR=%~dp0..\"
) else (
set FLUENT_PACKAGE_TOPDIR=%~dp0
set "FLUENT_PACKAGE_TOPDIR=%~dp0"
)
set FLUENT_PACKAGE_BINDIR=%FLUENT_PACKAGE_TOPDIR%bin
set PATH="%FLUENT_PACKAGE_BINDIR%";%PATH%
for /f "usebackq" %%i in (`%FLUENT_PACKAGE_BINDIR%\ruby.exe -rrbconfig -e "print RbConfig::CONFIG['ruby_version']"`) do set RUBY_VERSION=%%i
set GEM_HOME=%FLUENT_PACKAGE_TOPDIR%lib\ruby\gems\%RUBY_VERSION%
set GEM_PATH=%FLUENT_PACKAGE_TOPDIR%lib\ruby\gems\%RUBY_VERSION%
%FLUENT_PACKAGE_BINDIR%\fluent-gem %*
set "FLUENT_PACKAGE_BINDIR=%FLUENT_PACKAGE_TOPDIR%bin"
set PATH=%FLUENT_PACKAGE_BINDIR%;%PATH%
for /f "delims=" %%i in ('^""%FLUENT_PACKAGE_BINDIR%\ruby.exe" -rrbconfig -e "print RbConfig::CONFIG['ruby_version']"^"') do set RUBY_VERSION=%%i
set "GEM_HOME=%FLUENT_PACKAGE_TOPDIR%lib\ruby\gems\%RUBY_VERSION%"
set "GEM_PATH=%FLUENT_PACKAGE_TOPDIR%lib\ruby\gems\%RUBY_VERSION%"
"%FLUENT_PACKAGE_BINDIR%\fluent-gem" %*
12 changes: 6 additions & 6 deletions fluent-package/msi/assets/fluentd.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@echo off
if "%~nx0" == "td-agent.bat" (
set FLUENT_PACKAGE_TOPDIR=%~dp0..\
set "FLUENT_PACKAGE_TOPDIR=%~dp0..\"
) else (
set FLUENT_PACKAGE_TOPDIR=%~dp0
set "FLUENT_PACKAGE_TOPDIR=%~dp0"
)

@rem Convert path separator from backslash to forwardslash
Expand All @@ -11,12 +11,12 @@ set FLUENT_PACKAGE_TOPDIR=!FLUENT_PACKAGE_TOPDIR:\=/!

set PATH=%FLUENT_PACKAGE_TOPDIR%bin;%PATH%
set PATH=%FLUENT_PACKAGE_TOPDIR%;%PATH%
set FLUENT_CONF=%FLUENT_PACKAGE_TOPDIR%/etc/fluent/fluentd.conf
set FLUENT_PLUGIN=%FLUENT_PACKAGE_TOPDIR%/etc/fluent/plugin
set FLUENT_PACKAGE_VERSION=%FLUENT_PACKAGE_TOPDIR%/bin/fluent-package-version.rb
set FLUENT_CONF="%FLUENT_PACKAGE_TOPDIR%/etc/fluent/fluentd.conf"
set FLUENT_PLUGIN="%FLUENT_PACKAGE_TOPDIR%/etc/fluent/plugin"
set FLUENT_PACKAGE_VERSION="%FLUENT_PACKAGE_TOPDIR%/bin/fluent-package-version.rb"
for %%p in (%*) do (
if "%%p"=="--version" (
ruby "%FLUENT_PACKAGE_VERSION%"
ruby %FLUENT_PACKAGE_VERSION%
goto last
)
)
Expand Down
10 changes: 5 additions & 5 deletions fluent-package/msi/source.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<Property Id="InstallFluentdWinSvc" Value=" "/>
<CustomAction Id="SetInstallFluentdWinSvcCommand"
Property="InstallFluentdWinSvc"
Value="&quot;[FLUENTPROJECTLOCATION]fluentd.bat&quot; --reg-winsvc i --reg-winsvc-delay-start --reg-winsvc-fluentdopt &quot;-c [FLUENTPROJECTLOCATION]etc\fluent\fluentd.conf -o [FLUENTPROJECTLOCATION]fluentd.log&quot;"/>
Value="&quot;[FLUENTPROJECTLOCATION]fluentd.bat&quot; --reg-winsvc i --reg-winsvc-delay-start --reg-winsvc-fluentdopt &quot;-c '[FLUENTPROJECTLOCATION]etc\fluent\fluentd.conf' -o '[FLUENTPROJECTLOCATION]fluentd.log'&quot;"/>
<CustomAction Id="InstallFluentdWinSvc"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand All @@ -196,7 +196,7 @@
<Property Id="CreateCompatTdAgentBat" Value=" "/>
<CustomAction Id="SetCreateCompatTdAgentBat"
Property="CreateCompatTdAgentBat"
Value="&quot;cmd&quot; /c &quot;fsutil hardlink create [FLUENTPROJECTLOCATION]bin\td-agent.bat [FLUENTPROJECTLOCATION]fluentd.bat&quot;"/>
Value="&quot;cmd&quot; /c &quot;fsutil hardlink create ^&quot;[FLUENTPROJECTLOCATION]bin\td-agent.bat^&quot; ^&quot;[FLUENTPROJECTLOCATION]fluentd.bat^&quot;&quot;"/>
<CustomAction Id="CreateCompatTdAgentBat"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand All @@ -206,7 +206,7 @@
<Property Id="CreateCompatTdAgentGemBat" Value=" "/>
<CustomAction Id="SetCreateCompatTdAgentGemBat"
Property="CreateCompatTdAgentGemBat"
Value="&quot;cmd&quot; /c &quot;fsutil hardlink create [FLUENTPROJECTLOCATION]bin\td-agent-gem.bat [FLUENTPROJECTLOCATION]fluent-gem.bat&quot;"/>
Value="&quot;cmd&quot; /c &quot;fsutil hardlink create ^&quot;[FLUENTPROJECTLOCATION]bin\td-agent-gem.bat^&quot; ^&quot;[FLUENTPROJECTLOCATION]fluent-gem.bat^&quot;&quot;"/>
<CustomAction Id="CreateCompatTdAgentGemBat"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand All @@ -217,7 +217,7 @@
<Property Id="DeleteCompatTdAgentBat" Value=" "/>
<CustomAction Id="SetDeleteCompatTdAgentBat"
Property="DeleteCompatTdAgentBat"
Value="&quot;cmd&quot; /c &quot;del [FLUENTPROJECTLOCATION]bin\td-agent.bat&quot;"/>
Value="&quot;cmd&quot; /c &quot;del ^&quot;[FLUENTPROJECTLOCATION]bin\td-agent.bat^&quot;&quot;"/>
<CustomAction Id="DeleteCompatTdAgentBat"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand All @@ -227,7 +227,7 @@
<Property Id="DeleteCompatTdAgentGemBat" Value=" "/>
<CustomAction Id="SetDeleteCompatTdAgentGemBat"
Property="DeleteCompatTdAgentGemBat"
Value="&quot;cmd&quot; /c &quot;del [FLUENTPROJECTLOCATION]bin\td-agent-gem.bat&quot;"/>
Value="&quot;cmd&quot; /c &quot;del ^&quot;[FLUENTPROJECTLOCATION]bin\td-agent-gem.bat^&quot;&quot;"/>
<CustomAction Id="DeleteCompatTdAgentGemBat"
BinaryKey="WixCA"
DllEntry="WixQuietExec64"
Expand Down

0 comments on commit 425c6b5

Please sign in to comment.