Files
MINGW-packages/mingw-w64-octopi-git/0009-MSYS2-Add-getMSYS2Root.patch
2016-06-01 21:10:15 +01:00

79 lines
2.2 KiB
Diff

From af89197e56c4ee3cc377c50f7ef615c081562593 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sat, 27 Sep 2014 15:38:23 +0100
Subject: [PATCH 09/14] MSYS2: Add getMSYS2Root()
Because MSYS2 can be installed anywhere, the real location
is determined using a relative path from octopi.exe
---
src/unixcommand.cpp | 1 +
src/unixcommand.h | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/src/unixcommand.cpp b/src/unixcommand.cpp
index 4d4acbc..e1ad5a0 100644
--- a/src/unixcommand.cpp
+++ b/src/unixcommand.cpp
@@ -37,6 +37,7 @@
QFile *UnixCommand::m_temporaryFile = 0;
QProcessEnvironment *UnixCommand::m_env = 0;
+QString UnixCommand::m_msys2Root;
/*
* Executes given command and returns the StandardError Output.
diff --git a/src/unixcommand.h b/src/unixcommand.h
index b72c193..3d09880 100644
--- a/src/unixcommand.h
+++ b/src/unixcommand.h
@@ -24,6 +24,7 @@
#include <QObject>
#include <QProcess>
#include <QTime>
+#include <QCoreApplication>
#include <unistd.h>
#include "package.h"
@@ -45,6 +46,7 @@ private:
QProcess *m_process;
static QFile *m_temporaryFile;
static QProcessEnvironment *m_env;
+ static QString m_msys2Root;
public:
UnixCommand(QObject *parent);
@@ -116,6 +118,14 @@ public:
return (uid == 0); //Returns TRUE if root is running Octopi
}
+ static QString getMSYS2Root(){
+ if (m_msys2Root.isEmpty())
+ {
+ m_msys2Root = QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String("/../.."));
+ }
+ return m_msys2Root;
+ }
+
static QProcessEnvironment const& getEnv(){
if (!m_env)
{
@@ -126,6 +136,15 @@ public:
m_env->insert("LANG", "C");
m_env->insert("LC_MESSAGES", "C");
m_env->insert("LC_ALL", "C");
+ if (UnixCommand::getLinuxDistro() == ectn_MSYS2)
+ {
+ getMSYS2Root();
+ QString path = m_env->value(QLatin1String("PATH"));
+ QString msys2_usr_bin = QDir::cleanPath(m_msys2Root + "\\usr\\bin");
+ path.prepend(msys2_usr_bin+QLatin1Char(';'));
+ _wputenv_s(L"PATH", path.toStdWString().c_str());
+ m_env->insert("PATH", path);
+ }
}
return *m_env;
}
--
2.8.2