From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71632 invoked by alias); 24 Jan 2017 14:09:57 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 71612 invoked by uid 9795); 24 Jan 2017 14:09:57 -0000 Date: Tue, 24 Jan 2017 14:09:00 -0000 Message-ID: <20170124140957.71586.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program used to install Cygwin and keep it up to date] branch master, updated. release_2.877-9-gc123d34 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: bec58ba1fef9109eebcbfff0cb884bb200286d73 X-Git-Newrev: c123d344c7702e8d2d48a378991c130a20e337b8 X-SW-Source: 2017-q1/txt/msg00007.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=c123d344c7702e8d2d48a378991c130a20e337b8 commit c123d344c7702e8d2d48a378991c130a20e337b8 Author: Jon Turney Date: Sat Jan 21 18:07:02 2017 +0000 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 Diff: --- 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 */