[PATCH setup 00/15] Various setup patches

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH setup 00/15] Various setup patches

Jon TURNEY
Still lacking a convenient river to divert to wash out the filth

Jon Turney (15):
  Add Makefile rule to rename build products to form used when uploading
  Don't bother storing prev version
  Rename "Internet Explorer Proxy Settings" to "System Proxy Settings"
  Remove packageversion::sources(), only packageversion::source() is
    useful
  Remove unused forward declaration of non-existent class category
  Remove unneeded virtual from class packagesource's methods
  Simplify class packagesource
  Fix comments and indentation in check_for_cached
  Initial setting of trust should be TRUST_CURR
  Change PackageSpecification::_operator to an enum
  Remove useless PackageSpecification methods
  Stop pretending to support complex dependencies
  All, rather than just the first (usually current) version should get
    dependencies
  Make PackageDepends a type
  Add some progress reporting during preremove and uninstall

 IniDBBuilderPackage.cc  | 69 ++++++++++------------------------------
 IniDBBuilderPackage.h   |  6 ++--
 Makefile.am             |  6 ++++
 PackageSpecification.cc | 84 +++++++++++++++++++------------------------------
 PackageSpecification.h  | 49 ++++++++++-------------------
 PickView.cc             |  3 +-
 configure.ac            |  3 ++
 desktop.cc              |  1 -
 download.cc             | 53 +++++++++++--------------------
 iniparse.yy             | 16 +++++-----
 install.cc              | 29 ++++++++++-------
 package_db.cc           | 27 +++++++---------
 package_depends.h       | 21 +++++++++++++
 package_meta.cc         | 10 ++----
 package_meta.h          |  7 ++---
 package_source.cc       | 48 +++-------------------------
 package_source.h        | 64 +++++++------------------------------
 package_version.cc      | 60 ++++++++++++-----------------------
 package_version.h       | 21 +++++--------
 prereq.cc               | 12 +++----
 res.rc                  |  3 +-
 resource.h              |  1 -
 22 files changed, 204 insertions(+), 389 deletions(-)
 create mode 100644 package_depends.h

--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 01/15] Add Makefile rule to rename build products to form used when uploading

Jon TURNEY
---
 Makefile.am  | 5 +++++
 configure.ac | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index a947a78..7d5e1e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -273,6 +273,7 @@ inilint_SOURCES = \
 
 GITVER := $(shell cd $(srcdir) && git describe --match release_\* --abbrev=6 --dirty || "N/A")
 VER := $(subst release_,,$(GITVER))
+ARCH := @ARCH@
 
 setup_version.c : Makefile
  @echo "Setup version: " $(VER)
@@ -307,3 +308,7 @@ upx: strip
  else \
  echo "UPX doesn't seem to be installed, cannot compress setup$(EXEEXT)." ;\
  fi
+
+release: upx
+ cp setup.dbg setup-${VER}.${ARCH}.dbg
+ cp setup${EXEEXT} setup-${VER}.${ARCH}${EXEEXT}
diff --git a/configure.ac b/configure.ac
index 42ad3e2..ab548c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,15 +74,18 @@ dnl add portability sources to inilint
 case "$host" in
 i?86-*-mingw32)
   SETUP="setup"
+  ARCH="x86"
   ;;
 x86_64-*-mingw32)
   SETUP="setup"
+  ARCH="x86_64"
   ;;
 *)
   AC_MSG_ERROR([Cygwin Setup can only be built for Win32 or Win64 hosts])
   ;;
 esac
 AC_SUBST(SETUP)
+AC_SUBST(ARCH)
 
 AC_CONFIG_FILES([Makefile tests/Makefile])
 AC_OUTPUT
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 02/15] Don't bother storing prev version

Jon TURNEY
In reply to this post by Jon TURNEY
There's no means to select it since ec9c1d70, so don't bother remembering
which version is the prev version.
---
 IniDBBuilderPackage.cc |  4 ----
 package_meta.cc        | 10 ++--------
 package_meta.h         |  6 ++----
 prereq.cc              |  2 +-
 4 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index d506a9f..303ac34 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -139,7 +139,6 @@ IniDBBuilderPackage::buildPackageSource (const std::string& path,
       csp->versions.clear();
       csp->desired = packageversion();
       csp->installed = packageversion();
-      csp->prev = packageversion();
       csp->curr = packageversion();
       csp->exp = packageversion();
       db.sourcePackages.insert (packagedb::packagecollection::value_type(csp->name,csp));
@@ -424,9 +423,6 @@ IniDBBuilderPackage::add_correct_version()
     case TRUST_CURR:
       v = &(cp->curr);
     break;
-    case TRUST_PREV:
-      v = &(cp->prev);
-    break;
     case TRUST_TEST:
       v = &(cp->exp);
     break;
diff --git a/package_meta.cc b/package_meta.cc
index 24ed17e..cffb5b7 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -89,7 +89,7 @@ packagemeta::_actions::caption ()
 packagemeta::packagemeta (packagemeta const &rhs) :
   name (rhs.name), key (rhs.name),
   categories (rhs.categories), versions (rhs.versions),
-  installed (rhs.installed), prev (rhs.prev),
+  installed (rhs.installed),
   curr (rhs.curr),
   exp (rhs.exp),
   desired (rhs.desired)
@@ -593,8 +593,6 @@ packagemeta::logAllVersions () const
 std::string
 packagemeta::trustLabel(packageversion const &aVersion) const
 {
-    if (aVersion == prev)
- return "Prev";
     if (aVersion == curr)
  return "Curr";
     if (aVersion == exp)
@@ -606,8 +604,7 @@ void
 packagemeta::logSelectionStatus() const
 {
   packagemeta const & pkg = *this;
-  const char *trust = ((pkg.desired == pkg.prev) ? "prev"
-               : (pkg.desired == pkg.curr) ? "curr"
+  const char *trust = ((pkg.desired == pkg.curr) ? "curr"
                : (pkg.desired == pkg.exp) ? "test" : "unknown");
   std::string action = pkg.action_caption ();
   const std::string installed =
@@ -648,7 +645,6 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
   /* scan doesn't alter operator == for packageversions */
   bool lazy_scan = mirror_mode
    && (*i != pkg.installed
-       || pkg.installed == pkg.prev
        || pkg.installed == pkg.curr
        || pkg.installed == pkg.exp);
   const_cast<packageversion &>(*i).scan (lazy_scan);
@@ -662,8 +658,6 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
   if (!i->accessible () && !pkgsrcver.accessible ()
       && *i != pkg.installed)
     {
-      if (pkg.prev == *i)
- pkg.prev = packageversion ();
       if (pkg.curr == *i)
  pkg.curr = packageversion ();
       if (pkg.exp == *i)
diff --git a/package_meta.h b/package_meta.h
index 5f7842c..5c5e718 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -126,11 +126,9 @@ public:
   bool user_picked;
   /* which one is installed. */
   packageversion installed;
-  /* which one is listed as "prev" in our available packages db */
-  packageversion prev;
-  /* ditto for current - stable */
+  /* which one is listed as "current" (stable) in our available packages db */
   packageversion curr;
-  /* and finally the experimental version */
+  /* ditto for "test" (experimental) */
   packageversion exp;
   /* Now for the user stuff :] */
   /* What version does the user want ? */
diff --git a/prereq.cc b/prereq.cc
index 4b6cd68..5a94373 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -210,7 +210,7 @@ PrereqChecker::isMet ()
       Progress.SetBar1(pos, max);
 
       // Fetch the dependencies of the package. This assumes that the
-      // dependencies of the prev, curr, and exp versions are all the same.
+      // dependencies of all versions are all the same.
       const vector <vector <PackageSpecification *> *> *deps = pack->curr.depends ();
 
       // go through the package's dependencies
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 03/15] Rename "Internet Explorer Proxy Settings" to "System Proxy Settings"

Jon TURNEY
In reply to this post by Jon TURNEY
Nowadays, these settings are set via the settings app, and are used by
applications other than IE.

Also remove unused IDS_WININET
---
 res.rc     | 3 +--
 resource.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/res.rc b/res.rc
index 45b4207..96dcf00 100644
--- a/res.rc
+++ b/res.rc
@@ -159,7 +159,7 @@ FONT 8, "MS Shell Dlg"
 BEGIN
     CONTROL         "&Direct Connection",IDC_NET_DIRECT,"Button",
                     BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,60,55,73,10
-    CONTROL         "Use &Internet Explorer Proxy Settings",IDC_NET_IE5,"Button",
+    CONTROL         "Use &System Proxy Settings",IDC_NET_IE5,"Button",
                     BS_AUTORADIOBUTTON | WS_TABSTOP,60,70,185,10
     CONTROL         "Use HTTP/FTP &Proxy:",IDC_NET_PROXY,"Button",
                     BS_AUTORADIOBUTTON | WS_TABSTOP,60,85,88,10
@@ -520,7 +520,6 @@ BEGIN
     IDS_DOWNLOAD_COMPLETE   "Download Complete"
     IDS_NOLOGFILE           "Cannot open log file %s for writing"
     IDS_UNINSTALL_COMPLETE  "Uninstalls complete."
-    IDS_WININET             "Unable to find or load the Internet Explorer 5 DLLs"
     IDS_ERR_CHDIR           "Could not change dir to %s: %s [%.8x]"
     IDS_OLD_SETUP_VERSION   "This setup is version %s, but setup.ini claims version %s is available.\nYou might want to upgrade to get the latest features and bug fixes."
     IDS_DOWNLOAD_INCOMPLETE "Download Incomplete.  Try again?"
diff --git a/resource.h b/resource.h
index 5bbb668..a2add84 100644
--- a/resource.h
+++ b/resource.h
@@ -13,7 +13,6 @@
 #define IDS_DOWNLOAD_COMPLETE             110
 #define IDS_NOLOGFILE                     111
 #define IDS_UNINSTALL_COMPLETE            112
-#define IDS_WININET                       113
 #define IDS_ERR_CHDIR                     114
 #define IDS_OLD_SETUP_VERSION             115
 #define IDS_DOWNLOAD_INCOMPLETE           116
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 04/15] Remove packageversion::sources(), only packageversion::source() is useful

Jon TURNEY
In reply to this post by Jon TURNEY
The comments seems to indicate this was for supporting a package consisting
of multiple archives.

We only supported downloading such packages, not describing them in
setup.ini or installing them.

No such mythical beast has been sighted.
---
 download.cc        | 24 ++++++------------------
 package_version.cc | 31 ++++++++++---------------------
 package_version.h  |  8 +-------
 3 files changed, 17 insertions(+), 46 deletions(-)

diff --git a/download.cc b/download.cc
index f9354bb..5cc5e2b 100644
--- a/download.cc
+++ b/download.cc
@@ -219,19 +219,13 @@ do_download_thread (HINSTANCE h, HWND owner)
     {
           if (version.picked())
  {
-  for (vector<packagesource>::iterator i =
-       version.sources ()->begin();
-       i != version.sources ()->end(); ++i)
-    if (!check_for_cached (*i))
-            total_download_bytes += i->size;
+    if (!check_for_cached (*version.source()))
+      total_download_bytes += version.source()->size;
  }
           if (sourceversion.picked () || IncludeSource)
  {
-  for (vector<packagesource>::iterator i =
-       sourceversion.sources ()->begin();
-       i != sourceversion.sources ()->end(); ++i)
-    if (!check_for_cached (*i))
-      total_download_bytes += i->size;
+    if (!check_for_cached (*sourceversion.source()))
+      total_download_bytes += sourceversion.source()->size;
  }
     }
   catch (Exception * e)
@@ -259,17 +253,11 @@ do_download_thread (HINSTANCE h, HWND owner)
   packageversion sourceversion = version.sourcePackage();
   if (version.picked())
     {
-      for (vector<packagesource>::iterator i =
-     version.sources ()->begin();
-   i != version.sources ()->end(); ++i)
-     e += download_one (*i, owner);
+ e += download_one (*version.source(), owner);
     }
   if (sourceversion && (sourceversion.picked() || IncludeSource))
     {
-      for (vector<packagesource>::iterator i =
-     sourceversion.sources ()->begin();
-   i != sourceversion.sources ()->end(); ++i)
-     e += download_one (*i, owner);
+ e += download_one (*sourceversion.source (), owner);
     }
   errors += e;
 #if 0
diff --git a/package_version.cc b/package_version.cc
index 7f52c27..1fc5d77 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -264,15 +264,7 @@ packageversion::uninstall ()
 packagesource *
 packageversion::source () const
 {
-  if (!data->sources.size())
-    data->sources.push_back (packagesource());
-  return &data->sources[0];
-}
-
-vector<packagesource> *
-packageversion::sources () const
-{
-  return &data->sources;
+  return &data->source;
 }
 
 bool
@@ -392,24 +384,21 @@ _packageversion::sourcePackage ()
   return sourceVersion;
 }
 
+// is archive accessible
 bool
 _packageversion::accessible() const
 {
-  bool cached (sources.size() > 0);
-  for (vector<packagesource>::const_iterator i = sources.begin();
-       i!=sources.end(); ++i)
-    if (!i->Cached ())
-      cached = false;
-  if (cached)
+  // cached ?
+  if (source.Cached ())
     return true;
+  // net access allowed?
   if (::source == IDC_SOURCE_LOCALDIR)
     return false;
-  unsigned int retrievable = 0;
-  for (vector<packagesource>::const_iterator i = sources.begin();
-      i!=sources.end(); ++i)
-    if (i->sites.size() || i->Cached ())
-      retrievable += 1;
-  return retrievable > 0;
+  // retrievable ?
+  if (source.sites.size() || source.Cached ())
+    return true;
+  // otherwise, not accessible
+  return false;
 }
 
 void
diff --git a/package_version.h b/package_version.h
index b728acc..1b255a5 100644
--- a/package_version.h
+++ b/package_version.h
@@ -119,12 +119,6 @@ public:
   void uninstall ();
   /* invariant: never null */
   packagesource *source() const; /* where can we source the file from */
-  /* invariant: never null */
-  std::vector <packagesource> *sources() const; /* expose the list of files.
- source() returns the 'default' file
- sources() allows managing multiple files
- in a single package
- */
 
   bool accessible () const;
   /* scan for local copies */
@@ -184,7 +178,7 @@ public:
  /* This will also trigger reinstalled if it is set */
 
   virtual void uninstall () = 0;
-  std::vector<packagesource> sources; /* where can we source the files from */
+  packagesource source; /* where can we source the file from */
 
   virtual bool accessible () const;
 
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 05/15] Remove unused forward declaration of non-existent class category

Jon TURNEY
In reply to this post by Jon TURNEY
---
 package_meta.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/package_meta.h b/package_meta.h
index 5c5e718..506d0f2 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -18,7 +18,6 @@
 
 class packageversion;
 class packagemeta;
-class category;
 
 /* Required to parse this completely */
 #include <set>
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 06/15] Remove unneeded virtual from class packagesource's methods

Jon TURNEY
In reply to this post by Jon TURNEY
This class has no subclasses, and there are no plans for such.

Also remove some irrelevant comments which seem to have been cut-and-pasted
from packageversion.h
---
 package_source.h | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/package_source.h b/package_source.h
index 9e68bdc..883ff08 100644
--- a/package_source.h
+++ b/package_source.h
@@ -20,29 +20,12 @@
  * source as in http/ftp/disk file) operations.
  */
 
-/* required to parse this file */
 #include "sha2.h"
 #include "strings.h"
 #include "String++.h"
 #include "csu_util/MD5Sum.h"
 #include <vector>
 
-/* standard binary package metadata:
- * Name (ie mutt
- * Vendor Version (ie 2.5.1)
- * Package Version (ie 16)
- * Stability
- * Files
- */
-
-/* For non installed files, this class can be populated via information about
- * what is available on the net, or by parsing a specific package file.
- * for installed packages, this class should represent what is currently installed,
- * - updated by what net metadata has about it.
- * i.e. the stability of this version will change simply because the net mirrors
- * now consider it old.
- */
-
 class site
 {
 public:
@@ -68,26 +51,26 @@ public:
   /* The canonical name - the complete path to the source file
    * i.e. foo/bar/package-1.tar.bz2
    */
-  virtual const char *Canonical () const
+  const char *Canonical () const
   {
     return canonical;
   };
   /* The basename - without extention
    * i.e. package-1
    */
-  virtual const char *Base () const
+  const char *Base () const
   {
     return base;
   };
   /* The basename - with extention
    * i.e. package-1.tar.bz2
    */
-  virtual const char *Filename () const
+  const char *Filename () const
   {
     return filename;
   };
   /* what is the cached filename, to prevent directory scanning during install */
-  virtual char const *Cached () const
+  char const *Cached () const
   {
     /* Pointer-coerce-to-boolean is used by many callers. */
     if (cached.empty())
@@ -95,15 +78,15 @@ public:
     return cached.c_str();
   };
   /* sets the canonical path, and parses and creates base and filename */
-  virtual void set_canonical (char const *);
-  virtual void set_cached (const std::string& );
+  void set_canonical (char const *);
+  void set_cached (const std::string& );
   unsigned char sha512sum[SHA512_DIGEST_LENGTH];
   bool sha512_isSet;
   MD5Sum md5;
   typedef std::vector <site> sitestype;
   sitestype sites;
 
-  virtual ~ packagesource ()
+  ~packagesource ()
   {
     if (canonical)
       delete []canonical;
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 07/15] Simplify class packagesource

Jon TURNEY
In reply to this post by Jon TURNEY
packagesource::Filename() is unused

packagesource::Base() was only used in reporting progress in install.
Instead report the package name and package version.  (It would be nice to
do so consistently in uninstall well, but we don't really know what version
we are uninstalling)

The default copy constructor is not overriden, which is unsafe, as the class
contains a pointer to new-ed memory. Use std::string instead, retaining the
relied-upon behaviour of returning NULL for an empty string.
---
 install.cc        | 24 ++++++++++++------------
 package_source.cc | 48 ++++--------------------------------------------
 package_source.h  | 39 ++++++++-------------------------------
 3 files changed, 24 insertions(+), 87 deletions(-)

diff --git a/install.cc b/install.cc
index fb3e93f..6e59a80 100644
--- a/install.cc
+++ b/install.cc
@@ -148,7 +148,7 @@ Installer::StandardDirs[] = {
 };
 
 static int num_installs, num_uninstalls;
-static void chksum_one (const packagesource& source);
+static void chksum_one (const packagemeta &pkg, const packagesource& pkgsource);
 
 void
 Installer::preremoveOne (packagemeta & pkg)
@@ -362,7 +362,7 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
   if (!source.Canonical())
     return;
   Progress.SetText1 ("Installing");
-  Progress.SetText2 (source.Base () ? source.Base () : "(unknown)");
+  Progress.SetText2 ((pkgm.name + "-" + ver.Canonical_version()).c_str());
 
   io_stream *pkgfile = NULL;
 
@@ -763,7 +763,7 @@ do_install_thread (HINSTANCE h, HWND owner)
     {
       try
       {
-        chksum_one (*pkg.desired.source ());
+        chksum_one (pkg, *pkg.desired.source ());
       }
       catch (Exception *e)
       {
@@ -783,7 +783,7 @@ do_install_thread (HINSTANCE h, HWND owner)
       bool skiprequested = false ;
       try
       {
-        chksum_one (*pkg.desired.sourcePackage ().source ());
+        chksum_one (pkg, *pkg.desired.sourcePackage ().source ());
       }
       catch (Exception *e)
       {
@@ -930,7 +930,7 @@ sha512_str (const unsigned char *in, char *buf)
 }
 
 static void
-sha512_one (const packagesource& pkgsource)
+sha512_one (const packagemeta &pkg, const packagesource& pkgsource)
 {
   std::string fullname (pkgsource.Cached ());
 
@@ -949,7 +949,7 @@ sha512_one (const packagesource& pkgsource)
   Log (LOG_BABBLE) << "Checking SHA512 for " << fullname << endLog;
 
   Progress.SetText1 ((std::string ("Checking SHA512 for ")
-      + pkgsource.Base ()).c_str ());
+      + pkg.name).c_str ());
   Progress.SetText4 ("Progress:");
   Progress.SetBar1 (0);
 
@@ -986,7 +986,7 @@ sha512_one (const packagesource& pkgsource)
 }
 
 static void
-md5_one (const packagesource& pkgsource)
+md5_one (const packagemeta &pkg, const packagesource& pkgsource)
 {
   std::string fullname (pkgsource.Cached ());
 
@@ -1001,7 +1001,7 @@ md5_one (const packagesource& pkgsource)
   Log (LOG_BABBLE) << "Checking MD5 for " << fullname << endLog;
 
   Progress.SetText1 ((std::string ("Checking MD5 for ")
-      + pkgsource.Base ()).c_str ());
+      + pkg.name).c_str ());
   Progress.SetText4 ("Progress:");
   Progress.SetBar1 (0);
 
@@ -1035,16 +1035,16 @@ md5_one (const packagesource& pkgsource)
 }
 
 static void
-chksum_one (const packagesource& pkgsource)
+chksum_one (const packagemeta &pkg, const packagesource& pkgsource)
 {
   if (!pkgsource.Cached ())
     return;
   if (pkgsource.sha512_isSet)
-    sha512_one (pkgsource);
+    sha512_one (pkg, pkgsource);
   else if (pkgsource.md5.isSet())
-    md5_one (pkgsource);
+    md5_one (pkg, pkgsource);
   else
-    Log (LOG_BABBLE) << "No checksum recorded for " << pkgsource.Base ()
+    Log (LOG_BABBLE) << "No checksum recorded for " << pkg.name
      << ", cannot determine integrity of package!"
      << endLog;
 }
diff --git a/package_source.cc b/package_source.cc
index 192fe5f..15540f6 100644
--- a/package_source.cc
+++ b/package_source.cc
@@ -14,59 +14,19 @@
  */
 
 /* this is the parent class for all package source (not source code - installation
- * source as in http/ftp/disk file) operations.
+ * source as in http/ftp/disk file) operations.
  */
 
-#include <stdlib.h>
-#include <strings.h>
 #include "package_source.h"
 
 site::site (const std::string& newkey) : key(newkey)
 {
-};
-  
+}
+
 void
 packagesource::set_canonical (char const *fn)
 {
-  if (canonical)
-    delete[] canonical;
-  canonical = new char[strlen (fn) + 1];
-  strcpy (canonical, fn);
-
-  /* The base is from the last '/' to the '.tar' following the last - */
-  char const *bstart = strchr (fn, '/');
-  char const *tmp;
-  while (bstart && (tmp = strchr (bstart + 1, '/')))
-    bstart = tmp;
-
-  if (bstart)
-    bstart++;
-  else
-    bstart = fn;
-  char const *bend = strchr (bstart, '-');
-  while (bend && (tmp = strchr (bend + 1, '-')))
-    bend = tmp;
-  if (bend)
-    bend = strstr (bend, ".tar");
-  else
-    bend = strstr (bstart, ".tar");
-
-  if (!bend)
-    bend = strchr (bstart, '\0');
-  char const *end = strchr (fn, '\0');
-  if (base)
-    delete[] base;
-  base = new char[bend - bstart + 1];
-  memcpy (base, bstart, bend - bstart);
-  base[bend - bstart] = '\0';
-
-  if (filename)
-    delete[] filename;
-  filename = new char[end - bstart + 1];
-  memcpy (filename, bstart, end - bstart);
-  filename[end - bstart] = '\0';
-
-  cached = std::string();
+  canonical = fn;
 }
 
 void
diff --git a/package_source.h b/package_source.h
index 883ff08..8675c51 100644
--- a/package_source.h
+++ b/package_source.h
@@ -41,33 +41,22 @@ public:
 class packagesource
 {
 public:
-  packagesource ():size (0), canonical (0), base (0), filename (0), cached ()
+  packagesource ():size (0), canonical (), cached ()
   {
     memset (sha512sum, 0, sizeof sha512sum);
     sha512_isSet = false;
   };
   /* how big is the source file */
   size_t size;
-  /* The canonical name - the complete path to the source file
+  /* The canonical name - the complete path to the source file
    * i.e. foo/bar/package-1.tar.bz2
    */
   const char *Canonical () const
   {
-    return canonical;
-  };
-  /* The basename - without extention
-   * i.e. package-1
-   */
-  const char *Base () const
-  {
-    return base;
-  };
-  /* The basename - with extention
-   * i.e. package-1.tar.bz2
-   */
-  const char *Filename () const
-  {
-    return filename;
+    if (!canonical.empty())
+      return canonical.c_str();
+
+    return NULL;
   };
   /* what is the cached filename, to prevent directory scanning during install */
   char const *Cached () const
@@ -77,7 +66,7 @@ public:
       return NULL;
     return cached.c_str();
   };
-  /* sets the canonical path, and parses and creates base and filename */
+  /* sets the canonical path */
   void set_canonical (char const *);
   void set_cached (const std::string& );
   unsigned char sha512sum[SHA512_DIGEST_LENGTH];
@@ -86,20 +75,8 @@ public:
   typedef std::vector <site> sitestype;
   sitestype sites;
 
-  ~packagesource ()
-  {
-    if (canonical)
-      delete []canonical;
-    if (base)
-      delete []base;
-    if (filename)
-      delete []filename;
-  };
-
 private:
-  char *canonical;
-  char *base;
-  char *filename;
+  std::string canonical;
   std::string cached;
 };
 
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 08/15] Fix comments and indentation in check_for_cached

Jon TURNEY
In reply to this post by Jon TURNEY
---
 download.cc | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/download.cc b/download.cc
index 5cc5e2b..59af2d6 100644
--- a/download.cc
+++ b/download.cc
@@ -72,41 +72,38 @@ validateCachedPackage (const std::string& fullname, packagesource & pkgsource)
 int
 check_for_cached (packagesource & pkgsource, bool mirror_mode)
 {
-  /* search algo:
-     1) is there a legacy version in the cache dir available.
-     (Note that the cache dir is represented by a mirror site of
-     file://local_dir
-   */
-
   // Already found one.
   if (pkgsource.Cached())
     return 1;
-  
+
+  /* Note that the cache dir is represented by a mirror site of file://local_dir */
   std::string prefix = "file://" + local_dir + "/";
-  /* FIXME: Nullness check can go away once packagesource is properly
-   * std::string-ified, and doesn't use overcomplex semantics. */
-  std::string fullname = prefix +
-    (pkgsource.Canonical() ? pkgsource.Canonical() : "");
+  std::string fullname = prefix + pkgsource.Canonical();
+
   if (mirror_mode)
     {
       /* Just assume correctness of mirror. */
       pkgsource.set_cached (fullname);
       return 1;
     }
+
+  /*
+     1) is there a legacy version in the cache dir available.
+  */
   if (io_stream::exists (fullname))
     {
       if (validateCachedPackage (fullname, pkgsource))
- pkgsource.set_cached (fullname);
+        pkgsource.set_cached (fullname);
       else
- throw new Exception (TOSTRING(__LINE__) " " __FILE__,
-    "Package validation failure for " + fullname,
-    APPERR_CORRUPT_PACKAGE);
+        throw new Exception (TOSTRING(__LINE__) " " __FILE__,
+            "Package validation failure for " + fullname,
+            APPERR_CORRUPT_PACKAGE);
       return 1;
     }
 
   /*
      2) is there a version from one of the selected mirror sites available ?
-     */
+  */
   for (packagesource::sitestype::const_iterator n = pkgsource.sites.begin();
        n != pkgsource.sites.end(); ++n)
   {
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 09/15] Initial setting of trust should be TRUST_CURR

Jon TURNEY
In reply to this post by Jon TURNEY
---
 PickView.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/PickView.cc b/PickView.cc
index b3b1c1a..222bcb8 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -491,8 +491,7 @@ PickView::init_headers (HDC dc)
   headers[last_col].width += total_delta_x;
 }
 
-
-PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN),
+PickView::PickView (Category &cat) : deftrust (TRUST_CURR),
 contents (*this, cat, 0, false, true), showObsolete (false),
 packageFilterString (), hasWindowRect (false), total_delta_x (0)
 {
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 10/15] Change PackageSpecification::_operator to an enum

Jon TURNEY
In reply to this post by Jon TURNEY
---
 PackageSpecification.cc | 71 ++++++++++++++++++++++---------------------------
 PackageSpecification.h  | 46 +++++++++++---------------------
 2 files changed, 48 insertions(+), 69 deletions(-)

diff --git a/PackageSpecification.cc b/PackageSpecification.cc
index a0818b3..f59b11b 100644
--- a/PackageSpecification.cc
+++ b/PackageSpecification.cc
@@ -18,7 +18,7 @@
 #include "package_version.h"
 
 PackageSpecification::PackageSpecification (const std::string& packageName)
-  : _packageName (packageName) , _operator (0), _version ()
+  : _packageName (packageName) , _operator (Equals), _version ()
 {
 }
 
@@ -29,9 +29,9 @@ PackageSpecification::packageName () const
 }
 
 void
-PackageSpecification::setOperator (_operators const &anOperator)
+PackageSpecification::setOperator (_operators anOperator)
 {
-  _operator = &anOperator;
+  _operator = anOperator;
 }
 
 void
@@ -45,9 +45,28 @@ PackageSpecification::satisfies (packageversion const &aPackage) const
 {
   if (casecompare(_packageName, aPackage.Name()) != 0)
     return false;
-  if (_operator && _version.size()
-      && !_operator->satisfies (aPackage.Canonical_version (), _version))
-    return false;
+
+  // The default values of _operator = Equals and _version is an empty-string
+  // match any version
+  if (_version.size())
+    {
+      int comparison = casecompare(aPackage.Canonical_version (), _version);
+      switch (_operator)
+        {
+        case Equals:
+          return (comparison == 0);
+        case LessThan:
+          return (comparison < 0);
+        case MoreThan:
+          return (comparison > 0);
+        case LessThanEquals:
+          return (comparison <= 0);
+        case MoreThanEquals:
+          return (comparison >= 0);
+        default:
+          return false;
+        }
+    }
   return true;
 }
 
@@ -69,52 +88,26 @@ operator << (std::ostream &os, PackageSpecification const &spec)
 {
   os << spec._packageName;
   if (spec._operator)
-    os << " " << spec._operator->caption() << " " << spec._version;
+    os << " " << PackageSpecification::caption(spec._operator) << " " << spec._version;
   return os;
 }
 
-const PackageSpecification::_operators PackageSpecification::Equals(0);
-const PackageSpecification::_operators PackageSpecification::LessThan(1);
-const PackageSpecification::_operators PackageSpecification::MoreThan(2);
-const PackageSpecification::_operators PackageSpecification::LessThanEquals(3);
-const PackageSpecification::_operators PackageSpecification::MoreThanEquals(4);
-
 char const *
-PackageSpecification::_operators::caption () const
+PackageSpecification::caption (_operators _value)
 {
   switch (_value)
     {
-    case 0:
+    case Equals:
     return "==";
-    case 1:
+    case LessThan:
     return "<";
-    case 2:
+    case MoreThan:
     return ">";
-    case 3:
+    case LessThanEquals:
     return "<=";
-    case 4:
+    case MoreThanEquals:
     return ">=";
     }
   // Pacify GCC: (all case options are checked above)
   return "Unknown operator";
 }
-
-bool
-PackageSpecification::_operators::satisfies (const std::string& lhs,
-                                             const std::string& rhs) const
-{
-  switch (_value)
-    {
-    case 0:
-      return casecompare(lhs, rhs) == 0;
-    case 1:
-      return casecompare(lhs, rhs) < 0;
-    case 2:
-      return casecompare(lhs, rhs) > 0;
-    case 3:
-      return casecompare(lhs, rhs) <= 0;
-    case 4:
-      return casecompare(lhs, rhs) >= 0;
-    }
-  return false;
-}
diff --git a/PackageSpecification.h b/PackageSpecification.h
index 8d622f3..a26431a 100644
--- a/PackageSpecification.h
+++ b/PackageSpecification.h
@@ -25,14 +25,21 @@ class packageversion;
 class PackageSpecification
 {
 public:
-  PackageSpecification () : _packageName (), _operator(0) {}
+  PackageSpecification () : _packageName (), _operator(Equals) {}
   PackageSpecification (const std::string& packageName);
   ~PackageSpecification () {}
 
-  class _operators;
-
-  const std::string& packageName() const;
-  void setOperator (_operators const &);
+  enum _operators
+  {
+    Equals,
+    LessThan,
+    MoreThan,
+    LessThanEquals,
+    MoreThanEquals,
+  };
+
+  const std::string& packageName() const;
+  void setOperator (_operators);
   void setVersion (const std::string& );
 
   bool satisfies (packageversion const &) const;
@@ -42,33 +49,12 @@ public:
 
   friend std::ostream &operator << (std::ostream &, PackageSpecification const &);
 
-  class _operators
-    {
-    public:
-      _operators ():_value (0) {};
-      _operators (int aInt) {
- _value = aInt;
- if (_value < 0 ||  _value > 4)
-  _value = 0;
-      }
-      _operators & operator ++ ();
-      bool operator == (_operators const &rhs) { return _value == rhs._value; }
-      bool operator != (_operators const &rhs) { return _value != rhs._value; }
-      const char *caption () const;
-      bool satisfies (const std::string& lhs, const std::string& rhs) const;
-    private:
-      int _value;
-    };
-  static const _operators Equals;
-  static const _operators LessThan;
-  static const _operators MoreThan;
-  static const _operators LessThanEquals;
-  static const _operators MoreThanEquals;
-
 private:
+  static char const * caption (_operators _value);
+
   std::string _packageName; /* foobar */
-  _operators const * _operator; /* >= */
-  std::string _version;       /* 1.20 */
+  _operators  _operator;    /* >= */
+  std::string _version;     /* 1.20 */
 };
 
 std::ostream &
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 11/15] Remove useless PackageSpecification methods

Jon TURNEY
Remove unused PackageSpecification::serialise()

Remove dangerous PackageSpecification::operator= which doesn't copy all
object state
---
 PackageSpecification.cc | 13 -------------
 PackageSpecification.h  |  3 ---
 2 files changed, 16 deletions(-)

diff --git a/PackageSpecification.cc b/PackageSpecification.cc
index f59b11b..247f3da 100644
--- a/PackageSpecification.cc
+++ b/PackageSpecification.cc
@@ -70,19 +70,6 @@ PackageSpecification::satisfies (packageversion const &aPackage) const
   return true;
 }
 
-std::string
-PackageSpecification::serialise () const
-{
-  return _packageName;
-}
-
-PackageSpecification &
-PackageSpecification::operator= (PackageSpecification const &rhs)
-{
-  _packageName = rhs._packageName;
-  return *this;
-}
-
 std::ostream &
 operator << (std::ostream &os, PackageSpecification const &spec)
 {
diff --git a/PackageSpecification.h b/PackageSpecification.h
index a26431a..4c3ed6d 100644
--- a/PackageSpecification.h
+++ b/PackageSpecification.h
@@ -43,9 +43,6 @@ public:
   void setVersion (const std::string& );
 
   bool satisfies (packageversion const &) const;
-  std::string serialise () const;
-
-  PackageSpecification &operator= (PackageSpecification const &);
 
   friend std::ostream &operator << (std::ostream &, PackageSpecification const &);
 
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 12/15] Stop pretending to support complex dependencies

Jon TURNEY
In reply to this post by Jon TURNEY
We pretend that we can parse dependencies of the form "A | B".  But
PrereqChecker will just treat that as "A".

This is a hard problem to solve, as we'd need UI to ask, or policy to know
if A or B is preferred.

So just remove the pretense, simplifying lots of stuff.
---
 IniDBBuilderPackage.cc | 62 +++++++++++---------------------------------------
 IniDBBuilderPackage.h  |  6 ++---
 iniparse.yy            | 16 ++++++-------
 package_db.cc          | 27 +++++++++-------------
 package_version.cc     | 29 ++++++++---------------
 package_version.h      | 12 +++++-----
 prereq.cc              | 10 +++-----
 7 files changed, 52 insertions(+), 110 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 303ac34..cd5c922 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -34,7 +34,7 @@
 using namespace std;
 
 IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const &aFeedback) :
-cp (0), cbpv (), cspv (), currentSpec (0), currentOrList (0), currentAndList (0), trust (0), _feedback (aFeedback){}
+cp (0), cbpv (), cspv (), currentSpec (0), currentNodeList (0), trust (0), _feedback (aFeedback){}
 
 IniDBBuilderPackage::~IniDBBuilderPackage()
 {
@@ -76,8 +76,9 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
       if (cbpv)
  {
   Log (LOG_BABBLE) << "Version " << cbpv.Canonical_version() << endLog;
-  Log (LOG_BABBLE) << "Depends:" << endLog;
+  Log (LOG_BABBLE) << "Depends:";
   dumpAndList (cbpv.depends(), Log (LOG_BABBLE));
+  Log (LOG_BABBLE) << endLog;
  }
     }
 #endif
@@ -91,8 +92,7 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
   cbpv = cygpackage::createInstance (name, package_binary);
   cspv = packageversion ();
   currentSpec = NULL;
-  currentOrList = NULL;
-  currentAndList = NULL;
+  currentNodeList = NULL;
   trust = TRUST_CURR;
 #if DEBUG
   Log (LOG_BABBLE) << "Created package " << name << endLog;
@@ -191,11 +191,10 @@ IniDBBuilderPackage::buildBeginDepends ()
 #if DEBUG
   Log (LOG_BABBLE) << "Beginning of a depends statement for " << cp->name
     << endLog;
-  dumpAndList (currentAndList, Log (LOG_BABBLE));
+  dumpAndList (currentNodeList, Log (LOG_BABBLE));
 #endif
   currentSpec = NULL;
-  currentOrList = NULL; /* set by the build AndListNode */
-  currentAndList = cbpv.depends();
+  currentNodeList = cbpv.depends();
 }
 
 void
@@ -241,11 +240,9 @@ IniDBBuilderPackage::buildBeginBuildDepends ()
 {
 #if DEBUG
   Log (LOG_BABBLE) << "Beginning of a Build-Depends statement" << endLog;
-  dumpAndList (currentAndList, Log (LOG_BABBLE));
 #endif
   currentSpec = NULL;
-  currentOrList = NULL; /* set by the build AndListNode */
-  currentAndList = cspv.depends ();
+  currentNodeList = NULL; /* there is currently nowhere to store Build-Depends information */
 }
 
 void
@@ -284,48 +281,16 @@ IniDBBuilderPackage::buildSourceNameVersion (const std::string& version)
 }
 
 void
-IniDBBuilderPackage::buildPackageListAndNode ()
+IniDBBuilderPackage::buildPackageListNode (const std::string & name)
 {
-  if (currentAndList)
+  if (currentNodeList)
     {
 #if DEBUG
-      Log (LOG_BABBLE) << "New AND node for a package list" << endLog;
-      if (currentOrList)
-     {
-      ostream &os = Log (LOG_BABBLE);
-      os << "Current OR list is :";
-      for (vector<PackageSpecification *>::const_iterator i= currentOrList->begin();
-           i != currentOrList->end(); ++i)
-          os << endl << **i;
-      os << endLog;
-     }
+      Log (LOG_BABBLE) << "New node '" << name << "' for package list" << endLog;
 #endif
-      currentSpec = NULL;
-      currentOrList = new vector<PackageSpecification *>;
-      currentAndList->push_back (currentOrList);
+      currentSpec = new PackageSpecification (name);
+      currentNodeList->push_back (currentSpec);
     }
-  else
-    _feedback.warning ((std::string ("Attempt to add And node when no AndList"
- " present for package ")
-                        + std::string(cp->name)).c_str());
-}
-
-void
-IniDBBuilderPackage::buildPackageListOrNode (const std::string& packageName)
-{
-  if (currentOrList)
-    {
-      currentSpec = new PackageSpecification (packageName);
-      currentOrList->push_back (currentSpec);
-#if DEBUG
-      Log (LOG_BABBLE) << "New OR node in a package list refers to \"" <<
-        *currentSpec << "\"." << endLog;
-#endif
-    }
-  else
-    _feedback.warning ((std::string ("Attempt to set specification for package ")
-                        + std::string(cp->name)
- + " before creation of a version.").c_str());
 }
 
 void
@@ -394,8 +359,7 @@ IniDBBuilderPackage::add_correct_version()
   *ver.depends() = *cbpv.depends();
  /* TODO: other package lists */
  /* Prevent dangling references */
- currentOrList = NULL;
- currentAndList = NULL;
+ currentNodeList = NULL;
  currentSpec = NULL;
         cbpv = *n;
         merged = 1;
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index a39a95f..ef1a6bf 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -49,8 +49,7 @@ public:
   void buildMessage (const std::string&, const std::string&);
   void buildSourceName (const std::string& );
   void buildSourceNameVersion (const std::string& );
-  void buildPackageListAndNode ();
-  void buildPackageListOrNode (const std::string& );
+  void buildPackageListNode (const std::string& );
   void buildPackageListOperator (PackageSpecification::_operators const &);
   void buildPackageListOperatorVersion (const std::string& );
 
@@ -73,8 +72,7 @@ private:
   packagemeta *csp;
   packageversion cspv;
   PackageSpecification *currentSpec;
-  std::vector<PackageSpecification *> *currentOrList;
-  std::vector<std::vector<PackageSpecification *> *> *currentAndList;
+  std::vector<PackageSpecification *> *currentNodeList;
   int trust;
   IniParseFeedback const &_feedback;
 };
diff --git a/iniparse.yy b/iniparse.yy
index 9ef4801..2480cc6 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -131,30 +131,28 @@ versioninfo: /* empty */
  ;
 
 versionedpackagelist /* non-empty */
- : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
- | versionedpackagelist listseparator { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
+ : versionedpackageentry
+ | versionedpackagelist listseparator versionedpackageentry
  ;
 
 versionedpackagelistsp /* non-empty */
- : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
- | versionedpackagelistsp { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
+ : versionedpackageentry
+ | versionedpackagelistsp versionedpackageentry
  ;
 
-
 listseparator: /* empty */
  | COMMA
  | COMMA NL
  ;
-
+
 versionedpackageentry /* empty not allowed */
- : STRING { iniBuilder->buildPackageListOrNode($1); } versioncriteria
- | versionedpackageentry OR STRING { iniBuilder->buildPackageListOrNode($3); } versioncriteria
+ : STRING { iniBuilder->buildPackageListNode($1); } versioncriteria
  ;
 
 versioncriteria: /* empty */
  | OPENBRACE operator STRING CLOSEBRACE { iniBuilder->buildPackageListOperatorVersion ($3); }
  ;
-
+
 operator /* non-empty */
  : EQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::Equals); }
  | LT { iniBuilder->buildPackageListOperator (PackageSpecification::LessThan); }
diff --git a/package_db.cc b/package_db.cc
index c2e1b63..e97eea1 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -311,31 +311,27 @@ ConnectedLoopFinder::visit(packagemeta *nodeToVisit)
   size_t minimumVisitId = visited;
   nodesInStronglyConnectedComponent.push(nodeToVisit);
 
-  vector <vector <PackageSpecification *> *>::const_iterator dp = nodeToVisit->installed.depends()->begin();
-  /* walk through each and clause (a link in the graph) */
+  /* walk through each node */
+  std::vector <PackageSpecification *>::const_iterator dp = nodeToVisit->installed.depends()->begin();
   while (dp != nodeToVisit->installed.depends()->end())
     {
-      /* check each or clause for an installed match */
-      vector <PackageSpecification *>::const_iterator i = find_if ((*dp)->begin(), (*dp)->end(), checkForInstalled);
-      if (i != (*dp)->end())
+      /* check for an installed match */
+      if (checkForInstalled (*dp))
  {
   /* we found an installed ok package */
   /* visit it if needed */
   /* UGLY. Need to refactor. iterators in the outer would help as we could simply
    * vist the iterator
    */
-  const packagedb::packagecollection::iterator n = db.packages.find((*i)->packageName());
+  const packagedb::packagecollection::iterator n = db.packages.find((*dp)->packageName());
 
   if (n == db.packages.end())
-     Log (LOG_PLAIN) << "Search for package '" << (*i)->packageName() << "' failed." << endLog;
+     Log (LOG_PLAIN) << "Search for package '" << (*dp)->packageName() << "' failed." << endLog;
    else
    {
        packagemeta *nodeJustVisited = n->second;
        minimumVisitId = std::min (minimumVisitId, visit (nodeJustVisited));
    }
-  /* next and clause */
-  ++dp;
-  continue;
  }
  /* not installed or not available we ignore */
       ++dp;
@@ -492,15 +488,14 @@ packagedb::guessUserPicked()
       if (!pkgm.installed)
  continue;
 
-      /* walk through each and clause */
-      vector <vector <PackageSpecification *> *>::const_iterator dp = pkgm.installed.depends()->begin();
+      /* walk through each node */
+      std::vector <PackageSpecification *>::const_iterator dp = pkgm.installed.depends()->begin();
       while (dp != pkgm.installed.depends()->end())
  {
-  /* check each or clause for an installed match */
-  vector <PackageSpecification *>::const_iterator i = find_if ((*dp)->begin(), (*dp)->end(), checkForInstalled);
-  if (i != (*dp)->end())
+  /* check for an installed match */
+          if (checkForInstalled(*dp))
     {
-      const packagedb::packagecollection::iterator n = packages.find((*i)->packageName());
+      const packagedb::packagecollection::iterator n = packages.find((*dp)->packageName());
       if (n != packages.end())
  {
   packagemeta *pkgm2 = n->second;
diff --git a/package_version.cc b/package_version.cc
index 1fc5d77..cd2d509 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -229,13 +229,13 @@ packageversion::setSourcePackageSpecification (PackageSpecification const &spec)
   data->setSourcePackageSpecification(spec);
 }
 
-vector <vector <PackageSpecification *> *> *
+vector <PackageSpecification *> *
 packageversion::depends()
 {
   return &data->depends;
 }
 
-const vector <vector <PackageSpecification *> *> *
+const vector <PackageSpecification *> *
 packageversion::depends() const
 {
   return &data->depends;
@@ -414,28 +414,19 @@ _packageversion::scripts()
 }
 
 void
-dumpAndList (vector<vector <PackageSpecification *> *> const *currentAndList,
+dumpAndList (std::vector <PackageSpecification *> const *currentList,
              std::ostream &logger)
 {
-  return;
-  if (currentAndList)
+  if (currentList)
   {
-    vector<vector <PackageSpecification *> *>::const_iterator iAnd =
-      currentAndList->begin();
+    Log (LOG_BABBLE) << "( ";
+    std::vector <PackageSpecification *>::const_iterator i = currentList->begin();
     while (true)
     {
-      if ((*iAnd)->size() > 1) Log (LOG_BABBLE) << "( ";
-      vector<PackageSpecification *>::const_iterator i= (*iAnd)->begin();
-      while (true)
-      {
-        Log (LOG_BABBLE) << **i;
-        if (++i == (*iAnd)->end()) break;
-        Log (LOG_BABBLE) << " | ";
-      }
-      if ((*iAnd)->size() > 1) Log (LOG_BABBLE) << " )";
-      if (++iAnd == currentAndList->end()) break;
-      Log (LOG_BABBLE) << " & ";
+      if (i == currentList->end()) break;
+      Log (LOG_BABBLE) << **i << " ";
+      ++i;
     }
+    Log (LOG_BABBLE) << ")";
   }
 }
-
diff --git a/package_version.h b/package_version.h
index 1b255a5..2f277bf 100644
--- a/package_version.h
+++ b/package_version.h
@@ -110,8 +110,8 @@ public:
   void setSourcePackageSpecification (PackageSpecification const &);
 
   /* invariant: these never return NULL */
-  std::vector <std::vector <PackageSpecification *> *> *depends();
-  const std::vector <std::vector <PackageSpecification *> *> *depends() const;
+  std::vector <PackageSpecification *> *depends();
+  const std::vector <PackageSpecification *> *depends() const;
 
   bool picked() const;   /* true if this version is to be installed */
   void pick(bool, packagemeta *); /* trigger an install/reinsall */
@@ -170,9 +170,9 @@ public:
   virtual packageversion sourcePackage ();
   virtual PackageSpecification & sourcePackageSpecification ();
   virtual void setSourcePackageSpecification (PackageSpecification const &);
-  
-  std::vector <std::vector <PackageSpecification *> *> depends;
-  
+
+  std::vector <PackageSpecification *> depends;
+
   virtual void pick(bool const &newValue) { picked = newValue;}
   bool picked; /* non zero if this version is to be installed */
  /* This will also trigger reinstalled if it is set */
@@ -196,6 +196,6 @@ protected:
 };
 
 // not sure where this belongs :}.
-void dumpAndList (std::vector<std::vector <PackageSpecification *> *> const *currentAndList, std::ostream &);
+void dumpAndList (std::vector <PackageSpecification *> const *currentList, std::ostream &);
 
 #endif /* SETUP_PACKAGE_VERSION_H */
diff --git a/prereq.cc b/prereq.cc
index 5a94373..7477f79 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -211,17 +211,13 @@ PrereqChecker::isMet ()
 
       // Fetch the dependencies of the package. This assumes that the
       // dependencies of all versions are all the same.
-      const vector <vector <PackageSpecification *> *> *deps = pack->curr.depends ();
+      const std::vector <PackageSpecification *> *deps = pack->curr.depends ();
 
       // go through the package's dependencies
-      for (vector <vector <PackageSpecification *> *>::const_iterator d =
+      for (std::vector <PackageSpecification *>::const_iterator d =
             deps->begin (); d != deps->end (); ++d)
         {
-          // XXX: the following assumes that there is only a single
-          // node in each OR clause, which is currently the case.
-          // if setup is ever pushed to use AND/OR in "depends:"
-          // lines this will have to be updated
-          PackageSpecification *dep_spec = (*d)->at(0);
+          PackageSpecification *dep_spec = *d;
           packagemeta *dep = db.findBinary (*dep_spec);
 
           if (dep)
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 13/15] All, rather than just the first (usually current) version should get dependencies

Jon TURNEY
In reply to this post by Jon TURNEY
It seems that dependencies are only recorded against the first version
encountered, which is fortunately usually the current version.  If one were
to install a different version than that the first time a package is
installed, it's dependencies wouldn't be installed.

More zany hijinks from the wacky world of setup :)
---
 IniDBBuilderPackage.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index cd5c922..7f500d6 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -333,6 +333,9 @@ IniDBBuilderPackage::buildPackageListOperatorVersion (const std::string& aVersio
 void
 IniDBBuilderPackage::add_correct_version()
 {
+  if (currentNodeList)
+    *cbpv.depends() = *currentNodeList;
+
   int merged = 0;
   for (set<packageversion>::iterator n = cp->versions.begin();
        !merged && n != cp->versions.end(); ++n)
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 14/15] Make PackageDepends a type

Jon TURNEY
In reply to this post by Jon TURNEY
Make PackageDepends a type, rather than repeating it's definition
everywhere.
---
 IniDBBuilderPackage.h |  2 +-
 Makefile.am           |  1 +
 desktop.cc            |  1 -
 package_db.cc         |  2 +-
 package_depends.h     | 21 +++++++++++++++++++++
 package_version.cc    |  8 ++++----
 package_version.h     |  9 +++++----
 prereq.cc             |  4 ++--
 8 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 package_depends.h

diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index ef1a6bf..4df1bdb 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -72,7 +72,7 @@ private:
   packagemeta *csp;
   packageversion cspv;
   PackageSpecification *currentSpec;
-  std::vector<PackageSpecification *> *currentNodeList;
+  PackageDepends *currentNodeList;
   int trust;
   IniParseFeedback const &_feedback;
 };
diff --git a/Makefile.am b/Makefile.am
index 7d5e1e3..f0f36f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -202,6 +202,7 @@ inilint_SOURCES = \
  nio-http.h \
  package_db.cc \
  package_db.h \
+ package_depends.h \
  package_meta.cc \
  package_meta.h \
  package_source.cc \
diff --git a/desktop.cc b/desktop.cc
index 81278dd..24908f8 100644
--- a/desktop.cc
+++ b/desktop.cc
@@ -39,7 +39,6 @@
 #include "filemanip.h"
 #include "io_stream.h"
 #include "getopt++/BoolOption.h"
-#include "PackageSpecification.h"
 #include "LogFile.h"
 
 static BoolOption NoShortcutsOption (false, 'n', "no-shortcuts", "Disable creation of desktop and start menu shortcuts");
diff --git a/package_db.cc b/package_db.cc
index e97eea1..3978421 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -312,7 +312,7 @@ ConnectedLoopFinder::visit(packagemeta *nodeToVisit)
   nodesInStronglyConnectedComponent.push(nodeToVisit);
 
   /* walk through each node */
-  std::vector <PackageSpecification *>::const_iterator dp = nodeToVisit->installed.depends()->begin();
+  PackageDepends::const_iterator dp = nodeToVisit->installed.depends()->begin();
   while (dp != nodeToVisit->installed.depends()->end())
     {
       /* check for an installed match */
diff --git a/package_depends.h b/package_depends.h
new file mode 100644
index 0000000..05e0dc6
--- /dev/null
+++ b/package_depends.h
@@ -0,0 +1,21 @@
+/*
+ * 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/
+ *
+ */
+
+#ifndef PACKAGE_DEPENDS_H
+#define PACKAGE_DEPENDS_H
+
+#include <vector>
+
+typedef std::vector <PackageSpecification *> PackageDepends;
+
+#endif // PACKAGE_DEPENDS_H
diff --git a/package_version.cc b/package_version.cc
index cd2d509..6a903c5 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -229,13 +229,13 @@ packageversion::setSourcePackageSpecification (PackageSpecification const &spec)
   data->setSourcePackageSpecification(spec);
 }
 
-vector <PackageSpecification *> *
+PackageDepends *
 packageversion::depends()
 {
   return &data->depends;
 }
 
-const vector <PackageSpecification *> *
+const PackageDepends *
 packageversion::depends() const
 {
   return &data->depends;
@@ -414,13 +414,13 @@ _packageversion::scripts()
 }
 
 void
-dumpAndList (std::vector <PackageSpecification *> const *currentList,
+dumpAndList (PackageDepends const *currentList,
              std::ostream &logger)
 {
   if (currentList)
   {
     Log (LOG_BABBLE) << "( ";
-    std::vector <PackageSpecification *>::const_iterator i = currentList->begin();
+    PackageDepends::const_iterator i = currentList->begin();
     while (true)
     {
       if (i == currentList->end()) break;
diff --git a/package_version.h b/package_version.h
index 2f277bf..ff16eb8 100644
--- a/package_version.h
+++ b/package_version.h
@@ -43,6 +43,7 @@ class CategoryList;
 #include "package_source.h"
 #include "PackageSpecification.h"
 #include "PackageTrust.h"
+#include "package_depends.h"
 #include "script.h"
 #include <vector>
 
@@ -110,8 +111,8 @@ public:
   void setSourcePackageSpecification (PackageSpecification const &);
 
   /* invariant: these never return NULL */
-  std::vector <PackageSpecification *> *depends();
-  const std::vector <PackageSpecification *> *depends() const;
+  PackageDepends *depends();
+  const PackageDepends *depends() const;
 
   bool picked() const;   /* true if this version is to be installed */
   void pick(bool, packagemeta *); /* trigger an install/reinsall */
@@ -171,7 +172,7 @@ public:
   virtual PackageSpecification & sourcePackageSpecification ();
   virtual void setSourcePackageSpecification (PackageSpecification const &);
 
-  std::vector <PackageSpecification *> depends;
+  PackageDepends depends;
 
   virtual void pick(bool const &newValue) { picked = newValue;}
   bool picked; /* non zero if this version is to be installed */
@@ -196,6 +197,6 @@ protected:
 };
 
 // not sure where this belongs :}.
-void dumpAndList (std::vector <PackageSpecification *> const *currentList, std::ostream &);
+void dumpAndList (PackageDepends const *currentList, std::ostream &);
 
 #endif /* SETUP_PACKAGE_VERSION_H */
diff --git a/prereq.cc b/prereq.cc
index 7477f79..eb8e21f 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -211,10 +211,10 @@ PrereqChecker::isMet ()
 
       // Fetch the dependencies of the package. This assumes that the
       // dependencies of all versions are all the same.
-      const std::vector <PackageSpecification *> *deps = pack->curr.depends ();
+      const PackageDepends *deps = pack->curr.depends ();
 
       // go through the package's dependencies
-      for (std::vector <PackageSpecification *>::const_iterator d =
+      for (PackageDepends::const_iterator d =
             deps->begin (); d != deps->end (); ++d)
         {
           PackageSpecification *dep_spec = *d;
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 15/15] Add some progress reporting during preremove and uninstall

Jon TURNEY
In reply to this post by Jon TURNEY
---
 install.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/install.cc b/install.cc
index 6e59a80..3721047 100644
--- a/install.cc
+++ b/install.cc
@@ -812,15 +812,20 @@ do_install_thread (HINSTANCE h, HWND owner)
   }
 
   /* start with uninstalls - remove files that new packages may replace */
+  Progress.SetBar2(0);
   for (vector <packagemeta *>::iterator i = uninstall_q.begin ();
        i != uninstall_q.end (); ++i)
   {
     myInstaller.preremoveOne (**i);
+    Progress.SetBar2(std::distance(uninstall_q.begin(), i) + 1, uninstall_q.size());
   }
+
+  Progress.SetBar2(0);
   for (vector <packagemeta *>::iterator i = uninstall_q.begin ();
        i != uninstall_q.end (); ++i)
   {
     myInstaller.uninstallOne (**i);
+    Progress.SetBar2(std::distance(uninstall_q.begin(), i) + 1, uninstall_q.size());
   }
 
   for (vector <packagemeta *>::iterator i = install_q.begin ();
--
2.12.3

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH setup 08/15] Fix comments and indentation in check_for_cached

Achim Gratz
In reply to this post by Jon TURNEY
Jon Turney writes:
> +  /* Note that the cache dir is represented by a mirror site of file://local_dir */
>    std::string prefix = "file://" + local_dir + "/";
> -  /* FIXME: Nullness check can go away once packagesource is properly
> -   * std::string-ified, and doesn't use overcomplex semantics. */
> -  std::string fullname = prefix +
> -    (pkgsource.Canonical() ? pkgsource.Canonical() : "");
> +  std::string fullname = prefix + pkgsource.Canonical();
> +

That part of the patch was a bit premature, but I see you've already
fixed it.  I found that interestingly it only crashed on 64bit, which
seems a bit odd, but maybe that's Windows for you.


Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds