floss: Update symlinks when re-running --run-bootstrap
If re-running --run-bootstrap multiple times, do everything except git
clone on re-runs. This makes it possible to switch between multiple
repos when developing while sharing the staging directory at ~/.floss.
Bug: 207009162
Tag: #floss
Test: ./build.py --run-bootstrap
Change-Id: Iba7324a3ab88ae47cf275e1492395508135ff76d
diff --git a/build.py b/build.py
index 3fcb2fb..3297c20 100755
--- a/build.py
+++ b/build.py
@@ -511,19 +511,18 @@
This will check out all the git repos and symlink everything correctly.
"""
- # If already set up, exit early
+ # Create all directories we will need to use
+ for dirpath in [self.git_dir, self.staging_dir, self.output_dir, self.external_dir]:
+ os.makedirs(dirpath, exist_ok=True)
+
+ # If already set up, only update platform2
if os.path.isfile(self.dir_setup_complete):
print('{} already set-up. Updating instead.'.format(self.base_dir))
self._update_platform2()
- return
-
- # Create all directories we will need to use
- for dirpath in [self.git_dir, self.staging_dir, self.output_dir, self.external_dir]:
- os.makedirs(dirpath)
-
- # Check out all repos in git directory
- for repo in BOOTSTRAP_GIT_REPOS.values():
- subprocess.check_call(['git', 'clone', repo], cwd=self.git_dir)
+ else:
+ # Check out all repos in git directory
+ for repo in BOOTSTRAP_GIT_REPOS.values():
+ subprocess.check_call(['git', 'clone', repo], cwd=self.git_dir)
# Symlink things
symlinks = [
@@ -537,6 +536,7 @@
# Create symlinks
for pairs in symlinks:
(src, dst) = pairs
+ os.unlink(dst)
os.symlink(src, dst)
# Write to setup complete file so we don't repeat this step