]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Propagate --symlink-type setting to post-install scripts
authorJon Turney <jon.turney@dronecode.org.uk>
Sat, 31 Jul 2021 11:54:00 +0000 (12:54 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Tue, 28 Sep 2021 13:59:49 +0000 (14:59 +0100)
Propagate --symlink-type setting to post-install scripts, by setting the
CYGWIN env var appropriately.

script.cc

index 69dc1155dfb08cd59f8b164b78ce1df70567f07d..6818f4b255c0696ed9beff4baa201377a5bb718a 100644 (file)
--- a/script.cc
+++ b/script.cc
@@ -36,6 +36,7 @@
 #define alloca __builtin_alloca
 #endif
 #endif
+#include "mklink2.h"
 
 static std::string sh, dash;
 static const char *cmd;
@@ -71,6 +72,40 @@ sanitize_PATH ()
   SetEnvironmentVariable ("PATH", newpath.c_str());
 }
 
+static void
+modify_CYGWIN ()
+{
+  std::string cygwin;
+  DWORD len = GetEnvironmentVariable ("CYGWIN", &cygwin[0], 0);
+  if (len > 0)
+    {
+      cygwin.resize(len);
+      GetEnvironmentVariable ("CYGWIN", &cygwin[0], len);
+      cygwin.resize(len-1); // trim terminating null
+      cygwin.append(" ");
+    }
+
+  switch (symlinkType)
+    {
+    case SymlinkTypeNative:
+      cygwin.append("winsymlinks:native");
+      break;
+
+    case SymlinkTypeWsl:
+      cygwin.append("winsymlinks:wsl");
+      break;
+
+    case SymlinkTypeMagic:
+      cygwin.append("winsymlinks:sys");
+      break;
+
+    case SymlinkTypeShortcut: /* not yet implemented */
+    default:
+      break;
+    }
+
+  SetEnvironmentVariable ("CYGWIN", cygwin.c_str());
+}
 
 void
 init_run_script ()
@@ -100,6 +135,7 @@ init_run_script ()
       FreeEnvironmentStrings (env);
     }
 
+  modify_CYGWIN();
   SetEnvironmentVariable ("CYGWINROOT", get_root_dir ().c_str());
   SetEnvironmentVariable ("CYGWINFORALL",
                           (root_scope == IDC_ROOT_SYSTEM) ? "-A" : NULL);
This page took 0.036776 seconds and 5 git commands to generate.