Skip to content

Commit 3e8eba0

Browse files
committed
build: cleaner path variable update
1 parent 3f8afc1 commit 3e8eba0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/docker_utils/download_musl_toolchains.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ def extract_tarball(filename: str, dst: Path):
3535
print(f"{filename} extracted")
3636

3737
def add_to_path(curr_path: str, package_path: Path):
38-
return curr_path + ":" + str((package_path / "bin").resolve())
38+
new_path = str((package_path / "bin").resolve())
39+
if curr_path != "":
40+
return new_path + ":" + curr_path
41+
return new_path
3942

4043

4144
def main():
4245
os.mkdir(MUSL_TOOLCHAINS_DIR)
4346

44-
updated_path = "$PATH"
47+
updated_path = ""
4548
for arch, url in ARCHS.items():
4649
filename = url.split("/")[-1]
4750
download_file(url, filename)
@@ -64,7 +67,7 @@ def main():
6467
with open(ENTRYPOINT, mode="w") as f:
6568
f.write(
6669
f"""#!/usr/bin/env bash
67-
export PATH="{updated_path}"
70+
export PATH="$PATH:{updated_path}"
6871
exec "$@"
6972
""")
7073

@@ -73,7 +76,7 @@ def main():
7376

7477
# Append the path to bash.bashrc so that other users will have these paths.
7578
with open("/etc/bash.bashrc", mode="a") as f:
76-
f.write(f"\nexport PATH=\"{updated_path}\"")
79+
f.write(f"\nexport PATH=\"$PATH:{updated_path}\"")
7780

7881

7982
if __name__ == "__main__":

0 commit comments

Comments
 (0)