Topics

[edk2-staging/EdkRepo] [PATCH V3 2/2] EdkRepo: Add support for subst drives


Nate DeSimone
 

get_workspace_path() now converts a virtual drive path
to a real path before any git repo operations are done.

Cc: Ashley E Desimone <ashley.e.desimone@...>
Cc: Puja Pandya <puja.pandya@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Prince Agyeman <prince.agyeman@...>
Cc: Erik Bjorge <erik.c.bjorge@...>
Signed-off-by: Nate DeSimone <@natedesimone>
---
edkrepo/commands/clone_command.py | 8 ++++++++
edkrepo/config/config_factory.py | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/edkrepo/commands/clone_command.py b/edkrepo/commands/clone_command.py
index f638090..8769102 100644
--- a/edkrepo/commands/clone_command.py
+++ b/edkrepo/commands/clone_command.py
@@ -9,6 +9,7 @@

import os
import shutil
+import sys

from edkrepo.commands.edkrepo_command import EdkrepoCommand
from edkrepo.commands.edkrepo_command import SubmoduleSkipArgument, SourceManifestRepoArgument
@@ -20,6 +21,7 @@ from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException,
from edkrepo.common.edkrepo_exception import EdkrepoManifestNotFoundException
from edkrepo.common.humble import CLONE_INVALID_WORKSPACE, CLONE_INVALID_PROJECT_ARG, CLONE_INVALID_COMBO_ARG
from edkrepo.common.humble import SPARSE_CHECKOUT, CLONE_INVALID_LOCAL_ROOTS
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo.common.workspace_maintenance.workspace_maintenance import case_insensitive_single_match
from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_all_manifest_repos, find_project_in_all_indices
from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos
@@ -77,6 +79,12 @@ class CloneCommand(EdkrepoCommand):
workspace_dir = os.getcwd()
else:
workspace_dir = os.path.abspath(workspace_dir)
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(workspace_dir)[0][0].upper()
+ if drive in subst:
+ workspace_dir = os.path.join(subst[drive], os.path.splitdrive(workspace_dir)[1][1:])
+ workspace_dir = os.path.normpath(workspace_dir)
if os.path.isdir(workspace_dir) and os.listdir(workspace_dir):
raise EdkrepoInvalidParametersException(CLONE_INVALID_WORKSPACE)
if not os.path.isdir(workspace_dir):
diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py
index a82a438..fe69460 100644
--- a/edkrepo/config/config_factory.py
+++ b/edkrepo/config/config_factory.py
@@ -11,13 +11,16 @@ import os
import sys
import configparser
import collections
-from ctypes import *
+if sys.platform == "win32":
+ from ctypes import oledll, c_void_p, c_uint32, c_wchar_p
+ from ctypes import create_unicode_buffer

import edkrepo.config.humble.config_factory_humble as humble
from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundException, EdkrepoConfigFileInvalidException
from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectoryNotFoundException
from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyException
from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DECODE_WARNING, MAX_PATCH_SET_INVALID
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo_manifest_parser import edk_manifest
from edkrepo.common.pathfix import expanduser

@@ -238,6 +241,11 @@ def get_workspace_path():
while True:
if os.path.isdir(os.path.join(path, "repo")):
if os.path.isfile(os.path.join(os.path.join(path, "repo"), "Manifest.xml")):
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(path)[0][0].upper()
+ if drive in subst:
+ path = os.path.join(subst[drive], os.path.splitdrive(path)[1][1:])
return path
if os.path.dirname(path) == path:
break
--
2.27.0.windows.1


Bjorge, Erik C
 

Reviewed-by: Erik Bjorge <erik.c.bjorge@...>

-----Original Message-----
From: Nate DeSimone <@natedesimone>
Sent: Friday, September 25, 2020 6:28 PM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...>; Bjorge, Erik C <erik.c.bjorge@...>
Subject: [edk2-staging/EdkRepo] [PATCH V3 2/2] EdkRepo: Add support for subst drives

get_workspace_path() now converts a virtual drive path to a real path before any git repo operations are done.

Cc: Ashley E Desimone <ashley.e.desimone@...>
Cc: Puja Pandya <puja.pandya@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Prince Agyeman <prince.agyeman@...>
Cc: Erik Bjorge <erik.c.bjorge@...>
Signed-off-by: Nate DeSimone <@natedesimone>
---
edkrepo/commands/clone_command.py | 8 ++++++++ edkrepo/config/config_factory.py | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/edkrepo/commands/clone_command.py b/edkrepo/commands/clone_command.py
index f638090..8769102 100644
--- a/edkrepo/commands/clone_command.py
+++ b/edkrepo/commands/clone_command.py
@@ -9,6 +9,7 @@

import os
import shutil
+import sys

from edkrepo.commands.edkrepo_command import EdkrepoCommand from edkrepo.commands.edkrepo_command import SubmoduleSkipArgument, SourceManifestRepoArgument @@ -20,6 +21,7 @@ from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException,
from edkrepo.common.edkrepo_exception import EdkrepoManifestNotFoundException from edkrepo.common.humble import CLONE_INVALID_WORKSPACE, CLONE_INVALID_PROJECT_ARG, CLONE_INVALID_COMBO_ARG from edkrepo.common.humble import SPARSE_CHECKOUT, CLONE_INVALID_LOCAL_ROOTS
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo.common.workspace_maintenance.workspace_maintenance import case_insensitive_single_match from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_all_manifest_repos, find_project_in_all_indices from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos @@ -77,6 +79,12 @@ class CloneCommand(EdkrepoCommand):
workspace_dir = os.getcwd()
else:
workspace_dir = os.path.abspath(workspace_dir)
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(workspace_dir)[0][0].upper()
+ if drive in subst:
+ workspace_dir = os.path.join(subst[drive], os.path.splitdrive(workspace_dir)[1][1:])
+ workspace_dir = os.path.normpath(workspace_dir)
if os.path.isdir(workspace_dir) and os.listdir(workspace_dir):
raise EdkrepoInvalidParametersException(CLONE_INVALID_WORKSPACE)
if not os.path.isdir(workspace_dir):
diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py
index a82a438..fe69460 100644
--- a/edkrepo/config/config_factory.py
+++ b/edkrepo/config/config_factory.py
@@ -11,13 +11,16 @@ import os
import sys
import configparser
import collections
-from ctypes import *
+if sys.platform == "win32":
+ from ctypes import oledll, c_void_p, c_uint32, c_wchar_p
+ from ctypes import create_unicode_buffer

import edkrepo.config.humble.config_factory_humble as humble from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundException, EdkrepoConfigFileInvalidException from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectoryNotFoundException
from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyException
from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DECODE_WARNING, MAX_PATCH_SET_INVALID
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo_manifest_parser import edk_manifest from edkrepo.common.pathfix import expanduser

@@ -238,6 +241,11 @@ def get_workspace_path():
while True:
if os.path.isdir(os.path.join(path, "repo")):
if os.path.isfile(os.path.join(os.path.join(path, "repo"), "Manifest.xml")):
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(path)[0][0].upper()
+ if drive in subst:
+ path = os.path.join(subst[drive],
+ os.path.splitdrive(path)[1][1:])
return path
if os.path.dirname(path) == path:
break
--
2.27.0.windows.1


Ashley E Desimone
 

Reviewed-by: Ashley DeSimone <ashley.e.desimone@...>

-----Original Message-----
From: Nate DeSimone <@natedesimone>
Sent: Friday, September 25, 2020 6:28 PM
To: devel@edk2.groups.io
Cc: Desimone, Ashley E <ashley.e.desimone@...>; Pandya, Puja <puja.pandya@...>; Bret Barkelew <Bret.Barkelew@...>; Agyeman, Prince <prince.agyeman@...>; Bjorge, Erik C <erik.c.bjorge@...>
Subject: [edk2-staging/EdkRepo] [PATCH V3 2/2] EdkRepo: Add support for subst drives

get_workspace_path() now converts a virtual drive path to a real path before any git repo operations are done.

Cc: Ashley E Desimone <ashley.e.desimone@...>
Cc: Puja Pandya <puja.pandya@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Prince Agyeman <prince.agyeman@...>
Cc: Erik Bjorge <erik.c.bjorge@...>
Signed-off-by: Nate DeSimone <@natedesimone>
---
edkrepo/commands/clone_command.py | 8 ++++++++ edkrepo/config/config_factory.py | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/edkrepo/commands/clone_command.py b/edkrepo/commands/clone_command.py
index f638090..8769102 100644
--- a/edkrepo/commands/clone_command.py
+++ b/edkrepo/commands/clone_command.py
@@ -9,6 +9,7 @@

import os
import shutil
+import sys

from edkrepo.commands.edkrepo_command import EdkrepoCommand from edkrepo.commands.edkrepo_command import SubmoduleSkipArgument, SourceManifestRepoArgument @@ -20,6 +21,7 @@ from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException,
from edkrepo.common.edkrepo_exception import EdkrepoManifestNotFoundException from edkrepo.common.humble import CLONE_INVALID_WORKSPACE, CLONE_INVALID_PROJECT_ARG, CLONE_INVALID_COMBO_ARG from edkrepo.common.humble import SPARSE_CHECKOUT, CLONE_INVALID_LOCAL_ROOTS
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo.common.workspace_maintenance.workspace_maintenance import case_insensitive_single_match from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_all_manifest_repos, find_project_in_all_indices from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos @@ -77,6 +79,12 @@ class CloneCommand(EdkrepoCommand):
workspace_dir = os.getcwd()
else:
workspace_dir = os.path.abspath(workspace_dir)
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(workspace_dir)[0][0].upper()
+ if drive in subst:
+ workspace_dir = os.path.join(subst[drive], os.path.splitdrive(workspace_dir)[1][1:])
+ workspace_dir = os.path.normpath(workspace_dir)
if os.path.isdir(workspace_dir) and os.listdir(workspace_dir):
raise EdkrepoInvalidParametersException(CLONE_INVALID_WORKSPACE)
if not os.path.isdir(workspace_dir):
diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py
index a82a438..fe69460 100644
--- a/edkrepo/config/config_factory.py
+++ b/edkrepo/config/config_factory.py
@@ -11,13 +11,16 @@ import os
import sys
import configparser
import collections
-from ctypes import *
+if sys.platform == "win32":
+ from ctypes import oledll, c_void_p, c_uint32, c_wchar_p
+ from ctypes import create_unicode_buffer

import edkrepo.config.humble.config_factory_humble as humble from edkrepo.common.edkrepo_exception import EdkrepoGlobalConfigNotFoundException, EdkrepoConfigFileInvalidException from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceInvalidException, EdkrepoGlobalDataDirectoryNotFoundException
from edkrepo.common.edkrepo_exception import EdkrepoConfigFileReadOnlyException
from edkrepo.common.humble import MIRROR_PRIMARY_REPOS_MISSING, MIRROR_DECODE_WARNING, MAX_PATCH_SET_INVALID
+from edkrepo.common.pathfix import get_subst_drive_dict
from edkrepo_manifest_parser import edk_manifest from edkrepo.common.pathfix import expanduser

@@ -238,6 +241,11 @@ def get_workspace_path():
while True:
if os.path.isdir(os.path.join(path, "repo")):
if os.path.isfile(os.path.join(os.path.join(path, "repo"), "Manifest.xml")):
+ if sys.platform == "win32":
+ subst = get_subst_drive_dict()
+ drive = os.path.splitdrive(path)[0][0].upper()
+ if drive in subst:
+ path = os.path.join(subst[drive],
+ os.path.splitdrive(path)[1][1:])
return path
if os.path.dirname(path) == path:
break
--
2.27.0.windows.1