Skip to content

Commit 271602b

Browse files
authored
Updated s5cmd script to build with specified version of go to address related CVEs (deepjavalibrary#2945)
1 parent dda4c22 commit 271602b

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

serving/docker/scripts/install_s5cmd.sh

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@ set -ex
44

55
ARCH=$1
66

7-
# Download custom s5cmd binary built with Go 1.25.4
7+
# Install jq if not available (for lmi container)
8+
if ! command -v jq &> /dev/null; then
9+
apt-get update && apt-get install -y jq
10+
fi
11+
12+
# Retrieve latest patched version
13+
GO_MAJOR_MINOR="1.25"
14+
GO_VERSION=$(curl -s https://go.dev/dl/?mode=json | jq -r ".[].version" | grep "^go${GO_MAJOR_MINOR}" | head -1 | sed 's/go//')
15+
echo "Using Go version: ${GO_VERSION} (latest in ${GO_MAJOR_MINOR}.x series)"
16+
817
if [[ $ARCH == "aarch64" ]]; then
9-
curl -f https://publish.djl.ai/s5cmd/go1.25.4/s5cmd-linux-arm64 -L -o s5cmd
18+
GO_ARCH="arm64"
1019
else
11-
curl -f https://publish.djl.ai/s5cmd/go1.25.4/s5cmd-linux-amd64 -L -o s5cmd
20+
GO_ARCH="amd64"
1221
fi
1322

14-
INSTALL_DIR="/opt/djl/bin"
23+
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" | tar -xz -C /tmp
24+
export PATH="/tmp/go/bin:${PATH}"
25+
export GOPATH="/tmp/gopath"
26+
export GOCACHE="/tmp/gocache"
1527

28+
# Download s5cmd release source
29+
S5CMD_VERSION="v2.3.0"
30+
echo "Building s5cmd ${S5CMD_VERSION}"
31+
curl -fsSL "https://github.com/peak/s5cmd/archive/refs/tags/${S5CMD_VERSION}.tar.gz" | tar -xz -C /tmp
32+
mv /tmp/s5cmd-${S5CMD_VERSION#v} /tmp/s5cmd
33+
cd /tmp/s5cmd
34+
go build -ldflags "-X github.com/peak/s5cmd/v2/version.Version=${S5CMD_VERSION}" -o s5cmd .
35+
36+
# Install s5cmd
37+
INSTALL_DIR="/opt/djl/bin"
1638
mkdir -p "${INSTALL_DIR}"
1739
mv s5cmd "${INSTALL_DIR}/"
1840
chmod +x "${INSTALL_DIR}/s5cmd"
1941

42+
rm -rf /tmp/go /tmp/gopath /tmp/gocache /tmp/s5cmd
43+
2044
export PATH="${INSTALL_DIR}:${PATH}"
2145
echo "export PATH=${INSTALL_DIR}:\$PATH" >>~/.bashrc

0 commit comments

Comments
 (0)