From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id A556B385E830; Sat, 21 Mar 2020 17:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A556B385E830 To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.903-5-ga7f2d458 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: f681d72f73742906af0dda247655ea6da264fb76 X-Git-Newrev: a7f2d458db2ed508959d2a425d326b0cc94806da Message-Id: <20200321172235.A556B385E830@sourceware.org> Date: Sat, 21 Mar 2020 17:22:35 +0000 (GMT) From: Jon TURNEY X-BeenThere: cygwin-apps-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin-apps-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2020 17:22:35 -0000 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=a7f2d458db2ed508959d2a425d326b0cc94806da commit a7f2d458db2ed508959d2a425d326b0cc94806da Author: Jon Turney Date: Wed Mar 18 22:04:47 2020 +0000 Fix an allocation length error Allow for the terminating null. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=2fd5251b66ff0634579c3bfd8c0d0109fc0116b7 commit 2fd5251b66ff0634579c3bfd8c0d0109fc0116b7 Author: Jon Turney Date: Tue Mar 17 15:21:50 2020 +0000 Disable old Cygwin setup signing key by default Add a new option '--enable-old-keys', for if you really need to install from an old mirror for some reason. '--disable-old-keys' is still accepted, but is the default now. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=8effde7afc285895e7a4d40a944ab2a7b9e51af1 commit 8effde7afc285895e7a4d40a944ab2a7b9e51af1 Author: Jon Turney Date: Tue Mar 17 14:27:02 2020 +0000 Implement paired boolean options Add some infrastructure for options which may appear with multiple prefixes. Add an implementation of paired boolean options like '--enable-foo' and '--disable-foo', or '--bar' and '--no-bar'. Add/fix tests https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=9a7997b94b5e9cf382e5094f91163f76b64ccb0f commit 9a7997b94b5e9cf382e5094f91163f76b64ccb0f Author: Jon Turney Date: Tue Mar 17 13:54:16 2020 +0000 Rename Start Menu folder for 32-bit installs on WoW64 This is not totally straightforward: Since setup can install Cygwin with either bitness (using the '--arch 32|64' option), we must do the right thing if this is a 64-bit installer being used to install 32-bit Cygwin, which will run under WoW, even if the installer isn't... (Naming things like this makes things consistent with Cygwin-X, which already names it's Start Menu folder 'Cygwin-X (32-bit)' on WoW64. It also ensures that there aren't collisions between any setup created shortcuts for 32-bit and 64-bits.) The desktop icon is already named 'Cygwin Terminal' or 'Cygwin64 Terminal' so doesn't need attention. Start menu links made in the 'Cygwin' folder by cygwin-doc, and possibly other packages will also need adjusting. https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=e73fb694a2d21f3cf36e658d9dd066b8ceaaa330 commit e73fb694a2d21f3cf36e658d9dd066b8ceaaa330 Author: Jon Turney Date: Tue Mar 17 13:52:55 2020 +0000 Factor out WoW detection Factor out WoW detection as a separate function Diff: --- archive.cc | 2 +- crypto.cc | 7 ++-- desktop.cc | 13 ++++-- libgetopt++/include/getopt++/BoolOption.h | 17 ++++++-- libgetopt++/include/getopt++/Option.h | 6 ++- libgetopt++/include/getopt++/OptionSet.h | 3 +- libgetopt++/include/getopt++/StringArrayOption.h | 2 +- libgetopt++/include/getopt++/StringOption.h | 2 +- libgetopt++/src/BoolOption.cc | 40 ++++++++++++++++--- libgetopt++/src/Option.cc | 7 ++++ libgetopt++/src/OptionSet.cc | 50 +++++++++++++++--------- libgetopt++/src/StringArrayOption.cc | 2 +- libgetopt++/src/StringOption.cc | 2 +- libgetopt++/tests/BoolOptionTest.cc | 26 +++++++++--- libgetopt++/tests/OptionSet.cc | 4 +- nio-ie5.cc | 45 ++++++++------------- win32.cc | 26 ++++++++++++ win32.h | 2 + 18 files changed, 177 insertions(+), 79 deletions(-) diff --git a/archive.cc b/archive.cc index e4af4f7b..1ceb3552 100644 --- a/archive.cc +++ b/archive.cc @@ -173,7 +173,7 @@ archive::extract_file (archive * source, const std::string& prefixURL, break; case ARCHIVE_FILE_DIRECTORY: { - char *path = (char *) alloca (destfilename.size()); + char *path = (char *) alloca (destfilename.size() + 1); strcpy (path, destfilename.c_str()); while (path[0] && path[strlen (path) - 1] == '/') path[strlen (path) - 1] = 0; diff --git a/crypto.cc b/crypto.cc index 2e4ba218..88ced387 100644 --- a/crypto.cc +++ b/crypto.cc @@ -52,8 +52,9 @@ static BoolOption UntrustedKeysOption (false, 'u', "untrusted-keys", "Use untrusted saved extra keys"); static BoolOption KeepUntrustedKeysOption (false, 'U', "keep-untrusted-keys", "Use untrusted keys and retain all"); -static BoolOption DisableOldKeysOption (false, '\0', "disable-old-keys", - "Disable old cygwin.com keys"); +static BoolOption EnableOldKeysOption (false, '\0', "old-keys", + "Enable old cygwin.com keys", + BoolOption::BoolOptionType::pairedAble); /* Embedded public half of Cygwin signing key. */ static const char *cygwin_pubkey_sexpr = @@ -708,7 +709,7 @@ verify_ini_file_sig (io_stream *ini_file, io_stream *ini_sig_file, HWND owner) /* If not disabled, also try the old built-in key */ gcry_sexp_t cygwin_old_key; - if (!DisableOldKeysOption) + if (EnableOldKeysOption) { rv = gcry_sexp_new (&cygwin_old_key, cygwin_old_pubkey_sexpr, strlen (cygwin_old_pubkey_sexpr), 1); if (rv != GPG_ERR_NO_ERROR) diff --git a/desktop.cc b/desktop.cc index eec8ca91..29dbf635 100644 --- a/desktop.cc +++ b/desktop.cc @@ -95,6 +95,14 @@ make_link (const std::string& linkpath, icon.c_str(), fname.c_str()); } +static const char *startmenudir() +{ + if (!is_64bit && (WowNativeMachine() != IMAGE_FILE_MACHINE_I386)) + return "/Cygwin (32-bit)"; + else + return "/Cygwin"; +} + static void start_menu (const std::string& title, const std::string& target, const std::string& arg, const std::string& iconpath) @@ -107,7 +115,7 @@ start_menu (const std::string& title, const std::string& target, issystem ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, &id); SHGetPathFromIDList (id, path); - strncat (path, "/Cygwin", MAX_PATH - strlen(path) - 1); + strncat (path, startmenudir(), MAX_PATH - strlen(path) - 1); LogBabblePrintf ("Program directory for program link: %s", path); make_link (path, title, target, arg, iconpath); } @@ -194,7 +202,6 @@ save_icon (std::string &iconpath, const char *resource_name) #define TERMINALICON "/Cygwin-Terminal.ico" #define TERMINALTITLE (is_64bit ? "Cygwin64 Terminal" \ : "Cygwin Terminal") -#define STARTMENUDIR "/Cygwin" static void do_desktop_setup () @@ -300,7 +307,7 @@ check_startmenu (const std::string title, const std::string target) CSIDL_PROGRAMS, &id); SHGetPathFromIDList (id, path); LogBabblePrintf ("Program directory for program link: %s", path); - strcat (path, STARTMENUDIR); + strcat (path, startmenudir()); std::string fname = std::string(path) + "/" + title + ".lnk"; if (_access (fname.c_str(), 0) == 0) diff --git a/libgetopt++/include/getopt++/BoolOption.h b/libgetopt++/include/getopt++/BoolOption.h index 35227cb1..8b20e1cc 100644 --- a/libgetopt++/include/getopt++/BoolOption.h +++ b/libgetopt++/include/getopt++/BoolOption.h @@ -23,17 +23,25 @@ class BoolOption : public Option { public: + enum class BoolOptionType + { + simple, + pairedAble, + pairedNo, + }; + BoolOption(bool const defaultvalue, char shortopt, char const *longopt = 0, - std::string const &shorthelp = std::string(), - OptionSet &owner=GetOption::GetInstance()); + std::string const &shorthelp = std::string(), + BoolOptionType type = BoolOptionType::simple, + OptionSet &owner=GetOption::GetInstance()); virtual ~ BoolOption (); virtual std::string const shortOption () const; virtual std::string const longOption () const; + virtual std::vector const & longOptionPrefixes () const; virtual std::string const shortHelp () const; - virtual Result Process (char const *); + virtual Result Process (char const *, int); virtual Argument argument () const; operator bool () const; - private: bool _value; @@ -41,6 +49,7 @@ private: char _shortopt; char const *_longopt; std::string _shorthelp; + BoolOptionType _type; }; #endif // _BOOLOPTION_H_ diff --git a/libgetopt++/include/getopt++/Option.h b/libgetopt++/include/getopt++/Option.h index a32f9495..b3b140ff 100644 --- a/libgetopt++/include/getopt++/Option.h +++ b/libgetopt++/include/getopt++/Option.h @@ -21,9 +21,10 @@ #endif #if HAVE_STRING_H #include -#else +#else #error " required" #endif +#include // Each registered option must implement this class. class Option @@ -32,13 +33,14 @@ public: virtual ~ Option (); virtual std::string const shortOption () const = 0; virtual std::string const longOption () const = 0; + virtual std::vector const & longOptionPrefixes () const; virtual std::string const shortHelp () const = 0; enum Result { Failed, Ok, Stop }; - virtual Result Process (char const *) = 0; + virtual Result Process (char const *, int) = 0; enum Argument { None, Optional, diff --git a/libgetopt++/include/getopt++/OptionSet.h b/libgetopt++/include/getopt++/OptionSet.h index 4ccaddaf..dbd8046b 100644 --- a/libgetopt++/include/getopt++/OptionSet.h +++ b/libgetopt++/include/getopt++/OptionSet.h @@ -44,7 +44,8 @@ private: bool isOption(std::string::size_type) const; void doOption(std::string &option, std::string::size_type const &pos); bool doNoArgumentOption(std::string &option, std::string::size_type const &pos); - Option * findOption(std::string &option, std::string::size_type const &pos) const; + void findOption(std::string &option, std::string::size_type const &pos, + Option *&theOption, int & prefixIndex) const; std::vector