[PATCH setup 2/2] Add a command line option to choose symlink type used
Jon Turney
jon.turney@dronecode.org.uk
Sun May 23 18:27:37 GMT 2021
The default is 'magic', the historical behaviour of setup.
---
main.cc | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/main.cc b/main.cc
index b3854a8..d4ec0d2 100644
--- a/main.cc
+++ b/main.cc
@@ -63,6 +63,7 @@
#include "getopt++/GetOption.h"
#include "getopt++/BoolOption.h"
#include "getopt++/StringOption.h"
+#include "mklink2.h"
#include "Exception.h"
#include <stdexcept>
@@ -95,6 +96,8 @@ static BoolOption HelpOption (false, 'h', "help", "Print help");
static BoolOption VersionOption (false, 'V', "version", "Show version");
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");
+static StringOption SymlinkTypeOption ("magic", '\0', "symlink-type", "Symlink type (magic, shortcut, native, wsl)", false);
+
std::string SetupBaseName;
static void inline
@@ -258,6 +261,32 @@ WinMain (HINSTANCE h,
exit (1);
}
+ if (((std::string)SymlinkTypeOption).size())
+ {
+ if (((std::string)SymlinkTypeOption).compare("wsl") == 0)
+ {
+ VersionInfo v = GetVer();
+ if ((v.major() < 10) ||
+ ((v.major() == 10) && (v.buildNumber() < 14393)))
+ {
+ fprintf (stderr, "*** --symlink-type wsl requires Windows 10 1607 or later\n");
+ exit(1);
+ }
+ else
+ symlinkType = SymlinkTypeWsl;
+ }
+ else if (((std::string)SymlinkTypeOption).compare("magic") == 0)
+ symlinkType = SymlinkTypeMagic;
+ else
+ {
+ char buff[80 + ((std::string)SymlinkTypeOption).size()];
+ sprintf (buff, "Invalid choice for --symlink-type option: \"%s\"",
+ ((std::string)SymlinkTypeOption).c_str());
+ fprintf (stderr, "*** %s\n", buff);
+ exit(1);
+ }
+ }
+
unattended_mode = PackageManagerOption ? chooseronly
: (UnattendedOption ? unattended : attended);
--
2.31.1
More information about the Cygwin-apps
mailing list