From c7f01711bdcc0bb7d0146695ad311832274f4de8 Mon Sep 17 00:00:00 2001 From: "Denis N. Antonioli" Date: Sat, 22 Apr 2023 15:54:41 -0700 Subject: [PATCH] split the installation scripts, inline or clean-up as possible --- Dockerfile | 33 ++++++++++++-- scripts/bash-exec.sh | 8 ++++ scripts/install-checkstyle.sh | 14 ++++++ scripts/install-dart-sdk.sh | 33 ++++++++++++++ scripts/install-google-java-format.sh | 14 ++++++ scripts/install-ktlint.sh | 43 ------------------ scripts/install-lua.sh | 30 +++++++++++++ scripts/install-raku.sh | 63 --------------------------- scripts/install-rustfmt.sh | 16 +++---- 9 files changed, 137 insertions(+), 117 deletions(-) create mode 100755 scripts/bash-exec.sh create mode 100755 scripts/install-checkstyle.sh create mode 100755 scripts/install-dart-sdk.sh create mode 100755 scripts/install-google-java-format.sh create mode 100755 scripts/install-lua.sh delete mode 100755 scripts/install-raku.sh diff --git a/Dockerfile b/Dockerfile index b5569674..7157090a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -208,12 +208,39 @@ COPY dependencies/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub COPY scripts/install-ktlint.sh / RUN --mount=type=secret,id=GITHUB_TOKEN /install-ktlint.sh && rm -rf /install-ktlint.sh +#################### +# Install dart-sdk # +#################### +COPY scripts/install-dart-sdk.sh / +RUN --mount=type=secret,id=GITHUB_TOKEN /install-dart-sdk.sh && rm -rf /install-dart-sdk.sh + +################################ +# Install Bash-Exec # +################################ +COPY --chmod=555 scripts/bash-exec.sh /usr/bin/bash-exec + ################################################# # Install Raku and additional Edge dependencies # ################################################# -# Basic setup, programs and init -COPY scripts/install-raku.sh / -RUN --mount=type=secret,id=GITHUB_TOKEN /install-raku.sh && rm -rf /install-raku.sh +RUN apk add --no-cache rakudo zef + +###################### +# Install CheckStyle # +###################### +COPY scripts/install-checkstyle.sh / +RUN --mount=type=secret,id=GITHUB_TOKEN /install-checkstyle.sh && rm -rf /install-checkstyle.sh + +############################## +# Install google-java-format # +############################## +COPY scripts/install-google-java-format.sh / +RUN --mount=type=secret,id=GITHUB_TOKEN /install-google-java-format.sh && rm -rf /install-google-java-format.sh + +################################# +# Install luacheck and luarocks # +################################# +COPY scripts/install-lua.sh / +RUN --mount=type=secret,id=GITHUB_TOKEN /install-lua.sh && rm -rf /install-lua.sh ################################################################################ # Grab small clean image to build python packages ############################## diff --git a/scripts/bash-exec.sh b/scripts/bash-exec.sh new file mode 100755 index 00000000..596352ea --- /dev/null +++ b/scripts/bash-exec.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if ! [[ -x "$1" ]]; then + echo "Error: File:[$1] is not executable" + exit 1 +fi diff --git a/scripts/install-checkstyle.sh b/scripts/install-checkstyle.sh new file mode 100755 index 00000000..f924ace1 --- /dev/null +++ b/scripts/install-checkstyle.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euo pipefail + +url=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "https://api.github.com/repos/checkstyle/checkstyle/releases/tags/checkstyle-${CHECKSTYLE_VERSION}" | + jq --arg name "checkstyle-${CHECKSTYLE_VERSION}-all.jar" -r '.assets | .[] | select(.name==$name) | .url') +curl --retry 5 --retry-delay 5 -sL -o /usr/bin/checkstyle \ + -H "Accept: application/octet-stream" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "${url}" +chmod a+x /usr/bin/checkstyle diff --git a/scripts/install-dart-sdk.sh b/scripts/install-dart-sdk.sh new file mode 100755 index 00000000..837d2310 --- /dev/null +++ b/scripts/install-dart-sdk.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -euo pipefail + +case $TARGETARCH in +amd64) + target=x64 + ;; +arm64) + target=arm64 + ;; +*) + echo "$TARGETARCH is not supported" + exit 1 + ;; +esac + +url=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "https://api.github.com/repos/sgerrand/alpine-pkg-glibc/releases/tags/${GLIBC_VERSION}" | + jq --arg name "glibc-${GLIBC_VERSION}.apk" -r '.assets | .[] | select(.name | contains($name)) | .url') +curl --retry 5 --retry-delay 5 -sL -o "glibc-${GLIBC_VERSION}.apk" \ + -H "Accept: application/octet-stream" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "${url}" +apk add --no-cache --force-overwrite "glibc-${GLIBC_VERSION}.apk" +rm "glibc-${GLIBC_VERSION}.apk" + +curl --retry 5 --retry-delay 5 -sO "https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-${target}-release.zip" +unzip -q dartsdk-linux-${target}-release.zip +chmod +x dart-sdk/bin/dart* && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ +rm -r dart-sdk/ dartsdk-linux-${target}-release.zip diff --git a/scripts/install-google-java-format.sh b/scripts/install-google-java-format.sh new file mode 100755 index 00000000..e23f725a --- /dev/null +++ b/scripts/install-google-java-format.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -euo pipefail + +url=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "https://api.github.com/repos/google/google-java-format/releases/tags/v${GOOGLE_JAVA_FORMAT_VERSION}" | + jq --arg name "google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar" -r '.assets | .[] | select(.name==$name) | .url') +curl --retry 5 --retry-delay 5 -sL -o /usr/bin/google-java-format \ + -H "Accept: application/octet-stream" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "${url}" +chmod a+x /usr/bin/google-java-format diff --git a/scripts/install-ktlint.sh b/scripts/install-ktlint.sh index ee1d1aff..a2a93109 100755 --- a/scripts/install-ktlint.sh +++ b/scripts/install-ktlint.sh @@ -2,22 +2,6 @@ set -euo pipefail -case $TARGETARCH in -amd64) - target=x64 - ;; -arm64) - target=arm64 - ;; -*) - echo "$TARGETARCH is not supported" - exit 1 - ;; -esac - -################## -# Install ktlint # -################## url=$(curl -s \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ @@ -30,30 +14,3 @@ curl --retry 5 --retry-delay 5 -sL -o "/usr/bin/ktlint" \ chmod a+x /usr/bin/ktlint terrascan init cd ~ && touch .chktexrc - -#################### -# Install dart-sdk # -#################### -url=$(curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "https://api.github.com/repos/sgerrand/alpine-pkg-glibc/releases/tags/${GLIBC_VERSION}" | - jq --arg name "glibc-${GLIBC_VERSION}.apk" -r '.assets | .[] | select(.name | contains($name)) | .url') -curl --retry 5 --retry-delay 5 -sL -o "glibc-${GLIBC_VERSION}.apk" \ - -H "Accept: application/octet-stream" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "${url}" -apk add --no-cache --force-overwrite "glibc-${GLIBC_VERSION}.apk" -rm "glibc-${GLIBC_VERSION}.apk" - -curl --retry 5 --retry-delay 5 -sO "https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-${target}-release.zip" -unzip -q dartsdk-linux-${target}-release.zip -chmod +x dart-sdk/bin/dart* && mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ -rm -r dart-sdk/ dartsdk-linux-${target}-release.zip - -################################ -# Create and install Bash-Exec # -################################ -# shellcheck disable=SC2016 -printf '#!/bin/bash\nif [[ -x "$1" ]]; then exit 0; else echo "Error: File:[$1] is not executable"; exit 1; fi' >/usr/bin/bash-exec -chmod +x /usr/bin/bash-exec diff --git a/scripts/install-lua.sh b/scripts/install-lua.sh new file mode 100755 index 00000000..d3662c14 --- /dev/null +++ b/scripts/install-lua.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -euo pipefail + +curl --retry 5 --retry-delay 5 -s https://www.lua.org/ftp/lua-5.3.5.tar.gz | tar -xz +cd lua-5.3.5 +make linux +make install +cd .. && rm -r lua-5.3.5/ + +url=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + https://api.github.com/repos/cvega/luarocks/releases/latest | jq -r '.tarball_url') +curl --retry 5 --retry-delay 5 -sL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ + "${url}" | tar -xz +cd cvega-luarocks-6b1aee6 +./configure --with-lua-include=/usr/local/include +make +make -b install +cd .. +rm -r cvega-luarocks-6b1aee6 + +luarocks install luacheck +luarocks install argparse +luarocks install luafilesystem +mv /etc/R/* /usr/lib/R/etc/ +find /usr/ -type f -name '*.md' -exec rm {} + diff --git a/scripts/install-raku.sh b/scripts/install-raku.sh deleted file mode 100755 index 90503aa3..00000000 --- a/scripts/install-raku.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -apk add --no-cache rakudo zef - -###################### -# Install CheckStyle # -###################### -url=$(curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "https://api.github.com/repos/checkstyle/checkstyle/releases/tags/checkstyle-${CHECKSTYLE_VERSION}" | - jq --arg name "checkstyle-${CHECKSTYLE_VERSION}-all.jar" -r '.assets | .[] | select(.name==$name) | .url') -curl --retry 5 --retry-delay 5 -sL -o /usr/bin/checkstyle \ - -H "Accept: application/octet-stream" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "${url}" -chmod a+x /usr/bin/checkstyle - -############################## -# Install google-java-format # -############################## -url=$(curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "https://api.github.com/repos/google/google-java-format/releases/tags/v${GOOGLE_JAVA_FORMAT_VERSION}" | - jq --arg name "google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar" -r '.assets | .[] | select(.name==$name) | .url') -curl --retry 5 --retry-delay 5 -sL -o /usr/bin/google-java-format \ - -H "Accept: application/octet-stream" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "${url}" -chmod a+x /usr/bin/google-java-format - -################################# -# Install luacheck and luarocks # -################################# -curl --retry 5 --retry-delay 5 -s https://www.lua.org/ftp/lua-5.3.5.tar.gz | tar -xz -cd lua-5.3.5 -make linux -make install -cd .. && rm -r lua-5.3.5/ - -url=$(curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - https://api.github.com/repos/cvega/luarocks/releases/latest | jq -r '.tarball_url') -curl --retry 5 --retry-delay 5 -sL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $(cat /run/secrets/GITHUB_TOKEN)" \ - "${url}" | tar -xz -cd cvega-luarocks-6b1aee6 -./configure --with-lua-include=/usr/local/include -make -make -b install -cd .. -rm -r cvega-luarocks-6b1aee6 - -luarocks install luacheck -luarocks install argparse -luarocks install luafilesystem -mv /etc/R/* /usr/lib/R/etc/ -find /usr/ -type f -name '*.md' -exec rm {} + diff --git a/scripts/install-rustfmt.sh b/scripts/install-rustfmt.sh index 6ef3f7e6..c47a714a 100755 --- a/scripts/install-rustfmt.sh +++ b/scripts/install-rustfmt.sh @@ -1,6 +1,4 @@ #!/usr/bin/env bash -# shellcheck disable=SC2016 -# shellcheck disable=SC2129 # https://doc.rust-lang.org/rustc/platform-support.html @@ -29,10 +27,12 @@ ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/rust ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/cargo /usr/bin/cargo ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/cargo-clippy /usr/bin/cargo-clippy -echo '#!/usr/bin/env bash' >/usr/bin/clippy -echo 'pushd $(dirname $1)' >>/usr/bin/clippy -echo 'cargo-clippy' >>/usr/bin/clippy -echo 'rc=$?' >>/usr/bin/clippy -echo 'popd' >>/usr/bin/clippy -echo 'exit $rc' >>/usr/bin/clippy +cat <<'EOF' >/usr/bin/clippy +#!/usr/bin/env bash +pushd $(dirname $1) +cargo-clippy +rc=$? +popd +exit $rc +EOF chmod +x /usr/bin/clippy