Skip to content

Commit a8fe911

Browse files
committed
Refactor Dockerfile to use JLink version as a build argument and update installation logic for architecture-specific packages
1 parent e0eeb45 commit a8fe911

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

.github/workflows/jlinkRemoteServerEmu.dockerfile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Set JLink version as build argument
2+
ARG JLINK_VERSION=V794e
13
##
24
# Usage example:
35
# Build:
@@ -19,19 +21,30 @@ RUN apt-get update && \
1921

2022

2123
# Copy both JLink packages into the container (they must be present in build context)
22-
COPY .github/workflows/JLink_Linux_V896_x86_64.deb /tmp/JLink_Linux_V896_x86_64.deb
23-
COPY .github/workflows/JLink_Linux_V896_arm64.deb /tmp/JLink_Linux_V896_arm64.deb
24+
COPY .github/workflows/JLink_Linux_${JLINK_VERSION}_x86_64.deb /tmp/JLink_Linux_${JLINK_VERSION}_x86_64.deb
25+
COPY .github/workflows/JLink_Linux_${JLINK_VERSION}_arm64.deb /tmp/JLink_Linux_${JLINK_VERSION}_arm64.deb
2426

2527
# Install the appropriate JLink package depending on architecture (force install, then fix deps)
26-
RUN arch=$(uname -m) && \
27-
if [ "$arch" = "x86_64" ]; then \
28-
dpkg --force-depends -i /tmp/JLink_Linux_V896_x86_64.deb; \
29-
elif [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; then \
30-
dpkg --force-depends -i /tmp/JLink_Linux_V896_arm64.deb; \
28+
WORKDIR /tmp
29+
RUN if [ "${ENABLE_JLINK}" = "true" ]; then \
30+
ARCH=$(uname -m) && \
31+
if [ "$ARCH" = "x86_64" ]; then \
32+
wget --post-data "accept_license_agreement=accepted" \
33+
https://www.segger.com/downloads/jlink/JLink_Linux_${JLINK_VERSION}_x86_64.deb \
34+
-O JLink.deb && \
35+
dpkg --force-depends -i JLink.deb && \
36+
rm JLink.deb; \
37+
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \
38+
wget --post-data "accept_license_agreement=accepted" \
39+
https://www.segger.com/downloads/jlink/JLink_Linux_${JLINK_VERSION}_arm64.deb \
40+
-O JLink.deb && \
41+
dpkg --force-depends -i JLink.deb && \
42+
rm JLink.deb; \
43+
fi && \
44+
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="1366", MODE="0666"' > /etc/udev/rules.d/99-jlink.rules; \
3145
else \
32-
echo "Unsupported architecture: $arch" && exit 1; \
33-
fi && \
34-
apt-get install -f -y
46+
echo "Skipping J-Link installation (ENABLE_JLINK=${ENABLE_JLINK})"; \
47+
fi
3548

3649
# Add user (optional)
3750
RUN useradd -ms /bin/bash jlink

0 commit comments

Comments
 (0)