This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup] Add --allow-unsupported-windows option


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]