Skip to content

Commit

Permalink
Fix update debian function
Browse files Browse the repository at this point in the history
Follow requested changes, updated variable names and reorganized logic for
improved readability.
  • Loading branch information
Jenkins-J committed Jan 12, 2024
1 parent d4240bd commit 557d703
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,27 @@ def write_file(file, contents):
f.write(contents)

def update_debian():
buster_arch_case = 'dpkgArch="$(dpkg --print-architecture)"; \\\n'
buster_arch_case += ' case "${dpkgArch##*-}" in \\\n'
for arch in debian_buster_arches:
arch_case = 'dpkgArch="$(dpkg --print-architecture)"; \\\n'
arch_case += ' case "${dpkgArch##*-}" in \\\n'
for arch in debian_arches:
hash = rustup_hash(arch.rust)
buster_arch_case += f" {arch.dpkg}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n"
arch_case += f" {arch.dpkg}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n"

debian_arch_case = buster_arch_case
for arch in debian_other_arches:
hash = rustup_hash(arch.rust)
debian_arch_case += f" {arch.dpkg}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n"

end_case = ' *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \\\n'
end_case += ' esac'

debian_arch_case += end_case
buster_arch_case += end_case
end = ' *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \\\n'
end += ' esac'

template = read_file("Dockerfile-debian.template")
slim_template = read_file("Dockerfile-slim.template")

for variant in debian_variants:
case = debian_arch_case
if variant == "buster":
case = buster_arch_case
case = arch_case
if variant != "buster":
for arch in debian_non_buster_arches:
hash = rustup_hash(arch.rust)
case += f" {arch.dpkg}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n"

case += end

rendered = template \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
Expand Down

0 comments on commit 557d703

Please sign in to comment.