]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Add --allow-unsupported-windows option
authorJon Turney <jon.turney@dronecode.org.uk>
Sat, 21 Jan 2017 18:07:02 +0000 (18:07 +0000)
committerJon Turney <jon.turney@dronecode.org.uk>
Tue, 24 Jan 2017 13:39:49 +0000 (13:39 +0000)
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

main.cc
site.cc
site.h

diff --git a/main.cc b/main.cc
index e1f1defa60bb4bdd5e8739eea8e547168d2de582..fe1d6c1987c5f5aab911adb69cf32fc110e2725c 100644 (file)
--- 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 1ff3a39bad22f82a568cca8f85d16879b675772e..b05657b864d9f57675233497e32641e6d346a124 100644 (file)
--- 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 529ac31d037967f7f3c2623f3f0ba287add7ae62..457aaeecd9d2d373f1bcc50430725cfbc10ca181 100644 (file)
--- 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 */
This page took 0.056605 seconds and 5 git commands to generate.