From 5aee83296aad408fccdd71e7e4395b121028ee73 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Tue, 1 Dec 2020 22:13:48 +0100 Subject: [PATCH] Add Alpine support for AArch64 Necessarily bumps rustup to 1.23.0 since it is the first version to support the aarch64-unknown-linux-musl platform. Closes: #50 --- 1.48.0/alpine3.11/Dockerfile | 12 +++++++++--- 1.48.0/alpine3.12/Dockerfile | 12 +++++++++--- 1.48.0/buster/Dockerfile | 10 +++++----- 1.48.0/buster/slim/Dockerfile | 10 +++++----- Dockerfile-alpine.template | 7 ++++--- x.py | 21 ++++++++++++++++++--- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/1.48.0/alpine3.11/Dockerfile b/1.48.0/alpine3.11/Dockerfile index e670007..d8db8a2 100644 --- a/1.48.0/alpine3.11/Dockerfile +++ b/1.48.0/alpine3.11/Dockerfile @@ -10,11 +10,17 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUST_VERSION=1.48.0 RUN set -eux; \ - url="https://static.rust-lang.org/rustup/archive/1.22.1/x86_64-unknown-linux-musl/rustup-init"; \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + x86_64) rustArch='x86_64-unknown-linux-musl'; rustupSha256='8ab4f7759e22c308b49d737b5dc055c0d334f730632fdc6a169eda033983b846' ;; \ + aarch64) rustArch='aarch64-unknown-linux-musl'; rustupSha256='b3f15d01db21e4e9f192a81bfcbbb72e9055f6b01b4d0893b24f9f6c9f9d2b92' ;; \ + *) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.23.0/${rustArch}/rustup-init"; \ wget "$url"; \ - echo "cee31c6f72b953c6293fd5d40142c7d61aa85db2a5ea81b3519fe1b492148dc9 *rustup-init" | sha256sum -c -; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host x86_64-unknown-linux-musl; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ rm rustup-init; \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ rustup --version; \ diff --git a/1.48.0/alpine3.12/Dockerfile b/1.48.0/alpine3.12/Dockerfile index 998844b..485dc47 100644 --- a/1.48.0/alpine3.12/Dockerfile +++ b/1.48.0/alpine3.12/Dockerfile @@ -10,11 +10,17 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUST_VERSION=1.48.0 RUN set -eux; \ - url="https://static.rust-lang.org/rustup/archive/1.22.1/x86_64-unknown-linux-musl/rustup-init"; \ + apkArch="$(apk --print-arch)"; \ + case "$apkArch" in \ + x86_64) rustArch='x86_64-unknown-linux-musl'; rustupSha256='8ab4f7759e22c308b49d737b5dc055c0d334f730632fdc6a169eda033983b846' ;; \ + aarch64) rustArch='aarch64-unknown-linux-musl'; rustupSha256='b3f15d01db21e4e9f192a81bfcbbb72e9055f6b01b4d0893b24f9f6c9f9d2b92' ;; \ + *) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.23.0/${rustArch}/rustup-init"; \ wget "$url"; \ - echo "cee31c6f72b953c6293fd5d40142c7d61aa85db2a5ea81b3519fe1b492148dc9 *rustup-init" | sha256sum -c -; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host x86_64-unknown-linux-musl; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ rm rustup-init; \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ rustup --version; \ diff --git a/1.48.0/buster/Dockerfile b/1.48.0/buster/Dockerfile index ea3e096..a991cd2 100644 --- a/1.48.0/buster/Dockerfile +++ b/1.48.0/buster/Dockerfile @@ -8,13 +8,13 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN set -eux; \ dpkgArch="$(dpkg --print-architecture)"; \ case "${dpkgArch##*-}" in \ - amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='49c96f3f74be82f4752b8bffcf81961dea5e6e94ce1ccba94435f12e871c3bdb' ;; \ - armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='5a2be2919319e8778698fa9998002d1ec720efe7cb4f6ee4affb006b5e73f1be' ;; \ - arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='d93ef6f91dab8299f46eef26a56c2d97c66271cea60bf004f2f088a86a697078' ;; \ - i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e3d0ae3cfce5c6941f74fed61ca83e53d4cd2deb431b906cbd0687f246efede4' ;; \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ee7ade44063c96c6a37012cc599cb560dce95205c86d17b247c726d2285b230c' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='afab10b89436bfb5ff7db4f4d5ad4d82faee98165915801d73e965e873661b1c' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='99f42ab89c790e8825d91c99edee22b0176f68969d42dc27a89a5d9651c3ceba' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='6fefdd5c429545b9c710c5492402215e1256cb002f19840db64303281b5ded3c' ;; \ *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ esac; \ - url="https://static.rust-lang.org/rustup/archive/1.22.1/${rustArch}/rustup-init"; \ + url="https://static.rust-lang.org/rustup/archive/1.23.0/${rustArch}/rustup-init"; \ wget "$url"; \ echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ diff --git a/1.48.0/buster/slim/Dockerfile b/1.48.0/buster/slim/Dockerfile index ffccb66..9907d7e 100644 --- a/1.48.0/buster/slim/Dockerfile +++ b/1.48.0/buster/slim/Dockerfile @@ -15,13 +15,13 @@ RUN set -eux; \ ; \ dpkgArch="$(dpkg --print-architecture)"; \ case "${dpkgArch##*-}" in \ - amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='49c96f3f74be82f4752b8bffcf81961dea5e6e94ce1ccba94435f12e871c3bdb' ;; \ - armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='5a2be2919319e8778698fa9998002d1ec720efe7cb4f6ee4affb006b5e73f1be' ;; \ - arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='d93ef6f91dab8299f46eef26a56c2d97c66271cea60bf004f2f088a86a697078' ;; \ - i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e3d0ae3cfce5c6941f74fed61ca83e53d4cd2deb431b906cbd0687f246efede4' ;; \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ee7ade44063c96c6a37012cc599cb560dce95205c86d17b247c726d2285b230c' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='afab10b89436bfb5ff7db4f4d5ad4d82faee98165915801d73e965e873661b1c' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='99f42ab89c790e8825d91c99edee22b0176f68969d42dc27a89a5d9651c3ceba' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='6fefdd5c429545b9c710c5492402215e1256cb002f19840db64303281b5ded3c' ;; \ *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ esac; \ - url="https://static.rust-lang.org/rustup/archive/1.22.1/${rustArch}/rustup-init"; \ + url="https://static.rust-lang.org/rustup/archive/1.23.0/${rustArch}/rustup-init"; \ wget "$url"; \ echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 8fe1736..3c9df96 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -10,11 +10,12 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUST_VERSION=%%RUST-VERSION%% RUN set -eux; \ - url="https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/x86_64-unknown-linux-musl/rustup-init"; \ + %%ARCH-CASE%%; \ + url="https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/${rustArch}/rustup-init"; \ wget "$url"; \ - echo "%%RUSTUP-SHA256%% *rustup-init" | sha256sum -c -; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ chmod +x rustup-init; \ - ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host x86_64-unknown-linux-musl; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ rm rustup-init; \ chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ rustup --version; \ diff --git a/x.py b/x.py index 3ee2e63..0e970b4 100755 --- a/x.py +++ b/x.py @@ -7,7 +7,7 @@ import sys rust_version = "1.48.0" -rustup_version = "1.22.1" +rustup_version = "1.23.0" DebianArch = namedtuple("DebianArch", ["bashbrew", "dpkg", "rust"]) @@ -24,6 +24,13 @@ default_debian_variant = "buster" +AlpineArch = namedtuple("AlpineArch", ["bashbrew", "apk", "rust"]) + +alpine_arches = [ + AlpineArch("amd64", "x86_64", "x86_64-unknown-linux-musl"), + AlpineArch("arm64v8", "aarch64", "aarch64-unknown-linux-musl"), +] + alpine_versions = [ "3.11", "3.12", @@ -75,6 +82,14 @@ def update_debian(): write_file(f"{rust_version}/{variant}/slim/Dockerfile", rendered) def update_alpine(): + arch_case = 'apkArch="$(apk --print-arch)"; \\\n' + arch_case += ' case "$apkArch" in \\\n' + for arch in alpine_arches: + hash = rustup_hash(arch.rust) + arch_case += f" {arch.apk}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n" + arch_case += ' *) echo >&2 "unsupported architecture: $apkArch"; exit 1 ;; \\\n' + arch_case += ' esac' + template = read_file("Dockerfile-alpine.template") for version in alpine_versions: @@ -82,7 +97,7 @@ def update_alpine(): .replace("%%RUST-VERSION%%", rust_version) \ .replace("%%RUSTUP-VERSION%%", rustup_version) \ .replace("%%TAG%%", version) \ - .replace("%%RUSTUP-SHA256%%", rustup_hash("x86_64-unknown-linux-musl")) + .replace("%%ARCH-CASE%%", arch_case) write_file(f"{rust_version}/alpine{version}/Dockerfile", rendered) def update_travis(): @@ -176,7 +191,7 @@ def generate_stackbrew_library(): library += single_library( tags, - ["amd64"], + map(lambda a: a.bashbrew, alpine_arches), os.path.join(rust_version, f"alpine{version}")) print(library)