From de3852f1123b643ba3897d26fe1091a8811ab834 Mon Sep 17 00:00:00 2001 From: Jackson West Date: Wed, 12 Jun 2024 17:25:14 +0000 Subject: [PATCH] adds 7zip to builder-base --- builder-base/Dockerfile | 15 +++++++ builder-base/checksums/7zip-amd64-checksum | 1 + builder-base/checksums/7zip-arm64-checksum | 1 + builder-base/scripts/install_7zip.sh | 43 +++++++++++++++++++++ builder-base/scripts/update_shasums.sh | 4 ++ builder-base/scripts/validate_components.sh | 2 +- builder-base/scripts/versions.sh | 1 + builder-base/versions.yaml | 1 + 8 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 builder-base/checksums/7zip-amd64-checksum create mode 100644 builder-base/checksums/7zip-arm64-checksum create mode 100755 builder-base/scripts/install_7zip.sh diff --git a/builder-base/Dockerfile b/builder-base/Dockerfile index 58ac87363..07446196c 100644 --- a/builder-base/Dockerfile +++ b/builder-base/Dockerfile @@ -98,6 +98,20 @@ RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \ /install_yq.sh && \ /remove_yum_packages.sh +FROM ${BUILDER_IMAGE} as sevenzip +ARG TARGETARCH +WORKDIR /workdir +ARG SEVENZIP_VERSION +ENV SEVENZIP_VERSION=$SEVENZIP_VERSION + +COPY --link --from=upx /upx / +COPY ./scripts/install_base_yum_packages.sh ./scripts/remove_yum_packages.sh ./scripts/common_vars.sh \ + ./scripts/install_7zip.sh ./checksums/7zip-${TARGETARCH}-checksum / +RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \ + /install_base_yum_packages.sh && \ + /install_7zip.sh && \ + /remove_yum_packages.sh + FROM ${BUILDER_IMAGE} as packer ARG TARGETARCH WORKDIR /workdir @@ -539,6 +553,7 @@ COPY --link --from=skopeo /skopeo / COPY --link --from=upx /upx / COPY --link --from=notation /notation / COPY --link --from=oras /oras / +COPY --link --from=sevenzip /7zip / FROM minimal-copy-stage as full-copy-stage diff --git a/builder-base/checksums/7zip-amd64-checksum b/builder-base/checksums/7zip-amd64-checksum new file mode 100644 index 000000000..ae5cfc4af --- /dev/null +++ b/builder-base/checksums/7zip-amd64-checksum @@ -0,0 +1 @@ +807bd858433b13215abc915cbb9ccdc806fc7b421418a4088a194e1729a6a6b2 7z2406-linux-x64.tar.xz diff --git a/builder-base/checksums/7zip-arm64-checksum b/builder-base/checksums/7zip-arm64-checksum new file mode 100644 index 000000000..52833fd77 --- /dev/null +++ b/builder-base/checksums/7zip-arm64-checksum @@ -0,0 +1 @@ +bc7337381e07c6ecdc872adc3636b9abd8a00a61543880777bbc3bb7acb5330d 7z2406-linux-arm64.tar.xz diff --git a/builder-base/scripts/install_7zip.sh b/builder-base/scripts/install_7zip.sh new file mode 100755 index 000000000..6a153d999 --- /dev/null +++ b/builder-base/scripts/install_7zip.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +set -o pipefail + +SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" + +NEWROOT=/7zip + +source $SCRIPT_ROOT/common_vars.sh + +if [ $TARGETARCH == 'amd64' ]; then + ARCH='x64' +else + ARCH='arm64' +fi + +SEVENZIP_DOWNLOAD_URL="https://github.com/ip7z/7zip/releases/download/${SEVENZIP_VERSION}/7z${SEVENZIP_VERSION//.}-linux-${ARCH}.tar.xz" + +function install_7zip() { + wget \ + --progress dot:giga \ + $SEVENZIP_DOWNLOAD_URL + sha256sum -c $BASE_DIR/7zip-$TARGETARCH-checksum + tar -C $USR_BIN -xJf 7z${SEVENZIP_VERSION//.}-linux-${ARCH}.tar.xz 7zz License.txt + + time upx --best --no-lzma $USR_BIN/7zz +} + +[ ${SKIP_INSTALL:-false} != false ] || install_7zip diff --git a/builder-base/scripts/update_shasums.sh b/builder-base/scripts/update_shasums.sh index 2137d6bac..d16351dd1 100755 --- a/builder-base/scripts/update_shasums.sh +++ b/builder-base/scripts/update_shasums.sh @@ -76,6 +76,10 @@ for TARGETARCH in arm64 amd64; do # Oras echo "$(curl -sSL --retry 5 -v $ORAS_CHECKSUM_URL 2>&1 | grep $ORAS_FILENAME | cut -d ":" -f 2)" > $CHECKSUMS_ROOT/checksums/oras-$TARGETARCH-checksum + + # 7zip + sha256=$(curl -sSL --retry 5 $SEVENZIP_DOWNLOAD_URL | sha256sum | awk '{print $1}') + echo "$sha256 7z${SEVENZIP_VERSION//.}-linux-${ARCH}.tar.xz" > $CHECKSUMS_ROOT/checksums/7zip-$TARGETARCH-checksum done # HUGO diff --git a/builder-base/scripts/validate_components.sh b/builder-base/scripts/validate_components.sh index 4c63bac85..7ed8594e3 100755 --- a/builder-base/scripts/validate_components.sh +++ b/builder-base/scripts/validate_components.sh @@ -30,7 +30,7 @@ docker buildx version buildctl --version aws --version bash --version - +7zz if [ $TARGETARCH == 'amd64' ]; then hugo version diff --git a/builder-base/scripts/versions.sh b/builder-base/scripts/versions.sh index 0f7cfcdca..5ff4e6300 100755 --- a/builder-base/scripts/versions.sh +++ b/builder-base/scripts/versions.sh @@ -32,3 +32,4 @@ source $SCRIPT_ROOT/install_bash.sh source $SCRIPT_ROOT/install_upx.sh source $SCRIPT_ROOT/install_notation.sh source $SCRIPT_ROOT/install_oras.sh +source $SCRIPT_ROOT/install_7zip.sh \ No newline at end of file diff --git a/builder-base/versions.yaml b/builder-base/versions.yaml index 866bf6a20..232e91562 100644 --- a/builder-base/versions.yaml +++ b/builder-base/versions.yaml @@ -22,6 +22,7 @@ OVERRIDE_BASH_VERSION: 4.3 PACKER_VERSION: 1.9.5 PACKER_ANSIBLE_PLUGIN: v1.1.1 PYWINRM_VERSION: 0.4.1 +SEVENZIP_VERSION: 24.06 SKOPEO_VERSION: v1.5.2 SKOPEO_VERSION_AL23: v1.13.3 UPX_VERSION: 4.2.0