public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup 00/10] Various setup patches
@ 2017-05-23 16:46 Jon Turney
  2017-05-23 16:47 ` [PATCH setup 05/10] Move and rename dumpAndList() Jon Turney
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:46 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Oh, I think I can see a bit of floor over there!

Jon Turney (10):
  isBinary() should return true for orphaned packages
  Correctly calculate total data to checksum when using IncludeSource
  Rename category "Misc" to "Orphaned"
  Make PrereqChecker::setTrust() a static method
  Move and rename dumpAndList()
  Fold IniDBBuilderPackage::buildInstallSize() into
    buildPackageInstall()
  Fold build(Install|Source)(MD5|SHA512) into
    buildPackage(Install|Source)
  Fix infinite recursion in grammar for depends
  Improve error recovery in setup.ini parsing
  Remove OR from grammar

 IniDBBuilderPackage.cc | 88 ++++++++++++++++++++++++++------------------------
 IniDBBuilderPackage.h  | 21 ++++++++----
 Makefile.am            |  1 +
 ScanFindVisitor.cc     |  4 +--
 choose.cc              |  5 ++-
 inilex.ll              |  3 +-
 iniparse.yy            | 26 ++++++---------
 install.cc             |  2 +-
 package_db.cc          |  2 +-
 package_depends.cc     | 33 +++++++++++++++++++
 package_depends.h      |  3 ++
 package_meta.cc        |  8 ++---
 package_version.cc     | 18 -----------
 package_version.h      |  3 --
 prereq.h               |  2 +-
 15 files changed, 118 insertions(+), 101 deletions(-)
 create mode 100644 package_depends.cc

-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 07/10] Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source)
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
                   ` (5 preceding siblings ...)
  2017-05-23 16:47 ` [PATCH setup 03/10] Rename category "Misc" to "Orphaned" Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:59 ` [PATCH setup 08/10] Fix infinite recursion in grammar for depends Jon Turney
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source), so
the (pathname, size, hash) information from an install: or source: line is
all processed together.
---
 IniDBBuilderPackage.cc | 76 ++++++++++++++++++++++++++++----------------------
 IniDBBuilderPackage.h  | 20 +++++++++----
 iniparse.yy            | 16 +++--------
 3 files changed, 60 insertions(+), 52 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index c90bfe3..ad1cc88 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -120,15 +120,37 @@ IniDBBuilderPackage::buildPackageLDesc (const std::string& theDesc)
 
 void
 IniDBBuilderPackage::buildPackageInstall (const std::string& path,
-                                          const std::string& size)
+                                          const std::string& size,
+                                          char *hash,
+                                          hashType type)
 {
   process_src (*cbpv.source(), path);
   setSourceSize (*cbpv.source(), size);
+
+  switch (type) {
+  case hashType::sha512:
+    if (hash && !cbpv.source()->sha512_isSet)
+      {
+        memcpy (cbpv.source()->sha512sum, hash, sizeof(cbpv.source()->sha512sum));
+        cbpv.source()->sha512_isSet = true;
+      }
+    break;
+
+  case hashType::md5:
+    if (hash && !cbpv.source()->md5.isSet())
+      cbpv.source()->md5.set((unsigned char *)hash);
+    break;
+
+  case hashType::none:
+    break;
+  }
 }
 
 void
 IniDBBuilderPackage::buildPackageSource (const std::string& path,
-                                         const std::string& size)
+                                         const std::string& size,
+                                         char *hash,
+                                         hashType type)
 {
   packagedb db;
   /* get an appropriate metadata */
@@ -168,6 +190,24 @@ IniDBBuilderPackage::buildPackageSource (const std::string& path,
   spec.setVersion (cbpv.Canonical_version());
 
   setSourceSize (*cspv.source(), size);
+
+  switch (type) {
+  case hashType::sha512:
+    if (hash && !cspv.source()->sha512_isSet)
+      {
+        memcpy (cspv.source()->sha512sum, hash, sizeof(cspv.source()->sha512sum));
+        cspv.source()->sha512_isSet = true;
+      }
+    break;
+
+  case hashType::md5:
+    if (hash && !cspv.source()->md5.isSet())
+      cspv.source()->md5.set((unsigned char *)hash);
+    break;
+
+  case hashType::none:
+    break;
+  }
 }
 
 void
@@ -200,38 +240,6 @@ IniDBBuilderPackage::buildBeginDepends ()
 }
 
 void
-IniDBBuilderPackage::buildInstallSHA512 (unsigned char const *sha512)
-{
-  if (sha512 && !cbpv.source()->sha512_isSet) {
-    memcpy (cbpv.source()->sha512sum, sha512, sizeof cbpv.source()->sha512sum);
-    cbpv.source()->sha512_isSet = true;
-  }
-}
-
-void
-IniDBBuilderPackage::buildSourceSHA512 (unsigned char const *sha512)
-{
-  if (sha512 && !cspv.source()->sha512_isSet) {
-    memcpy (cspv.source()->sha512sum, sha512, sizeof cspv.source()->sha512sum);
-    cspv.source()->sha512_isSet = true;
-  }
-}
-
-void
-IniDBBuilderPackage::buildInstallMD5 (unsigned char const *md5)
-{
-  if (md5 && !cbpv.source()->md5.isSet())
-    cbpv.source()->md5.set(md5);
-}
-
-void
-IniDBBuilderPackage::buildSourceMD5 (unsigned char const *md5)
-{
-  if (md5 && !cspv.source()->md5.isSet())
-    cspv.source()->md5.set(md5);
-}
-
-void
 IniDBBuilderPackage::buildBeginBuildDepends ()
 {
 #if DEBUG
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 1dab41b..766a5ef 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -18,10 +18,13 @@
 
 #include <vector>
 #include "package_version.h"
+
 class IniParseFeedback;
 class packagesource;
 class packagemeta;
 
+enum class hashType { none, md5, sha512 };
+
 class IniDBBuilderPackage
 {
 public:
@@ -34,16 +37,21 @@ public:
   void buildPackageVersion (const std::string& );
   void buildPackageSDesc (const std::string& );
   void buildPackageLDesc (const std::string& );
-  void buildPackageInstall (const std::string&, const std::string&);
-  void buildPackageSource (const std::string&, const std::string&);
+  void buildPackageInstall (const std::string&, const std::string&,
+                            char *, hashType);
+  void buildPackageSource (const std::string&, const std::string&,
+                           char *, hashType);
+
+  // helpers for ScanFindVisitor
+  void buildPackageInstall (const std::string& path, const std::string& size)
+  { buildPackageInstall(path, size, NULL, hashType::none); }
+  void buildPackageSource (const std::string& path, const std::string& size)
+  { buildPackageSource(path, size, NULL, hashType::none); }
+
   void buildPackageTrust (int);
   void buildPackageCategory (const std::string& );
 
   void buildBeginDepends ();
-  void buildInstallSHA512 (unsigned char const[64]);
-  void buildSourceSHA512 (unsigned char const[64]);
-  void buildInstallMD5 (unsigned char const[16]);
-  void buildSourceMD5 (unsigned char const[16]);
   void buildBeginBuildDepends ();
   void buildMessage (const std::string&, const std::string&);
   void buildSourceName (const std::string& );
diff --git a/iniparse.yy b/iniparse.yy
index 98b51bb..d768400 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -96,8 +96,10 @@ singleitem /* non-empty */
  | T_OTHER NL			{ iniBuilder->buildPackageTrust (TRUST_OTHER); }
  | SOURCEPACKAGE source NL
  | CATEGORY categories NL
- | INSTALL STRING STRING { iniBuilder->buildPackageInstall ($2, $3);} installchksum NL
- | SOURCE STRING STRING sourcechksum NL {iniBuilder->buildPackageSource ($2, $3);}
+ | INSTALL STRING STRING MD5 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::md5); }
+ | INSTALL STRING STRING SHA512 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::sha512); }
+ | SOURCE STRING STRING MD5 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::md5); }
+ | SOURCE STRING STRING SHA512 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::sha512); }
  | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
  | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
  | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
@@ -112,16 +114,6 @@ categories: /* empty */
  | categories STRING		{ iniBuilder->buildPackageCategory ($2); }
  ;
 
-installchksum /* non-empty */
- : MD5 			{ iniBuilder->buildInstallMD5 ((unsigned char *)$1);}
- | SHA512		{ iniBuilder->buildInstallSHA512 ((unsigned char *)$1);}
- ;
-
-sourcechksum /* non-empty */
- : MD5 			{ iniBuilder->buildSourceMD5 ((unsigned char *)$1); }
- | SHA512 		{ iniBuilder->buildSourceSHA512 ((unsigned char *)$1); }
- ;
-
 source /* non-empty */
  : STRING { iniBuilder->buildSourceName ($1); } versioninfo
  ;
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 04/10] Make PrereqChecker::setTrust() a static method
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
  2017-05-23 16:47 ` [PATCH setup 05/10] Move and rename dumpAndList() Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 02/10] Correctly calculate total data to checksum when using IncludeSource Jon Turney
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Rather than instantiating PrereqChecker just to call an accessor method
which changes a static data member, make that method static as well.
---
 choose.cc | 3 +--
 prereq.h  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/choose.cc b/choose.cc
index 4ac5aae..1bc4c0b 100644
--- a/choose.cc
+++ b/choose.cc
@@ -373,8 +373,7 @@ ChooserPage::changeTrust(trusts aTrust)
   SetBusy ();
   chooser->defaultTrust (aTrust);
   chooser->refresh();
-  PrereqChecker p;
-  p.setTrust (aTrust);
+  PrereqChecker::setTrust (aTrust);
   ClearBusy ();
 }
 
diff --git a/prereq.h b/prereq.h
index 2aed63a..163af6e 100644
--- a/prereq.h
+++ b/prereq.h
@@ -45,7 +45,7 @@ public:
   void selectMissing ();
   
   // notes the current trust (for use in selectMissing)
-  void setTrust (trusts t) { theTrust = t; };
+  static void setTrust (trusts t) { theTrust = t; };
 
 private:
   
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 05/10] Move and rename dumpAndList()
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 04/10] Make PrereqChecker::setTrust() a static method Jon Turney
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

---
 IniDBBuilderPackage.cc |  4 ++--
 Makefile.am            |  1 +
 package_depends.cc     | 33 +++++++++++++++++++++++++++++++++
 package_depends.h      |  3 +++
 package_meta.cc        |  2 +-
 package_version.cc     | 18 ------------------
 package_version.h      |  3 ---
 7 files changed, 40 insertions(+), 24 deletions(-)
 create mode 100644 package_depends.cc

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 7f500d6..b5b5f4c 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -77,7 +77,7 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
 	{
 	  Log (LOG_BABBLE) << "Version " << cbpv.Canonical_version() << endLog;
 	  Log (LOG_BABBLE) << "Depends:";
-	  dumpAndList (cbpv.depends(), Log (LOG_BABBLE));
+	  dumpPackageDepends (cbpv.depends(), Log (LOG_BABBLE));
 	  Log (LOG_BABBLE) << endLog;
 	}
     }
@@ -191,7 +191,7 @@ IniDBBuilderPackage::buildBeginDepends ()
 #if DEBUG
   Log (LOG_BABBLE) << "Beginning of a depends statement for " << cp->name
     << endLog;
-  dumpAndList (currentNodeList, Log (LOG_BABBLE));
+  dumpPackageDepends (currentNodeList, Log (LOG_BABBLE));
 #endif
   currentSpec = NULL;
   currentNodeList = cbpv.depends();
diff --git a/Makefile.am b/Makefile.am
index af89af5..d4c8472 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -203,6 +203,7 @@ inilint_SOURCES = \
 	package_db.cc \
 	package_db.h \
 	package_depends.h \
+	package_depends.cc \
 	package_meta.cc \
 	package_meta.h \
 	package_source.cc \
diff --git a/package_depends.cc b/package_depends.cc
new file mode 100644
index 0000000..e288c0b
--- /dev/null
+++ b/package_depends.cc
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Jon Turney
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ */
+
+#include <package_depends.h>
+#include <LogSingleton.h>
+
+void
+dumpPackageDepends (PackageDepends const *currentList,
+                    std::ostream &logger)
+{
+  if (currentList)
+    {
+      Log (LOG_BABBLE) << "( ";
+      PackageDepends::const_iterator i = currentList->begin();
+      while (true)
+        {
+          if (i == currentList->end()) break;
+          Log (LOG_BABBLE) << **i << " ";
+          ++i;
+        }
+      Log (LOG_BABBLE) << ")";
+    }
+}
diff --git a/package_depends.h b/package_depends.h
index 05e0dc6..af3fa01 100644
--- a/package_depends.h
+++ b/package_depends.h
@@ -14,8 +14,11 @@
 #ifndef PACKAGE_DEPENDS_H
 #define PACKAGE_DEPENDS_H
 
+#include <PackageSpecification.h>
 #include <vector>
 
 typedef std::vector <PackageSpecification *> PackageDepends;
 
+void dumpPackageDepends (PackageDepends const *currentList, std::ostream &);
+
 #endif // PACKAGE_DEPENDS_H
diff --git a/package_meta.cc b/package_meta.cc
index 208b948..b35b554 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -564,7 +564,7 @@ packagemeta::logAllVersions () const
 	{
 	  std::ostream & logger = Log (LOG_BABBLE);
 	  logger << "      depends=";
-	  dumpAndList(i->depends(), logger);
+	  dumpPackageDepends(i->depends(), logger);
 	  logger << endLog;
 	}
       }
diff --git a/package_version.cc b/package_version.cc
index 6a903c5..f022e70 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -412,21 +412,3 @@ _packageversion::scripts()
 {
   return scripts_;
 }
-
-void
-dumpAndList (PackageDepends const *currentList,
-             std::ostream &logger)
-{
-  if (currentList)
-  {
-    Log (LOG_BABBLE) << "( ";
-    PackageDepends::const_iterator i = currentList->begin();
-    while (true)
-    {
-      if (i == currentList->end()) break;
-      Log (LOG_BABBLE) << **i << " ";
-      ++i;
-    }
-    Log (LOG_BABBLE) << ")";
-  }
-}
diff --git a/package_version.h b/package_version.h
index ff16eb8..d70eda0 100644
--- a/package_version.h
+++ b/package_version.h
@@ -196,7 +196,4 @@ protected:
   std::vector <Script> scripts_;
 };
 
-// not sure where this belongs :}.
-void dumpAndList (PackageDepends const *currentList, std::ostream &);
-
 #endif /* SETUP_PACKAGE_VERSION_H */
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 03/10] Rename category "Misc" to "Orphaned"
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
                   ` (4 preceding siblings ...)
  2017-05-23 16:47 ` [PATCH setup 06/10] Fold IniDBBuilderPackage::buildInstallSize() into buildPackageInstall() Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 07/10] Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source) Jon Turney
  2017-05-23 16:59 ` [PATCH setup 08/10] Fix infinite recursion in grammar for depends Jon Turney
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Packages which have no category are placed into this category.  Since a
category is mandatory for all packages in setup.ini, this effectively means
packages which are "orphaned" in the sense that they are installed, but
don't appear in any setup.ini.

Usually it's safe to uninstall such packages (with --delete-orphans), unless
you are actually using them, or have locally built packages which rely on
them.
---
 choose.cc       | 2 +-
 package_db.cc   | 2 +-
 package_meta.cc | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/choose.cc b/choose.cc
index 2016caa..4ac5aae 100644
--- a/choose.cc
+++ b/choose.cc
@@ -260,7 +260,7 @@ ChooserPage::OnInit ()
       bool wanted    = pkg.isManuallyWanted();
       bool deleted   = pkg.isManuallyDeleted();
       bool basemisc  = (pkg.categories.find ("Base") != pkg.categories.end ()
-		     || pkg.categories.find ("Misc") != pkg.categories.end ());
+		     || pkg.categories.find ("Orphaned") != pkg.categories.end ());
       bool upgrade   = wanted || (!pkg.installed && basemisc)
 		     || UpgradeAlsoOption || !hasManualSelections;
       bool install   = wanted  && !deleted && !pkg.installed;
diff --git a/package_db.cc b/package_db.cc
index 3978421..dbec17e 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -435,7 +435,7 @@ packagedb::defaultTrust (trusts trust)
       packagemeta & pkg = *(i->second);
       if (pkg.installed
             || pkg.categories.find ("Base") != pkg.categories.end ()
-            || pkg.categories.find ("Misc") != pkg.categories.end ())
+            || pkg.categories.find ("Orphaned") != pkg.categories.end ())
         {
           pkg.desired = pkg.trustp (true, trust);
           if (pkg.desired)
diff --git a/package_meta.cc b/package_meta.cc
index b1db191..208b948 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -464,7 +464,7 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
     {
       if (installed
 	  || categories.find ("Base") != categories.end ()
-	  || categories.find ("Misc") != categories.end ())
+	  || categories.find ("Orphaned") != categories.end ())
 	{
 	  desired = default_version;
 	  if (desired)
@@ -688,7 +688,7 @@ packagemeta::hasNoCategories() const
 void
 packagemeta::setDefaultCategories()
 {
-  add_category ("Misc");
+  add_category ("Orphaned");
 }
 
 void
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 02/10] Correctly calculate total data to checksum when using IncludeSource
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
  2017-05-23 16:47 ` [PATCH setup 05/10] Move and rename dumpAndList() Jon Turney
  2017-05-23 16:47 ` [PATCH setup 04/10] Make PrereqChecker::setTrust() a static method Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 01/10] isBinary() should return true for orphaned packages Jon Turney
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Correctly account for source packages installed due to IncludeSource in the
total amount of data to checksum.

The fact that this obvious bug is unreported kind of suggests that no-one is
actually using this option...
---
 install.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/install.cc b/install.cc
index 3721047..79ddd20 100644
--- a/install.cc
+++ b/install.cc
@@ -745,7 +745,7 @@ do_install_thread (HINSTANCE h, HWND owner)
       md5sum_total_bytes += pkg.desired.source()->size;
     }
 
-    if (pkg.desired.sourcePackage ().picked())
+    if (pkg.desired.sourcePackage ().picked() || IncludeSource)
     {
       md5sum_total_bytes += pkg.desired.sourcePackage ().source()->size;
     }
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 06/10] Fold IniDBBuilderPackage::buildInstallSize() into buildPackageInstall()
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
                   ` (3 preceding siblings ...)
  2017-05-23 16:47 ` [PATCH setup 01/10] isBinary() should return true for orphaned packages Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 03/10] Rename category "Misc" to "Orphaned" Jon Turney
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

As mentioned in 5a3799dc, this ripples through into ScanFindVisitor as well.
---
 IniDBBuilderPackage.cc | 10 +++-------
 IniDBBuilderPackage.h  |  3 +--
 ScanFindVisitor.cc     |  4 ++--
 iniparse.yy            |  2 +-
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index b5b5f4c..c90bfe3 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -119,9 +119,11 @@ IniDBBuilderPackage::buildPackageLDesc (const std::string& theDesc)
 }
 
 void
-IniDBBuilderPackage::buildPackageInstall (const std::string& path)
+IniDBBuilderPackage::buildPackageInstall (const std::string& path,
+                                          const std::string& size)
 {
   process_src (*cbpv.source(), path);
+  setSourceSize (*cbpv.source(), size);
 }
 
 void
@@ -198,12 +200,6 @@ IniDBBuilderPackage::buildBeginDepends ()
 }
 
 void
-IniDBBuilderPackage::buildInstallSize (const std::string &size)
-{
-  setSourceSize (*cbpv.source(), size);
-}
-
-void
 IniDBBuilderPackage::buildInstallSHA512 (unsigned char const *sha512)
 {
   if (sha512 && !cbpv.source()->sha512_isSet) {
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 4df1bdb..1dab41b 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -34,13 +34,12 @@ public:
   void buildPackageVersion (const std::string& );
   void buildPackageSDesc (const std::string& );
   void buildPackageLDesc (const std::string& );
-  void buildPackageInstall (const std::string& );
+  void buildPackageInstall (const std::string&, const std::string&);
   void buildPackageSource (const std::string&, const std::string&);
   void buildPackageTrust (int);
   void buildPackageCategory (const std::string& );
 
   void buildBeginDepends ();
-  void buildInstallSize (const std::string& );
   void buildInstallSHA512 (unsigned char const[64]);
   void buildSourceSHA512 (unsigned char const[64]);
   void buildInstallMD5 (unsigned char const[16]);
diff --git a/ScanFindVisitor.cc b/ScanFindVisitor.cc
index 02cd6e8..14c3722 100644
--- a/ScanFindVisitor.cc
+++ b/ScanFindVisitor.cc
@@ -46,8 +46,8 @@ ScanFindVisitor::visitFile(const std::string& basePath,
   if (!f.what.size())
     {
       //assume binary
-      _Builder.buildPackageInstall (basePath + theFile->cFileName);
-      _Builder.buildInstallSize(stringify(theFile->nFileSizeLow));
+      _Builder.buildPackageInstall (basePath + theFile->cFileName,
+                                    stringify(theFile->nFileSizeLow));
     }
   else
     // patch or src, assume src until someone complains
diff --git a/iniparse.yy b/iniparse.yy
index 2480cc6..98b51bb 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -96,7 +96,7 @@ singleitem /* non-empty */
  | T_OTHER NL			{ iniBuilder->buildPackageTrust (TRUST_OTHER); }
  | SOURCEPACKAGE source NL
  | CATEGORY categories NL
- | INSTALL STRING STRING { iniBuilder->buildPackageInstall ($2); iniBuilder->buildInstallSize($3);} installchksum NL
+ | INSTALL STRING STRING { iniBuilder->buildPackageInstall ($2, $3);} installchksum NL
  | SOURCE STRING STRING sourcechksum NL {iniBuilder->buildPackageSource ($2, $3);}
  | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
  | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 01/10] isBinary() should return true for orphaned packages
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
                   ` (2 preceding siblings ...)
  2017-05-23 16:47 ` [PATCH setup 02/10] Correctly calculate total data to checksum when using IncludeSource Jon Turney
@ 2017-05-23 16:47 ` Jon Turney
  2017-05-23 16:47 ` [PATCH setup 06/10] Fold IniDBBuilderPackage::buildInstallSize() into buildPackageInstall() Jon Turney
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:47 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Test added in c23d96d6 is incorrect and results in orphaned packages being
omitted from picker.
---
 package_meta.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package_meta.cc b/package_meta.cc
index cffb5b7..b1db191 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -546,7 +546,7 @@ packagemeta::isBinary () const
 {
   for (set<packageversion>::iterator i=versions.begin();
        i != versions.end(); ++i)
-    if ((i->Type() == package_binary) && i->accessible())
+    if ((i->Type() == package_binary) && (i->accessible() || (*i == installed)))
       return true;
 
   return false;
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 08/10] Fix infinite recursion in grammar for depends
  2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
                   ` (6 preceding siblings ...)
  2017-05-23 16:47 ` [PATCH setup 07/10] Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source) Jon Turney
@ 2017-05-23 16:59 ` Jon Turney
  2017-05-23 16:59   ` [PATCH setup 10/10] Remove OR from grammar Jon Turney
  2017-05-23 16:59   ` [PATCH setup 09/10] Improve error recovery in setup.ini parsing Jon Turney
  7 siblings, 2 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:59 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Allowing listseparator to be empty allows an infinite recursion in the
versionedpackagelist rule

Also make the comment documenting versionedpackageentry is non-empty
consistent with all other similar comments

Also allow lower-case depends:
---
 inilex.ll   | 2 +-
 iniparse.yy | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/inilex.ll b/inilex.ll
index 798a04b..b454f0f 100644
--- a/inilex.ll
+++ b/inilex.ll
@@ -121,7 +121,7 @@ B64	[a-zA-Z0-9_-]
 
 "category:"|"Section:"	return CATEGORY;
 "requires:"		return REQUIRES;
-"Depends:"		return DEPENDS;
+[dD]"epends:"		return DEPENDS;
 
 ^{STR}":"		ignore_line ();
 
diff --git a/iniparse.yy b/iniparse.yy
index d768400..8ee7dc3 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -132,12 +132,12 @@ versionedpackagelistsp /* non-empty */
  | versionedpackagelistsp versionedpackageentry
  ;
 
-listseparator: /* empty */
- | COMMA
+listseparator /* non-empty */
+ : COMMA
  | COMMA NL
  ;
 
-versionedpackageentry /* empty not allowed */
+versionedpackageentry /* non-empty */
  : STRING { iniBuilder->buildPackageListNode($1); } versioncriteria
  ;
 
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 09/10] Improve error recovery in setup.ini parsing
  2017-05-23 16:59 ` [PATCH setup 08/10] Fix infinite recursion in grammar for depends Jon Turney
  2017-05-23 16:59   ` [PATCH setup 10/10] Remove OR from grammar Jon Turney
@ 2017-05-23 16:59   ` Jon Turney
  1 sibling, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:59 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Following the error token with a NL allows the parser to discard tokens
until a NL is found to resynchronize, rather than aborting.

This doesn't help hugely, as *any* parse errors are considered fatal by
do_remote_ini()/do_local_ini() and won't let us proceed.
---
 iniparse.yy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iniparse.yy b/iniparse.yy
index 8ee7dc3..c540146 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -104,7 +104,7 @@ singleitem /* non-empty */
  | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
  | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
  | MESSAGE STRING STRING NL	{ iniBuilder->buildMessage ($2, $3); }
- | error 			{ yyerror (std::string("unrecognized line ") 
+ | error NL			{ yyerror (std::string("unrecognized line ")
 					  + stringify(yylineno)
 					  + " (do you have the latest setup?)");
 				}
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH setup 10/10] Remove OR from grammar
  2017-05-23 16:59 ` [PATCH setup 08/10] Fix infinite recursion in grammar for depends Jon Turney
@ 2017-05-23 16:59   ` Jon Turney
  2017-05-23 16:59   ` [PATCH setup 09/10] Improve error recovery in setup.ini parsing Jon Turney
  1 sibling, 0 replies; 11+ messages in thread
From: Jon Turney @ 2017-05-23 16:59 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Unused since removal of complex dependency rules in 60b4f6ca
---
 inilex.ll   | 1 -
 iniparse.yy | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/inilex.ll b/inilex.ll
index b454f0f..13422b1 100644
--- a/inilex.ll
+++ b/inilex.ll
@@ -141,7 +141,6 @@ B64	[a-zA-Z0-9_-]
 "<"			return LT;
 "="                     return EQUAL;
 \,			return COMMA;
-"|"			return OR;
 "@"			return AT;
 
 {STR}			{ yylval = new char [strlen(yytext) + 1];
diff --git a/iniparse.yy b/iniparse.yy
index c540146..18ebe2a 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -42,7 +42,7 @@ extern int yylineno;
 %token MD5 SHA512
 %token SOURCEPACKAGE
 %token PACKAGENAME
-%token COMMA OR NL AT
+%token COMMA NL AT
 %token OPENBRACE CLOSEBRACE EQUAL GT LT GTEQUAL LTEQUAL 
 %token BUILDDEPENDS
 %token MESSAGE
-- 
2.12.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-05-23 16:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 16:46 [PATCH setup 00/10] Various setup patches Jon Turney
2017-05-23 16:47 ` [PATCH setup 05/10] Move and rename dumpAndList() Jon Turney
2017-05-23 16:47 ` [PATCH setup 04/10] Make PrereqChecker::setTrust() a static method Jon Turney
2017-05-23 16:47 ` [PATCH setup 02/10] Correctly calculate total data to checksum when using IncludeSource Jon Turney
2017-05-23 16:47 ` [PATCH setup 01/10] isBinary() should return true for orphaned packages Jon Turney
2017-05-23 16:47 ` [PATCH setup 06/10] Fold IniDBBuilderPackage::buildInstallSize() into buildPackageInstall() Jon Turney
2017-05-23 16:47 ` [PATCH setup 03/10] Rename category "Misc" to "Orphaned" Jon Turney
2017-05-23 16:47 ` [PATCH setup 07/10] Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source) Jon Turney
2017-05-23 16:59 ` [PATCH setup 08/10] Fix infinite recursion in grammar for depends Jon Turney
2017-05-23 16:59   ` [PATCH setup 10/10] Remove OR from grammar Jon Turney
2017-05-23 16:59   ` [PATCH setup 09/10] Improve error recovery in setup.ini parsing Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).