From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85274 invoked by alias); 22 Jan 2017 14:27:54 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 85260 invoked by uid 89); 22 Jan 2017 14:27:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=destroy, Download, 876, 976 X-HELO: rgout0706.bt.lon5.cpcloud.co.uk Received: from rgout0706.bt.lon5.cpcloud.co.uk (HELO rgout0706.bt.lon5.cpcloud.co.uk) (65.20.0.146) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 22 Jan 2017 14:27:43 +0000 X-OWM-Source-IP: 86.166.190.63 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-Junkmail-Premium-Raw: score=7/50,refid=2.7.2:2017.1.22.135415:17:7.944,ip=,rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __CC_NAME, __CC_NAME_DIFF_FROM_ACC, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __FROM_DOMAIN_IN_ANY_CC1, __ANY_URI, __URI_NO_WWW, __CP_NAME_BODY, __NO_HTML_TAG_RAW, BODY_SIZE_4000_4999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, __FROM_DOMAIN_IN_RCPT, __MIME_TEXT_P, BODY_SIZE_7000_LESS, NO_URI_HTTPS, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS Received: from localhost.localdomain (86.166.190.63) by rgout07.bt.lon5.cpcloud.co.uk (9.0.019.13-1) (authenticated as jonturney@btinternet.com) id 58482FD703FB0B35; Sun, 22 Jan 2017 14:27:40 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup] Add --allow-unsupported-windows option Date: Sun, 22 Jan 2017 14:27:00 -0000 Message-Id: <20170122142724.252024-1-jon.turney@dronecode.org.uk> X-SW-Source: 2017-01/txt/msg00044.txt.bz2 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 --- 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