Re: Perl layout for 5.26+

2017-05-31 Thread Achim Gratz
Yaakov Selkowitz writes:
> Using lib for archful things vs. share for noarch, and /usr/local for
> site*, is for compliance with FHS, and the latter avoids a lot of
> confusion over which should be used by packages.

Also, why do you propose to drop archname from the *arch directories?
This would make it impossible to put these on shared drives, so I'm
more inclined to leave these as they were.

prefix="/usr"
siteprefix="/usr/local"
vendorprefix="/usr"

vendorman1dir="${vendorprefix}/share/man/man1"
vendorman3dir="${vendorprefix}/share/man/man3"
html1dir="${prefix}/share/doc/perl/html/html1"
html3dir="${prefix}/share/doc/perl/html/html3"
sitehtml1dir="${siteprefix}/share/doc/perl/html/html1"
sitehtml3dir="${siteprefix}/share/doc/perl/html/html3"
vendorhtml1dir="${vendorprefix}/share/doc/perl/html/html1"
vendorhtml3dir="${vendorprefix}/share/doc/perl/html/html3"

archname=${ARCHNAME}
privlib="${prefix}/share/perl5/${PERLV}"
sitelib="${siteprefix}/share/perl5/site_perl/${PERLV}"
vendorlib="${vendorprefix}/lib/perl5/vendor_perl/${PERLV}"
archlib="${prefix}/lib/perl5/${PERLV}/${ARCHNAME}"
sitearch="${siteprefix}/lib/perl5/vendor_perl/${PERLV}/${ARCHNAME}"
vendorarch="${vendorprefix}/lib/perl5/site_perl/${PERLV}/${ARCHNAME}"

sitebin="${siteprefix}/bin"
sitescript="${siteprefix}/bin"

I would also leave the versioning on the noarch dirs.  We need to do a
full rebuild for 5.26 anyway and for 5.28 we can just as easily include
the previous version of the noarch directories in @INC if that is known
to work just like we did between 5.10 and 5.14.


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


[PATCH setup 12/14] Use solver to check for problems and produce a list of package transactions

2017-05-31 Thread Jon Turney
Convert chooser UI selections into a SolverTaskList

Apply SolverSolution to that task list (with choice of keep, upgrade,
upgrade with test, IncludeSource) to produce a vector of SolverTransactions.
Store a solution object in packagedb

The transaction list returned by the solver is postprocessed to add
reinstall and IncludeSource actions

Very crudely present solver problems in the PrereqChecker page UI, as text.
Change tickbox to say "accept default solutions" and don't allow to preceed
unless those solutions are accepted (ideally we would have a UI to choose
solutions).  Remove warning about missing dependencies.

Also pass initial trust state to PrereqChecker
---
 choose.cc |   7 +-
 libsolv.cc| 244 ++
 libsolv.h |  84 
 package_db.cc |   1 +
 package_db.h  |   1 +
 prereq.cc | 207 +++--
 prereq.h  |  22 ++
 res.rc|   4 +-
 8 files changed, 393 insertions(+), 177 deletions(-)

diff --git a/choose.cc b/choose.cc
index abfc14a..db8f561 100644
--- a/choose.cc
+++ b/choose.cc
@@ -153,6 +153,8 @@ ChooserPage::createListview ()
   /* FIXME: do we need to init the desired fields ? */
   static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_CURR, IDC_CHOOSE_EXP, 0 };
   rbset (GetHWND (), ta, IDC_CHOOSE_CURR);
+  changeTrust (TRUST_CURR);
+
   ClearBusy ();
 }
 
@@ -364,6 +366,8 @@ ChooserPage::keepClicked()
   pkg.desired = pkg.installed;
 }
   chooser->refresh();
+
+  PrereqChecker::setUpgrade(false);
 }
 
 void
@@ -372,7 +376,8 @@ ChooserPage::changeTrust(trusts aTrust)
   SetBusy ();
   chooser->defaultTrust (aTrust);
   chooser->refresh();
-  PrereqChecker::setTrust (aTrust);
+  PrereqChecker::setUpgrade(true);
+  PrereqChecker::setTestPackages(aTrust == TRUST_TEST);
   ClearBusy ();
 }
 
diff --git a/libsolv.cc b/libsolv.cc
index 67c68b5..df0af3d 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -18,6 +18,7 @@
 #include "solv/evr.h"
 
 #include "LogSingleton.h"
+#include  
 
 // ---
 // Utility functions for mapping between Operators and Relation Ids
@@ -441,3 +442,246 @@ SolverPool::internalize()
   repodata_internalize(i->second->data);
 }
 }
+
+
+void
+SolverPool::use_test_packages(bool use_test_packages)
+{
+  // Only enable repos containing test packages if wanted
+  for (RepoList::iterator i = repos.begin();
+   i != repos.end();
+   i++)
+{
+  if (i->second->test)
+{
+  i->second->repo->disabled = !use_test_packages;
+}
+}
+}
+
+// ---
+// implements class SolverSolution
+//
+// A wrapper around the libsolv solver
+// ---
+
+SolverSolution::~SolverSolution()
+{
+  if (solv)
+{
+  solver_free(solv);
+  solv = NULL;
+}
+}
+
+static
+std::ostream <<(std::ostream ,
+ SolverTransaction::transType type)
+{
+  switch (type)
+{
+case SolverTransaction::transInstall:
+  stream << "install";
+  break;
+case SolverTransaction::transErase:
+  stream << "erase";
+  break;
+default:
+  stream << "unknown";
+}
+  return stream;
+}
+
+bool
+SolverSolution::update(SolverTasks , bool update, bool 
use_test_packages, bool include_source)
+{
+  Log (LOG_PLAIN) << "solving: " << tasks.tasks.size() << " tasks," <<
+" update: " << (update ? "yes" : "no") << "," <<
+" use test packages: " << (use_test_packages ? "yes" : "no") << "," <<
+" include_source: " << (include_source ? "yes" : "no") << endLog;
+
+  pool.use_test_packages(use_test_packages);
+
+  Queue job;
+  queue_init();
+  // solver accepts a queue containing pairs of (cmd, id) tasks
+  // cmd is job and selection flags ORed together
+  for (SolverTasks::taskList::const_iterator i = tasks.tasks.begin();
+   i != tasks.tasks.end();
+   i++)
+{
+  const SolvableVersion  = (*i).first;
+
+  switch ((*i).second)
+{
+case SolverTasks::taskInstall:
+  queue_push2(, SOLVER_INSTALL | SOLVER_SOLVABLE, sv.id);
+  break;
+case SolverTasks::taskUninstall:
+  queue_push2(, SOLVER_ERASE | SOLVER_SOLVABLE, sv.id);
+  break;
+case SolverTasks::taskReinstall:
+  // we don't know how to ask solver for this, so we just add the erase
+  // and install later
+  break;
+default:
+  Log (LOG_PLAIN) << "unknown task " << (*i).second << endLog;
+}
+}
+
+  if (update)
+queue_push2(, SOLVER_UPDATE | SOLVER_SOLVABLE_ALL, 0);
+
+  if (!solv)
+solv = solver_create(pool.pool);
+
+  solver_set_flag(solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, 1);
+  solver_set_flag(solv, SOLVER_FLAG_ALLOW_DOWNGRADE, 0);
+  solver_solve(solv, );
+  queue_free();
+
+  int pcnt 

[PATCH setup 11/14] Drop in SolvableVersion as a replacement for packageversion

2017-05-31 Thread Jon Turney
---
 Makefile.am|  1 +
 PackageSpecification.h |  4 +++-
 package_db.cc  |  1 +
 package_meta.h |  3 ++-
 package_version.h  | 21 +
 5 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 package_version.h

diff --git a/Makefile.am b/Makefile.am
index 7ea9d89..7fe4b2f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,6 +208,7 @@ inilint_SOURCES = \
package_meta.h \
package_source.cc \
package_source.h \
+   package_version.h \
PackageSpecification.cc \
PackageSpecification.h \
PackageTrust.h \
diff --git a/PackageSpecification.h b/PackageSpecification.h
index ef992fa..0706ec8 100644
--- a/PackageSpecification.h
+++ b/PackageSpecification.h
@@ -18,7 +18,9 @@
 
 #include 
 #include "String++.h"
-class packageversion;
+
+class SolvableVersion;
+typedef SolvableVersion packageversion;
 
 /* Describe a package - i.e. we need version 5 of apt */
 
diff --git a/package_db.cc b/package_db.cc
index ae71900..123e4f3 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -31,6 +31,7 @@
 #include "compress.h"
 
 #include "filemanip.h"
+#include "package_version.h"
 #include "package_db.h"
 #include "package_meta.h"
 #include "Exception.h"
diff --git a/package_meta.h b/package_meta.h
index 421646a..b6faab8 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -16,7 +16,8 @@
 #ifndef SETUP_PACKAGE_META_H
 #define SETUP_PACKAGE_META_H
 
-class packageversion;
+class SolvableVersion;
+typedef SolvableVersion packageversion;
 class packagemeta;
 
 #include 
diff --git a/package_version.h b/package_version.h
new file mode 100644
index 000..43cf146
--- /dev/null
+++ b/package_version.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_VERSION_H
+#define PACKAGE_VERSION_H
+
+#include "libsolv.h"
+
+typedef SolvableVersion packageversion;
+
+#endif // PACKAGE_VERSION_H
-- 
2.12.3



[PATCH setup 13/14] Download/checksum/install/uninstall what transaction wants

2017-05-31 Thread Jon Turney
Some of this goes rather around the houses to avoid lots of churm: In lots
of cases, we're looking up packagemeta for a given packageversion just so we
can use the pacakgemeta to access the name, which we could do via
packageversion just as easily.

We do actually need packagmeta for a couple of things: To note the package
as installed/uninstalled, and to note postinstalls scripts.

If IncludeSource is on source packages installs will have been added to the
task list in post-processing, so we don't need to handle that specially
anymore.

Source packages to be installed are kept in a separate queue as they are
installed differently to binary packages (root is /usr/src, install isn't
recorded, etc.)
---
 download.cc |  71 ++
 install.cc  | 102 
 2 files changed, 64 insertions(+), 109 deletions(-)

diff --git a/download.cc b/download.cc
index fda175f..4b2fb6f 100644
--- a/download.cc
+++ b/download.cc
@@ -44,14 +44,10 @@
 
 #include "Exception.h"
 
-#include "getopt++/BoolOption.h"
-
 using namespace std;
 
 extern ThreeBarProgressPage Progress;
 
-BoolOption IncludeSource (false, 'I', "include-source", "Automatically include 
source download");
-
 static bool
 validateCachedPackage (const std::string& fullname, packagesource & pkgsource)
 {
@@ -202,59 +198,38 @@ do_download_thread (HINSTANCE h, HWND owner)
   Progress.SetText3 ("");
 
   packagedb db;
-  /* calculate the amount needed */
-  for (packagedb::packagecollection::iterator i = db.packages.begin ();
-   i != db.packages.end (); ++i)
+  const SolverTransactionList  = db.solution.transactions();
+
+  /* calculate the total size of the download */
+  for (SolverTransactionList::const_iterator i = t.begin (); i != t.end (); 
++i)
 {
-  packagemeta & pkg = *(i->second);
-  if (pkg.picked () || pkg.srcpicked ())
-   {
- packageversion version = pkg.desired;
- packageversion sourceversion = version.sourcePackage();
- try 
-   {
- if (pkg.picked())
-   {
-   if (!check_for_cached (*version.source()))
- total_download_bytes += version.source()->size;
-   }
- if (pkg.srcpicked () || IncludeSource)
-   {
-   if (!check_for_cached (*sourceversion.source()))
- total_download_bytes += sourceversion.source()->size;
-   }
-   }
- catch (Exception * e)
-   {
- // We know what to do with these..
- if (e->errNo() == APPERR_CORRUPT_PACKAGE)
-   fatal (owner, IDS_CORRUPT_PACKAGE, pkg.name.c_str());
- // Unexpected exception.
- throw e;
-   }
-   }
+  packageversion version = i->version;
+
+  try
+{
+  if (!check_for_cached (*version.source()))
+total_download_bytes += version.source()->size;
+}
+  catch (Exception * e)
+{
+  // We know what to do with these..
+  if (e->errNo() == APPERR_CORRUPT_PACKAGE)
+fatal (owner, IDS_CORRUPT_PACKAGE, version.Name().c_str());
+  // Unexpected exception.
+  throw e;
+}
 }
 
   /* and do the download. FIXME: This here we assign a new name for the cached 
version
* and check that above.
*/
-  for (packagedb::packagecollection::iterator i = db.packages.begin ();
-   i != db.packages.end (); ++i)
+  for (SolverTransactionList::const_iterator i = t.begin (); i != t.end (); 
++i)
 {
-  packagemeta & pkg = *(i->second);
-  if (pkg.picked () || pkg.srcpicked ())
+  packageversion version = i->version;
+
{
  int e = 0;
- packageversion version = pkg.desired;
- packageversion sourceversion = version.sourcePackage();
- if (pkg.picked())
-   {
-   e += download_one (*version.source(), owner);
-   }
- if (sourceversion && (pkg.srcpicked() || IncludeSource))
-   {
-   e += download_one (*sourceversion.source (), owner);
-   }
+ e += download_one (*version.source(), owner);
  errors += e;
 #if 0
  if (e)
diff --git a/install.cc b/install.cc
index 9c4c01b..94c2b16 100644
--- a/install.cc
+++ b/install.cc
@@ -69,7 +69,6 @@ static long long int total_bytes = 0;
 static long long int total_bytes_sofar = 0;
 static int package_bytes = 0;
 
-extern BoolOption IncludeSource;
 static BoolOption NoReplaceOnReboot (false, 'r', "no-replaceonreboot",
 "Disable replacing in-use files on next "
 "reboot.");
@@ -799,84 +798,61 @@ do_install_thread (HINSTANCE h, HWND owner)
   /* Writes Cygwin/setup/rootdir registry value */
   create_install_root ();
 
-  vector  install_q, uninstall_q, sourceinstall_q;
+  vector  install_q, uninstall_q, 

[PATCH setup 14/14] Add obsoletes: support

2017-05-31 Thread Jon Turney
Note that we need separate depends and obsoletes nodelists
---
 IniDBBuilderPackage.cc | 23 ++-
 IniDBBuilderPackage.h  |  5 -
 inilex.ll  |  1 +
 iniparse.yy|  3 +++
 libsolv.cc |  2 ++
 libsolv.h  |  1 +
 package_db.cc  |  1 +
 7 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index b929c7e..4e92961 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -88,7 +88,9 @@ IniDBBuilderPackage::buildPackage (const std::string& _name)
   cbpv.archive = packagesource();
 
   currentSpec = NULL;
-  currentNodeList = PackageDepends();
+  currentNodeList = NULL;
+  dependsNodeList = PackageDepends();
+  obsoletesNodeList = PackageDepends();
 #if DEBUG
   Log (LOG_BABBLE) << "Created package " << name << endLog;
 #endif
@@ -208,8 +210,9 @@ IniDBBuilderPackage::buildBeginDepends ()
   Log (LOG_BABBLE) << "Beginning of a depends statement " << endLog;
 #endif
   currentSpec = NULL;
-  currentNodeList = PackageDepends();
-  cbpv.requires = 
+  dependsNodeList= PackageDepends();
+  currentNodeList = 
+  cbpv.requires = 
 }
 
 void
@@ -219,11 +222,20 @@ IniDBBuilderPackage::buildBeginBuildDepends ()
   Log (LOG_BABBLE) << "Beginning of a Build-Depends statement" << endLog;
 #endif
   currentSpec = NULL;
-  currentNodeList = PackageDepends();
+  currentNodeList = NULL;
   /* there is currently nowhere to store Build-Depends information */
 }
 
 void
+IniDBBuilderPackage::buildBeginObsoletes ()
+{
+  currentSpec = NULL;
+  obsoletesNodeList =   PackageDepends();
+  currentNodeList = 
+  cbpv.obsoletes = 
+}
+
+void
 IniDBBuilderPackage::buildSourceName (const std::string& _name)
 {
   // When there is a Source: line, that names a real source package
@@ -247,7 +259,8 @@ IniDBBuilderPackage::buildPackageListNode (const 
std::string & name)
   Log (LOG_BABBLE) << "New node '" << name << "' for package list" << endLog;
 #endif
   currentSpec = new PackageSpecification (name);
-  currentNodeList.push_back (currentSpec);
+  if (currentNodeList)
+currentNodeList->push_back (currentSpec);
 }
 
 void
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 307d2b5..4e34680 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -57,6 +57,7 @@ public:
 
   void buildBeginDepends ();
   void buildBeginBuildDepends ();
+  void buildBeginObsoletes ();
   void buildMessage (const std::string&, const std::string&);
   void buildSourceName (const std::string& );
   void buildSourceNameVersion (const std::string& );
@@ -83,7 +84,9 @@ private:
   std::string message_id;
   std::string message_string;
   PackageSpecification *currentSpec;
-  PackageDepends currentNodeList;
+  PackageDepends *currentNodeList;
+  PackageDepends dependsNodeList;
+  PackageDepends obsoletesNodeList;
   SolverPool::addPackageData cbpv;
 
   IniParseFeedback const &_feedback;
diff --git a/inilex.ll b/inilex.ll
index 13422b1..698775c 100644
--- a/inilex.ll
+++ b/inilex.ll
@@ -122,6 +122,7 @@ B64 [a-zA-Z0-9_-]
 "category:"|"Section:" return CATEGORY;
 "requires:"return REQUIRES;
 [dD]"epends:"  return DEPENDS;
+[oO]"bsoletes:"return OBSOLETES;
 
 ^{STR}":"  ignore_line ();
 
diff --git a/iniparse.yy b/iniparse.yy
index 18ebe2a..3b74e36 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -45,6 +45,7 @@ extern int yylineno;
 %token COMMA NL AT
 %token OPENBRACE CLOSEBRACE EQUAL GT LT GTEQUAL LTEQUAL 
 %token BUILDDEPENDS
+%token OBSOLETES
 %token MESSAGE
 %token ARCH RELEASE
 
@@ -103,6 +104,8 @@ singleitem /* non-empty */
  | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
  | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
  | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist 
NL
+ | OBSOLETES { iniBuilder->buildBeginObsoletes(); } versionedpackagelist NL
+
  | MESSAGE STRING STRING NL{ iniBuilder->buildMessage ($2, $3); }
  | error NL{ yyerror (std::string("unrecognized line ")
  + stringify(yylineno)
diff --git a/libsolv.cc b/libsolv.cc
index df0af3d..f509617 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -350,6 +350,8 @@ SolverPool::addPackage(const std::string& pkgname, const 
addPackageData 
   solvable->provides = repo_addid_dep(repo, solvable->provides, 
pool_rel2id(pool, solvable->name, solvable->evr, REL_EQ, 1), 0);
   if (pkgdata.requires)
 solvable->requires = makedeps(repo, pkgdata.requires);
+  if (pkgdata.obsoletes)
+solvable->obsoletes = makedeps(repo, pkgdata.obsoletes);
 
   /* a solvable can also store arbitrary attributes not needed for dependency
  resolution, if we need them */
diff --git a/libsolv.h b/libsolv.h
index 43b37d2..be518e9 100644
--- a/libsolv.h
+++ b/libsolv.h
@@ -130,6 +130,7 @@ public:
 PackageSpecification spkg;
 SolvableVersion spkg_id;
 PackageDepends *requires;
+

[PATCH setup 08/14] Change to using a libsolv pool for storing package information

2017-05-31 Thread Jon Turney
Add class SolverVersion, a wrapper around a Solvable Id. The interface is
similar to class packageversion, the name change is just to make sure I've
got everything.

Place test packages into separate repos.

Expressing that curr: packages are preferred to prev: ones when that is not
the version number ordering should be done with epoch numbers.

Wire up various bits of data in packageversion to Solvable attributes,
including sourcepackage, stability, archive (packagesource) and depends.

Store sourcePackage() by the id rather than name, for much faster lookup.

SolverVersions for the same package can be ordered and compared by evr.

Factor out packagedb:addBinary() and also use it in IniDBBuilder, rather
that inlining the process of adding a package there. Add an analagous
packagedb:addSource() to do the same thing for source packages.

Change to reading installed.db after setup.ini's have been read, so we can
supplement the installed.db packages with information from setup.ini.

Make packagemeta::add_version() check for successful insertion of version.
Record the version at a stability level. The last version wins in setting
curr/test.

Use a Solver object inside packagedb

XXX: All SolvableVersion methods need to check for null solvable?
---
 IniDBBuilderPackage.cc  | 304 ++---
 IniDBBuilderPackage.h   |  28 +--
 Makefile.am |   4 +-
 PackageSpecification.cc |  12 ++
 PackageSpecification.h  |   3 +
 configure.ac|   1 +
 ini.cc  |   5 +-
 libsolv.cc  | 443 
 libsolv.h   | 146 
 package_db.cc   |  90 --
 package_db.h|   6 +
 package_meta.cc | 101 ---
 package_meta.h  |   6 +-
 13 files changed, 887 insertions(+), 262 deletions(-)
 create mode 100644 libsolv.cc
 create mode 100644 libsolv.h

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index fb200a8..b929c7e 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -22,8 +22,6 @@
 #include "IniParseFeedback.h"
 #include "package_db.h"
 #include "package_meta.h"
-#include "package_version.h"
-#include "cygpackage.h"
 #include "ini.h"
 // for strtoul
 #include 
@@ -34,7 +32,7 @@
 using namespace std;
 
 IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const ) :
-cp (0), cbpv (), cspv (), currentSpec (0), _feedback (aFeedback){}
+currentSpec (0), _feedback (aFeedback){}
 
 IniDBBuilderPackage::~IniDBBuilderPackage()
 {
@@ -67,31 +65,28 @@ IniDBBuilderPackage::buildVersion (const std::string& 
aVersion)
 }
 
 void
-IniDBBuilderPackage::buildPackage (const std::string& name)
+IniDBBuilderPackage::buildPackage (const std::string& _name)
 {
-#if DEBUG
-  if (cp)
-{
-  Log (LOG_BABBLE) << "Finished with package " << cp->name << endLog;
-  if (cbpv)
-   {
- Log (LOG_BABBLE) << "Version " << cbpv.Canonical_version() << endLog;
- Log (LOG_BABBLE) << "Depends:";
- dumpPackageDepends (cbpv.depends(), Log (LOG_BABBLE));
- Log (LOG_BABBLE) << endLog;
-   }
-}
-#endif
-  packagedb db;
-  cp = db.findBinary (PackageSpecification(name));
-  if (!cp)
-{
-  cp = new packagemeta (name);
-  db.packages.insert 
(packagedb::packagecollection::value_type(cp->name,cp));
-}
-  cbpv = cygpackage::createInstance (name, package_binary);
-  cbpv.SetStability(TRUST_CURR);
-  cspv = packageversion ();
+  process();
+
+  /* Reset for next package */
+  name = _name;
+  message_id = "";
+  message_string = "";
+  categories.clear();
+
+  cbpv.reponame = release;
+  cbpv.version = "";
+  cbpv.vendor = release;
+  cbpv.sdesc = "";
+  cbpv.ldesc = "";
+  cbpv.stability = TRUST_CURR;
+  cbpv.type = package_binary;
+  cbpv.spkg = PackageSpecification();
+  cbpv.spkg_id = packageversion();
+  cbpv.requires = NULL;
+  cbpv.archive = packagesource();
+
   currentSpec = NULL;
   currentNodeList = PackageDepends();
 #if DEBUG
@@ -102,20 +97,19 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
 void
 IniDBBuilderPackage::buildPackageVersion (const std::string& version)
 {
-  cbpv.setCanonicalVersion (version);
-  add_correct_version();
+  cbpv.version = version;
 }
 
 void
 IniDBBuilderPackage::buildPackageSDesc (const std::string& theDesc)
 {
-  cbpv.set_sdesc(theDesc);
+  cbpv.sdesc = theDesc;
 }
 
 void
 IniDBBuilderPackage::buildPackageLDesc (const std::string& theDesc)
 {
-  cbpv.set_ldesc(theDesc);
+  cbpv.ldesc = theDesc;
 }
 
 void
@@ -124,21 +118,23 @@ IniDBBuilderPackage::buildPackageInstall (const 
std::string& path,
   char *hash,
   hashType type)
 {
-  process_src (*cbpv.source(), path);
-  setSourceSize (*cbpv.source(), size);
+  // set archive path, size, mirror, hash
+  cbpv.archive.set_canonical(path.c_str());
+  cbpv.archive.size = atoi(size.c_str());
+  

[PATCH setup 10/14] Remove packageversion class

2017-05-31 Thread Jon Turney
Remove packageversion, _packageversion, defaultversion classes
---
 Makefile.am|   2 -
 PickPackageLine.cc |   1 -
 PickView.cc|   1 -
 choose.cc  |   1 -
 desktop.cc |   1 -
 download.cc|   1 -
 package_db.cc  |   2 -
 package_meta.cc|   3 -
 package_version.cc | 334 -
 package_version.h  | 168 ---
 10 files changed, 514 deletions(-)
 delete mode 100644 package_version.cc
 delete mode 100644 package_version.h

diff --git a/Makefile.am b/Makefile.am
index 27bb8f1..7ea9d89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,8 +208,6 @@ inilint_SOURCES = \
package_meta.h \
package_source.cc \
package_source.h \
-   package_version.cc \
-   package_version.h \
PackageSpecification.cc \
PackageSpecification.h \
PackageTrust.h \
diff --git a/PickPackageLine.cc b/PickPackageLine.cc
index 95c1557..6f44192 100644
--- a/PickPackageLine.cc
+++ b/PickPackageLine.cc
@@ -16,7 +16,6 @@
 #include "PickPackageLine.h"
 #include "PickView.h"
 #include "package_db.h"
-#include "package_version.h"
 
 void
 PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, int col_num, int 
show_cat)
diff --git a/PickView.cc b/PickView.cc
index 4c728f8..5bc7504 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -21,7 +21,6 @@
 #include "PickPackageLine.h"
 #include "PickCategoryLine.h"
 #include "package_db.h"
-#include "package_version.h"
 #include "dialog.h"
 #include "resource.h"
 /* For 'source' */
diff --git a/choose.cc b/choose.cc
index 1bc4c0b..abfc14a 100644
--- a/choose.cc
+++ b/choose.cc
@@ -48,7 +48,6 @@
 
 #include "package_db.h"
 #include "package_meta.h"
-#include "package_version.h"
 
 #include "threebar.h"
 #include "Generic.h"
diff --git a/desktop.cc b/desktop.cc
index 24908f8..927c02f 100644
--- a/desktop.cc
+++ b/desktop.cc
@@ -35,7 +35,6 @@
 #include "mklink2.h"
 #include "package_db.h"
 #include "package_meta.h"
-#include "package_version.h"
 #include "filemanip.h"
 #include "io_stream.h"
 #include "getopt++/BoolOption.h"
diff --git a/download.cc b/download.cc
index a2237a7..fda175f 100644
--- a/download.cc
+++ b/download.cc
@@ -38,7 +38,6 @@
 
 #include "package_db.h"
 #include "package_meta.h"
-#include "package_version.h"
 #include "package_source.h"
 
 #include "threebar.h"
diff --git a/package_db.cc b/package_db.cc
index 2d6d22c..ae71900 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -31,8 +31,6 @@
 #include "compress.h"
 
 #include "filemanip.h"
-
-#include "package_version.h"
 #include "package_db.h"
 #include "package_meta.h"
 #include "Exception.h"
diff --git a/package_meta.cc b/package_meta.cc
index 3d1d666..ab358b9 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -35,10 +35,7 @@ using namespace std;
 /* this goes at the same time */
 #include "win32.h"
 
-
 #include "script.h"
-
-#include "package_version.h"
 #include "package_db.h"
 
 #include 
diff --git a/package_version.cc b/package_version.cc
deleted file mode 100644
index 2d4416e..000
--- a/package_version.cc
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 2001, 2003 Robert Collins.
- *
- * 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/
- *
- * Written by Robert Collins  
- *
- */
-
-/* this is the parent class for all package operations. 
- */
-
-#include "package_version.h"
-#include "package_db.h"
-#include "package_meta.h"
-#include "LogSingleton.h"
-#include "state.h"
-#include "resource.h"
-#include 
-#include "csu_util/version_compare.h"
-
-using namespace std;
-
-/* a default class to avoid special casing empty packageversions */
-  
-/* TODO place into the class header */
-class _defaultversion : public _packageversion
-{
-public:
-  _defaultversion()
-{
-  // never try to free me!
-  ++references;
-}
-  const std::string Name(){return std::string();}
-  const std::string Vendor_version() {return std::string();}
-  const std::string Package_version() {return std::string();}
-  const std::string Canonical_version() {return std::string();}
-  void setCanonicalVersion (const std::string& ) {}
-  package_stability_t Stability (){return TRUST_UNKNOWN;}
-  void SetStability (package_stability_t) {}
-  package_type_t Type () {return package_binary;}
-  const std::string SDesc () {return std::string();}
-  void set_sdesc (const std::string& ) {}
-  const std::string LDesc () {return std::string();}
-  void set_ldesc (const std::string& ) {}
-};
-static _defaultversion defaultversion;
-
-/* the wrapper class */
-packageversion::packageversion() : data ()
-{
-  ++data->references;
-}
-
-/* Create from an 

[PATCH setup 09/14] Remove cygpackage class

2017-05-31 Thread Jon Turney
---
 Makefile.am |   2 -
 bootstrap.sh|   2 +-
 cygpackage.cc   | 136 
 cygpackage.h|  82 --
 package_db.cc   |   1 -
 package_meta.cc |   1 -
 6 files changed, 1 insertion(+), 223 deletions(-)
 delete mode 100644 cygpackage.cc
 delete mode 100644 cygpackage.h

diff --git a/Makefile.am b/Makefile.am
index a8bfe4b..27bb8f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,8 +128,6 @@ inilint_SOURCES = \
crypto.cc \
crypto.h \
cyg-pubkey.h \
-   cygpackage.cc \
-   cygpackage.h \
desktop.cc \
desktop.h \
dialog.cc \
diff --git a/bootstrap.sh b/bootstrap.sh
index f21206d..a676268 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -21,7 +21,7 @@ bootstrap() {
 cd "$srcdir"
 
 # Make sure we are running in the right directory
-if [ ! -f cygpackage.cc ]; then
+if [ ! -f bmain.cc ]; then
   echo "You must run this script from the directory containing it"
   exit 1
 fi
diff --git a/cygpackage.cc b/cygpackage.cc
deleted file mode 100644
index 2724249..000
--- a/cygpackage.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2001, Robert Collins.
- *
- * 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/
- *
- * Written by Robert Collins  
- *
- */
-
-/* this is the parent class for all package operations. 
- */
-
-#include "cygpackage.h"
-#include 
-#include 
-#include 
-
-#include "io_stream.h"
-#include "compress.h"
-
-#include "package_version.h"
-#include "cygpackage.h"
-#include "LogSingleton.h"
-
-/* this constructor creates an invalid package - further details MUST be 
provided */
-cygpackage::cygpackage ():
-name (),
-vendor (),
-packagev (),
-canonical (),
-sdesc (),
-ldesc (),
-type (package_binary)
-{
-  /* FIXME: query the install database for the currently installed 
-   * version details
-   */
-}
-
-packageversion
-cygpackage::createInstance (const std::string& pkgname,
-const package_type_t type)
-{
-  cygpackage *temp = new cygpackage;
-  temp->name = pkgname;
-  temp->type = type;
-  return packageversion(temp);
-}
-
-packageversion
-cygpackage::createInstance (const std::string& pkgname,
-const std::string& version,
-   package_type_t const newtype)
-{
-  cygpackage *temp = new cygpackage;
-  temp->name = pkgname;
-  temp->type = newtype;
-  temp->setCanonicalVersion (version);
-  return packageversion(temp);
-}
-
-/* tell the version */
-void
-cygpackage::setCanonicalVersion (const std::string& version)
-{
-  canonical = version;
-
-  const char *start = canonical.c_str();
-  const char *curr = strchr(start, '-');
-
-  if (curr)
-{
-  const char *next;
-  while ((next = strchr (curr + 1, '-')))
-   curr = next;
-
-  /* package version appears after the last '-' in the version string */
-  packagev = curr + 1;
-  /* vendor version is everything up to that last '-' */
-  vendor.assign(canonical.c_str(), (size_t)(curr - start));
-}
-  else
-{
-  // FIXME: What's up with the "0"? It's probably a mistake, and should be
-  // "". It used to be written as 0, and was subject to a bizarre implicit
-  // conversion by the unwise String(int) constructor.
-  packagev = "0";
-  vendor = version;
-}
-}
-
-cygpackage::~cygpackage ()
-{
-}
-
-const std::string
-cygpackage::Name ()
-{
-  return name;
-}
-
-const std::string
-cygpackage::Vendor_version ()
-{
-  return vendor;
-}
-
-const std::string
-cygpackage::Package_version ()
-{
-  return packagev;
-}
-
-std::string  const
-cygpackage::Canonical_version ()
-{
-  return canonical;
-}
-
-void
-cygpackage::set_sdesc (const std::string& desc)
-{
-  sdesc = desc;
-}
-
-void
-cygpackage::set_ldesc (const std::string& desc)
-{
-  ldesc = desc;
-}
diff --git a/cygpackage.h b/cygpackage.h
deleted file mode 100644
index 720921d..000
--- a/cygpackage.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2001, Robert Collins.
- *
- * 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/
- *
- * Written by Robert Collins  
- *
- */
-
-#ifndef SETUP_CYGPACKAGE_H
-#define SETUP_CYGPACKAGE_H
-
-/* This is a cygwin specific package class, that should be able to 
- * arbitrate acceess to cygwin binary packages 

[PATCH setup 06/14] Hoist scan() up from packageversion to packagemeta

2017-05-31 Thread Jon Turney
---
 package_meta.cc| 37 +++--
 package_meta.h |  2 ++
 package_version.cc | 29 -
 package_version.h  |  2 --
 4 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/package_meta.cc b/package_meta.cc
index f4678f0..425df59 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -44,6 +44,9 @@ using namespace std;
 
 #include 
 #include "Generic.h"
+#include "download.h"
+#include "Exception.h"
+#include "resource.h"
 
 using namespace std;
 
@@ -582,6 +585,36 @@ packagemeta::logSelectionStatus() const
   pkg.logAllVersions();
 }
 
+/* scan for local copies of package */
+void
+packagemeta::scan (const packageversion , bool mirror_mode)
+{
+  /* Already have something */
+  if (!pkg)
+return;
+
+  /* Remove mirror sites.
+   * FIXME: This is a bit of a hack.
+   */
+  try
+{
+  if (!check_for_cached (*(pkg.source ()), mirror_mode)
+ && ::source == IDC_SOURCE_LOCALDIR)
+   pkg.source ()->sites.clear ();
+}
+  catch (Exception * e)
+{
+  // We can ignore these, since we're clearing the source list anyway
+  if (e->errNo () == APPERR_CORRUPT_PACKAGE)
+   {
+ pkg.source ()->sites.clear ();
+ return;
+   }
+  // Unexpected exception.
+  throw e;
+}
+}
+
 void
 packagemeta::ScanDownloadedFiles (bool mirror_mode)
 {
@@ -601,10 +634,10 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
   && (*i != pkg.installed
   || pkg.installed == pkg.curr
   || pkg.installed == pkg.exp);
- const_cast(*i).scan (lazy_scan);
+ scan (*i, lazy_scan);
  packageversion foo = *i;
  packageversion pkgsrcver = foo.sourcePackage ();
- pkgsrcver.scan (lazy_scan);
+ scan (pkgsrcver, lazy_scan);
 
  /* For local installs, if there is no src and no bin, the version
   * is unavailable
diff --git a/package_meta.h b/package_meta.h
index 529b2a2..8041aa1 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -159,6 +159,8 @@ protected:
 private:
   std::string trustLabel(packageversion const &) const;
   std::vector 

[PATCH setup 04/14] Hoist pick() up to packagemeta

2017-05-31 Thread Jon Turney
We are always writing packagemeta.desired.pick(bool, packagemeta).  This
kind of suggests something not quite right.

The pick flag means install/reinstall, so despite being stored per
packageversion, is only significant to download/install for the desired
version.

There's a slight wrinkle in that we want to also set/clear this flag for the
source packageversion.  We can't change this to point to packagemeta rather
than packageversion, as that may not be the same for all versions, so
instead just track this flag separately as srcpicked.

Note that there is still a complicated mapping between the state of desired
and pick and the action represented in the UI:

desired == empty, installed == desired : skip
desired == empty, installed != desired : uninstall
desired == installed, pick == true : reinstall
desired == installed, pick == false: keep
desired != installed, pick == true : upgrade
desired != installed, pick == false: invalid
---
 PickPackageLine.cc | 13 +--
 PickView.cc|  8 +++
 download.cc| 12 +-
 install.cc | 19 
 package_db.cc  |  2 +-
 package_meta.cc| 67 ++
 package_meta.h | 11 -
 package_version.cc | 16 -
 package_version.h  |  7 --
 prereq.cc  | 11 +
 10 files changed, 90 insertions(+), 76 deletions(-)

diff --git a/PickPackageLine.cc b/PickPackageLine.cc
index 60ece7f..95c1557 100644
--- a/PickPackageLine.cc
+++ b/PickPackageLine.cc
@@ -44,7 +44,7 @@ PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, 
int col_num, int sho
   /* current version */ pkg.desired == pkg.installed ||
   /* no source */ !pkg.desired.accessible())
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkna);
-  else if (pkg.desired.picked())
+  else if (pkg.picked())
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkyes);
   else
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkno);
@@ -67,7 +67,7 @@ PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, 
int col_num, int sho
   /* when no source mirror available */
   !pkg.desired.sourcePackage().accessible())
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkna);
-  else if (pkg.desired.sourcePackage().picked())
+  else if (pkg.srcpicked())
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkyes);
   else
 theView.DrawIcon (hdc, x + HMARGIN/2, by, theView.bm_checkno);
@@ -100,7 +100,7 @@ PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, 
int col_num, int sho
   /* Include the size of the binary package, and if selected, the source
  package as well.  */
   sz += picked.source()->size;
-  if (picked.sourcePackage().picked())
+  if (pkg.srcpicked())
 sz += picked.sourcePackage().source()->size;
 
   /* If size still 0, size must be unknown.  */
@@ -133,20 +133,19 @@ PickPackageLine::click (int const myrow, int const 
ClickedRow, int const x)
   && x <= theView.headers[theView.bintick_col + 1].x - HMARGIN / 2)
 {
   if (pkg.desired.accessible ())
-   pkg.desired.pick (!pkg.desired.picked (), );
+   pkg.pick (!pkg.picked ());
 }
   else if (x >= theView.headers[theView.srctick_col].x - HMARGIN / 2
   && x <= theView.headers[theView.srctick_col + 1].x - HMARGIN / 2)
 {
   if (pkg.desired.sourcePackage ().accessible ())
-   pkg.desired.sourcePackage ().pick (
-   !pkg.desired.sourcePackage ().picked (), NULL);
+   pkg.srcpick (!pkg.srcpicked ());
 }
   /* Unchecking binary while source is unchecked or vice versa is equivalent
  to uninstalling.  It's essential to set desired correctly, otherwise the
  package gets uninstalled without visual feedback to the user.  The package
  will not even show up in the "Pending" view! */
-  if (!pkg.desired.picked () && !pkg.desired.sourcePackage ().picked ())
+  if (!pkg.picked () && !pkg.srcpicked ())
 pkg.desired = packageversion ();
   return 0;
 }
diff --git a/PickView.cc b/PickView.cc
index 222bcb8..4c728f8 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -175,13 +175,13 @@ PickView::setViewMode (views mode)
   || (view_mode == PickView::views::PackagePending &&
   ((!pkg.desired && pkg.installed) || // uninstall
 (pkg.desired &&
-  (pkg.desired.picked () ||   // install bin
-   pkg.desired.sourcePackage ().picked () // src
+  (pkg.picked () ||   // install bin
+   pkg.srcpicked () // src
   
   // "Up to date" : installed packages that will not be changed
   || (view_mode == PickView::views::PackageKeeps &&
-  (pkg.installed && pkg.desired && 

[PATCH setup 01/14] Opaque how PackageDepends is stored

2017-05-31 Thread Jon Turney
We want to be more opaque about how the PackageDepends for a packageversion
is stored, so rather than exposing a pointer to a PackageDepends object
inside class packageversion, access it by value.

This also makes us be more explicit about set/get of package depends()

Fix some iterations to deal with depends() returning a value rather than a
pointer.

Also adjust dumpPackageDepends() appropriately
Also remove useless debug showing the dependency list before we build it.
---
 IniDBBuilderPackage.cc | 30 --
 IniDBBuilderPackage.h  |  2 +-
 package_db.cc  | 10 ++
 package_depends.cc | 19 ---
 package_depends.h  |  2 +-
 package_meta.cc| 11 ---
 package_version.cc | 10 +-
 package_version.h  |  5 ++---
 prereq.cc  |  4 ++--
 9 files changed, 41 insertions(+), 52 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index ad1cc88..0e1be78 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -34,7 +34,7 @@
 using namespace std;
 
 IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const ) :
-cp (0), cbpv (), cspv (), currentSpec (0), currentNodeList (0), trust (0), 
_feedback (aFeedback){}
+cp (0), cbpv (), cspv (), currentSpec (0), trust (0), _feedback (aFeedback){}
 
 IniDBBuilderPackage::~IniDBBuilderPackage()
 {
@@ -92,7 +92,7 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
   cbpv = cygpackage::createInstance (name, package_binary);
   cspv = packageversion ();
   currentSpec = NULL;
-  currentNodeList = NULL;
+  currentNodeList = PackageDepends();
   trust = TRUST_CURR;
 #if DEBUG
   Log (LOG_BABBLE) << "Created package " << name << endLog;
@@ -231,12 +231,10 @@ void
 IniDBBuilderPackage::buildBeginDepends ()
 {
 #if DEBUG
-  Log (LOG_BABBLE) << "Beginning of a depends statement for " << cp->name
-<< endLog;
-  dumpPackageDepends (currentNodeList, Log (LOG_BABBLE));
+  Log (LOG_BABBLE) << "Beginning of a depends statement " << endLog;
 #endif
   currentSpec = NULL;
-  currentNodeList = cbpv.depends();
+  currentNodeList = PackageDepends();
 }
 
 void
@@ -246,7 +244,7 @@ IniDBBuilderPackage::buildBeginBuildDepends ()
   Log (LOG_BABBLE) << "Beginning of a Build-Depends statement" << endLog;
 #endif
   currentSpec = NULL;
-  currentNodeList = NULL; /* there is currently nowhere to store Build-Depends 
information */
+  currentNodeList = PackageDepends(); /* there is currently nowhere to store 
Build-Depends information */
 }
 
 void
@@ -287,14 +285,11 @@ IniDBBuilderPackage::buildSourceNameVersion (const 
std::string& version)
 void
 IniDBBuilderPackage::buildPackageListNode (const std::string & name)
 {
-  if (currentNodeList)
-{
 #if DEBUG
-  Log (LOG_BABBLE) << "New node '" << name << "' for package list" << 
endLog;
+  Log (LOG_BABBLE) << "New node '" << name << "' for package list" << endLog;
 #endif
-  currentSpec = new PackageSpecification (name);
-  currentNodeList->push_back (currentSpec);
-}
+  currentSpec = new PackageSpecification (name);
+  currentNodeList.push_back (currentSpec);
 }
 
 void
@@ -337,8 +332,7 @@ IniDBBuilderPackage::buildPackageListOperatorVersion (const 
std::string& aVersio
 void
 IniDBBuilderPackage::add_correct_version()
 {
-  if (currentNodeList)
-*cbpv.depends() = *currentNodeList;
+  cbpv.setDepends(currentNodeList);
 
   int merged = 0;
   for (set::iterator n = cp->versions.begin();
@@ -362,11 +356,11 @@ IniDBBuilderPackage::add_correct_version()
   ver.set_sdesc (cbpv.SDesc ());
 if (cbpv.LDesc ().size() && !n->LDesc ().size())
   ver.set_ldesc (cbpv.LDesc ());
-   if (cbpv.depends()->size() && !ver.depends ()->size())
- *ver.depends() = *cbpv.depends();
+   if (cbpv.depends().size() && !ver.depends().size())
+ ver.setDepends(cbpv.depends());
/* TODO: other package lists */
/* Prevent dangling references */
-   currentNodeList = NULL;
+   currentNodeList = PackageDepends();
currentSpec = NULL;
 cbpv = *n;
 merged = 1;
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 766a5ef..dee65d4 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -79,7 +79,7 @@ private:
   packagemeta *csp;
   packageversion cspv;
   PackageSpecification *currentSpec;
-  PackageDepends *currentNodeList;
+  PackageDepends currentNodeList;
   int trust;
   IniParseFeedback const &_feedback;
 };
diff --git a/package_db.cc b/package_db.cc
index dbec17e..00395d3 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -312,8 +312,9 @@ ConnectedLoopFinder::visit(packagemeta *nodeToVisit)
   nodesInStronglyConnectedComponent.push(nodeToVisit);
 
   /* walk through each node */
-  PackageDepends::const_iterator dp = 
nodeToVisit->installed.depends()->begin();
-  while (dp != nodeToVisit->installed.depends()->end())
+  const PackageDepends deps = nodeToVisit->installed.depends();
+  

[PATCH setup 00/14] Use libsolv, solve all our problems... (WIP)

2017-05-31 Thread Jon Turney
... solve some problems, perhaps add some new ones, I guess.  I'm not 100% 
sure this is the right approach to take, but I wrote it, so here it is.

This replaces the current PackageVersion class with a similar one which stores 
the information in a libsolv pool, and the current depsolver with the libsolv 
solver (as used by zypper, dnf and others).

Immediately, this enables:
- use of a version relation in package dependencies
- an obsoletes: relation between packages

This also makes it much easier to support:
- version numbers with an epoch component (I think just how we handle ':' in 
filenames needs auditing to make this work)
- other commonly-implemented package relations such as conflicts:, provides: 
etc.

What remains to be done:
- I've dodged a lot of the UI issues: If the solver reports problems, all that 
can be done is accept the default solution or cancel.  This possibly isn't a 
big problem until we have a package set which can contain problems...
- We had a very poor UI for showing what will actually be done (combine in 
your head the "Pending" view with packages listed in the text on the 
PrereChecker page), and this removes part of that
- As implemented, selecting "Current" overrides "Keep".  This is wrong, and a 
change from current behaviour, but is probably a symptom of some deeper 
confusion in the picker UI I'm not sure how to address

libsolv needs to be lightly patched to build for Win32, see [1].  I will ITP 
that, but it probably also needs an RPM to support cross-building.

[1] https://github.com/jon-turney/libsolv

Jon Turney (14):
  Opaque how PackageDepends is stored
  Factor out reading installed.db
  Hoist addScript() etc. up from packageversion to packagemeta
  Hoist pick() up to packagemeta
  Hoist uninstall up to Installer::uninstallOne()
  Hoist scan() up from packageversion to packagemeta
  Store package stability in class packageversion
  Change to using a libsolv pool for storing package information
  Remove cygpackage class
  Remove packageversion class
  Drop in SolvableVersion as a replacement for packageversion
  Use solver to check for problems and produce a list of package
transactions
  Download/checksum/install/uninstall what transaction wants
  Add obsoletes: support

 IniDBBuilderPackage.cc  | 331 ---
 IniDBBuilderPackage.h   |  32 ++-
 Makefile.am |   7 +-
 PackageSpecification.cc |  12 +
 PackageSpecification.h  |   7 +-
 PickPackageLine.cc  |  14 +-
 PickView.cc |   9 +-
 bootstrap.sh|   2 +-
 choose.cc   |   8 +-
 configure.ac|   1 +
 cygpackage.cc   | 187 -
 cygpackage.h|  88 ---
 desktop.cc  |   1 -
 download.cc |  72 ++---
 ini.cc  |   1 +
 inilex.ll   |   1 +
 iniparse.yy |   3 +
 install.cc  | 176 -
 libsolv.cc  | 689 
 libsolv.h   | 231 
 package_db.cc   | 115 ++--
 package_db.h|   8 +
 package_depends.cc  |  19 +-
 package_depends.h   |   2 +-
 package_meta.cc | 294 -
 package_meta.h  |  30 ++-
 package_version.cc  | 414 -
 package_version.h   | 190 +
 postinstall.cc  |   6 +-
 prereq.cc   | 206 ---
 prereq.h|  22 +-
 res.rc  |   4 +-
 32 files changed, 1606 insertions(+), 1576 deletions(-)
 delete mode 100644 cygpackage.cc
 delete mode 100644 cygpackage.h
 create mode 100644 libsolv.cc
 create mode 100644 libsolv.h
 delete mode 100644 package_version.cc

-- 
2.12.3



[PATCH setup 03/14] Hoist addScript() etc. up from packageversion to packagemeta

2017-05-31 Thread Jon Turney
We're only interesting in storing scripts and later running them from the
desired version as we install it, so despite being stored per
packageversion, this is only significant for the desired version.

Hoist it up from packageversion to packagemeta.
---
 install.cc |  2 +-
 package_meta.cc| 12 
 package_meta.h |  7 ++-
 package_version.cc | 28 
 package_version.h  |  8 
 postinstall.cc |  6 +++---
 6 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/install.cc b/install.cc
index 79ddd20..cd3128c 100644
--- a/install.cc
+++ b/install.cc
@@ -485,7 +485,7 @@ Installer::installOne (packagemeta , const 
packageversion ,
   lst->write (tmp.c_str(), tmp.size());
 }
   if (Script::isAScript (fn))
-pkgm.desired.addScript (Script (canonicalfn));
+pkgm.addScript (Script (canonicalfn));
 
   int iteration = 0;
   archive::extract_results extres;
diff --git a/package_meta.cc b/package_meta.cc
index 1f548e2..f37340b 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -693,3 +693,15 @@ packagemeta::addToCategoryAll()
 {
   add_category ("All");
 }
+
+void
+packagemeta::addScript(Script const )
+{
+  scripts_.push_back(aScript);
+}
+
+std::vector 

[PATCH setup 02/14] Factor out reading installed.db

2017-05-31 Thread Jon Turney
Rather that doing implicitly the first time a packagedb is constructed, do
it explicitly at a certain point in time that is early enough.
---
 ini.cc| 4 +++-
 package_db.cc | 9 +++--
 package_db.h  | 1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ini.cc b/ini.cc
index 82990a2..1162b91 100644
--- a/ini.cc
+++ b/ini.cc
@@ -346,13 +346,15 @@ do_remote_ini (HWND owner)
 static bool
 do_ini_thread (HINSTANCE h, HWND owner)
 {
+  packagedb db;
+  db.read();
+
   size_t ini_count = 0;
   if (source == IDC_SOURCE_LOCALDIR)
 ini_count = do_local_ini (owner);
   else
 ini_count = do_remote_ini (owner);
 
-  packagedb db;
   db.upgrade();
 
   if (ini_count == 0)
diff --git a/package_db.cc b/package_db.cc
index 00395d3..3d6d0de 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -45,10 +45,15 @@ using namespace std;
 
 packagedb::packagedb ()
 {
-  io_stream *db = 0;
+}
+
+void
+packagedb::read ()
+{
   if (!installeddbread)
 {
-  /* no parameters. Read in the local installation database. */
+  /* Read in the local installation database. */
+  io_stream *db = 0;
   db = io_stream::open ("cygfile:///etc/setup/installed.db", "rt", 0);
   installeddbread = 1;
   if (!db)
diff --git a/package_db.h b/package_db.h
index d02dbc4..d26f8ad 100644
--- a/package_db.h
+++ b/package_db.h
@@ -63,6 +63,7 @@ class packagedb
 {
 public:
   packagedb ();
+  void read();
   /* 0 on success */
   int flush ();
   void upgrade ();
-- 
2.12.3