From d49dc0460c3afb0c2874f78590668895a60e8ffa Mon Sep 17 00:00:00 2001 From: Chad Austin Date: Thu, 3 Feb 2022 12:05:46 -0800 Subject: [PATCH] don't follow mount points when applying shipit transformation Summary: If a getdeps project creates a bind mount in a subdirectory, we don't want the shipit transformer to copy all of the bind mount's contents to the ship-transformed output. This manifested when I was using Vagrant inside of Watchman and `getdeps.py fetch watchman` would copy all of the Vagrant VMs too. Reviewed By: ahornby Differential Revision: D33855553 fbshipit-source-id: e2bc50ecfe0d067490c95be05d074d6a844f30d5 --- build/fbcode_builder/getdeps/fetcher.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/build/fbcode_builder/getdeps/fetcher.py b/build/fbcode_builder/getdeps/fetcher.py index 79368bf99..63602d146 100644 --- a/build/fbcode_builder/getdeps/fetcher.py +++ b/build/fbcode_builder/getdeps/fetcher.py @@ -447,14 +447,28 @@ class ShipitPathMap(object): # Record the full set of files that should be in the tree full_file_list = set() + if sys.platform == "win32": + # Let's not assume st_dev has a consistent value on Windows. + def st_dev(path): + return 1 + + else: + + def st_dev(path): + return os.lstat(path).st_dev + for fbsource_subdir in self.roots: dir_to_mirror = os.path.join(fbsource_root, fbsource_subdir) + root_dev = st_dev(dir_to_mirror) prefetch_dir_if_eden(dir_to_mirror) if not os.path.exists(dir_to_mirror): raise Exception( "%s doesn't exist; check your sparse profile!" % dir_to_mirror ) - for root, _dirs, files in os.walk(dir_to_mirror): + + for root, dirs, files in os.walk(dir_to_mirror): + dirs[:] = [d for d in dirs if root_dev == st_dev(os.path.join(root, d))] + for src_file in files: full_name = os.path.join(root, src_file) rel_name = os.path.relpath(full_name, fbsource_root)