public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [setup - the official Cygwin setup program] branch master, updated. release_2.908
@ 2021-04-25 11:55 Jon TURNEY
  0 siblings, 0 replies; only message in thread
From: Jon TURNEY @ 2021-04-25 11:55 UTC (permalink / raw)
  To: cygwin-apps-cvs




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=78edbfe458b9354ad248870fc506a9d72bf2ea1a

commit 78edbfe458b9354ad248870fc506a9d72bf2ea1a
Author: David Allsopp <David.Allsopp@cl.cam.ac.uk>
Date:   Tue Apr 20 15:23:52 2021 +0100

    Add --allow-test-packages

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=bacef89a667091df41a57b2bd6d7c5b14e22e9ca

commit bacef89a667091df41a57b2bd6d7c5b14e22e9ca
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Aug 27 15:48:06 2020 +0100

    Handle '--packages package=version'
    
    Handle '--packages package=version' to allow specifing the version of a
    package to install on the command line.
    
    isManuallyWanted() now returns the target packageversion (if specified),
    or an empty packageversion (which is translated into an instruction to
    the solver to choose the version).
    
    In the 'upgrade' case, this changes from using the complex logic of
    packagemeta::trustp() to determine the target version, when unspecified
    on the command line, to allowing the solver to make that decision (which
    should be broadly the same i.e. not downgrading test versions, etc.).
    
    This also subtly changes the behaviour when the package version is not
    specified.  Instead of forcing the current version, we allow the solver
    to choose the version, so it may not pick that version, if other
    constraints exist, which prevent a solution containing that version.
    
    There's probably some future work which can be done to simplify the
    remaining uses packagemeta::trustp(), which are only related to the UI.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=eb62a79ad327ef83ca2d2e5316b149c29927ea42

commit eb62a79ad327ef83ca2d2e5316b149c29927ea42
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Sep 16 16:14:56 2020 +0100

    Add GUI language to default User-Agent string

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=4936dbcac72a22505e3aa8a9cd879d3f3aaece61

commit 4936dbcac72a22505e3aa8a9cd879d3f3aaece61
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Apr 15 18:13:07 2021 +0100

    Putative changes to bitness reporting for Win64-on-ARM64


Diff:
---
 choose.cc       | 17 +++++++++-----
 nio-ie5.cc      | 64 +++++++++++++++++++++++++++++++++------------------
 package_meta.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 package_meta.h  |  3 ++-
 win32.cc        |  6 ++---
 5 files changed, 124 insertions(+), 37 deletions(-)

diff --git a/choose.cc b/choose.cc
index 4fa0c749..bcff57b9 100644
--- a/choose.cc
+++ b/choose.cc
@@ -63,6 +63,7 @@ static BoolOption UpgradeAlsoOption (false, 'g', "upgrade-also", "Also upgrade i
 static BoolOption CleanOrphansOption (false, 'o', "delete-orphans", "Remove orphaned packages");
 static BoolOption ForceCurrentOption (false, 'f', "force-current", "Select the current version for all packages");
 static BoolOption PruneInstallOption (false, 'Y', "prune-install", "Prune the installation to only the requested packages");
+static BoolOption AllowTestOption (false, 't', "allow-test-packages", "Consider package versions marked test");
 
 extern ThreeBarProgressPage Progress;
 
@@ -165,7 +166,7 @@ ChooserPage::initialUpdateState()
   if (ForceCurrentOption)
     {
       update_mode_id = IDC_CHOOSE_SYNC;
-      changeTrust(update_mode_id, false, true);
+      changeTrust(update_mode_id, AllowTestOption, true);
     }
   else if (hasManualSelections && !UpgradeAlsoOption)
     {
@@ -176,7 +177,7 @@ ChooserPage::initialUpdateState()
   else
     {
       update_mode_id = IDC_CHOOSE_BEST;
-      changeTrust (update_mode_id, false, true);
+      changeTrust (update_mode_id, AllowTestOption, true);
     }
 
   static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_BEST, IDC_CHOOSE_SYNC, 0 };
@@ -251,6 +252,9 @@ ChooserPage::OnInit ()
 {
   CheckDlgButton (GetHWND (), IDC_CHOOSE_HIDE, BST_CHECKED);
 
+  if (AllowTestOption)
+    CheckDlgButton (GetHWND (), IDC_CHOOSE_EXP, BST_CHECKED);
+
   /* Populate view dropdown list with choices */
   HWND viewlist = GetDlgItem (IDC_CHOOSE_VIEW);
   SendMessage (viewlist, CB_RESETCONTENT, 0, 0);
@@ -289,7 +293,8 @@ ChooserPage::applyCommandLinePackageSelection()
        i != db.packages.end (); ++i)
     {
       packagemeta &pkg = *(i->second);
-      bool wanted    = pkg.isManuallyWanted();
+      packageversion wanted_version;
+      bool wanted    = pkg.isManuallyWanted(wanted_version);
       bool deleted   = pkg.isManuallyDeleted();
       bool base      = pkg.categories.find ("Base") != pkg.categories.end ();
       bool orphaned  = pkg.categories.find ("Orphaned") != pkg.categories.end ();
@@ -299,15 +304,15 @@ ChooserPage::applyCommandLinePackageSelection()
       bool uninstall = (!(wanted  || base) && (deleted || PruneInstallOption))
 		     || (orphaned && CleanOrphansOption);
       if (install)
-        pkg.set_action (packagemeta::Install_action, UpgradeAlsoOption ? packageversion () : pkg.curr, true);
+        pkg.set_action (packagemeta::Install_action, UpgradeAlsoOption ? packageversion () : wanted_version, true);
       else if (reinstall)
-	pkg.set_action (packagemeta::Reinstall_action, pkg.curr);
+	pkg.set_action (packagemeta::Reinstall_action, !wanted ? pkg.curr : wanted_version);
       else if (uninstall)
 	pkg.set_action (packagemeta::Uninstall_action, packageversion ());
       else if (PruneInstallOption)
 	pkg.set_action (packagemeta::NoChange_action, pkg.curr);
       else if (upgrade)
-	pkg.set_action (packagemeta::Install_action, pkg.trustp(true, TRUST_UNKNOWN));
+	pkg.set_action (packagemeta::Install_action, !wanted ? packageversion () : wanted_version);
       else
 	pkg.set_action (packagemeta::NoChange_action, pkg.installed);
     }
diff --git a/nio-ie5.cc b/nio-ie5.cc
index fe61b778..e93d6d4b 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -30,13 +30,31 @@
 #include "setup_version.h"
 #include "getopt++/StringOption.h"
 #include <sstream>
-
-#ifndef IMAGE_FILE_MACHINE_ARM64
-#define IMAGE_FILE_MACHINE_ARM64 0xAA64
-#endif
+#include <iomanip>
 
 static StringOption UserAgent ("", '\0', "user-agent", "User agent string for HTTP requests");
 
+static const std::string
+machine_name(USHORT machine)
+{
+  switch (machine)
+    {
+    case IMAGE_FILE_MACHINE_I386:
+      return "Win32";
+      break;
+    case IMAGE_FILE_MACHINE_AMD64:
+      return "Win64";
+      break;
+    case IMAGE_FILE_MACHINE_ARM64:
+      return "ARM64";
+      break;
+    default:
+      std::stringstream machine_desc;
+      machine_desc << std::hex << machine;
+      return machine_desc.str();
+    }
+}
+
 const std::string &
 determine_default_useragent(void)
 {
@@ -48,30 +66,32 @@ determine_default_useragent(void)
   std::stringstream os;
   os << "Windows NT " << OSMajorVersion() << "." << OSMinorVersion() << "." << OSBuildNumber();
 
-  std::string bitness = "Unknown";
 #ifdef __x86_64__
-  bitness = "Win64";
+  USHORT processMachine = IMAGE_FILE_MACHINE_AMD64;
 #else
+  USHORT processMachine = IMAGE_FILE_MACHINE_I386;
+#endif
+
   USHORT nativeMachine = WowNativeMachine();
-  std::stringstream native_desc;
 
-  switch (nativeMachine)
+  std::string bitness;
+  if (processMachine != nativeMachine)
+    bitness = machine_name(processMachine) + "-on-" + machine_name(nativeMachine);
+  else
+    bitness = machine_name(processMachine);
+
+  typedef LANGID (WINAPI *PFNGETTHREADUILANGUAGE)();
+  PFNGETTHREADUILANGUAGE pfnGetThreadUILanguage = (PFNGETTHREADUILANGUAGE)GetProcAddress(GetModuleHandle("kernel32"), "GetThreadUILanguage");
+  std::stringstream langid;
+  if (pfnGetThreadUILanguage)
     {
-    case IMAGE_FILE_MACHINE_I386:
-      bitness = "Win32";
-      break;
-    case IMAGE_FILE_MACHINE_AMD64:
-      bitness = "WoW64";
-      break;
-    case IMAGE_FILE_MACHINE_ARM64:
-      bitness = "WoW64-ARM64";
-      break;
-    default:
-      native_desc << "WoW64-" << std::hex << nativeMachine;
-      bitness = native_desc.str();
+      LANGID l = pfnGetThreadUILanguage();
+      langid << std::hex << std::setw(4) << std::setfill('0') << l;
     }
-#endif
-  default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ")";
+
+  default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ";" + langid.str() + ")";
+  Log (LOG_BABBLE) << "User-Agent: default is \"" << default_useragent << "\"" << endLog;
+
   return default_useragent;
 }
 
diff --git a/package_meta.cc b/package_meta.cc
index 73239f18..1c6183c6 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -214,6 +214,20 @@ packagemeta::add_version (const SolverPool::addPackageData &inpkgdata)
   return thepkg;
 }
 
+const packageversion *
+packagemeta::findVersion(std::string &version) const
+{
+  for (std::set <packageversion>::iterator i = versions.begin();
+       i != versions.end();
+       i++)
+    {
+      if (i->Canonical_version() == version)
+        return &(*i);
+    }
+
+  return NULL;
+}
+
 bool
 packagemeta::isBlacklisted(const packageversion &version) const
 {
@@ -310,10 +324,10 @@ validatePackageNames (std::set<std::string> &names)
     }
 }
 
-bool packagemeta::isManuallyWanted() const
+bool packagemeta::isManuallyWanted(packageversion &version) const
 {
   static bool parsed_yet = false;
-  static std::set<std::string> parsed_names;
+  static std::map<std::string, std::string> parsed_names;
   hasManualSelections |= parsed_names.size ();
   static std::set<std::string> parsed_categories;
   hasManualSelections |= parsed_categories.size ();
@@ -325,12 +339,40 @@ bool packagemeta::isManuallyWanted() const
   {
     std::vector<std::string> packages_options = PackageOption;
     std::vector<std::string> categories_options = CategoryOption;
+
+    std::set<std::string> items;
     for (std::vector<std::string>::iterator n = packages_options.begin ();
 		n != packages_options.end (); ++n)
       {
-	parseNames (parsed_names, *n);
+	parseNames (items, *n);
       }
-    validatePackageNames (parsed_names);
+
+    std::set<std::string> packages;
+    /* Separate any 'package=version' into package and version parts */
+    for (std::set<std::string>::iterator n = items.begin();
+         n != items.end();
+         ++n)
+      {
+        std::string package;
+        std::string version;
+        std::string::size_type loc = n->find ("=", 0);
+        if (loc != std::string::npos)
+          {
+            package = n->substr(0, loc);
+            version = n->substr(loc+1);
+          }
+        else
+          {
+            package = *n;
+            version = "";
+          }
+        Log (LOG_BABBLE) << "package: " << package << " version: " << version << endLog;
+        parsed_names[package] = version;
+        packages.insert(package);
+      }
+
+    validatePackageNames (packages);
+
     for (std::vector<std::string>::iterator n = categories_options.begin ();
 		n != categories_options.end (); ++n)
       {
@@ -341,7 +383,25 @@ bool packagemeta::isManuallyWanted() const
 
   /* Once we've already parsed the option string, just do
     a lookup in the cache of already-parsed names.  */
-  bReturn = parsed_names.find(name) != parsed_names.end();
+  std::map<std::string, std::string>::iterator i = parsed_names.find(name);
+  if (i != parsed_names.end())
+    {
+      bReturn = true;
+
+      /* Wanted version is unspecified */
+      version = packageversion();
+
+      /* ... unless a version was explicitly specified */
+      std::string v = i->second;
+      if (!v.empty())
+        {
+          const packageversion *pv = findVersion(v);
+          if (pv)
+            version = *pv;
+          else
+            Log (LOG_PLAIN) << "package: " << name << " version: " << v << " not found" << endLog;
+        }
+    }
 
   /* If we didn't select the package manually, did we select any
      of the categories it is in? */
@@ -352,6 +412,7 @@ bool packagemeta::isManuallyWanted() const
 	if (parsed_categories.find (*curcat) != parsed_categories.end ())
 	  {
 	    Log (LOG_BABBLE) << "Found category " << *curcat << " in package " << name << endLog;
+	    version = packageversion();
 	    bReturn = true;
 	  }
     }
diff --git a/package_meta.h b/package_meta.h
index 4faff410..fee385b3 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -107,7 +107,7 @@ public:
   std::string name;			/* package name, like "cygwin" */
 
   /* true if package was selected on command-line. */
-  bool isManuallyWanted() const;
+  bool isManuallyWanted(packageversion &version) const;
   /* true if package was deleted on command-line. */
   bool isManuallyDeleted() const;
 
@@ -163,6 +163,7 @@ private:
   std::string trustLabel(packageversion const &) const;
   std::vector <Script> scripts_;
   static bool scan (const packageversion &pkg, bool mirror_mode);
+  const packageversion * findVersion(std::string &version) const;
 
   _actions _action;
 
diff --git a/win32.cc b/win32.cc
index acc01bf8..ffc52e6d 100644
--- a/win32.cc
+++ b/win32.cc
@@ -398,9 +398,6 @@ VersionInfo& GetVer ()
 USHORT
 WowNativeMachine ()
 {
-#ifdef __x86_64__
-  return IMAGE_FILE_MACHINE_AMD64;
-#else
   typedef BOOL (WINAPI *PFNISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *);
   PFNISWOW64PROCESS2 pfnIsWow64Process2 = (PFNISWOW64PROCESS2)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process2");
 
@@ -416,6 +413,9 @@ WowNativeMachine ()
     if (pfnIsWow64Process(GetCurrentProcess(), &bIsWow64))
       return bIsWow64 ? IMAGE_FILE_MACHINE_AMD64 : IMAGE_FILE_MACHINE_I386;
   }
+#ifdef __x86_64__
+  return IMAGE_FILE_MACHINE_AMD64;
+#else
   return IMAGE_FILE_MACHINE_I386;
 #endif
 }



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-25 11:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-25 11:55 [setup - the official Cygwin setup program] branch master, updated. release_2.908 Jon TURNEY

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