public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: "cygwin-apps@cygwin.com" <cygwin-apps@cygwin.com>
Subject: Re: setup: problems with local install
Date: Tue, 06 Mar 2018 15:18:00 -0000	[thread overview]
Message-ID: <76209447-c5a7-2fa4-941e-4040a2de484f@dronecode.org.uk> (raw)
In-Reply-To: <3cd80653-6a63-ae3d-d79c-a1642ad63fce@cornell.edu>

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

On 05/03/2018 18:34, Ken Brown wrote:
> This is a followup to the thread started here:
> 
>    https://cygwin.com/ml/cygwin/2018-03/msg00027.html
> 
> There are two problems with installing from a local directory.

Thanks very much for looking into these.

> 2. In several of the views, all packages from setup.ini are listed, even 
> if there is no corresponding archive in the local directory.  What 
> happens is that packagemeta::scan() calls pkg.source()->sites.clear() 
> for such packages, but this information is never used to prevent the 
> package from appearing in the list.
> 
> It used to be that such packages would be declared inaccessible, but 
> SolvableVersion::accessible() no longer does this.
> 
> Jon, you wrote the following comment in the definition of 
> SolvableVersion::accessible():
> 
> "The 'accessible' check used to test if an archive was available locally 
> or from a mirror.  This seems utterly pointless as binary packages which 
> aren't 'accessible' never get to appear in the package list."
> 
> Do we need to reinstate the old function of the accessibility check?

I guess I looked at packagemeta::ScanDownloadedFiles() and saw that it 
was removing versions, and thought everything was good.

I didn't notice accessible() was indirectly how the result of scan() was 
returned :S

So yeah, I guess putting some complexity back in accessible() would 
work, or perhaps the attached?  (This doesn't do the right thing for a 
few packages, for reasons I'm still looking into...)

(I also note we have also have another 'erase an element from a vector 
while we are iterating over it' here, so that needs fixing, as well)

I'm kind of uncertain what the side-effects of this code are when source 
!= IDC_SOURCE_LOCALDIR, or if they are desired?  Perhaps it's removing 
packages which have corrupt local copies or something?  It would be 
clearer to omit the whole thing in that case.


[-- Attachment #2: 0001-Fix-packagemeta-ScanDownloadedFiles.patch --]
[-- Type: text/plain, Size: 2759 bytes --]

From d8aac08cf3d1ddf98ab9a6a8706b2c7b8bdfd7ad Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Tue, 6 Mar 2018 14:56:40 +0000
Subject: [PATCH setup] Fix packagemeta::ScanDownloadedFiles

packagemeta::scan clears the site list if the package was not found, and
packagemeta::ScanDownloadedFiles uses packageversion::accessible() to check
that.

Instead communicate via a return value
---
 package_meta.cc | 27 ++++++++++++---------------
 package_meta.h  |  2 +-
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/package_meta.cc b/package_meta.cc
index c488e35..f0a0c20 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -664,33 +664,30 @@ packagemeta::logSelectionStatus() const
 }
 
 /* scan for local copies of package */
-void
+bool
 packagemeta::scan (const packageversion &pkg, bool mirror_mode)
 {
-  /* Already have something */
+  /* empty version */
   if (!pkg)
-    return;
+    return true;
 
-  /* Remove mirror sites.
-   * FIXME: This is a bit of a hack.
-   */
   try
     {
       if (!check_for_cached (*(pkg.source ()), NULL, mirror_mode, false)
-	  && ::source == IDC_SOURCE_LOCALDIR)
-	pkg.source ()->sites.clear ();
+          && ::source == IDC_SOURCE_LOCALDIR)
+        return false;
     }
   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;
-	}
+        return false;
+
       // Unexpected exception.
       throw e;
     }
+
+  return true;
 }
 
 void
@@ -712,15 +709,15 @@ packagemeta::ScanDownloadedFiles (bool mirror_mode)
 			   && (*i != pkg.installed
 			       || pkg.installed == pkg.curr
 			       || pkg.installed == pkg.exp);
-	  scan (*i, lazy_scan);
+	  bool accessible = scan (*i, lazy_scan);
 	  packageversion foo = *i;
 	  packageversion pkgsrcver = foo.sourcePackage ();
-	  scan (pkgsrcver, lazy_scan);
+	  bool src_accessible = scan (pkgsrcver, lazy_scan);
 
 	  /* For local installs, if there is no src and no bin, the version
 	   * is unavailable
 	   */
-	  if (!i->accessible () && !pkgsrcver.accessible ()
+	  if (!accessible && !src_accessible
 	      && *i != pkg.installed)
 	    {
 	      if (pkg.curr == *i)
diff --git a/package_meta.h b/package_meta.h
index 32372e2..600a163 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -170,7 +170,7 @@ protected:
 private:
   std::string trustLabel(packageversion const &) const;
   std::vector <Script> scripts_;
-  static void scan (const packageversion &pkg, bool mirror_mode);
+  static bool scan (const packageversion &pkg, bool mirror_mode);
 
   bool _picked; /* true if desired version is to be (re)installed */
   bool _srcpicked;
-- 
2.16.2


  parent reply	other threads:[~2018-03-06 15:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 18:34 Ken Brown
2018-03-06  2:18 ` Ken Brown
2018-03-06 16:38   ` Jon Turney
2018-03-06 15:18 ` Jon Turney [this message]
2018-03-06 18:47   ` Jon Turney
2018-03-07 21:53     ` Ken Brown
2018-03-08 15:59       ` Ken Brown
2018-03-08 21:59         ` Ken Brown
2018-03-12 13:22           ` Ken Brown
2018-03-14 16:07             ` Jon Turney
2018-03-14 19:25               ` Ken Brown
2018-03-15 21:02                 ` Jon Turney
2018-03-06 19:31   ` Ken Brown
2018-03-06 22:13     ` Jon Turney
2018-03-07  7:32     ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76209447-c5a7-2fa4-941e-4040a2de484f@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).