Re: [ITA] units

2017-04-27 Thread Jon Turney

On 27/04/2017 00:20, Brian Inglis wrote:

On 2017-04-26 17:16, Brian Inglis wrote:

On 2017-04-26 12:30, Yaakov Selkowitz wrote:

On 2017-04-26 10:50, Brian Inglis wrote:

- x86 does not have the libreadline7 direct dependency in .hint

That means you were missing libreadline-devel; you will need to
install that for x86 and rebuild.


Should I add libreadline-devel to .cygport DEPEND=?


Yes.

It would be better (works when cross-compiled) to write that as a 
pkg-config dependency, but unfortunately libreadline doesn't seem to 
have a .pc file.


You might also want to explicitly add --enable-readline (or whatever the 
right thing is) to the configure line.




[PATCH setup 00/11] Various setup patches

2017-04-28 Thread Jon Turney
More cleaning out of the Augean stables.

Jon Turney (11):
  Remove pointless abstract base class IniDBBuilder
  Remove unused package_status_t stored in packageversion class
  Remove cygpackage::destroy() because it does nothing
  Make packageversion::source(|s) const
  Use const version of packageversion::depends() in PrereqChecker
  packageversion::sourcePackageSpecification() is const
  Don't handle missing 'version:'
  Don't do unneeded work when changing stability level
  Make building with DEBUG less useless
  Don't show source-only packages in package list
  Use wininet for fetching URLs in direct (non-proxy) case (DO NOT
APPLY)

 ConnectionSetting.cc   |   5 ++
 IniDBBuilder.h |  59 
 IniDBBuilderPackage.cc |  15 -
 IniDBBuilderPackage.h  |  62 -
 PickView.cc|   7 ++-
 ScanFindVisitor.cc |   4 +-
 ScanFindVisitor.h  |   6 +-
 choose.cc  |   8 ---
 cygpackage.cc  |  11 
 cygpackage.h   |   7 ---
 ini.h  |   4 +-
 inilex.ll  |   4 +-
 iniparse.yy|   4 +-
 net.cc |  34 ++--
 netio.cc   |  32 ++-
 netio.h|   2 +
 nio-ie5.cc |  23 +---
 nio-ie5.h  |   2 +-
 package_db.cc  |  12 
 package_db.h   |   1 -
 package_meta.cc|  47 +---
 package_meta.h |  13 ++---
 package_version.cc | 147 +
 package_version.h  |  15 +
 prereq.cc  |   4 +-
 res.rc |   2 +
 resource.h |   1 +
 27 files changed, 148 insertions(+), 383 deletions(-)
 delete mode 100644 IniDBBuilder.h

-- 
2.12.2



[PATCH setup 01/11] Remove pointless abstract base class IniDBBuilder

2017-04-28 Thread Jon Turney
There can be no instances of IniDBBuilder (it has pure virtual methods).
There is only one derived class IniDBBuilderPackage.
We can't think of any use for other derived classes.
---
 IniDBBuilder.h| 59 
 IniDBBuilderPackage.h | 62 ++-
 ScanFindVisitor.cc|  4 ++--
 ScanFindVisitor.h |  6 ++---
 ini.h |  4 ++--
 inilex.ll |  4 ++--
 iniparse.yy   |  4 ++--
 7 files changed, 47 insertions(+), 96 deletions(-)
 delete mode 100644 IniDBBuilder.h

diff --git a/IniDBBuilder.h b/IniDBBuilder.h
deleted file mode 100644
index b3f5c57..000
--- a/IniDBBuilder.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2002, 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_INIDBBUILDER_H
-#define SETUP_INIDBBUILDER_H
-
-#include "PackageSpecification.h"
-
-class IniDBBuilder
-{
-public:
-  virtual ~IniDBBuilder() {};
-  virtual void buildTimestamp (const std::string& ) = 0;
-  virtual void buildVersion (const std::string& ) = 0;
-  virtual void buildPackage (const std::string& ) = 0;
-  virtual void buildPackageVersion (const std::string& ) = 0;
-  virtual void buildPackageSDesc (const std::string& ) = 0;
-  virtual void buildPackageLDesc (const std::string& ) = 0;
-  virtual void buildPackageInstall (const std::string& ) = 0;
-  virtual void buildPackageSource (const std::string&, const std::string&) = 0;
-  virtual void buildPackageTrust (int) = 0;
-  virtual void buildPackageCategory (const std::string& ) = 0;
-  virtual void buildBeginDepends () = 0;
-  virtual void buildInstallSize (const std::string& ) = 0;
-  virtual void buildInstallSHA512 (unsigned char const[64]) = 0;
-  virtual void buildSourceSHA512 (unsigned char const[64]) = 0;
-  virtual void buildInstallMD5 (unsigned char const[16]) = 0;
-  virtual void buildSourceMD5 (unsigned char const[16]) = 0;
-  virtual void buildBeginBuildDepends () = 0;
-  virtual void buildSourceName (const std::string& ) = 0;
-  virtual void buildSourceNameVersion (const std::string& ) = 0;
-  virtual void buildPackageListAndNode () = 0;
-  virtual void buildPackageListOrNode (const std::string& ) = 0;
-  virtual void buildPackageListOperator (PackageSpecification::_operators 
const &) = 0;
-  virtual void buildPackageListOperatorVersion (const std::string& ) = 0;
-  virtual void buildMessage (const std::string&, const std::string&) = 0;
-  void set_arch (const std::string& a) { arch = a; }
-  void set_release (const std::string& rel) { release = rel; }
-
-  unsigned int timestamp;
-  std::string arch;
-  std::string release;
-  std::string version;
-  std::string parse_mirror;
-};
-
-#endif /* SETUP_INIDBBUILDER_H */
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index a97c53f..a39a95f 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -16,48 +16,58 @@
 #ifndef SETUP_INIDBBUILDERPACKAGE_H
 #define SETUP_INIDBBUILDERPACKAGE_H
 
-#include "IniDBBuilder.h"
 #include 
 #include "package_version.h"
 class IniParseFeedback;
 class packagesource;
 class packagemeta;
 
-class IniDBBuilderPackage:public IniDBBuilder
+class IniDBBuilderPackage
 {
 public:
   IniDBBuilderPackage (IniParseFeedback const &);
   ~IniDBBuilderPackage ();
-  virtual void buildTimestamp (const std::string& );
-  virtual void buildVersion (const std::string& );
-  virtual void buildPackage (const std::string& );
-  virtual void buildPackageVersion (const std::string& );
-  virtual void buildPackageSDesc (const std::string& );
-  virtual void buildPackageLDesc (const std::string& );
-  virtual void buildPackageInstall (const std::string& );
-  virtual void buildPackageSource (const std::string&, const std::string&);
-  virtual void buildPackageTrust (int);
-  virtual void buildPackageCategory (const std::string& );
 
-  virtual void buildBeginDepends ();
-  virtual void buildInstallSize (const std::string& );
-  virtual void buildInstallSHA512 (unsigned char const[64]);
-  virtual void buildSourceSHA512 (unsigned char const[64]);
-  virtual void buildInstallMD5 (unsigned char const[16]);
-  virtual void buildSourceMD5 (unsigned char const[16]);
-  virtual void buildBeginBuildDepends ();
-  virtual void buildMessage (const std::string&, const std::string&);
-  virtual void buildSourceName (const std::string& );
-  virtual void buildSourceNameVersion (const std::string& );
-  virtual void buildPackageListAndNode ();
-  virtual void buildPackageListOrNode (const std::string& );
-  virtual void buildPackageListOperator (PackageSpecification::_operato

[PATCH setup 02/11] Remove unused package_status_t stored in packageversion class

2017-04-28 Thread Jon Turney
The package installed/not installed status is tracked by the packagemeta
class, currently
---
 cygpackage.cc  | 3 ---
 cygpackage.h   | 6 --
 package_db.cc  | 1 -
 package_version.cc | 1 -
 package_version.h  | 9 -
 5 files changed, 20 deletions(-)

diff --git a/cygpackage.cc b/cygpackage.cc
index cd4b6bd..14c0c98 100644
--- a/cygpackage.cc
+++ b/cygpackage.cc
@@ -36,7 +36,6 @@ packagev (),
 canonical (),
 sdesc (),
 ldesc (),
-status (package_installed),
 type (package_binary),
 listdata (),
 listfile ()
@@ -61,12 +60,10 @@ cygpackage::createInstance (const std::string& pkgname,
 packageversion
 cygpackage::createInstance (const std::string& pkgname,
 const std::string& version,
-   package_status_t const newstatus,
package_type_t const newtype)
 {
   cygpackage *temp = new cygpackage;
   temp->name = pkgname;
-  temp->status = newstatus;
   temp->type = newtype;
   temp->setCanonicalVersion (version);
   return packageversion(temp);
diff --git a/cygpackage.h b/cygpackage.h
index 991072a..4c57b95 100644
--- a/cygpackage.h
+++ b/cygpackage.h
@@ -34,10 +34,6 @@ public:
   virtual const std::string Vendor_version ();
   virtual const std::string Package_version ();
   virtual const std::string Canonical_version ();
-  virtual package_status_t Status ()
-  {
-return status;
-  };
   virtual package_type_t Type ()
   {
 return type;
@@ -72,7 +68,6 @@ public:
 
   static packageversion createInstance (const std::string& pkgname,
 const std::string& version,
-   package_status_t const,
package_type_t const);
 
 private:
@@ -86,7 +81,6 @@ private:
   char getfilenamebuffer[CYG_PATH_MAX];
 
 //  package_stability_t stability;
-  package_status_t status;
   package_type_t type;
 
   io_stream *listdata, *listfile;
diff --git a/package_db.cc b/package_db.cc
index ba1a561..a47fb11 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -107,7 +107,6 @@ packagedb::packagedb ()
 
  packageversion binary = 
cygpackage::createInstance (pkgname, f.ver,
-   package_installed,
package_binary);
 
  pkg->add_version (binary);
diff --git a/package_version.cc b/package_version.cc
index 8ed8ac8..1a4d041 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -45,7 +45,6 @@ public:
   const std::string Package_version() {return std::string();}
   const std::string Canonical_version() {return std::string();}
   void setCanonicalVersion (const std::string& ) {}
-  package_status_t Status (){return package_notinstalled;}
   package_type_t Type () {return package_binary;}
   const std::string getfirstfile () {return std::string();}
   const std::string getnextfile () {return std::string();}
diff --git a/package_version.h b/package_version.h
index edfd15a..c271f73 100644
--- a/package_version.h
+++ b/package_version.h
@@ -57,13 +57,6 @@ package_stability_t;
 
 typedef enum
 {
-  package_notinstalled,
-  package_installed
-}
-package_status_t;
-
-typedef enum
-{
   package_binary,
   package_source
 }
@@ -105,7 +98,6 @@ public:
   const std::string Package_version () const;
   const std::string Canonical_version () const;
   void setCanonicalVersion (const std::string& );
-  package_status_t Status () const;
   package_type_t Type () const;
   const std::string getfirstfile ();
   const std::string getnextfile ();
@@ -165,7 +157,6 @@ public:
   virtual const std::string Package_version () = 0;
   virtual const std::string Canonical_version () = 0;
   virtual void setCanonicalVersion (const std::string& ) = 0;
-  virtual package_status_t Status () = 0;
 //  virtual package_stability_t Stability () = 0;
   virtual package_type_t Type () = 0;
   /* TODO: we should probably return a metaclass - file name & path & size & 
type
-- 
2.12.2



[PATCH setup 03/11] Remove cygpackage::destroy() because it does nothing

2017-04-28 Thread Jon Turney
---
 cygpackage.cc | 8 
 cygpackage.h  | 1 -
 2 files changed, 9 deletions(-)

diff --git a/cygpackage.cc b/cygpackage.cc
index 14c0c98..56c1da8 100644
--- a/cygpackage.cc
+++ b/cygpackage.cc
@@ -101,14 +101,6 @@ cygpackage::setCanonicalVersion (const std::string& 
version)
 
 cygpackage::~cygpackage ()
 {
-  destroy ();
-}
-
-/* helper functions */
-
-void
-cygpackage::destroy ()
-{
 }
 
 const std::string
diff --git a/cygpackage.h b/cygpackage.h
index 4c57b95..4022472 100644
--- a/cygpackage.h
+++ b/cygpackage.h
@@ -72,7 +72,6 @@ public:
 
 private:
   cygpackage ();
-  void destroy ();
   std::string name;
   std::string vendor;
   std::string packagev;
-- 
2.12.2



[PATCH setup 05/11] Use const version of packageversion::depends() in PrereqChecker

2017-04-28 Thread Jon Turney
---
 prereq.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/prereq.cc b/prereq.cc
index 0d3b93c..4b6cd68 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 the prev, curr, and exp versions are all the same.
-  vector  *> *deps = pack->curr.depends ();
+  const vector  *> *deps = 
pack->curr.depends ();
 
   // go through the package's dependencies
-  for (vector  *>::iterator d =
+  for (vector  *>::const_iterator d =
 deps->begin (); d != deps->end (); ++d)
 {
   // XXX: the following assumes that there is only a single
-- 
2.12.2



[PATCH setup 07/11] Don't handle missing 'version:'

2017-04-28 Thread Jon Turney
If the setup.ini is missing a 'version:' line, parse the version number out
of the 'install:' filename.  Let's not do that anymore...
---
 IniDBBuilderPackage.cc | 12 
 1 file changed, 12 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 582d249..a453a7d 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -24,7 +24,6 @@
 #include "package_meta.h"
 #include "package_version.h"
 #include "cygpackage.h"
-#include "filemanip.h"
 #include "ini.h"
 // for strtoul
 #include 
@@ -170,7 +169,6 @@ IniDBBuilderPackage::buildPackageSource (const std::string& 
path,
   spec.setOperator (PackageSpecification::Equals);
   spec.setVersion (cbpv.Canonical_version());
 
-  // process_src (*cspv.source(), path);
   setSourceSize (*cspv.source(), size);
 }
 
@@ -457,16 +455,6 @@ IniDBBuilderPackage::process_src (packagesource &src, 
const std::string& path)
   if (!src.Canonical())
 src.set_canonical (path.c_str());
   src.sites.push_back(site(parse_mirror));
-
-  if (!cbpv.Canonical_version ().size())
-{
-  fileparse f;
-  if (parse_filename (path, f))
-   {
- cbpv.setCanonicalVersion (f.ver);
- add_correct_version ();
-   }
-}
 }
 
 void
-- 
2.12.2



[PATCH setup 08/11] Don't do unneeded work when changing stability level

2017-04-28 Thread Jon Turney
Since 2c4487b3, we stopped recomputing all the dependencies every time
something was changed in the PickView.  Remove all the depsolver code which
was used to do that.

The only remaining use was when we changed stability level, to select all
the package versions at that stability level.  That work is already being
done by packagedb::defaultTrust() (called by ChooserPage::changeTrust()).

(Note that this changes behaviour slightly: New dependencies of currently
installed packages used to be shown in the PickView, but now they won't be
reported until the PrereqChecker)

(This still leaves the crude depsolver we actually use in PrereqChecker,
which just selects all the unmet dependencies with the current trust level)
---
 choose.cc  |   8 ---
 package_db.cc  |  11 -
 package_db.h   |   1 -
 package_meta.cc|  35 +-
 package_meta.h |  11 +
 package_version.cc | 140 -
 6 files changed, 3 insertions(+), 203 deletions(-)

diff --git a/choose.cc b/choose.cc
index a0dcc1b..2016caa 100644
--- a/choose.cc
+++ b/choose.cc
@@ -372,14 +372,6 @@ ChooserPage::changeTrust(trusts aTrust)
 {
   SetBusy ();
   chooser->defaultTrust (aTrust);
-  packagedb db;
-  db.markUnVisited ();
-
-  for (packagedb::packagecollection::iterator i = db.packages.begin(); i != 
db.packages.end(); i++)
-{
-  i->second->set_requirements(aTrust);
-}
-
   chooser->refresh();
   PrereqChecker p;
   p.setTrust (aTrust);
diff --git a/package_db.cc b/package_db.cc
index a47fb11..c2e1b63 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -381,17 +381,6 @@ packagedb::connectedEnd()
 }
 
 void
-packagedb::markUnVisited()
-{
-  for (packagedb::packagecollection::iterator n = packages.begin ();
-   n != packages.end (); ++n)
-{
-  packagemeta & pkgm = *(n->second);
-  pkgm.visited(false);
-}
-}
-
-void
 packagedb::setExistence ()
 {
   /* binary packages */
diff --git a/package_db.h b/package_db.h
index 6a99398..d02dbc4 100644
--- a/package_db.h
+++ b/package_db.h
@@ -72,7 +72,6 @@ public:
   PackageDBConnectedIterator connectedEnd();
   void fillMissingCategory();
   void defaultTrust (trusts trust);
-  void markUnVisited();
   void setExistence();
   typedef std::map  packagecollection;
   /* all seen binary packages */
diff --git a/package_meta.cc b/package_meta.cc
index 4ea9a4f..0f97f1d 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -92,8 +92,7 @@ packagemeta::packagemeta (packagemeta const &rhs) :
   installed (rhs.installed), prev (rhs.prev),
   curr (rhs.curr),
   exp (rhs.exp),
-  desired (rhs.desired),
-  visited_(rhs.visited_)
+  desired (rhs.desired)
 {
   
 }
@@ -457,26 +456,6 @@ packagemeta::set_action (trusts const trust)
 user_picked = true;
 }
 
-int
-packagemeta::set_requirements (trusts deftrust, size_t depth)
-{
-  if (visited())
-return 0;
-  /* Only prevent further checks once we have been required by something else 
*/
-  if (depth)
-visited(true);
-  int changed = 0;
-  /* handle build-depends */
-  if (depth == 0 && desired.sourcePackage ().picked())
-changed += desired.sourcePackage ().set_requirements (deftrust, depth + 1);
-  if (!desired || (desired != installed && !desired.picked ()))
-/* uninstall || source only */
-return changed;
-
-  return changed + desired.set_requirements (deftrust, depth);
-}
-
-
 // Set a particular type of action.
 void
 packagemeta::set_action (_actions action, packageversion const 
&default_version)
@@ -612,18 +591,6 @@ packagemeta::trustLabel(packageversion const &aVersion) 
const
 }
 
 void
-packagemeta::visited(bool const &aBool)
-{
-  visited_ = aBool;
-}
-
-bool
-packagemeta::visited() const
-{
-  return visited_;
-}
-
-void
 packagemeta::logSelectionStatus() const
 {
   packagemeta const & pkg = *this;
diff --git a/package_meta.h b/package_meta.h
index f23073e..9bf8336 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -35,8 +35,7 @@ public:
   static void ScanDownloadedFiles (bool);
   packagemeta (packagemeta const &);
   packagemeta (const std::string& pkgname)
-  : name (pkgname), key(pkgname), user_picked (false),
-visited_(false)
+  : name (pkgname), key(pkgname), user_picked (false)
   {
   }
 
@@ -44,8 +43,6 @@ public:
 
   void add_version (packageversion &);
   void set_installed (packageversion &);
-  void visited(bool const &);
-  bool visited() const;
   void addToCategoryBase();
   bool hasNoCategories() const;
   void setDefaultCategories();
@@ -74,10 +71,7 @@ public:
   void set_action (trusts const t);
   void set_action (_actions, packageversion const & default_version);
   void uninstall ();
-  int set_requirements (trusts deftrust, size_t depth);
-  // explicit separation for generic programming.
-  int set_requirements (trusts deftrust) 
-{ return set_requirements (deftrust, 0); }
+
   void set_message (const std::string& message_id, const std::string& 
message_string)
   {
 message.set (message_id, messa

[PATCH setup 04/11] Make packageversion::source(|s) const

2017-04-28 Thread Jon Turney
Make packageversion::source() and sources() const

Remove a temporary used to dererence an packageversion iterator to avoid
problems with const-correctness
---
 PickView.cc| 4 ++--
 package_version.cc | 4 ++--
 package_version.h  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/PickView.cc b/PickView.cc
index 3de49f7..1ba55e8 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -442,9 +442,9 @@ PickView::init_headers (HDC dc)
   if (*i != pkg.installed)
 note_width (headers, dc, i->Canonical_version (),
 HMARGIN + SPIN_WIDTH, new_col);
- std::string z = format_1000s(packageversion(*i).source ()->size);
+ std::string z = format_1000s(i->source ()->size);
  note_width (headers, dc, z, HMARGIN, size_col);
- z = format_1000s(packageversion(i->sourcePackage ()).source ()->size);
+ z = format_1000s(i->sourcePackage ().source ()->size);
  note_width (headers, dc, z, HMARGIN, size_col);
}
   std::string s = pkg.name;
diff --git a/package_version.cc b/package_version.cc
index 1a4d041..695641f 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -262,7 +262,7 @@ packageversion::uninstall ()
 }
 
 packagesource *
-packageversion::source ()
+packageversion::source () const
 {
   if (!data->sources.size())
 data->sources.push_back (packagesource());
@@ -270,7 +270,7 @@ packageversion::source ()
 }
 
 vector *
-packageversion::sources ()
+packageversion::sources () const
 {
   return &data->sources;
 }
diff --git a/package_version.h b/package_version.h
index c271f73..6f6fcde 100644
--- a/package_version.h
+++ b/package_version.h
@@ -118,9 +118,9 @@ public:
 
   void uninstall ();
   /* invariant: never null */
-  packagesource *source(); /* where can we source the file from */
+  packagesource *source() const; /* where can we source the file from */
   /* invariant: never null */
-  std::vector  *sources(); /* expose the list of files.
+  std::vector  *sources() const; /* expose the list of files.
source() returns the 'default' file
sources() allows managing multiple files
in a single package
-- 
2.12.2



[PATCH setup 09/11] Make building with DEBUG less useless

2017-04-28 Thread Jon Turney
Showing a messagebox with ldesc for every single package is annoying.
---
 IniDBBuilderPackage.cc | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index a453a7d..d506a9f 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -116,9 +116,6 @@ void
 IniDBBuilderPackage::buildPackageLDesc (const std::string& theDesc)
 {
   cbpv.set_ldesc(theDesc);
-#if DEBUG
-  _feedback.warning(theDesc.c_str());
-#endif
 }
 
 void
-- 
2.12.2



[PATCH setup 10/11] Don't show source-only packages in package list

2017-04-28 Thread Jon Turney
external-source: packages which have no binary package will be marked skip:
and so won't show up in setup.ini at all.

If we change to using the Source: line to identify a source package, which
is (by definition) source only, these will appear in setup.ini, but without
any install: lines, so we need to explcitly avoid showing them in the
package list.

Future work: perhaps add another view to show just source packages?
---
 PickView.cc |  3 +++
 package_meta.cc | 12 
 package_meta.h  |  2 ++
 3 files changed, 17 insertions(+)

diff --git a/PickView.cc b/PickView.cc
index 1ba55e8..b3b1c1a 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -165,6 +165,9 @@ PickView::setViewMode (views mode)
 {
   packagemeta & pkg = *(i->second);
 
+  if (!pkg.isBinary())
+continue;
+
   if ( // "Full" : everything
   (view_mode == PickView::views::PackageFull)
 
diff --git a/package_meta.cc b/package_meta.cc
index 0f97f1d..24ed17e 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -537,6 +537,18 @@ packagemeta::sourceAccessible () const
   if (bin.sourcePackage().accessible())
 return true;
 }
+
+  return false;
+}
+
+bool
+packagemeta::isBinary () const
+{
+  for (set::iterator i=versions.begin();
+   i != versions.end(); ++i)
+if ((i->Type() == package_binary) && i->accessible())
+  return true;
+
   return false;
 }
 
diff --git a/package_meta.h b/package_meta.h
index 9bf8336..5f7842c 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -142,6 +142,8 @@ public:
   bool accessible () const;
   bool sourceAccessible() const;
 
+  bool isBinary() const;
+
   void logSelectionStatus() const;
   void logAllVersions() const;
 
-- 
2.12.2



[PATCH setup 06/11] packageversion::sourcePackageSpecification() is const

2017-04-28 Thread Jon Turney
---
 package_version.cc | 2 +-
 package_version.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/package_version.cc b/package_version.cc
index 695641f..1f9f2d8 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -218,7 +218,7 @@ packageversion::sourcePackage() const
 }
 
 PackageSpecification &
-packageversion::sourcePackageSpecification ()
+packageversion::sourcePackageSpecification () const
 {
   return data->sourcePackageSpecification ();
 }
diff --git a/package_version.h b/package_version.h
index 6f6fcde..b728acc 100644
--- a/package_version.h
+++ b/package_version.h
@@ -106,7 +106,7 @@ public:
   const std::string LDesc () const;
   void set_ldesc (const std::string& );
   packageversion sourcePackage () const;
-  PackageSpecification & sourcePackageSpecification ();
+  PackageSpecification & sourcePackageSpecification () const;
   void setSourcePackageSpecification (PackageSpecification const &);
 
   /* invariant: these never return NULL */
-- 
2.12.2



[PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-04-28 Thread Jon Turney
>From the discussion in [1], I was somewhat surprised to learn that setup
doesn't support https or ftps.

Switch to using wininet for fetching URLs in the direct (non-proxy) case, as
well. (It's already used in proxy case). This allows https and ftps
protocols to be used.

For the moment, we keep around the existing, hand-built URL fetching as
'Direct (legacy)'.

Problems with this patch:

No progress feedback as we download.  We just get handed the whole file by
wininet.

Files are cached by wininet.  This is good for setup.ini, as we don't fetch
it again when it hasn't changed, but bad for package archives as we end up
with two copies (one in wininet's cache and one in setup's cache).

I think the reason we have a handbuilt HTTP client is that back in 2000 or
so, we were concerned about the case where IE5 wasn't installed and so
wininet wasn't available.  But who knows...

[1] https://cygwin.com/ml/cygwin/2017-03/msg00384.html
---
 ConnectionSetting.cc |  5 +
 net.cc   | 34 +-
 netio.cc | 32 +---
 netio.h  |  2 ++
 nio-ie5.cc   | 23 ++-
 nio-ie5.h|  2 +-
 res.rc   |  2 ++
 resource.h   |  1 +
 8 files changed, 71 insertions(+), 30 deletions(-)

diff --git a/ConnectionSetting.cc b/ConnectionSetting.cc
index 5baf76c..1154d94 100644
--- a/ConnectionSetting.cc
+++ b/ConnectionSetting.cc
@@ -49,6 +49,9 @@ ConnectionSetting::~ConnectionSetting ()
   sprintf(port_str, "%d", NetIO::net_proxy_port);
   UserSettings::instance().set("net-proxy-port", port_str);
   break;
+case IDC_NET_DIRECT_LEGACY:
+  UserSettings::instance().set("net-method", "Legacy");
+  break;
 default:
break;
 }
@@ -63,6 +66,8 @@ ConnectionSetting::typeFromString(const std::string& aType)
 return IDC_NET_IE5;
   if (!casecompare(aType, "Proxy"))
 return IDC_NET_PROXY;
+  if (!casecompare(aType, "Legacy"))
+return IDC_NET_DIRECT_LEGACY;
 
   /* A sanish default */
   return IDC_NET_IE5;
diff --git a/net.cc b/net.cc
index 659cf9b..903f096 100644
--- a/net.cc
+++ b/net.cc
@@ -37,30 +37,31 @@ extern ThreeBarProgressPage Progress;
 
 static StringOption ProxyOption ("", 'p', "proxy", "HTTP/FTP proxy 
(host:port)", false);
 
-static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
+static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 
IDC_NET_DIRECT_LEGACY, 0 };
 static bool doing_loading = false;
 
 void
 NetPage::CheckIfEnableNext ()
 {
-  int e = 0, p = 0, pu = 0;
+  int e = 0, p = 0;
   DWORD ButtonFlags = PSWIZB_BACK;
 
-  if (NetIO::net_method == IDC_NET_IE5)
-pu = 1;
-  if (NetIO::net_method == IDC_NET_IE5 || NetIO::net_method == IDC_NET_DIRECT)
+  if (NetIO::net_method == IDC_NET_IE5 ||
+  NetIO::net_method == IDC_NET_DIRECT ||
+  NetIO::net_method == IDC_NET_DIRECT_LEGACY)
 e = 1;
   else if (NetIO::net_method == IDC_NET_PROXY)
 {
-  p = pu = 1;
+  p = 1;
   if (NetIO::net_proxy_host && NetIO::net_proxy_port)
-   e = 1;
+e = 1;
+}
+
+  if (e)
+{
+  // There's something in the proxy and port boxes, enable "Next".
+  ButtonFlags |= PSWIZB_NEXT;
 }
-   if (e)
-   {
-   // There's something in the proxy and port boxes, enable "Next".
-   ButtonFlags |= PSWIZB_NEXT;
-   }
 
   GetOwner ()->SetButtons (ButtonFlags);
 
@@ -131,8 +132,8 @@ NetPage::OnInit ()
 
   // Check to see if any radio buttons are selected. If not, select a default.
   if (SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) != BST_CHECKED
-  && SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0)
-!= BST_CHECKED)
+  && SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0) != 
BST_CHECKED
+  && SendMessage (GetDlgItem (IDC_NET_DIRECT_LEGACY), BM_GETCHECK, 0, 0) 
!= BST_CHECKED)
 SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_CLICK, 0, 0);
 }
 
@@ -141,9 +142,7 @@ NetPage::OnNext ()
 {
   save_dialog (GetHWND ());
 
-  Log (LOG_PLAIN) << "net: "
-<< ((NetIO::net_method == IDC_NET_IE5) ? "IE5" :
-(NetIO::net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy") << endLog;
+  Log (LOG_PLAIN) << "net: " << NetIO::net_method_name()  << endLog;
 
   Progress.SetActivateTask (WM_APP_START_SITE_INFO_DOWNLOAD);
   return IDD_INSTATUS;
@@ -170,6 +169,7 @@ NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
 case IDC_NET_IE5:
 case IDC_NET_DIRECT:
 case IDC_NET_PROXY:
+case IDC_NET_DIRECT_LEGACY:
 case IDC_PROXY_HOST:
 case IDC_PROXY_PORT:
   save_dialog (GetHWND());
diff --git a/netio.cc b/netio.cc
index 5ec0b9a..76d0c8a 100644
--- a/netio.cc
+++ b/netio.cc
@@ -126,22 +126,28 @@ NetIO::open (char const *url)
 {
   NetIO *rv = 0;
   enum
-  { http, ftp, file }
+  { http, https, ftp, ftps, file }
   proto;
   if (strncmp (url, "http://";, 7) == 0)
 proto = http;
+  else if (st

Re: Requesting upload privileges

2017-04-29 Thread Jon Turney

On 29/04/2017 10:17, Andy Li wrote:

Name: Andy Li
Package: mbedtls


Done.



Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-04-29 Thread Jon Turney

On 28/04/2017 16:33, Åke Rehnman wrote:

On 2017-04-28 14:12, Jon Turney wrote:

 From the discussion in [1], I was somewhat surprised to learn that setup
doesn't support https or ftps.

For the same exact reason I've just recently patched in curl


I'd be very interested to see that patch :)


Problems with this patch:

No progress feedback as we download.  We just get handed the whole
file by
wininet.

curl doesn't have this problem.

Although it swell a bit compare to the original installer, from 861kB to
3766kB.


I don't think that's a problem.



Re: mbed TLS package

2017-04-29 Thread Jon Turney

On 29/04/2017 12:10, Andy Li wrote:

I've just tried to upload the package, and calm notified me about the
errors as follows:


ERROR: package 'libmbedtls10' version '2.4.2-1' requires nonexistent package 
'libmbedx509'
ERROR: package 'mbedtls-devel' version '2.4.2-1' requires nonexistent package 
'libmbedx509'
ERROR: error while validating merged x86 packages for Andy Li
SUMMARY: 3 ERROR(s)


Maybe it's because of "libmbedx509" having a number at the end of its
name, incorrectly interpreted as its version number (0)?
Its package name is "libmbedx509-0".


Using a package name containing a hyphen followed by a digit isn't 
actually forbidden currently, but perhaps should be.  It introduces an 
ambiguity about where the version starts.


This seems to tickle a bug somewhere in cygport as it doesn't generate 
the requires: correctly


It would be much better if cygport just said "no" when you tried to use 
a package name with a hyphen followed by a digit.



Any tips to fix it is appreciated.


Name the package 'libmbedx509_0'

See [1], which we generally follow:

"If the base package name ends with a digit, a single underscore ("_") 
MUST be appended to the name, and the version MUST be appended to that, 
in order to avoid confusion over where the name ends and the version 
begins."


[1] 
https://fedoraproject.org/wiki/Packaging:Naming?rd=Packaging:NamingGuidelines#MultiplePackages




Re: [ITP] polipo 1.1.1

2017-04-29 Thread Jon Turney

On 29/04/2017 08:20, Alexander Georgievskiy wrote:

Fixed, thanks.


Looks good.

Please provide a ssh key as per https://cygwin.com/package-upload.html



Re: [ITP] cygregext (formerly cygscript)

2017-04-29 Thread Jon Turney

On 28/04/2017 21:46, Eric Blake wrote:

On 04/28/2017 03:08 AM, Joni Eskelinen wrote:

Hi all,



I've renamed cygscript as proposed. Hopefully cygregext conveys its
purpose more clearly. A man page has also been added.


My first read was 'cygwin regular-expressions t'.  Maybe a slight tweak
to cygextreg (for cygwin extension registration) keeps the same length
but with less confusion with an already well-used abbreviation?


This makes sense to me, but it's your choice.


Nice work.  I'm kind of surprised we don't have something like this
already.





This application is not included in any other distro, so i reckon a vote
must be first passed.


+1


At any rate, I'm also +1 for inclusion, whether or not you take my
naming suggestion.


Please provide a ssh key as per https://cygwin.com/package-upload.html



Re: [ITP] man-italic

2017-04-29 Thread Jon Turney

On 21/04/2017 08:59, Thomas Wolff wrote:

Am 19.04.2017 um 20:38 schrieb Jon Turney:

On 28/09/2016 20:46, Thomas Wolff wrote:

The man-italic wrapper scripts enable italic display in manual pages
(where italic is specified in the page) in terminals supporting
italic mode.

wget http://towo.net/cygwin/man-italic/man-italic-0.9-0.tar.bz2
wget http://towo.net/cygwin/man-italic/man-italic-0.9-src.tar.bz2
wget http://towo.net/cygwin/man-italic/setup.hint


This seems to have fallen through the cracks and been completely
forgotten.  Sorry about that.

Fine you noticed anyway:)


Looking at this, I see that this is not a cygport package.  While this
is something which has been done historically, and I know it may seen
overkill for something this small, it's something I'm very reluctant
to see in new packages.

As you say, overkill; I've fiddled around with cygport a few times
already and I can't say I'm happy with it. While it seems to be
powerful, especially basic use isn't documented in a basic way... Would
you have a pattern for a script-only package for me, or even ready-to-use?


We could certainly do with some commented examples of cygport files in 
the packaging guide, but SHTDI...


Here's an attempt at a man-italic.cygport:

NAME=man-italic
VERSION=0.9
RELEASE=0
ARCH=noarch

LICENSE="Public Domain"
CATEGORY="Utils Doc"
SUMMARY="Enabling italic display in manual pages"
DESCRIPTION="man-italic installs two scripts and hooks them into the 
workflow of the 'man' command so that the italic attribute of manual 
pages is actually displayed in italics in terminals that support it."


SRC_URI="https://github.com/mintty/man-italic/releases/download/${VERSION}/man-italic-${VERSION}.tar.bz2";
SRC_DIR="man-italic"

src_compile() {
:
}

src_install() {
cd ${S}
doman man-italic.7
insinto /usr/share/${NAME}
doins grotty iroff
insinto /etc/postinstall
newins postinstall ${NAME}.sh
insinto /etc/preremove
newins preremove ${NAME}.sh
}


The license which applies to the original work here needs to be stated.

Checking the package contributor's guide, a license does not seem to be
strictly necessary, so I thought for a simple thing it could go as
public domain implicitly. But if you prefer, I'll attach a gnu to it.


Public domain is fine.  But we need a statement inside the source 
package what license applies.


I hope you can see that this is a simple consequence of the need to know 
that we can distribute the package.



It would be helpful if the description clarified that what this does
is "show italic text in man pages properly as italic, rather than as
underlined"

You mean the sdesc one-liner, not ldesc? I'd like to include the
"enabling" aspect because the package does not do the actual display
itself and does not need to be invoked as a tool, like:
sdesc: "Enabling proper italic display of italic text in man pages,
rather than underlined"


It's more that I was so used seeing underlined text in my manpages I 
didn't realize that it was supposed to be italic :-)



That said, this works and is pretty cool. Nice!

Thanks. Would that be a "GTG" after sorting out the issues, or are still
3 supporters needed as there used to be?


Thinking about this a bit more, I have concerns about the 
preremove/postinstall scripts.


These certainly won't correctly handle the groff package being upgraded.

Is it possible to change groff to use alternatives so this package can 
take over grotty?  Or patch this into groff and have this package just 
install an indicator file which turn on that behaviour?




Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-01 Thread Jon Turney

On 29/04/2017 11:53, Jon Turney wrote:

On 28/04/2017 16:33, Åke Rehnman wrote:

On 2017-04-28 14:12, Jon Turney wrote:

From the discussion in [1], I was somewhat surprised to learn
that setup doesn't support https or ftps.

For the same exact reason I've just recently patched in curl


I'd be very interested to see that patch :)


Thanks very much for the patch.

So... I'm in two minds about this.   Your patch seems good, but perhaps 
the problems with using wininet aren't insurmountable, and avoiding 
another dependency would also be good.


Anyhow, I had another go the wininet patch, attached.  I guess you have 
some use case for this, so perhaps you could give it a try and see if it 
works for you?
From b11932cacaa1743b3dc60c149f268d767e99bf9f Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Thu, 30 Mar 2017 11:48:44 +0100
Subject: [PATCH setup] Use wininet for fetching URLs in direct (non-proxy)
 case

From the discussion in [1], I was somewhat surprised to learn that setup
doesn't support https or ftps.

Switch to using wininet for fetching URLs in the direct (non-proxy) case, as
well. (It's already used in proxy case). This allows https and ftps
protocols to be used.

For the moment, we keep around the existing, hand-built URL fetching as
'Direct (legacy)'.

Arrange for mirrors.lst and setup.ini to be cached by wininet, but not
package archives (as setup maintains it's own cache of those)

Read from wininet in chunks rather than the whole file, so we can report
progress feedback as we download.

Also fix up some bad indentation.

I think the reason we have a handbuilt HTTP client is that back in 2000 or
so, we were concerned about the case where IE5 wasn't installed and so
wininet wasn't available.  But who knows...

[1] https://cygwin.com/ml/cygwin/2017-03/msg00384.html

Signed-off-by: Jon Turney 
---
 ConnectionSetting.cc |  5 +
 geturl.cc|  8 
 net.cc   | 34 +-
 netio.cc | 34 ++
 netio.h  |  4 +++-
 nio-ie5.cc   | 33 -
 nio-ie5.h|  4 ++--
 res.rc   |  2 ++
 resource.h   |  1 +
 9 files changed, 88 insertions(+), 37 deletions(-)

diff --git a/ConnectionSetting.cc b/ConnectionSetting.cc
index 5baf76c..1154d94 100644
--- a/ConnectionSetting.cc
+++ b/ConnectionSetting.cc
@@ -49,6 +49,9 @@ ConnectionSetting::~ConnectionSetting ()
   sprintf(port_str, "%d", NetIO::net_proxy_port);
   UserSettings::instance().set("net-proxy-port", port_str);
   break;
+case IDC_NET_DIRECT_LEGACY:
+  UserSettings::instance().set("net-method", "Legacy");
+  break;
 default:
break;
 }
@@ -63,6 +66,8 @@ ConnectionSetting::typeFromString(const std::string& aType)
 return IDC_NET_IE5;
   if (!casecompare(aType, "Proxy"))
 return IDC_NET_PROXY;
+  if (!casecompare(aType, "Legacy"))
+return IDC_NET_DIRECT_LEGACY;
 
   /* A sanish default */
   return IDC_NET_IE5;
diff --git a/geturl.cc b/geturl.cc
index 17ad8e9..5abd39a 100644
--- a/geturl.cc
+++ b/geturl.cc
@@ -106,12 +106,12 @@ progress (int bytes)
 }
 
 static void
-getUrlToStream (const string &_url, io_stream *output)
+getUrlToStream (const string &_url, io_stream *output, bool cachable)
 {
   Log (LOG_BABBLE) << "getUrlToStream " << _url << endLog;
   is_local_install = (source == IDC_SOURCE_LOCALDIR);
   init_dialog (_url, 0);
-  NetIO *n = NetIO::open (_url.c_str());
+  NetIO *n = NetIO::open (_url.c_str(), cachable);
   if (!n || !n->ok ())
 {
   delete n;
@@ -153,7 +153,7 @@ get_url_to_membuf (const string &_url, HWND owner)
   try 
 {
   Log (LOG_BABBLE) << "get_url_to_membuf " << _url << endLog;
-  getUrlToStream (_url, membuf);
+  getUrlToStream (_url, membuf, true);
   
   if (membuf->seek (0, IO_SEEK_SET))
{
@@ -213,7 +213,7 @@ get_url_to_file (const string &_url,
 
   remove (_filename.c_str());  /* but ignore errors */
 
-  NetIO *n = NetIO::open (_url.c_str());
+  NetIO *n = NetIO::open (_url.c_str(), false);
   if (!n || !n->ok ())
 {
   delete n;
diff --git a/net.cc b/net.cc
index 659cf9b..903f096 100644
--- a/net.cc
+++ b/net.cc
@@ -37,30 +37,31 @@ extern ThreeBarProgressPage Progress;
 
 static StringOption ProxyOption ("", 'p', "proxy", "HTTP/FTP proxy 
(host:port)", false);
 
-static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
+static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 
IDC_NET_DIRECT_LEGACY, 0 };
 static bool doing_loading = false;
 
 void
 NetPage::CheckIfEnableNext ()
 {
-  int e = 0, p = 0, pu = 0;
+  int e = 0, p = 0;
   DWORD ButtonFlags = PSWIZB_BACK;
 
- 

Re: noarching source packages

2017-05-01 Thread Jon Turney

On 27/04/2017 18:53, Achim Gratz wrote:

Jon Turney writes:

Picking up the discussion from [1], I've been looking a bit at
noarching the source packages.

So, the first problem is that we don't really have source packages.


I'll use this occasion to raise the topic of the debuginfo packages
again.  I still think we should change their naming convention (or
alternatively the naming convention for the source packages) and a large


What is your reason for changing the name?

I was wondering if we need to explicitly identify debuginfo archives as 
a different kind of thing.  Currently, debuginfo packages work just like 
any other install archive, which is fine, except for perhaps they need a 
separate filter in setup.



part of them is made up again of the source files, which should be
separated out into noarch also.


Nice idea, but the practicalities seem complex (e.g. generated source 
files needs to be treated correctly). In any case, this would seem to be 
a piece of work which falls after noarching the sources.



calm would need updating to look for packages in src/ as well as
noarch/ and /, and to emit 'Source:' rather than 'source:' lines
in setup.ini when the source is an actual source package.


I'd be hesitant to use yet another tree for this.  We already have way
too many directories that make up the repo.


'too many'? why?


It's not quite clear how to deal with making source packages.  If we
do it when we make the binary package (as now), then there is the near
certainly that the source package made for a different arch will
differ, gratuitously.


The only sane way is to mandate that the packages for all arches are
built together so that you can package the sources only once during the
packaging step.  Otherwise you either have to check that the contents


That would seem to require a cross-compilation environment for at least 
one cygwin arch, with all the dependencies available.



(ignoring the metadata that _will_ differ) is identical between the
source archives you've built seperately and then chose one of those for
upload or you'll have to force a reproducible build of the source
archive at least.


This also potentially loses information, as the maintainer might
adjust the .cygport to build on the 2nd architecture they try, but
those changes wouldn't be uploaded, (whereas currently the source
actually used for the build is uploaded)


It's easy enough to branch that decision inside the cygport file and the
only time I did that have passed now that the package content in both
arches is almost identical.  So is anybody really doing that currently?


At the moment, nothing prevents SRC_URI and PATCH_URI depending on the 
ARCH, so we just don't know.


But this is more a question of workflow: nothing stops the maintainer 
going back and changing the source package, then just rebuilding one 
architecture.


The ideal solution would be a build service which accepts a source 
package and produces the install archives, but I don't see that 
happening anytime soon...



But the real problem is that besides our own stuff some upstream sources
are archful.


Examples?


Applied retroactively, it looks like this would save about 13G (out of
a total mirror size of approximately 97G), but it seems that there are
many source packages which (usually spuriously) differ between arches,
so that saving wouldn't be immediately realized.


From my last dedup exercise (where my local Cygwin repo was around 80GB
since I don't mirror some of the cross-compilation and KDE packages)
doing the dedup on just the source and doc packages reduced the size of
the repo by 30GB.  I'll note again that if it was possible to split off
the noarch part of _all_ packages the gains would be larger than that.
The way it would work is that setup.exe should accept both noarch and
arch archives for the same package.  It would then proceed to first
install the noarch and then the arch part if it finds both of them.
Incidentally, this would keep the current tree structure intact and
allow us to freely move packages from arch to noarch and vice versa
between different releases with no manual intervention.


Great.  I look forward to reading the patches :)



Re: [PATCH setup 10/11] Don't show source-only packages in package list

2017-05-01 Thread Jon Turney

On 01/05/2017 15:45, Yaakov Selkowitz wrote:

On 2017-04-28 07:12, Jon Turney wrote:

external-source: packages which have no binary package will be
marked skip: and so won't show up in setup.ini at all.

If we change to using the Source: line to identify a source
package, which is (by definition) source only, these will appear in
setup.ini, but without any install: lines, so we need to explicitly
avoid showing them in the package list.


Does this necessitate a change to cygport?


Not of itself.

The first paragraph describes the current state of affairs, since calm 
generates 'source:' lines, not 'Source:' lines.


This is preparatory work for possible noarching of source packages as 
discussed in [1].


[1] https://cygwin.com/ml/cygwin-apps/2017-04/msg00069.html



Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-01 Thread Jon Turney

On 01/05/2017 16:30, Åke Rehnman wrote:

Hello,

I tested with my repo and it seem to fail if there is no setup.xz but
only setup.ini. It does quickly realize there are no setup.xz and
setup.xz.sig but then it takes forever to get past setup.bz2 etc and
fails to download setup.ini

These tests were done with -X flag.


Thanks very much for testing this.

It seems this could be an existing bug which could have been triggered 
the proxy case.


The attached incremental patch fixed this for me.
From a30dab3f8c9081d922b7287801b882001077ddeb Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Mon, 1 May 2017 21:40:40 +0100
Subject: [PATCH setup] Close rather than leak InternetOpenUrl() handles with
 errors

---
 nio-ie5.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/nio-ie5.cc b/nio-ie5.cc
index 3375c04..ba19ffa 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -122,6 +122,7 @@ try_again:
}
  else if (type >= 300)
{
+ InternetCloseHandle (connection);
  connection = 0;
  return;
}
-- 
2.12.2



Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-02 Thread Jon Turney

On 02/05/2017 08:28, Åke Rehnman wrote:

Hello all,

On 2017-05-01 22:45, Jon Turney wrote:

It seems this could be an existing bug which could have been triggered
the proxy case.

The attached incremental patch fixed this for me.


Seem to work fine for https and ftp now, I don't have the means to test
ftps yet.


Thanks very much for testing.


One thought though, why not let wininet take care of file:// URL's as
well? Or actually don't try to parse the url string at all and just pass
it down to NETIO_IE5 unfiltered? The advantage is setup would be able to


I'd be happy to look at a separate patch to do this.


handle what ever protocols wininet has. Also letting wininet taking care
of file:// url's would let the user install from a local network


I'm pretty sure I've done that in the past, so I think it already works. 
 The form of file: URL required might not be strictly correct, though, 
(I think file:server/pathname/ ?)


I can't see how to get a file:// URL for a local directory to parse 
correctly, though.



resource (i.e file server). I'm been thinking of the case when someone
wants to use a local directory repo would be slightly more complicated
since relative paths does not work with file url's. One way to solve
this particular case would be to check the first character for '.' and
use that as an indicator to a local dir.


Looking at the code, it seems that anything that is not recognized as a 
URL is just treated as a path, so this also may already be possible.


--
Jon Turney
Volunteer Cygwin/X X Server maintainer


setup release candidate

2017-05-02 Thread Jon Turney


Since this changes the file download mechanism, I think this could use 
some wider testing before being deployed.  Please test.


  https://cygwin.com/setup/setup-2.878.x86.exe
  https://cygwin.com/setup/setup-2.878.x86_64.exe

Changes compared to 2.877:

- "Direct Connection" now uses the WinINet API to fetch URLs.

This enables HTTPS and FTPS protocol support, and caching of mirrors.lst 
and setup.ini.


The existing, hand-built URL fetching, which only supports HTTP and FTP, 
is still available by choosing "Direct (legacy)".


- Fixes to "Use Internet Explorer Proxy Settings" mode

Progress is now reported for downloads.

Unwanted caching in "Temporary Internet Files" of package archives has 
been fixed.

(Addresses: https://cygwin.com/ml/cygwin/2016-09/msg00403.html)

A bug causing a long delay before downloading setup.ini from package 
repositories without a compressed setup.ini has been fixed.


- Add --allow-unsupported-windows option

Don't check the windows version.

The Cygwin mirror list is not read, so a URL (e.g. a Cygwin time machine 
circa) should be given with --site or via the GUI.


- Remove support for some long-obsolete setup.ini syntax (omitted 
version:, omitted size and checksum, various undocumented tokens)


- Remove cruft


[PATCH cygport 1/3] Pass DEPEND through to .hint for source package as build-depends:

2017-05-02 Thread Jon Turney
Converting a dependency atom to a package name with full generality requires
a database of all the pathnames contained in all packages, so we don't even
try to do that here, leaving that task for downstream processing of the
.hint file...
---
 lib/pkg_pkg.cygpart | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index 5552040..01dec69 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -710,6 +710,10 @@ _EOF
cat >> 
${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
 external-source: ${PN}
 _EOF
+   else
+   cat >> 
${distdir}/${PN}/${distsubdir}/${pkg_name[${n}]}-${PVR}.hint <<-_EOF
+build-depends: ${DEPEND}
+_EOF
fi
if defined ${pkg_message_var}
then
@@ -810,6 +814,7 @@ _EOF
cat > ${distdir}/${PN}/${PN}-${PVR}.hint <<-_EOF
 category: ${!pkg_category_var:-${CATEGORY}}
 requires:
+build-depends: ${DEPEND}
 sdesc: "${!pkg_summary_var:-${SUMMARY}}"
 ldesc: 
"${!pkg_description_var:-${DESCRIPTION:-${!pkg_summary_var:-${SUMMARY"
 skip:
-- 
2.12.2



[PATCH cygport 2/3] Don't allow SRC_URI or PATCH_URI to depend on ARCH

2017-05-02 Thread Jon Turney
The values which SRC_URI and PATCH_URI evaluate to should not change
depending on ARCH, as this will make the source package arch-dependent
---
 bin/cygport.in | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/bin/cygport.in b/bin/cygport.in
index 6cf0122..25d7e94 100644
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -409,6 +409,32 @@ then
error "${cygportfile} not found.";
 fi
 
+### perform some validation on the .cygport
+
+# SRC_URI and PATCH_URI should not change depending on ARCH, as this will make
+# the source package arch-dependent
+declare -i n
+declare -a VALUE
+ARCHES=("i686" "x86_64" "noarch")
+for VAR in "SRC_URI" "PATCH_URI"
+do
+n=0
+while (( n < ${#ARCHES[*]} ))
+do
+read -r < <(declare ARCH=${ARCHES[$n]}; declare ARCH_${ARCH}=1; source 
${top}/${cygportfile}; eval echo "\$${VAR}")
+VALUE[$n]=${REPLY}
+if (( n > 0 ))
+then
+if [ "x${VALUE[0]}" != "x${VALUE[$n]}" ]
+then
+error "${VAR} appears to depend on ARCH"
+fi
+fi
+n+=1;
+done
+done
+unset n VALUE ARCHES VAR
+
 ### load .cygport
 source ${top}/${cygportfile} || error "could not read ${cygportfile}"
 ###
-- 
2.12.2



[PATCH cygport 0/3] cygport patches

2017-05-02 Thread Jon Turney
Jon Turney (3):
  Pass DEPEND through to .hint for source package as build-depends:
  Don't allow SRC_URI or PATCH_URI to depend on ARCH
  Update documentation of all and almostall

 README  |  4 ++--
 bin/cygport.in  | 26 ++
 lib/help.cygpart|  3 ++-
 lib/pkg_pkg.cygpart |  5 +
 4 files changed, 35 insertions(+), 3 deletions(-)

-- 
2.12.2



[PATCH cygport 3/3] Update documentation of all and almostall

2017-05-02 Thread Jon Turney
'all of the above' is no longer accurate since the addition of upload etc.
---
 README   | 4 ++--
 lib/help.cygpart | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 573276e..fa09363 100644
--- a/README
+++ b/README
@@ -146,8 +146,8 @@ to be processed.  All other arguments are interpreted as a 
COMMAND, which may be
 package   - create binary and source packages
 upload- upload finished packages to cygwin.com
 finish- delete the working directory
-all   - run all of the above, including finish
-almostall - run all of the above, except for finish
+all   - run prep, compile, install, package and finish
+almostall - as all, excluding finish
 
 Other COMMANDs are meant primarily for maintainers:
 
diff --git a/lib/help.cygpart b/lib/help.cygpart
index 6e167ac..073486c 100644
--- a/lib/help.cygpart
+++ b/lib/help.cygpart
@@ -49,7 +49,8 @@ __show_help() {
  upload   upload finished packages to cygwin.com
  announce send an announcement email to cygwin.com
  finish   delete the working directory
- all  run all of the above, excluding finish
+ all  run prep, compile, install, package and finish
+ almostallas all, excluding finish
 
See the included README file for further documentation.
 
-- 
2.12.2



Re: [PATCH cygport 2/3] Don't allow SRC_URI or PATCH_URI to depend on ARCH

2017-05-02 Thread Jon Turney

On 02/05/2017 14:31, Andrew Schulman wrote:

The values which SRC_URI and PATCH_URI evaluate to should not change
depending on ARCH, as this will make the source package arch-dependent


In that case what's the right thing to do when we have arch-specific
patches? For example screen has one, for x86_64 only.


You could wrap C code in the patch in #ifdef __x86_64__ / #endif

However, looking at screen-terminfo-autoconf.patch, it would seem to be 
entirely benign to use that on x86.


I don't quite understand how screen reliably builds on any x86_64 
platform without that patch...




Re: [PATCH cygport 3/3] Update documentation of all and almostall

2017-05-02 Thread Jon Turney

On 02/05/2017 15:29, Andrew Schulman wrote:

'all of the above' is no longer accurate since the addition of upload etc.


In fact, all and almostall are identical. Neither includes finish. See line
627 of /usr/bin/cygport.

Both are misnamed IMO since they exclude get and upload.


Oh wow, I'd completely missed that change [1].  Just think of all the 
time I could have saved typing 'all' rather than 'almostall' :-)


Revised patch attached.

[1] 
https://github.com/cygwinports/cygport/commit/cf200fb6328323bb3ad5a3d557e11ab7f4203d0c
From 6d2426fe188df265846d93b9881cb208596b6b4b Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Sat, 8 Apr 2017 23:21:19 +0100
Subject: [PATCH cygport 3/3] Update documentation of all

'all of the above' is no longer accurate since the addition of upload etc.

Remove mention almostall which is identical
---
 README   | 3 +--
 lib/help.cygpart | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 573276e..985e682 100644
--- a/README
+++ b/README
@@ -146,8 +146,7 @@ to be processed.  All other arguments are interpreted as a 
COMMAND, which may be
 package   - create binary and source packages
 upload- upload finished packages to cygwin.com
 finish- delete the working directory
-all   - run all of the above, including finish
-almostall - run all of the above, except for finish
+all   - run prep, compile, install and package
 
 Other COMMANDs are meant primarily for maintainers:
 
diff --git a/lib/help.cygpart b/lib/help.cygpart
index 6e167ac..460f8f7 100644
--- a/lib/help.cygpart
+++ b/lib/help.cygpart
@@ -49,7 +49,7 @@ __show_help() {
  upload   upload finished packages to cygwin.com
  announce send an announcement email to cygwin.com
  finish   delete the working directory
- all  run all of the above, excluding finish
+ all  run prep, compile, install and package
 
See the included README file for further documentation.
 
-- 
2.12.2



Re: Neko package

2017-05-03 Thread Jon Turney

On 30/04/2017 18:51, Andy Li wrote:

Let me know if there is any remaining issue.


Looks ok to me.  I added neko to your package list.


# cygport cannot auto detect these, since the ndll files are not
# named with .dll.


If these really are just .dll by another name, you might want to explore 
patching cygport to teach it that (it already has to deal with some 
other non-standard extensions for DLLS)




Re: [ITP] extractpdfmark 1.0.2

2017-05-03 Thread Jon Turney

On 30/04/2017 11:31, Masamichi Hosoda wrote:

Hi, all

Extract PDFmark can extract page mode and named destinations
as PDFmark from PDF.
By using this you can get the small PDF files that have preserved them.


Thanks.

extractpdfmark.cygport:

DEPEND is for declaring build dependencies.  This should include 
libpoppler-devel


runtime dependencies which aren't autodetected should be declared in 
REQUIRES.



ldesc: "Extract PDFmark is able to extract page mode
and named destinations as PDFmark from PDF.
By using this you can get the small PDF files that have preserved them."


The last sentence is a bit unclear to me.  What is the referent of the 
final "them"?.




Re: Requesting upload privileges

2017-05-03 Thread Jon Turney

On 03/05/2017 07:13, Joni Eskelinen wrote:

Name: Joni Eskelinen
Package: cygextreg


Done.



Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-03 Thread Jon Turney

On 03/05/2017 08:22, Brian Inglis wrote:

On 2017-05-02 05:05, Jon Turney wrote:

On 02/05/2017 08:28, Åke Rehnman wrote:

On 2017-05-01 22:45, Jon Turney wrote:

I'm pretty sure I've done that in the past, so I think it already
works. The form of file: URL required might not be strictly correct,
though, (I think file:server/pathname/ ?)
I can't see how to get a file:// URL for a local directory to parse
correctly, though.


URLs are like http://host/path - file://host/path; if no host is given,
localhost is assumed in http:///path and file:///path

file:/// is the local root but some browsers accept just / e.g. lynx
on Cygwin and Linux - useful to test this stuff, as GUI browsers look
up URL history for completions.
Most Windows browsers require the drive at the start of the path so
should accept file:///d|/ (HTML originally allowed ":" only after the
proto, and before the password and port in
proto://[[[user][:pswd]@]host[:port]]/path
so d| was required but that was relaxed in IE, and later other browsers
followed), so likely file:///C:/, just C:, maybe C:/, rarely or never /.


Yes.  Unfortunately, none of this works correctly in setup at the moment.

Incorrect URLs of the form 'file:server/pathname/' work in setup, 
but my attempts to construct something setup would use as a file URL for 
a local directory were unsuccessful.




Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-03 Thread Jon Turney

On 02/05/2017 20:29, Åke Rehnman wrote:

One thought though, why not let wininet take care of file:// URL's as
well? Or actually don't try to parse the url string at all and just pass
it down to NETIO_IE5 unfiltered? The advantage is setup would be able to


I'd be happy to look at a separate patch to do this.

See proposed incremental patch. Have a look, give me your thoughts.



handle what ever protocols wininet has. Also letting wininet taking care
of file:// url's would let the user install from a local network


I'm pretty sure I've done that in the past, so I think it already
works.  The form of file: URL required might not be strictly correct,
though, (I think file:server/pathname/ ?)

Seem to work with \\server\share_name\path or //server/share_name/path
now anyway


Thanks for the patch. So there are a few separate things here:

* Pass unknown protocols to wininet

This seems a fine idea, but isn't what this patch does.

* Allow wininet to handle file:// URLs

I'm a little bit concerned that there may be current uses which rely on 
the incorrect parsing we do of file:// URLs to work.


Otoh, this should fix the file:// URL format we currently mishandle, so 
is probably worth doing.


* What to do with non-URL (i.e. pathname) addresses?

Perhaps WinInet can handle these, but assuming it does, is there a good 
reason to change from using NetIO_File()?


There are also some associated UI issues, in that we give no clue that a 
pathname is acceptable as a download site, and pathnames and file:// 
URLs are presented terribly in the download site list.




Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-04 Thread Jon Turney

On 03/05/2017 18:08, Åke Rehnman wrote:

On 2017-05-03 18:37, Jon Turney wrote:

Thanks for the patch. So there are a few separate things here:

* Pass unknown protocols to wininet

This seems a fine idea, but isn't what this patch does.

Yea, I know, I tested a few different solutions but it was difficult to
make something clean and proper.


Ok.



* Allow wininet to handle file:// URLs

I'm a little bit concerned that there may be current uses which rely
on the incorrect parsing we do of file:// URLs to work.

Otoh, this should fix the file:// URL format we currently mishandle,
so is probably worth doing.

I don't know how that could have ever worked... (or does it?)


Not really, see the other branch of this thread.



* What to do with non-URL (i.e. pathname) addresses?

Perhaps WinInet can handle these, but assuming it does, is there a
good reason to change from using NetIO_File()?

No. WinInet need proper file://host/path syntax. But the patch I made
send those unknown protocols to NetIO_File(), right?


Yes.

I'll add a comment that "URLs we can't parse are assumed to be paths" 
and apply this, after I've  released 2.878.


Thanks for working on this.


There are also some associated UI issues, in that we give no clue that
a pathname is acceptable as a download site, and pathnames and file://
URLs are presented terribly in the download site list.


I saw that. Perhaps fixing that is another patch?


Sure.  I just mention that for completeness, not out of any expectation 
it's going to get fixed :)




Re: noarching source packages

2017-05-04 Thread Jon Turney

On 03/05/2017 12:50, Ken Brown wrote:

On 5/1/2017 4:05 PM, Ken Brown wrote:

On 5/1/2017 3:57 PM, Achim Gratz wrote:

But the real problem is that besides our own stuff some upstream
sources
are archful.


Examples?


Last I looked, it was texlive.


This might go back to the time when biber was distributed as a packed
perl archive on x86 but not x86_64.


No, it was actually due to the existence of source files of the form

.-cygwin.tar.xz.

But it was fixed a year ago.  See the discussion at

https://sourceware.org/ml/cygwin-apps/2016-05/msg00049.html

and cygport commit 5c559d5ea49d69116d3073b68c8fb1e70522370a.


Interesting.

Anyhow, it seems that any cases of this we know of are bugs or mistakes.

We can always adopt the solution here, where the source package contains 
sources for both arches (ofc, if those are fundamentally different, 
there's a question as to in what sense they are the "same" package 
anyhow... :-))


Re: noarching source packages

2017-05-04 Thread Jon Turney

On 01/05/2017 20:57, Achim Gratz wrote:

Jon Turney writes:

What is your reason for changing the name?


There shouldn't be two different naming conventions for the same
purpose.  So

package-version-release[-purpose].tar.xz

with purpose:=[source|debuginfo] would be preferrable.


If we were starting from scratch, maybe.

The assumption that the "package" part is unique for installable 
packages is rather deeply entrenched, and I don't actually see any 
benefit apart from the aesthetic in changing this now.


If we're going for a foolish consistency, naming things as 
package-version[-purpose]-release would be probably easier to implement :-)



I was wondering if we need to explicitly identify debuginfo archives
as a different kind of thing.  Currently, debuginfo packages work just
like any other install archive, which is fine, except for perhaps they
need a separate filter in setup.


They wouldn't with the above naming convention and you'd just tick
another box to say you want them installed, just like sources.  We might
even skip the archful directories and just do [noarch|x86|x86_64] as
well in the same place.


I think it would be much better to have the associated debuginfo for a 
package described in setup.ini, rather than mapping package name -> 
source package name -> debuginfo package name, as you seem to be suggesting.



part of them is made up again of the source files, which should be
separated out into noarch also.


Nice idea, but the practicalities seem complex (e.g. generated source
files needs to be treated correctly). In any case, this would seem to
be a piece of work which falls after noarching the sources.


Agreed.


I'd be hesitant to use yet another tree for this.  We already have way
too many directories that make up the repo.


'too many'? why?


I currently have to pull the mirror through a HTTP proxy, and most of
the time is spent in traversing directories.  Yes, it'd be possible to
determine which packages are missing and directly pull those, but I
haven't got around to scripting that yet.


Ah, "too many" in some specific and limited sense. :-)

I'm not sure how many people are the situation of "I want to maintain a 
mirror, but can't use rsync".


It seems a reasonable intuition that a more compact directory tree would 
be somewhat more efficient, but that is basically saying that the 
connection setup time for transferring index.html dominates.


Have you tried a HTTP mirroring tool which can parallelize it's requests 
(assuming such a thing exists, I think axel can do that)?






Re: [PATCH cygport 1/3] Pass DEPEND through to .hint for source package as build-depends:

2017-05-06 Thread Jon Turney

On 05/05/2017 21:42, Yaakov Selkowitz wrote:

On 2017-05-02 08:13, Jon Turney wrote:

Converting a dependency atom to a package name with full generality
requires
a database of all the pathnames contained in all packages, so we don't
even
try to do that here, leaving that task for downstream processing of the
.hint file...


Or should we just replace DEPEND, which allowed atoms which are
unsupported by setup and whose name is confusing wrt REQUIRES, with a
BUILDREQUIRES variable which is package-name only?


Changing the name to something less confusing seems like a good idea.

I kind of like the current scheme, as it can do some checks when 
cross-compiling as well.


I think that something (calm?) needs to keep a database of all package 
pathnames, to check for pathname collisions between packages (I suspect 
we have some unnoticed cases of that at the moment), so the extra cost 
of doing a conversion from cygport dependency atoms in a .hint to 
package names in setup.ini shouldn't be too much.  It'll be a while 
before that happens, though... :)


People also like to typo this as DEPENDS, so some sort of warning that 
the .cygport sets a variable which has no effect might also be useful.




Re: [PATCH cygport 2/3] Don't allow SRC_URI or PATCH_URI to depend on ARCH

2017-05-06 Thread Jon Turney

On 05/05/2017 23:06, Yaakov Selkowitz wrote:

On 2017-05-02 08:13, Jon Turney wrote:

The values which SRC_URI and PATCH_URI evaluate to should not change
depending on ARCH, as this will make the source package arch-dependent


I think this would require a proper src_prep first, so that patches may
be still be arch-conditionalized there instead.


Ok, that makes sense.

So I guess there could be a hook called for each patch to cause it to be 
applied/skipped, or to adjust the patch list?  Or do you think more of 
__src_prep needs to be customizable?




Re: [ITP] extractpdfmark 1.0.2

2017-05-06 Thread Jon Turney

On 05/05/2017 11:53, Masamichi Hosoda wrote:

Extract PDFmark can extract page mode and named destinations
as PDFmark from PDF.
By using this you can get the small PDF files that have preserved
them.


Thanks.


Thank you for your reviewing.


extractpdfmark.cygport:

DEPEND is for declaring build dependencies.  This should include
libpoppler-devel


I've added it.


runtime dependencies which aren't autodetected should be declared in
REQUIRES.


texlive (pdftex), ghostscript (gs), and diffutils (diff)
are needed for testing "cygport extractpdfmark.cygport check".
They are not runtime dependencies.

I've added comment.


Great.

Please provide a ssh key as per https://cygwin.com/package-upload.html



Re: SSH key for upload access

2017-05-07 Thread Jon Turney

On 07/05/2017 02:36, Masamichi Hosoda wrote:

Name: Masamichi Hosoda
Package: extractpdfmark


Done.



Re: adopt and update libatomic_ops and libgc

2017-05-09 Thread Jon Turney

On 09/05/2017 06:59, Andy Li wrote:

On 2017-05-08 05:54, Jon Turney wrote:

libatomic_ops.cygport:
A comment that we need to correct for this installing it's
documentation into usr/share/libatomic_ops, rather that
usr/share/doc/libatomic_ops might be nice.
This could alternatively be written using a custom src_install which
calls cyginstall then moves the directory, which might be less
brittle to changes in the file list?
This might be an upstream defect if it doesn't respect --docdir?


Right, I've just sent a PR to the upstream to fix it. See
https://github.com/ivmai/libatomic_ops/pull/25
I've included it as a patch in the cygport file, which we can remove
in the next version if the PR is merged.


libgc.cygport:
DEPEND might be better written pkgconfig(atomic_ops)
Again, stuff installed to usr/share/gc/ should probably be moved to
usr/share/doc/gc


Similarly, the PR: https://github.com/ivmai/bdwgc/pull/161


I note we also have libgc-7.2d-2 as non-source package, which just
contains usr/share/doc/Cygwin/libgc.README. That probably needs to
be cleaned up by being obsoleted.


What is the procedure of obsoleting packages?


In this case I think you just need:

libgc_devel_OBSOLETES="libgc"

(See https://cygwinports.github.io/cygport/pkg_pkg_cygpart.html#robo445)

I added libatomic_ops and libgc to your package list.



Re: [PATCH cygport 2/3] Don't allow SRC_URI or PATCH_URI to depend on ARCH

2017-05-11 Thread Jon Turney

On 06/05/2017 12:32, Jon Turney wrote:

On 05/05/2017 23:06, Yaakov Selkowitz wrote:

On 2017-05-02 08:13, Jon Turney wrote:

The values which SRC_URI and PATCH_URI evaluate to should not change
depending on ARCH, as this will make the source package arch-dependent


I think this would require a proper src_prep first, so that patches may
be still be arch-conditionalized there instead.


Ok, that makes sense.

So I guess there could be a hook called for each patch to cause it to be
applied/skipped, or to adjust the patch list?  Or do you think more of
__src_prep needs to be customizable?



Attached is an implementation of the first suggestion.


From 4690490e81ddc2c429d3e124639b2814db96f249 Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Sat, 6 May 2017 13:37:13 +0100
Subject: [PATCH cygport] Add src_patch_apply_hook

---
 lib/check_funcs.cygpart |  1 +
 lib/src_prep.cygpart| 18 ++
 2 files changed, 19 insertions(+)

diff --git a/lib/check_funcs.cygpart b/lib/check_funcs.cygpart
index 93f3e12..bfa02f5 100644
--- a/lib/check_funcs.cygpart
+++ b/lib/check_funcs.cygpart
@@ -687,6 +687,7 @@ __check_unstable() {
else
warning "The ${1} API is not yet stable and is subject to 
change"
warning "You must define ${unstable_var} in order to use it"
+   return  0
fi
 }
 
diff --git a/lib/src_prep.cygpart b/lib/src_prep.cygpart
index d787d2f..aad5564 100644
--- a/lib/src_prep.cygpart
+++ b/lib/src_prep.cygpart
@@ -209,6 +209,24 @@ cygpatch() {
continue;
fi
 
+#v* Preparation/src_patch_apply_hook
+#  DESCRIPTION
+#  src_patch_apply_hook() is an optional function which can be defined
+#  to control patch application, for architecture dependent patches, etc.
+#  It receives a patch filename as an argument, and a non-zero result
+#  causes the patch to be skipped.
+#  (This API is not yet stable and is subject to change)
+#
+
+   if __check_function src_patch_apply_hook
+   then
+   if ! __check_unstable src_patch_apply_hook 
${patchfile_name}
+   then
+   warning "patch ${patchfile_name} skipped by 
src_patch_apply_hook";
+   continue;
+   fi
+   fi
+
patchlevel=0;
 
case ${patchfile_name} in
-- 
2.12.2



[ITP] python2-future and python3-future

2017-05-11 Thread Jon Turney


python-future is a compatibility layer for Python 2 and Python 3

This is a pre-requisite of buildbot-worker 0.9.x

cygport files:

https://github.com/jon-turney/python2-future-cygport/blob/master/python2-future.cygport
https://github.com/jon-turney/python3-future-cygport/blob/master/python3-future.cygport

package files:

http://www.dronecode.org.uk/cygwin/noarch/release/python2-future/
http://www.dronecode.org.uk/cygwin/noarch/release/python3-future/

license:

MIT


Re: [ITP] python2-future and python3-future

2017-05-11 Thread Jon Turney

On 11/05/2017 18:52, Yaakov Selkowitz wrote:

On 2017-05-11 12:11, Jon Turney wrote:

python-future is a compatibility layer for Python 2 and Python 3

This is a pre-requisite of buildbot-worker 0.9.x


[...]


The preferred packaging scheme for Python modules is now python-wheel
cygclass.  So instead, I suggest something like the attached.


Ah, very good. Let's do that then.

I'd also got a collision between the packages with the /usr/bin/ 
scripts, which this avoids :)





Re: Making a package obsolete

2017-05-13 Thread Jon Turney

On 12/05/2017 22:02, Ken Brown wrote:

I have a package that is going to become obsolete, but its contents will
be distributed among several other packages.  So I can't handle this by
defining OBSOLETES in any one .cygport file.  Is there a standard way to
deal with this using cygport, or should I just create the necessary
tarballs and .hint file manually?


I think the best way to do that is to bump your package revision, change 
it's category to _obsolete, make it's contents empty, and make it depend 
on the packages which are replacing it.




Re: [ITP] polipo 1.1.1

2017-05-13 Thread Jon Turney

2017-04-29 14:51 GMT+03:00 Jon Turney:

On 29/04/2017 08:20, Alexander Georgievskiy wrote:


Fixed, thanks.


Looks good.

Please provide a ssh key as per https://cygwin.com/package-upload.html



On 13/05/2017 07:56, Alexander Georgievskiy wrote:
> ssh-rsa ...

Those instructions ask for the key to be mailed to cygwin-apps@ and to 
be in RFC 4716 format.


Done.



Re: Making a package obsolete

2017-05-14 Thread Jon Turney

On 13/05/2017 20:44, Ken Brown wrote:

On 5/13/2017 7:12 AM, Jon Turney wrote:

On 12/05/2017 22:02, Ken Brown wrote:

I have a package that is going to become obsolete, but its contents will
be distributed among several other packages.  So I can't handle this by
defining OBSOLETES in any one .cygport file.  Is there a standard way to
deal with this using cygport, or should I just create the necessary
tarballs and .hint file manually?


I think the best way to do that is to bump your package revision, change
it's category to _obsolete, make it's contents empty, and make it depend
on the packages which are replacing it.


Yes, that was my first thought.  But there's no longer a source file for
the obsolete package[1], and cygport complains that SRC_URI must be
defined.  Maybe cygport should be patched to allow an empty SRC_URI when
the category is _obsolete.  Or do you see another way around this?


I would think you can use the same SRC_URI as previously, but set 
PKG_CONTENTS="" and PKG_IGNORE="*" ?




Re: Making a package obsolete

2017-05-15 Thread Jon Turney

On 15/05/2017 17:12, Brian Inglis wrote:

[intended for cygwin-apps?]


Doh! Yes.



[PATCH setup 00/15] Various setup patches

2017-05-16 Thread 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



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

2017-05-16 Thread 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_COMPLETE112
-#define IDS_WININET   113
 #define IDS_ERR_CHDIR 114
 #define IDS_OLD_SETUP_VERSION 115
 #define IDS_DOWNLOAD_INCOMPLETE   116
-- 
2.12.3



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

2017-05-16 Thread 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(*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  *> *deps = 
pack->curr.depends ();
 
   // go through the package's dependencies
-- 
2.12.3



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

2017-05-16 Thread 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 
-- 
2.12.3



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

2017-05-16 Thread 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 
 
-/* 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  sitestype;
   sitestype sites;
 
-  virtual ~ packagesource ()
+  ~packagesource ()
   {
 if (canonical)
   delete []canonical;
-- 
2.12.3



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

2017-05-16 Thread 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



[PATCH setup 07/15] Simplify class packagesource

2017-05-16 Thread 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 
-#include 
 #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");
-
- 

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

2017-05-16 Thread 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::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::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::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::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 *
-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::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::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  *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 sources; /* where can we source the files from */
+  packagesource source; /* where can we source the file from */
 
   virtual bool accessible () const;
 
-- 
2.12.3



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

2017-05-16 Thread 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



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

2017-05-16 Thread 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



[PATCH setup 11/15] Remove useless PackageSpecification methods

2017-05-16 Thread 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



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

2017-05-16 Thread 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;
-

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

2017-05-16 Thread 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::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;
-  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

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

2017-05-16 Thread 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::iterator n = cp->versions.begin();
!merged && n != cp->versions.end(); ++n)
-- 
2.12.3



[PATCH setup 14/15] Make PackageDepends a type

2017-05-16 Thread 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 *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 ::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 000..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 
+
+typedef std::vector  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  *
+PackageDepends *
 packageversion::depends()
 {
   return &data->depends;
 }
 
-const vector  *
+const PackageDepends *
 packageversion::depends() const
 {
   return &data->depends;
@@ -414,13 +414,13 @@ _packageversion::scripts()
 }
 
 void
-dumpAndList (std::vector  const *currentList,
+dumpAndList (PackageDepends const *currentList,
  std::ostream &logger)
 {
   if (currentList)
   {
 Log (LOG_BABBLE) << "( ";
-std::vector ::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 
 
@@ -110,8 +111,8 @@ public:
   void setSourcePackageSpecification (PackageSpecification const &);
 
   /* invariant: these never return NULL */
-  std::vector  *depends();
-  const std::vector  *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  depends;
+  PackageDepends depends;
 
   virtual void pick(bool const &newValue) { picked = newValue;}
   

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

2017-05-16 Thread 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 ::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 ::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 ::iterator i = install_q.begin ();
-- 
2.12.3



Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-16 Thread Jon Turney

On 04/05/2017 11:11, Jon Turney wrote:

On 03/05/2017 18:08, Åke Rehnman wrote:

On 2017-05-03 18:37, Jon Turney wrote:


* Allow wininet to handle file:// URLs

I'm a little bit concerned that there may be current uses which rely
on the incorrect parsing we do of file:// URLs to work.

Otoh, this should fix the file:// URL format we currently mishandle,
so is probably worth doing.

I don't know how that could have ever worked... (or does it?)


Not really, see the other branch of this thread.


So, I taking another look at this:

I am a bit confused about the behaviour I'm seeing, though.

I'm expecting "file:///c:/path" and "file://host/path" to work, but they 
don't seem to.


However, "file://c:/path" now works, which is good, and 
"file:host/path" continues to work


The documentation for InternetOpenUrl() says "Only URLs beginning with 
ftp:, http:, or https: are supported" so I'm wondering if this is really 
something we should be expecting to work...


Also, is there a reason for the hunk in nio-file.cc removing the 
reporting of a problem opening the file?





Re: [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY)

2017-05-17 Thread Jon Turney

On 16/05/17 18:05, Åke Rehnman wrote:

On 2017-05-16 16:00, Jon Turney wrote:

I am a bit confused about the behaviour I'm seeing, though.

I'm expecting "file:///c:/path" and "file://host/path" to work, but
they don't seem to.

Same behavior here...


Since those are apparently the correct form of URLs, any ideas about how 
we might get them to work?



However, "file://c:/path" now works, which is good, and
"file:host/path" continues to work

The documentation for InternetOpenUrl() says "Only URLs beginning with
ftp:, http:, or https: are supported" so I'm wondering if this is
really something we should be expecting to work...

Here is at least an enumeration of different schemes...
https://msdn.microsoft.com/en-us/library/windows/desktop/aa385149(v=vs.85).aspx


Hmm...  I'm not sure that's not just telling you what you can get back 
from InternetCrackUrl (which we should probably switch to using in 
NetIO::set_url() rather than doing things by hand)



Also, is there a reason for the hunk in nio-file.cc removing the
reporting of a problem opening the file?


It will complain for every setup file not found for instance if setup.xz
is missing bug setup.ini is present. And besides, why should nio_file
complain but not http and ftp?


Ah yes, I see the inconsistency now you point it out.  Makes sense.

I guess that should be changed to a log message.



[PATCH setup 00/10] Various setup patches

2017-05-23 Thread Jon Turney
Oh, I think I can see a bit of floor over there!

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

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

-- 
2.12.3



[PATCH setup 03/10] Rename category "Misc" to "Orphaned"

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

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

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



[PATCH setup 01/10] isBinary() should return true for orphaned packages

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

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



[PATCH setup 04/10] Make PrereqChecker::setTrust() a static method

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

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



[PATCH setup 05/10] Move and rename dumpAndList()

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

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

[PATCH setup 02/10] Correctly calculate total data to checksum when using IncludeSource

2017-05-23 Thread Jon Turney
Correctly account for source packages installed due to IncludeSource in the
total amount of data to checksum.

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

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



[PATCH setup 06/10] Fold IniDBBuilderPackage::buildInstallSize() into buildPackageInstall()

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

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



[PATCH setup 07/10] Fold build(Install|Source)(MD5|SHA512) into buildPackage(Install|Source)

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

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index c90bfe3..ad1cc88 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -120,15 +120,37 @@ IniDBBuilderPackage::buildPackageLDesc (const 
std::string& theDesc)
 
 void
 IniDBBuilderPackage::buildPackageInstall (const std::string& path,
-  const std::string& size)
+  const std::string& size,
+  char *hash,
+  hashType type)
 {
   process_src (*cbpv.source(), path);
   setSourceSize (*cbpv.source(), size);
+
+  switch (type) {
+  case hashType::sha512:
+if (hash && !cbpv.source()->sha512_isSet)
+  {
+memcpy (cbpv.source()->sha512sum, hash, 
sizeof(cbpv.source()->sha512sum));
+cbpv.source()->sha512_isSet = true;
+  }
+break;
+
+  case hashType::md5:
+if (hash && !cbpv.source()->md5.isSet())
+  cbpv.source()->md5.set((unsigned char *)hash);
+break;
+
+  case hashType::none:
+break;
+  }
 }
 
 void
 IniDBBuilderPackage::buildPackageSource (const std::string& path,
- const std::string& size)
+ const std::string& size,
+ char *hash,
+ hashType type)
 {
   packagedb db;
   /* get an appropriate metadata */
@@ -168,6 +190,24 @@ IniDBBuilderPackage::buildPackageSource (const 
std::string& path,
   spec.setVersion (cbpv.Canonical_version());
 
   setSourceSize (*cspv.source(), size);
+
+  switch (type) {
+  case hashType::sha512:
+if (hash && !cspv.source()->sha512_isSet)
+  {
+memcpy (cspv.source()->sha512sum, hash, 
sizeof(cspv.source()->sha512sum));
+cspv.source()->sha512_isSet = true;
+  }
+break;
+
+  case hashType::md5:
+if (hash && !cspv.source()->md5.isSet())
+  cspv.source()->md5.set((unsigned char *)hash);
+break;
+
+  case hashType::none:
+break;
+  }
 }
 
 void
@@ -200,38 +240,6 @@ IniDBBuilderPackage::buildBeginDepends ()
 }
 
 void
-IniDBBuilderPackage::buildInstallSHA512 (unsigned char const *sha512)
-{
-  if (sha512 && !cbpv.source()->sha512_isSet) {
-memcpy (cbpv.source()->sha512sum, sha512, sizeof cbpv.source()->sha512sum);
-cbpv.source()->sha512_isSet = true;
-  }
-}
-
-void
-IniDBBuilderPackage::buildSourceSHA512 (unsigned char const *sha512)
-{
-  if (sha512 && !cspv.source()->sha512_isSet) {
-memcpy (cspv.source()->sha512sum, sha512, sizeof cspv.source()->sha512sum);
-cspv.source()->sha512_isSet = true;
-  }
-}
-
-void
-IniDBBuilderPackage::buildInstallMD5 (unsigned char const *md5)
-{
-  if (md5 && !cbpv.source()->md5.isSet())
-cbpv.source()->md5.set(md5);
-}
-
-void
-IniDBBuilderPackage::buildSourceMD5 (unsigned char const *md5)
-{
-  if (md5 && !cspv.source()->md5.isSet())
-cspv.source()->md5.set(md5);
-}
-
-void
 IniDBBuilderPackage::buildBeginBuildDepends ()
 {
 #if DEBUG
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index 1dab41b..766a5ef 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -18,10 +18,13 @@
 
 #include 
 #include "package_version.h"
+
 class IniParseFeedback;
 class packagesource;
 class packagemeta;
 
+enum class hashType { none, md5, sha512 };
+
 class IniDBBuilderPackage
 {
 public:
@@ -34,16 +37,21 @@ public:
   void buildPackageVersion (const std::string& );
   void buildPackageSDesc (const std::string& );
   void buildPackageLDesc (const std::string& );
-  void buildPackageInstall (const std::string&, const std::string&);
-  void buildPackageSource (const std::string&, const std::string&);
+  void buildPackageInstall (const std::string&, const std::string&,
+char *, hashType);
+  void buildPackageSource (const std::string&, const std::string&,
+   char *, hashType);
+
+  // helpers for ScanFindVisitor
+  void buildPackageInstall (const std::string& path, const std::string& size)
+  { buildPackageInstall(path, size, NULL, hashType::none); }
+  void buildPackageSource (const std::string& path, const std::string& size)
+  { buildPackageSource(path, size, NULL, hashType::none); }
+
   void buildPackageTrust (int);
   void buildPackageCategory (const std::string& );
 
   void buildBeginDepends ();
-  void buildInstallSHA512 (unsigned char const[64]);
-  void buildSourceSHA512 (unsigned char const[64]);
-  void buildInstallMD5 (unsigned char const[16]);
-  void buildSourceMD5 (unsigned char const[

Re: calm: mksetupini doesn't allow non-empty source but empty install files for an obsolete package

2017-05-23 Thread Jon Turney

On 23/05/2017 14:44, Ken Brown wrote:

I've created an obsolete package (as discussed starting at 
https://sourceware.org/ml/cygwin-apps/2017-05/msg00084.html).  But mksetupini 
doesn't like it:

mksetupini: package 'texlive-collection-htmlxml' version '20170520-1' source 
has no non-empty install tarfiles
mksetupini: package set has errors, not writing setup.ini

I thought the following would fix it:

--- a/calm/package.py
+++ b/calm/package.py
@@ -636,6 +636,9 @@ def validate_packages(args, packages):
  if packages[p].tars[packages[p].vermap[v]['source']].is_empty:
  continue


This should be being caught by this case (source is empty), but it 
isn't, I guess because it's got a .keep file due to other problems 
previously discussed.




+if '_obsolete' in packages[p].vermap[v].get('category', ''):
+continue


I think this maybe needs to be 
packages[p].version_hints[v].get('category', '') ?



+
  if not packages[p].tars[packages[p].vermap[v]['source']].is_used:
  logging.error("package '%s' version '%s' source has no non-empty 
install tarfiles" % (p, v))
  error = True


But I must have something wrong, because I still get the error after this 
change.


[PATCH setup 09/10] Improve error recovery in setup.ini parsing

2017-05-23 Thread Jon Turney
Following the error token with a NL allows the parser to discard tokens
until a NL is found to resynchronize, rather than aborting.

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

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



[PATCH setup 10/10] Remove OR from grammar

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

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



[PATCH setup 08/10] Fix infinite recursion in grammar for depends

2017-05-23 Thread Jon Turney
Allowing listseparator to be empty allows an infinite recursion in the
versionedpackagelist rule

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

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

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



Re: calm: mksetupini doesn't allow non-empty source but empty install files for an obsolete package

2017-05-25 Thread Jon Turney

On 23/05/2017 19:16, Ken Brown wrote:

On 5/23/2017 12:55 PM, Jon Turney wrote:

On 23/05/2017 14:44, Ken Brown wrote:
I've created an obsolete package (as discussed starting at 
https://sourceware.org/ml/cygwin-apps/2017-05/msg00084.html).  But 
mksetupini doesn't like it:


mksetupini: package 'texlive-collection-htmlxml' version '20170520-1' 
source has no non-empty install tarfiles

mksetupini: package set has errors, not writing setup.ini

I thought the following would fix it:

--- a/calm/package.py
+++ b/calm/package.py
@@ -636,6 +636,9 @@ def validate_packages(args, packages):
  if 
packages[p].tars[packages[p].vermap[v]['source']].is_empty:

  continue


This should be being caught by this case (source is empty), but it 
isn't, I guess because it's got a .keep file due to other problems 
previously discussed.


The source contains a .cygport file and a fake upstream source tarball.


Of course it does.  Doh!

+if '_obsolete' in packages[p].vermap[v].get('category', 
''):

+continue


I think this maybe needs to be 
packages[p].version_hints[v].get('category', '') ?


Yes, that fixes it, thanks.  Patch attached.


Thanks, applied.


Re: Haxe package

2017-05-26 Thread Jon Turney

On 26/05/2017 03:03, Andy Li wrote:

I've revised according to all the comments in github.
Is there any other thing you would like to adjust?


This fails to build for me, the first error is:

make: *** No rule to make target 'libs/ilib/il.cmxa', needed by 
'src/context/common.cmx'.  Stop.


I wonder if I'm missing some build-dep?
cygport 0.24.1 

PF = haxe-3.4.2-1
S = /pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe
B = /pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build
D = /pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/inst
C = /pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe/CYGWIN-PATCHES
T = /pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/temp
CBUILD = x86_64-pc-cygwin
CHOST = x86_64-pc-cygwin
CTARGET = x86_64-pc-cygwin
CC = gcc
CFLAGS = -ggdb -O2 -pipe -Wimplicit-function-declaration 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
CPPFLAGS =
CXX = g++
CXXFLAGS = -ggdb -O2 -pipe 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
F77 = gfortran
FFLAGS = -ggdb -O2 -pipe 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
FC = gfortran
FCFLAGS = -ggdb -O2 -pipe 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
GOC = gccgo
GOFLAGS = -ggdb -O2 -pipe 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
OBJC = gcc
OBJCFLAGS = -ggdb -O2 -pipe -Wimplicit-function-declaration 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
OBJCXX = g++
OBJCXXFLAGS = -ggdb -O2 -pipe 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build=/usr/src/debug/haxe-3.4.2-1
 
-fdebug-prefix-map=/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/src/haxe=/usr/src/debug/haxe-3.4.2-1
LDFLAGS =
LIBS =
MAKEOPTS = -f Makefile.win


make -C libs/extlib OCAMLOPT=ocamlopt.opt OCAMLC=ocamlc native
ocamlopt.opt -bin-annot -g -w -3 -I libs/extlib -I libs/extc -I libs/neko -I 
libs/javalib -I libs/ziplib -I libs/swflib -I libs/xml-light -I libs/ttflib -I 
libs/ilib -I libs/objsize -I libs/pcre -I src -I src/context -I src/generators 
-I src/macro -I src/optimization -I src/syntax -I src/typing -I src/display -c 
src/json.ml
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
make[1]: Entering directory 
'/pkg/haxe-cygwin/haxe-3.4.2-1.x86_64/build/libs/extlib'
ocamlopt.opt -g -a -o extLib.cmxa enum.mli bitSet.mli dynArray.mli extArray.mli 
extHashtbl.mli extList.mli extString.mli global.mli rbuffer.mli IO.mli 
option.mli pMap.mli std.mli uChar.mli uTF8.mli base64.mli unzip.mli refList.mli 
optParse.mli dllist.mli multiArray.mli sMap.mli enum.ml bitSet.ml dynArray.ml 
extArray.ml extHashtbl.ml extList.ml extString.ml global.ml rbuffer.ml IO.ml 
option.ml pMap.ml std.ml uChar.ml uTF8.ml base64.ml unzip.ml refList.ml 
optParse.ml dllist.ml multiArray.ml sMap.ml extLib.ml
File "extString.mli", line 177, characters 1-100:
Warning 3: deprecated: [@@noalloc] should be used instead of "noalloc"
File "extString.mli", line 178, characters 1-91:
Warning 3: deprecated: [@@noalloc] should be used instead of "noalloc"
File "bitSet.ml", line 23, characters 40-53:
Warning 3: deprecated: String.create
Use Bytes.create instead.
File "bitSet.ml", line 28, characters 64-75:
Warning 3: deprecated: String.fill
Use Bytes.fill instead.
make -f Makefile.version_extra -s --no-print-directory ADD_REVISION=0 
BRANCH=master COMMIT_SHA=4170c14 COMMIT_DATE=20170516065120 > src/version.ml
ocamllex src/syntax/lexer.mll
make: *** No rule to make target 'libs/ilib/il.cmxa', needed by 
'src/context/common.cmx'.  Stop.
make: *** Waiting for unfinished jobs
ocamlopt.opt -bin-annot -g -w -3 -I libs/extlib -I libs/extc -I libs/neko -I 
libs/javalib -I libs/ziplib -I libs/swflib -I libs/xml-light -I libs/ttflib -I 
libs/ilib -I libs/objsize -I libs/pcre -I src -I src/context -I src/generators 
-I src/macro -I src/optimization -I src/syntax -I src/typing -I src/display -c 
src/version.ml
151 states, 1504 transitions, table size 6922 bytes
File "extString.ml", line 28, characters 9-15:
Warning 3: deprecated: create
Use Bytes.create instead.
File "extString.ml", line 30, characters 2-12:
Warning 3: deprecated: unsafe_set
File "extString.ml", line 111, characters 2-8:
Warning 3: deprecated: create
Use Bytes.create instead.
File "extString.ml", line 158, characters 9-15:
Warning 3: deprecated: create
Use

Re: Haxe package

2017-05-29 Thread Jon Turney

On 29/05/2017 03:11, Andy Li wrote:

On Fri, May 26, 2017 at 9:01 PM, Jon Turney wrote:

This fails to build for me, the first error is:

make: *** No rule to make target 'libs/ilib/il.cmxa', needed by
'src/context/common.cmx'.  Stop.

I wonder if I'm missing some build-dep?


I've just double check and it still build fine on my machine...
I notice your build log contains "make: *** Waiting for unfinished
jobs", does it mean `make` was run in parallel mode somehow?
The Haxe makefile doesn't support parallel build so I set
`MAKEOPTS="-f Makefile.win"` that removes the `-j` opt. Maybe there is
some other setting that caused a parallel build?


Yes, that seems to be it.  I have "MAKEFLAGS=-j8" in my environment.

I think the cygport reference manual recommends an explicit "-j1" in the 
cygport MAKEOPTS variable for packages which do not build properly with 
a parallel make.


With that added, package looks GTG.  I added it to your uploads.


[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



[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 &pkgm, const 
packageversion &ver,
   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 &aScript)
+{
+  scripts_.push_back(aScript);
+}
+
+std::vector 

[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 &aFeedback) :
-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();
+  Pa

[PATCH setup 05/14] Hoist uninstall up to Installer::uninstallOne()

2017-05-31 Thread Jon Turney
This calls packagemeta, which applies to packageversion (which delegates
through packageversion_ to cygpackage) to return lines from the .lst.gz file
(pretending that we know it contains a file list for that specific version)
and to remove the .lst.gz file when done.

Move this all up into Installer::uninstallOne(), where it's all in the same
place as the operation it is reversing, Installer::installOne().
---
 cygpackage.cc  | 46 +-
 cygpackage.h   | 14 ---
 install.cc | 73 +-
 package_meta.cc| 70 ---
 package_meta.h |  1 -
 package_version.cc | 21 
 package_version.h  |  9 ---
 7 files changed, 73 insertions(+), 161 deletions(-)

diff --git a/cygpackage.cc b/cygpackage.cc
index 56c1da8..32b9403 100644
--- a/cygpackage.cc
+++ b/cygpackage.cc
@@ -36,12 +36,8 @@ packagev (),
 canonical (),
 sdesc (),
 ldesc (),
-type (package_binary),
-listdata (),
-listfile ()
+type (package_binary)
 {
-  memset( getfilenamebuffer, '\0', CYG_PATH_MAX);
-
   /* FIXME: query the install database for the currently installed 
* version details
*/
@@ -104,46 +100,6 @@ cygpackage::~cygpackage ()
 }
 
 const std::string
-cygpackage::getfirstfile ()
-{
-  if (listdata)
-delete listdata;
-  listfile =
-io_stream::open ("cygfile:///etc/setup/" + name + ".lst.gz", "rb", 0);
-  listdata = compress::decompress (listfile);
-  if (!listdata)
-return std::string();
-  /* std::string(NULL) will crash, so be careful to test for that. */
-  const char *result = listdata->gets (getfilenamebuffer, sizeof 
(getfilenamebuffer));
-  if (result == NULL)
-Log (LOG_PLAIN) << "Corrupt package listing for " << name << ", can't 
uninstall old files." << endLog;
-  return std::string (result ? result : "");
-}
-
-const std::string
-cygpackage::getnextfile ()
-{
-  if (listdata)
-  {
-/* std::string(NULL) will crash, so be careful to test for that. */
-const char *sz = listdata->gets (getfilenamebuffer,
- sizeof (getfilenamebuffer));
-if (sz)
-  return std::string(sz);
-  }
-  return std::string();
-}
-
-void
-cygpackage::uninstall ()
-{
-  if (listdata)
-delete listdata;
-  listdata = 0;
-  io_stream::remove ("cygfile:///etc/setup/" + name + ".lst.gz");
-}
-
-const std::string
 cygpackage::Name ()
 {
   return name;
diff --git a/cygpackage.h b/cygpackage.h
index 4022472..c6d0657 100644
--- a/cygpackage.h
+++ b/cygpackage.h
@@ -20,9 +20,6 @@
  * arbitrate acceess to cygwin binary packages amd cygwin source packages
  */
 
-/* for MAX_PATH */
-#include "win32.h" 
-
 #include "package_version.h"
 
 class io_stream;
@@ -48,19 +45,11 @@ public:
   {
 return ldesc;
   };
-  virtual void uninstall ();
-
 
   /* pass the name of the package when constructing */
   void setCanonicalVersion (const std::string& );
 
-
   virtual ~ cygpackage ();
-  /* TODO: we should probably return a metaclass - file name & path & size & 
type
- - ie doc/script/binary
-   */
-  virtual const std::string getfirstfile ();
-  virtual const std::string getnextfile ();
 
   /* pass the name of the package when constructing */
   static packageversion createInstance (const std::string& pkgname,
@@ -77,12 +66,9 @@ private:
   std::string packagev;
   std::string canonical;
   std::string sdesc, ldesc;
-  char getfilenamebuffer[CYG_PATH_MAX];
 
 //  package_stability_t stability;
   package_type_t type;
-
-  io_stream *listdata, *listfile;
 };
 
 #endif /* SETUP_CYGPACKAGE_H */
diff --git a/install.cc b/install.cc
index fee2e19..9c4c01b 100644
--- a/install.cc
+++ b/install.cc
@@ -165,10 +165,81 @@ Installer::preremoveOne (packagemeta & pkg)
 void
 Installer::uninstallOne (packagemeta & pkg)
 {
+  if (!pkg.installed)
+return;
+
   Progress.SetText1 ("Uninstalling...");
   Progress.SetText2 (pkg.name.c_str());
   Log (LOG_PLAIN) << "Uninstalling " << pkg.name << endLog;
-  pkg.uninstall ();
+
+  std::set dirs;
+
+  io_stream *listfile = io_stream::open ("cygfile:///etc/setup/" + pkg.name + 
".lst.gz", "rb", 0);
+  io_stream *listdata = compress::decompress (listfile);
+
+  while (listdata)
+{
+  char getfilenamebuffer[CYG_PATH_MAX];
+  const char *sz = listdata->gets (getfilenamebuffer, sizeof 
(getfilenamebuffer));
+  if (sz == NULL)
+break;
+
+  std::string line(sz);
+
+  /* Insert the paths of all parent directories of line into dirs. */
+  size_t idx = line.length();
+  while ((idx = line.find_last_of('/', idx-1)) != string::npos)
+  {
+std::string dir_path = line.substr(0, idx);
+bool was_new = dirs.insert(dir_path).second;
+/* If the path was already present in dirs, then all parent paths
+ * must necessarily be present also, so don't do any further work.
+ * */
+if (!was_new) break;
+  }
+
+  std::string d = cygp

[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);
+   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 && !pkg.des

[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 &pkg, 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 07/14] Store package stability in class packageversion

2017-05-31 Thread Jon Turney
---
 IniDBBuilderPackage.cc | 12 +++-
 IniDBBuilderPackage.h  |  3 +--
 cygpackage.cc  |  7 ---
 cygpackage.h   | 10 +-
 package_version.cc | 14 ++
 package_version.h  | 14 +-
 6 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 0e1be78..fb200a8 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), trust (0), _feedback (aFeedback){}
+cp (0), cbpv (), cspv (), currentSpec (0), _feedback (aFeedback){}
 
 IniDBBuilderPackage::~IniDBBuilderPackage()
 {
@@ -90,10 +90,10 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
   db.packages.insert 
(packagedb::packagecollection::value_type(cp->name,cp));
 }
   cbpv = cygpackage::createInstance (name, package_binary);
+  cbpv.SetStability(TRUST_CURR);
   cspv = packageversion ();
   currentSpec = NULL;
   currentNodeList = PackageDepends();
-  trust = TRUST_CURR;
 #if DEBUG
   Log (LOG_BABBLE) << "Created package " << name << endLog;
 #endif
@@ -211,12 +211,12 @@ IniDBBuilderPackage::buildPackageSource (const 
std::string& path,
 }
 
 void
-IniDBBuilderPackage::buildPackageTrust (int newtrust)
+IniDBBuilderPackage::buildPackageTrust (package_stability_t newtrust)
 {
-  trust = newtrust;
   if (newtrust != TRUST_UNKNOWN)
 {
   cbpv = cygpackage::createInstance (cp->name, package_binary);
+  cbpv.SetStability(newtrust);
   cspv = packageversion ();
 }
 }
@@ -383,7 +383,7 @@ IniDBBuilderPackage::add_correct_version()
 databases, we should pick the one with the highest version number.
   */
   packageversion *v = NULL;
-  switch (trust)
+  switch (cbpv.Stability())
   {
 case TRUST_CURR:
   v = &(cp->curr);
@@ -391,6 +391,8 @@ IniDBBuilderPackage::add_correct_version()
 case TRUST_TEST:
   v = &(cp->exp);
 break;
+default:
+break;
   }
 
   if (v)
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index dee65d4..8825add 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -48,7 +48,7 @@ public:
   void buildPackageSource (const std::string& path, const std::string& size)
   { buildPackageSource(path, size, NULL, hashType::none); }
 
-  void buildPackageTrust (int);
+  void buildPackageTrust (package_stability_t);
   void buildPackageCategory (const std::string& );
 
   void buildBeginDepends ();
@@ -80,7 +80,6 @@ private:
   packageversion cspv;
   PackageSpecification *currentSpec;
   PackageDepends currentNodeList;
-  int trust;
   IniParseFeedback const &_feedback;
 };
 
diff --git a/cygpackage.cc b/cygpackage.cc
index 32b9403..2724249 100644
--- a/cygpackage.cc
+++ b/cygpackage.cc
@@ -134,10 +134,3 @@ cygpackage::set_ldesc (const std::string& desc)
 {
   ldesc = desc;
 }
-
-#if 0
-package_stability_t cygpackage::Stability ()
-{
-  return stability;
-}
-#endif
diff --git a/cygpackage.h b/cygpackage.h
index c6d0657..720921d 100644
--- a/cygpackage.h
+++ b/cygpackage.h
@@ -31,6 +31,14 @@ public:
   virtual const std::string Vendor_version ();
   virtual const std::string Package_version ();
   virtual const std::string Canonical_version ();
+  virtual package_stability_t Stability ()
+  {
+return stability;
+  }
+  virtual void SetStability (package_stability_t newstability)
+  {
+stability = newstability;
+  }
   virtual package_type_t Type ()
   {
 return type;
@@ -67,7 +75,7 @@ private:
   std::string canonical;
   std::string sdesc, ldesc;
 
-//  package_stability_t stability;
+  package_stability_t stability;
   package_type_t type;
 };
 
diff --git a/package_version.cc b/package_version.cc
index 6e8f692..2d4416e 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -43,6 +43,8 @@ public:
   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& ) {}
@@ -158,6 +160,18 @@ packageversion::setCanonicalVersion (const std::string& 
ver)
   data->setCanonicalVersion (ver);
 }
 
+package_stability_t
+packageversion::Stability () const
+{
+  return data->Stability ();
+}
+
+void
+packageversion::SetStability (package_stability_t stability)
+{
+  data->SetStability (stability);
+}
+
 package_type_t
 packageversion::Type () const
 {
diff --git a/package_version.h b/package_version.h
index 4c04d77..21d053e 100644
--- a/package_version.h
+++ b/package_version.h
@@ -45,14 +45,7 @@ class CategoryList;
 #include "PackageTrust.h"
 #include "package_depends.h"
 
-typedef enum
-{
-  package_invalid,
-  pa

[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 amd cygwin source packages
- */
-
-#include "pac

[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 (&defaultversion)
-{
-  ++data->references;
-}
-
-/* Create from an actual packa

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

2017-05-31 Thread Jon Turney
nst PackageSpecification::_operators
+PackageSpecification::op() const
+{
+  return _operator;
+}
+
+const std::string&
+PackageSpecification::version() const
+{
+  return _version;
+}
+
 void
 PackageSpecification::setOperator (_operators anOperator)
 {
diff --git a/PackageSpecification.h b/PackageSpecification.h
index 4c3ed6d..ef992fa 100644
--- a/PackageSpecification.h
+++ b/PackageSpecification.h
@@ -39,6 +39,9 @@ public:
   };
 
   const std::string& packageName() const;
+  const _operators op() const;
+  const std::string& version() const;
+
   void setOperator (_operators);
   void setVersion (const std::string& );
 
diff --git a/configure.ac b/configure.ac
index ab548c0..421b9b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,7 @@ AC_CHECK_HEADER(zlib.h, , missing_deps="$missing_deps zlib")
 AC_CHECK_HEADER(bzlib.h, , missing_deps="$missing_deps libbz2")
 AC_CHECK_HEADER(lzma.h, , missing_deps="$missing_deps liblzma")
 AC_CHECK_HEADER(gcrypt.h, , missing_deps="$missing_deps libgcrypt")
+AC_CHECK_HEADER(solv/pool.h, , missing_deps="$missing_deps libsolv")
 
 if test -n "$missing_deps"; then
AC_MSG_ERROR([missing prerequisites: $missing_deps])
diff --git a/ini.cc b/ini.cc
index 1162b91..b324e73 100644
--- a/ini.cc
+++ b/ini.cc
@@ -346,15 +346,14 @@ 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.read();
   db.upgrade();
 
   if (ini_count == 0)
diff --git a/libsolv.cc b/libsolv.cc
new file mode 100644
index 000..67c68b5
--- /dev/null
+++ b/libsolv.cc
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 2017 Jon Turney
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ */
+
+#include "libsolv.h"
+
+#include "solv/solver.h"
+#include "solv/solverdebug.h"
+#include "solv/evr.h"
+
+#include "LogSingleton.h"
+
+// ---
+// Utility functions for mapping between Operators and Relation Ids
+// ---
+
+static Id
+Operator2RelId(PackageSpecification::_operators op)
+{
+  switch (op)
+{
+case PackageSpecification::Equals:
+  return REL_EQ;
+case PackageSpecification::LessThan:
+  return REL_LT;
+case PackageSpecification::MoreThan:
+  return REL_GT;
+case PackageSpecification::LessThanEquals:
+  return REL_LT | REL_EQ;
+case PackageSpecification::MoreThanEquals:
+  return REL_GT | REL_EQ;
+}
+
+  return 0;
+}
+
+static PackageSpecification::_operators
+RelId2Operator(Id id)
+{
+  switch (id)
+{
+case REL_EQ:
+  return PackageSpecification::Equals;
+case REL_LT:
+  return PackageSpecification::LessThan;
+case REL_GT:
+  return PackageSpecification::MoreThan;
+case REL_LT | REL_EQ:
+  return PackageSpecification::LessThanEquals;
+case REL_GT | REL_EQ:
+  return PackageSpecification::MoreThanEquals;
+}
+
+  return PackageSpecification::Equals;
+}
+
+// ---
+// implements class SolvableVersion
+//
+// a wrapper around a libsolv Solvable
+// ---
+
+const std::string
+SolvableVersion::Name () const
+{
+  Solvable *solvable = pool_id2solvable(pool, id);
+  return std::string(pool_id2str(pool, solvable->name));
+}
+
+const std::string
+SolvableVersion::Canonical_version() const
+{
+  Solvable *solvable = pool_id2solvable(pool, id);
+  return std::string(pool_id2str(pool, solvable->evr));
+}
+
+package_type_t
+SolvableVersion::Type () const
+{
+  Solvable *solvable = pool_id2solvable(pool, id);
+  if (solvable->arch == ARCH_SRC)
+return package_source;
+  else
+return package_binary;
+}
+
+const PackageDepends
+SolvableVersion::depends() const
+{
+  Solvable *solvable = pool_id2solvable(pool, id);
+
+  Queue q;
+  queue_init(&q);
+
+  if (repo_lookup_idarray(solvable->repo, id, SOLVABLE_REQUIRES, &q))
+{
+  // convert
+  PackageDepends dep;
+
+  for (int i = 0; i < q.count; i++)
+{
+#ifdef DEBUG
+  Log (LOG_PLAIN) << "dep " << std::hex << q.elements[i] << ": " << 
pool_dep2str(pool, q.elements[i]) << endLog;
+#endif
+
+  const c

[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 = ¤tNodeList;
+  dependsNodeList= PackageDepends();
+  currentNodeList = &dependsNodeList;
+  cbpv.requires = &dependsNodeList;
 }
 
 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 = &obsoletesNodeList;
+  cbpv.obsoletes = &obsoletesNodeList;
+}
+
+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 &pkgdata
   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:
 Pa

[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 &t = 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, sour

[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 &operator<<(std::ostream &stream,
+ 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 &tasks, 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(&job);
+  // 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 &sv = (*i).first;
+
+  switch ((*i).second)
+{
+case SolverTasks::taskInstall:
+  queue_push2(&job, SOLVER_INSTALL | SOLVER_SOLVABLE, sv.id);
+  break;
+case SolverTasks::taskUninstall:
+  queue_push2(&job, 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(&job, 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

Re: ITP stoken 0.91

2017-06-04 Thread Jon Turney

On 27/05/2017 22:18, David Burrow wrote:

Initial submission

 From the author's website: https://sourceforge.net/p/stoken/wiki/Home/

stoken - Software Token for Linux/UNIX


Thanks.  I have a few comments.

stoken.cygport:

It's not necessary to have an empty PATCH_URI

It's probably a good idea add separate packages (libstoken1, 
libstoken-devle)  for the shared library and /usr/{include,lib} files, 
respectively.


You should probably add CYGCONF_ARGS="--with-gtk --with-nettle" so we 
don't build with different configuration if the requirements aren't present.


You should add DEPEND="pkgconfig(gtk+-3.0) pkgconfig(libxml-2.0) 
pkgconfig(nettle) pkgconfig(hogweed)" to describe the build-time 
dependencies.


<    1   2   3   4   5   6   7   8   9   10   >