Declare autorolled targets in a template to be imported

By declaring the autorolled targets in a template and then importing it
in //third_party/android_deps/BUILD.gn we can have the targets appear to
live in said gn file and thus not move around when they start to be
autorolled.

Bug: 40774645
Change-Id: I4b9a8dab4dd1f3c22f5498d26c3e6c6f547be73d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6368858
Auto-Submit: Mohamed Heikal <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Commit-Queue: Mohamed Heikal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1435409}
diff --git a/third_party/androidx/fetch_all_androidx.py b/third_party/androidx/fetch_all_androidx.py
index 8a7f1d6..1482f4e 100755
--- a/third_party/androidx/fetch_all_androidx.py
+++ b/third_party/androidx/fetch_all_androidx.py
@@ -204,6 +204,8 @@
             extra_args += ['--override-artifact', f'{subpath}:{url}']
 
     os.makedirs(_CIPD_PATH, exist_ok=True)
+    # gclient/cipd extract files as read only.
+    subprocess.run(['chmod', '-R', '+w', _CIPD_PATH])
 
     fetch_util.run_fetch_all(android_deps_dir=_ANDROIDX_PATH,
                              output_subdir='cipd',
@@ -232,9 +234,11 @@
                                     dirnames=['libs'],
                                     absolute_file_map=file_map)
     if args.local:
-        subprocess.run(
-            [_EXTRACT_SCRIPT_PATH, '--cipd-package-path', _CIPD_PATH],
-            check=True)
+        subprocess.run([
+            _EXTRACT_SCRIPT_PATH, '--cipd-package-path', _CIPD_PATH,
+            '--no-git-add'
+        ],
+                       check=True)
 
     fetch_util.write_cipd_yaml(package_root=_CIPD_PATH,
                                package_name=_CIPD_PACKAGE,