public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup] Add --allow-unsupported-windows option
@ 2017-01-22 14:27 Jon Turney
  2017-01-23 10:38 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Turney @ 2017-01-22 14:27 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

This patch was suggested in a discussion with Peter Castro.

The concern is that using old versions of setup to install time machine
mirrors is not ideal, as it misses possible fixes in newer versions of
setup.

However, we do want to make it hard for someone to destroy their working XP
installation, so allowing setup to simply run on XP, which will break it by
upgrading it to the latest version (which doesn't work on XP), seems
contraindicated.

When --allow-unsupported-windows is on:
- Don't check the windows version
- Don't read the mirror list from cygwin.com
- Don't use any stored mirror selection in the 'last-mirror' key (as this
may point to a cygwin mirror, which, if we install from will break things)
- Retain the mirror selection (presumably a time machine circa given with
--site or via the GUI) in an alternate key 'last-mirror-unsupported'

Also, for discoverability, rearrange things so --help works even on
unsupported windows versions

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 main.cc | 21 ++++++++++++---------
 site.cc | 18 ++++++++++++++++--
 site.h  |  1 +
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/main.cc b/main.cc
index e1f1def..fe1d6c1 100644
--- a/main.cc
+++ b/main.cc
@@ -94,6 +94,7 @@ static BoolOption NoAdminOption (false, 'B', "no-admin", "Do not check for and e
 static BoolOption WaitOption (false, 'W', "wait", "When elevating, wait for elevated child process");
 static BoolOption HelpOption (false, 'h', "help", "print help");
 static StringOption SetupBaseNameOpt ("setup", 'i', "ini-basename", "Use a different basename, e.g. \"foo\", instead of \"setup\"", false);
+BoolOption UnsupportedOption (false, '0', "allow-unsupported-windows", "Allow old, unsupported Windows versions");
 std::string SetupBaseName;
 
 static void inline
@@ -286,14 +287,6 @@ WinMain (HINSTANCE h,
 			<< setup_version << endLog;
       }
 
-    /* Check if Cygwin works on this Windows version */
-    if (OSMajorVersion () < 6)
-      {
-	mbox (NULL, "Cygwin is not supported on this Windows version",
-	      "Cygwin Setup", MB_ICONEXCLAMATION | MB_OK);
-	Logger ().exit (1, false);
-      }
-
     if (help_option)
       {
 	if (invalid_option)
@@ -302,8 +295,18 @@ WinMain (HINSTANCE h,
 	GetOption::GetInstance ().ParameterUsage (Log (LOG_PLAIN));
 	Log (LOG_PLAIN) << endLog;
 	Logger ().exit (invalid_option ? 1 : 0, false);
+	goto finish_up;
       }
-    else if (elevate)
+
+    /* Check if Cygwin works on this Windows version */
+    if (!UnsupportedOption && (OSMajorVersion () < 6))
+      {
+	mbox (NULL, "Cygwin is not supported on this Windows version",
+	      "Cygwin Setup", MB_ICONEXCLAMATION | MB_OK);
+	Logger ().exit (1, false);
+      }
+
+    if (elevate)
       {
 	char exe_path[MAX_PATH];
 	if (!GetModuleFileName(NULL, exe_path, ARRAYSIZE(exe_path)))
diff --git a/site.cc b/site.cc
index 1ff3a39..b05657b 100644
--- a/site.cc
+++ b/site.cc
@@ -97,6 +97,7 @@ SiteList dropped_site_list;
 StringArrayOption SiteOption('s', "site", "Download site");
 
 BoolOption OnlySiteOption(false, 'O', "only-site", "Ignore all sites except for -s");
+extern BoolOption UnsupportedOption;
 
 SiteSetting::SiteSetting (): saved (false)
 {
@@ -111,10 +112,19 @@ SiteSetting::SiteSetting (): saved (false)
     getSavedSites ();
 }
 
+const char *
+SiteSetting::lastMirrorKey ()
+{
+  if (UnsupportedOption)
+    return "last-mirror-unsupported";
+
+  return "last-mirror";
+}
+
 void 
 SiteSetting::save()
 {
-  io_stream *f = UserSettings::instance().open ("last-mirror");
+  io_stream *f = UserSettings::instance().open (lastMirrorKey ());
   if (f)
     {
       for (SiteList::const_iterator n = site_list.begin ();
@@ -305,6 +315,10 @@ get_site_list (HINSTANCE h, HWND owner)
   char mirror_url[1000];
 
   char *theMirrorString, *theCachedString;
+
+  if (UnsupportedOption)
+    return 0;
+
   const char *cached_mirrors = OnlySiteOption ? NULL : UserSettings::instance().get ("mirrors-lst");
   if (cached_mirrors)
     {
@@ -385,7 +399,7 @@ SiteSetting::registerSavedSite (const char * site)
 void
 SiteSetting::getSavedSites ()
 {
-  const char *buf = UserSettings::instance().get ("last-mirror");
+  const char *buf = UserSettings::instance().get (lastMirrorKey ());
   if (!buf)
     return;
   char *fg_ret = strdup (buf);
diff --git a/site.h b/site.h
index 529ac31..457aaee 100644
--- a/site.h
+++ b/site.h
@@ -87,6 +87,7 @@ class SiteSetting
     bool saved;
     void getSavedSites();
     void registerSavedSite(char const *);
+    const char *lastMirrorKey();
 };
 
 #endif /* SETUP_SITE_H */
-- 
2.8.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH setup] Add --allow-unsupported-windows option
  2017-01-22 14:27 [PATCH setup] Add --allow-unsupported-windows option Jon Turney
@ 2017-01-23 10:38 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-01-23 10:38 UTC (permalink / raw)
  To: cygwin-apps

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

On Jan 22 14:27, Jon Turney wrote:
> This patch was suggested in a discussion with Peter Castro.
> 
> The concern is that using old versions of setup to install time machine
> mirrors is not ideal, as it misses possible fixes in newer versions of
> setup.
> 
> However, we do want to make it hard for someone to destroy their working XP
> installation, so allowing setup to simply run on XP, which will break it by
> upgrading it to the latest version (which doesn't work on XP), seems
> contraindicated.
> 
> When --allow-unsupported-windows is on:
> - Don't check the windows version
> - Don't read the mirror list from cygwin.com
> - Don't use any stored mirror selection in the 'last-mirror' key (as this
> may point to a cygwin mirror, which, if we install from will break things)
> - Retain the mirror selection (presumably a time machine circa given with
> --site or via the GUI) in an alternate key 'last-mirror-unsupported'
> 
> Also, for discoverability, rearrange things so --help works even on
> unsupported windows versions

ACK


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-23 10:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-22 14:27 [PATCH setup] Add --allow-unsupported-windows option Jon Turney
2017-01-23 10:38 ` Corinna Vinschen

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).