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>
This commit is contained in:
David Schulz
2021-10-05 13:39:13 +02:00
parent 372b0c9b7e
commit 0f480cee70

View File

@@ -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});