Addon development: How do I ensure the correct version of an application gets installed?

I’m creating a new local addon to run a Microsoft dotnet application and I want to be able to deploy the addon to different architectures. There are versions of the dotnet framework runtime for different architectures; and I can run Microsoft’s installer to ensure the right one gets installed.

When it comes to the application itself though, it’s not so simple. There are versions available for multiple architectures, but I can’t see how to ensure that I download the correct one from the Dockerfile.

What I need is to map ${BUILD_ARCH} onto a specific filename, but I can’t how to do this.

Any help would be appreciated.

Gareth

Random google search:

Are you looking for something else?

Thanks, @koying.
That is what I’m looking for but I can’t get it to work. The if statement fails.

I’m using:

RUN \
  if [ "$BUILD_ARCH" = "armv7" ]; then  \
  wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && \
  unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip; \
  elif [ "$BUILD_ARCH" = "amd64" ]; then  \
  wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip && \
  unzip FRStackWebApi-linux-64_3_7_3_74.zip; \
  fi

“fail” is quite generic, and unlikely to trigger helpful comments, don’t you think?

Maybe try to run the command in a plain shell, to test it.

I always endeavour to treat others with a modicum of respect…

It’s not a matter of respect, but of empathy.
We cannot help you if you don’t detail what the failure is.

Anyway, good luck in your endeavor.

You’re quite right. Fail is pretty unspecific.
I’ll try in a terminal.

It works OK in a terminal, so I’m wondering if it’s something else in the Dockerfile.

# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM

# Execute during the build of the image
ARG TEMPIO_VERSION BUILD_ARCH
RUN \
  curl -sSLf -o /usr/bin/tempio \
  "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"

# install required dependencies
RUN \
  apk add \
  ca-certificates-bundle \
  libgcc \
  libssl3 \
  libstdc++ \
  zlib \
  icu-libs

# install dotnet using the Microsoft install script
WORKDIR /temp
RUN \
  wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
  bash ./dotnet-install.sh --version latest --runtime aspnetcore --install-dir /usr/local/bin

# Install the appropriate version of FRstackWebApi.dll
RUN mkdir -p /usr/local/frstack
WORKDIR /usr/local/frstack

RUN echo "$BUILD_ARCH"
RUN \
  if [ "${BUILD_ARCH}" = "armv7" ]; then  \
  wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && \
  unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip; \
  elif [ "${BUILD_ARCH}" = "amd64" ]; then  \
  wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip && \
  unzip FRStackWebApi-linux-64_3_7_3_74.zip; \
  fi



# Copy root filesystem
COPY rootfs /
RUN chmod +x /usr/local/bin/frstackwebapi

This is the error that gets thrown:

The command '/bin/ash -o pipefail -c if [ "${BUILD_ARCH}" = "armv7" ]; then wget https://www.mkcmsoftware.com/download/FRStackWebApi-rpi-arm64_3_7_3_74.zip && unzip FRStackWebApi-rpi-arm64_3_7_3_74.zip; 
elif [ "${BUILD_ARCH}" = "amd64" ]; then 
wget https://www.mkcmsoftware.com/download/FRStackWebApi-linux-x64_3_7_3_74.zip
 && unzip FRStackWebApi-linux-64_3_7_3_74.zip; fi' returned a non-zero code: 1

(I’ve added newlines as it’s just a single long line)

OK, I found it.

Simple typo in one of the commands in the if loop.
Sorry for the bad temper :frowning:

1 Like