On 06/07/2018 15:05, Jon Turney wrote:
On 06/07/2018 14:51, Jon Turney wrote:
Thanks for the patch.

The version is checked (again), at ini.cc:404

I've never understood why we have this twice.

(I think the idea might be that first we are checking the setup version as a proxy for the setup.ini format version, to warn if there might be problems parsing it.  The second time we are checking the setup version to see if an upgrade of setup is possible)

Ah, so now we have setup-minimum-version, checking setup-version: in the ini parser should probably be removed (or disabled when setup-minimum-version: is present?)

Like so:

From 0955c7b05bdb50ae180e9ab5f9bfb3c8489a0242 Mon Sep 17 00:00:00 2001
From: Ken Brown <[email protected]>
Date: Thu, 5 Jul 2018 11:22:20 -0400
Subject: [PATCH setup 1/2] Add --no-version-check option

This suppresses the warning that a newer version of setup is available.

This is intended to be used by shortcuts and scripts that run setup in a
'setup' package.

This would also suppress any future auto-update feature.
---
 ini.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ini.cc b/ini.cc
index 7afeba2..78684a7 100644
--- a/ini.cc
+++ b/ini.cc
@@ -62,6 +62,7 @@ IniList setup_ext_list (setup_exts,
                        setup_exts + (sizeof(setup_exts) / 
sizeof(*setup_exts)));
 
 static BoolOption NoVerifyOption (false, 'X', "no-verify", "Don't verify 
setup.ini signatures");
+static BoolOption NoVersionCheckOption (false, '\0', "no-version-check", 
"Suppress checking if a newer version of setup is available");
 
 extern int yyparse ();
 
@@ -401,7 +402,8 @@ do_ini_thread (HINSTANCE h, HWND owner)
        setup_version);
   if (ini_setup_version.size ())
     {
-      if (version_compare (setup_version, ini_setup_version) < 0)
+      if ((version_compare (setup_version, ini_setup_version) < 0)
+          && !NoVersionCheckOption)
        note (owner, IDS_OLD_SETUP_VERSION, setup_version,
              ini_setup_version.c_str ());
     }
-- 
2.17.0

From 7e82fb4f179155da810101133ab7189f93ed52d4 Mon Sep 17 00:00:00 2001
From: Jon Turney <[email protected]>
Date: Fri, 6 Jul 2018 17:45:42 +0100
Subject: [PATCH setup 2/2] If setup-minium-version: was checked, don't check
 setup-version:

Don't check setup-version: to warn about potential setup.ini parsing
problems if a setup-minimum-version: is specified.
---
 IniDBBuilderPackage.cc | 11 ++++++++++-
 IniDBBuilderPackage.h  |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 48a5d4a..87a0058 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -32,7 +32,7 @@
 using namespace std;
 
 IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const &aFeedback) :
-currentSpec (0), _feedback (aFeedback){}
+  currentSpec (0), _feedback (aFeedback), minimum_version_checked(FALSE) {}
 
 IniDBBuilderPackage::~IniDBBuilderPackage()
 {
@@ -48,6 +48,14 @@ IniDBBuilderPackage::buildTimestamp (const std::string& time)
 void
 IniDBBuilderPackage::buildVersion (const std::string& aVersion)
 {
+  /* We shouldn't need to warn about potential setup.ini parse problems if we
+     exceed the version in setup-minimum-version: (we will still advise about a
+     possible setup upgrade in do_ini_thread()).  If we don't exceed
+     setup-minimum-version:, we've already encountered a fatal error, so no 
need
+     to warn as well. */
+  if (minimum_version_checked)
+    return;
+
   version = aVersion;
   if (version.size())
     {
@@ -68,6 +76,7 @@ IniDBBuilderPackage::buildVersion (const std::string& 
aVersion)
 const std::string
 IniDBBuilderPackage::buildMinimumVersion (const std::string& minimum)
 {
+  minimum_version_checked = TRUE;
   if (version_compare(setup_version, minimum) < 0)
     {
       char min_vers[256];
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 79a864e..e5d3662 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -91,6 +91,7 @@ private:
   std::set <std::string> replace_versions;
 
   IniParseFeedback const &_feedback;
+  bool minimum_version_checked;
 };
 
 #endif /* SETUP_INIDBBUILDERPACKAGE_H */
-- 
2.17.0

Reply via email to