aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2021-10-05 13:39:13 +0200
committerDavid Schulz <david.schulz@qt.io>2021-10-06 09:56:53 +0000
commit0f480cee70a2bf0e4a99b9cfcd93194a00aa8f81 (patch)
treea0903785d41c81469c69f1438fa238983722b51f
parent372b0c9b7e6e4cb4ccd46a027d3c578b9b664d66 (diff)
Docker: allow windows style paths in settings
Makes sure to convert it to unix style path on the target and use the correct capitalisation on the host Change-Id: I0c6dff47c34c1844a8198c3215ea857fdb6375c7 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/docker/dockerdevice.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp
index bc732796a4..11be0ce2b0 100644
--- a/src/plugins/docker/dockerdevice.cpp
+++ b/src/plugins/docker/dockerdevice.cpp
@@ -834,9 +834,18 @@ void DockerDevicePrivate::startContainer()
dockerRun.addArgs({"-u", QString("%1:%2").arg(getuid()).arg(getgid())});
#endif
- for (const QString &mount : qAsConst(m_data.mounts)) {
- if (!mount.isEmpty())
- dockerRun.addArgs({"-v", mount + ':' + mount});
+ for (QString mount : qAsConst(m_data.mounts)) {
+ if (mount.isEmpty())
+ continue;
+ // make sure to convert windows style paths to unix style paths with the file system case:
+ // C:/dev/src -> /c/dev/src
+ if (const FilePath mountPath = FilePath::fromUserInput(mount).normalizedPathName();
+ mountPath.startsWithDriveLetter()) {
+ const QChar lowerDriveLetter = mountPath.path().at(0).toLower();
+ const FilePath path = FilePath::fromUserInput(mountPath.path().mid(2)); // strip C:
+ mount = '/' + lowerDriveLetter + path.path();
+ }
+ dockerRun.addArgs({"-v", mount + ':' + mount});
}
dockerRun.addArgs({"--entrypoint", "/bin/sh", m_data.imageId});