From f441c33c617bb29cfb46a3bcbd6cda6a1e811c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Thu, 1 Sep 2022 13:57:29 +0200 Subject: [PATCH 1/5] tools: add option to disable path check --- README.md | 1 + src/InnoSetup/Configuration.iss | 2 ++ src/InnoSetup/Environment.iss | 2 +- src/InnoSetup/Pages/IdfDownloadPage.iss | 9 +++++++-- src/InnoSetup/Pages/IdfPage.iss | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 215b86b..2d02e29 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Windows Installer `esp-idf-tools-setup` provides the following command-line para * ``/OFFLINE=[yes|no]`` - Execute installation of Python packages by PIP in offline mode. The same result can be achieved by setting the environment variable PIP_NO_INDEX. Default: no. * ``/USEEMBEDDEDGIT=[yes|no]`` - Use Embedded Git for the installation. Set to ``no`` to enable Git selection screen. Default: yes. * ``/USEEMBEDDEDPYTHON=[yes|no]`` - Use Embedded Python version for the installation. Set to ``no`` to allow Python selection screen in the installer. Default: yes. +* ``/PATHCHECK=[yes|no]`` - Check whether the installation path does not contain spaces or special characters or if it's too long. Set to ``no`` to disable checks. Default: yes. * ``/PYTHONNOUSERSITE=[yes|no]`` - Set PYTHONNOUSERSITE variable before launching any Python command to avoid loading Python packages from AppData\Roaming. Default: yes. * ``/PYTHONWHEELSURL=[URL]`` - Specify URLs to PyPi repositories for resolving binary Python Wheel dependencies. The same result can be achieved by setting the environment variable PIP_EXTRA_INDEX_URL. Default: https://dl.espressif.com/pypi * ``/SKIPSYSTEMCHECK=[yes|no]`` - Skip System Check page. Default: no. diff --git a/src/InnoSetup/Configuration.iss b/src/InnoSetup/Configuration.iss index a316550..ead43d5 100644 --- a/src/InnoSetup/Configuration.iss +++ b/src/InnoSetup/Configuration.iss @@ -10,6 +10,7 @@ var IsGitRecursive: Boolean; IsGitResetAllowed: Boolean; IsGitCleanAllowed: Boolean; + IsPathCheckEnabled: Boolean; IsPythonNoUserSite: Boolean; IsOfflineMode: Boolean; IDFDirectory: String; @@ -83,6 +84,7 @@ begin IDFVersionUrl := GetConfigurationString('IDFVERSIONSURL', 'https://dl.espressif.com/dl/esp-idf/idf_versions.txt'); IsOfflineMode := GetConfigurationBoolean('OFFLINE', '{#OFFLINE}'); IsPythonNoUserSite := GetConfigurationBoolean('PYTHONNOUSERSITE', 'yes'); + IsPathCheckEnabled := GetConfigurationBoolean('PATHCHECK', 'yes'); PythonWheelsUrl := GetConfigurationString('PYTHONWHEELSURL', 'https://dl.espressif.com/pypi'); PythonWheelsVersion := GetConfigurationString('PYTHONWHEELSVERSION', '{#PYTHONWHEELSVERSION}'); SkipSystemCheck := GetConfigurationBoolean('SKIPSYSTEMCHECK', 'no'); diff --git a/src/InnoSetup/Environment.iss b/src/InnoSetup/Environment.iss index c98b5ab..8c0af39 100644 --- a/src/InnoSetup/Environment.iss +++ b/src/InnoSetup/Environment.iss @@ -265,7 +265,7 @@ begin if IDFTempPath <> '' then CmdLine := CmdLine + ' --reference ' + IDFTempPath; - CmdLine := CmdLine + ' ' + GitRepository +' ' + IDFPath; + CmdLine := CmdLine + ' ' + GitRepository +' "' + IDFPath + '"'; Log('Cloning IDF: ' + CmdLine); DoCmdlineInstall(CustomMessage('DownloadingEspIdf'), CustomMessage('UsingGitToClone'), CmdLine); diff --git a/src/InnoSetup/Pages/IdfDownloadPage.iss b/src/InnoSetup/Pages/IdfDownloadPage.iss index daa33db..7048e7c 100644 --- a/src/InnoSetup/Pages/IdfDownloadPage.iss +++ b/src/InnoSetup/Pages/IdfDownloadPage.iss @@ -114,6 +114,11 @@ function IsDirNameValid(const Value: string): Boolean; var I: Integer; begin + if not IsPathCheckEnabled then begin + Result := True; + Exit; + end; + Result := False; for I := 1 to Length(Value) do if not IsCharValid(Value[I]) then @@ -147,14 +152,14 @@ begin exit; end; - if Pos(' ', IDFPath) <> 0 then + if (Pos(' ', IDFPath) <> 0) and IsPathCheckEnabled then begin MessageBox(CustomMessage('SpacesInPathNotSupported') + #13#10 + CustomMessage('ChooseDifferentDirectory'), mbError, MB_OK); exit; end; - if (Length(IDFPath) > 90) then begin + if (Length(IDFPath) > 90) and IsPathCheckEnabled then begin MessageBox(CustomMessage('ErrorTooLongIdfPath'), mbError, MB_OK); Result := False; exit; diff --git a/src/InnoSetup/Pages/IdfPage.iss b/src/InnoSetup/Pages/IdfPage.iss index 0e9a2d1..6119e7d 100644 --- a/src/InnoSetup/Pages/IdfPage.iss +++ b/src/InnoSetup/Pages/IdfPage.iss @@ -91,14 +91,14 @@ begin exit; end; - if Pos(' ', IDFPath) <> 0 then + if (Pos(' ', IDFPath) <> 0) and IsPathCheckEnabled then begin MessageBox(CustomMessage('SpacesInPathNotSupported') + #13#10 + CustomMessage('ChooseExistingEspIdfDirectory'), mbError, MB_OK); exit; end; - if (Length(IDFPath) > 90) then begin + if (Length(IDFPath) > 90) and IsPathCheckEnabled then begin MessageBox(CustomMessage('ErrorTooLongIdfPath'), mbError, MB_OK); Result := False; exit; From ed63672ae0274572897baae811b224ff4310427b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Thu, 1 Sep 2022 14:15:49 +0200 Subject: [PATCH 2/5] tools: fix quotes for clone command --- README.md | 2 +- src/InnoSetup/Configuration.iss | 4 ++-- src/InnoSetup/Environment.iss | 2 +- src/InnoSetup/Pages/IdfDownloadPage.iss | 6 +++--- src/InnoSetup/Pages/IdfPage.iss | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2d02e29..f09ebb8 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Note: Online Installer is recommended way of the installation. Windows Installer `esp-idf-tools-setup` provides the following command-line parameters: +* ``/CHECKPATH=[yes|no]`` - Check whether the installation path does not contain spaces or special characters or if it's too long. Set to ``no`` to disable checks. Default: yes. * ``/CONFIG=[PATH]`` - Path to ``ini`` configuration file to override default configuration of the installer. Default: ``config.ini``. * ``/GITCLEAN=[yes|no]`` - Perform git clean and remove untracked directories in Offline mode installation. Default: yes. * ``/GITDEPTH=[number]`` - Clone repository in shallow mode E.g. 1. Default: empty. @@ -84,7 +85,6 @@ Windows Installer `esp-idf-tools-setup` provides the following command-line para * ``/OFFLINE=[yes|no]`` - Execute installation of Python packages by PIP in offline mode. The same result can be achieved by setting the environment variable PIP_NO_INDEX. Default: no. * ``/USEEMBEDDEDGIT=[yes|no]`` - Use Embedded Git for the installation. Set to ``no`` to enable Git selection screen. Default: yes. * ``/USEEMBEDDEDPYTHON=[yes|no]`` - Use Embedded Python version for the installation. Set to ``no`` to allow Python selection screen in the installer. Default: yes. -* ``/PATHCHECK=[yes|no]`` - Check whether the installation path does not contain spaces or special characters or if it's too long. Set to ``no`` to disable checks. Default: yes. * ``/PYTHONNOUSERSITE=[yes|no]`` - Set PYTHONNOUSERSITE variable before launching any Python command to avoid loading Python packages from AppData\Roaming. Default: yes. * ``/PYTHONWHEELSURL=[URL]`` - Specify URLs to PyPi repositories for resolving binary Python Wheel dependencies. The same result can be achieved by setting the environment variable PIP_EXTRA_INDEX_URL. Default: https://dl.espressif.com/pypi * ``/SKIPSYSTEMCHECK=[yes|no]`` - Skip System Check page. Default: no. diff --git a/src/InnoSetup/Configuration.iss b/src/InnoSetup/Configuration.iss index ead43d5..74be43c 100644 --- a/src/InnoSetup/Configuration.iss +++ b/src/InnoSetup/Configuration.iss @@ -10,7 +10,7 @@ var IsGitRecursive: Boolean; IsGitResetAllowed: Boolean; IsGitCleanAllowed: Boolean; - IsPathCheckEnabled: Boolean; + IsCheckPathEnabled: Boolean; IsPythonNoUserSite: Boolean; IsOfflineMode: Boolean; IDFDirectory: String; @@ -71,6 +71,7 @@ begin Log('Configuration /CONFIG=' + ConfigurationFile); + IsCheckPathEnabled := GetConfigurationBoolean('CHECKPATH', 'yes'); IsGitCleanAllowed := GetConfigurationBoolean('GITCLEAN', 'yes'); IsGitRecursive := GetConfigurationBoolean('GITRECURSIVE', 'yes'); IsGitResetAllowed := GetConfigurationBoolean('GITRESET', 'yes'); @@ -84,7 +85,6 @@ begin IDFVersionUrl := GetConfigurationString('IDFVERSIONSURL', 'https://dl.espressif.com/dl/esp-idf/idf_versions.txt'); IsOfflineMode := GetConfigurationBoolean('OFFLINE', '{#OFFLINE}'); IsPythonNoUserSite := GetConfigurationBoolean('PYTHONNOUSERSITE', 'yes'); - IsPathCheckEnabled := GetConfigurationBoolean('PATHCHECK', 'yes'); PythonWheelsUrl := GetConfigurationString('PYTHONWHEELSURL', 'https://dl.espressif.com/pypi'); PythonWheelsVersion := GetConfigurationString('PYTHONWHEELSVERSION', '{#PYTHONWHEELSVERSION}'); SkipSystemCheck := GetConfigurationBoolean('SKIPSYSTEMCHECK', 'no'); diff --git a/src/InnoSetup/Environment.iss b/src/InnoSetup/Environment.iss index 8c0af39..7489e4a 100644 --- a/src/InnoSetup/Environment.iss +++ b/src/InnoSetup/Environment.iss @@ -388,7 +388,7 @@ begin TargetSupportTestCommand := '"' + IDFToolsPyCmd + '" install --targets=""'; { IDFPath not quoted, as it can not contain spaces } - IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path ' + IDFPath + ' ' + JSONArg + ' '; + IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path "' + IDFPath + '" ' + JSONArg + ' '; SetEnvironmentVariable('PYTHONUNBUFFERED', '1'); diff --git a/src/InnoSetup/Pages/IdfDownloadPage.iss b/src/InnoSetup/Pages/IdfDownloadPage.iss index 7048e7c..a60081f 100644 --- a/src/InnoSetup/Pages/IdfDownloadPage.iss +++ b/src/InnoSetup/Pages/IdfDownloadPage.iss @@ -114,7 +114,7 @@ function IsDirNameValid(const Value: string): Boolean; var I: Integer; begin - if not IsPathCheckEnabled then begin + if not IsCheckPathEnabled then begin Result := True; Exit; end; @@ -152,14 +152,14 @@ begin exit; end; - if (Pos(' ', IDFPath) <> 0) and IsPathCheckEnabled then + if (Pos(' ', IDFPath) <> 0) and IsCheckPathEnabled then begin MessageBox(CustomMessage('SpacesInPathNotSupported') + #13#10 + CustomMessage('ChooseDifferentDirectory'), mbError, MB_OK); exit; end; - if (Length(IDFPath) > 90) and IsPathCheckEnabled then begin + if (Length(IDFPath) > 90) and IsCheckPathEnabled then begin MessageBox(CustomMessage('ErrorTooLongIdfPath'), mbError, MB_OK); Result := False; exit; diff --git a/src/InnoSetup/Pages/IdfPage.iss b/src/InnoSetup/Pages/IdfPage.iss index 6119e7d..b9d539f 100644 --- a/src/InnoSetup/Pages/IdfPage.iss +++ b/src/InnoSetup/Pages/IdfPage.iss @@ -91,14 +91,14 @@ begin exit; end; - if (Pos(' ', IDFPath) <> 0) and IsPathCheckEnabled then + if (Pos(' ', IDFPath) <> 0) and IsCheckPathEnabled then begin MessageBox(CustomMessage('SpacesInPathNotSupported') + #13#10 + CustomMessage('ChooseExistingEspIdfDirectory'), mbError, MB_OK); exit; end; - if (Length(IDFPath) > 90) and IsPathCheckEnabled then begin + if (Length(IDFPath) > 90) and IsCheckPathEnabled then begin MessageBox(CustomMessage('ErrorTooLongIdfPath'), mbError, MB_OK); Result := False; exit; From c6eed40271e63afca9a4d0e0504492093b572220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Thu, 1 Sep 2022 14:40:10 +0200 Subject: [PATCH 3/5] tools: fix problem with trainling backslash in idf-path when calling idf_tools.py --- src/InnoSetup/Environment.iss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/InnoSetup/Environment.iss b/src/InnoSetup/Environment.iss index 7489e4a..3ed4e39 100644 --- a/src/InnoSetup/Environment.iss +++ b/src/InnoSetup/Environment.iss @@ -353,7 +353,7 @@ end; procedure IDFToolsSetup(); var CmdLine: String; - IDFPath: String; + IdfPathWithForwardSlashes: String; IDFToolsPyPath: String; IDFToolsPyCmd: String; BundledIDFToolsPyPath: String; @@ -362,7 +362,7 @@ var ResultCode: Integer; TargetSupportTestCommand: String; begin - IDFPath := GetIDFPath(''); + IdfPathWithForwardSlashes := GetPathWithForwardSlashes(GetIDFPath(''));; IDFToolsPyPath := GetIDFPath('tools\idf_tools.py'); BundledIDFToolsPyPath := ExpandConstant('{app}\idf_tools_fallback.py'); JSONArg := ''; @@ -388,7 +388,7 @@ begin TargetSupportTestCommand := '"' + IDFToolsPyCmd + '" install --targets=""'; { IDFPath not quoted, as it can not contain spaces } - IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path "' + IDFPath + '" ' + JSONArg + ' '; + IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path "' + IdfPathWithForwardSlashes + '" ' + JSONArg + ' '; SetEnvironmentVariable('PYTHONUNBUFFERED', '1'); From 279eccabc0c1e2e17e9529c2651cb9d40a5b8125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Mon, 5 Sep 2022 14:30:08 +0200 Subject: [PATCH 4/5] ci: fix 'v' replacement so the suffix like -dev works --- Build-Installer.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Build-Installer.ps1 b/Build-Installer.ps1 index 504de12..ffcc19c 100644 --- a/Build-Installer.ps1 +++ b/Build-Installer.ps1 @@ -305,7 +305,7 @@ function CheckInnoSetupInstallation { CheckInnoSetupInstallation if ('espressif-ide' -eq $InstallerType) { - $EspIdfBranchVersion = $OfflineBranch.Replace('v', '') + $EspIdfBranchVersion = $OfflineBranch -replace '^v' $OutputFileBaseName = "espressif-ide-setup-${InstallerType}-with-esp-idf-${EspIdfBranchVersion}-unsigned" $OutputFileSigned = "espressif-ide-setup-${InstallerType}-with-esp-idf-${EspIdfBranchVersion}-signed.exe" } else { @@ -332,7 +332,7 @@ PrepareIdfEnv if (('offline' -eq $InstallerType) -or ('espressif-ide' -eq $InstallerType)){ $IsccParameters += '/DOFFLINE=yes' - $IsccParameters += '/DOFFLINEBRANCH=' + $OfflineBranch.Replace('v', '') + $IsccParameters += '/DOFFLINEBRANCH=' + $OfflineBranch -replace '^v' $IsccParameters += '/DFRAMEWORK_ESP_IDF=' + $OfflineBranch if (($OfflineBranch -like 'v4.1*') -or ($OfflineBranch -like 'v4.2*') ){ @@ -364,7 +364,7 @@ if (('offline' -eq $InstallerType) -or ('espressif-ide' -eq $InstallerType)){ $IsccParameters += '/DJDKARTIFACTVERSION=' + $JdkArtifactVersion PrepareIdfEclipse } else { - $IsccParameters += '/DVERSION=' + $OfflineBranch.Replace('v', '') + $IsccParameters += '/DVERSION=' + $OfflineBranch -replace '^v' $IsccParameters += '/DAPPNAME=ESP-IDF Tools Offline' } "${OfflineBranch}" > $Versions From 3facb5e1d60458800317a8545fb443fd1fcbfc49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Mich=C3=A1lek?= Date: Mon, 5 Sep 2022 15:15:02 +0200 Subject: [PATCH 5/5] ci: fix concatenation with replace --- Build-Installer.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build-Installer.ps1 b/Build-Installer.ps1 index ffcc19c..420b5a7 100644 --- a/Build-Installer.ps1 +++ b/Build-Installer.ps1 @@ -332,7 +332,7 @@ PrepareIdfEnv if (('offline' -eq $InstallerType) -or ('espressif-ide' -eq $InstallerType)){ $IsccParameters += '/DOFFLINE=yes' - $IsccParameters += '/DOFFLINEBRANCH=' + $OfflineBranch -replace '^v' + $IsccParameters += '/DOFFLINEBRANCH=' + ($OfflineBranch -replace '^v') $IsccParameters += '/DFRAMEWORK_ESP_IDF=' + $OfflineBranch if (($OfflineBranch -like 'v4.1*') -or ($OfflineBranch -like 'v4.2*') ){ @@ -364,7 +364,7 @@ if (('offline' -eq $InstallerType) -or ('espressif-ide' -eq $InstallerType)){ $IsccParameters += '/DJDKARTIFACTVERSION=' + $JdkArtifactVersion PrepareIdfEclipse } else { - $IsccParameters += '/DVERSION=' + $OfflineBranch -replace '^v' + $IsccParameters += '/DVERSION=' + ($OfflineBranch -replace '^v') $IsccParameters += '/DAPPNAME=ESP-IDF Tools Offline' } "${OfflineBranch}" > $Versions