Skip to content

Commit

Permalink
better arch detection and option to override
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenye committed Mar 22, 2023
1 parent 7abf163 commit 0fc7e0d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 37 deletions.
67 changes: 47 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,84 @@ FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base
COPY rootfs/ /

RUN set -x && \
#
# Install libusb
apt-get update -y && \
apt-get install --no-install-recommends -y libusb-1.0-0 && \
apt-get -v clean && \
# Download airspy_adsb armhf binary
#
# Download airspy_adsb arm binary
curl \
--location \
--output /tmp/airspy_adsb-linux-arm.tgz \
"https://airspy.com/?ddownload=3753" \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-arm.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-arm.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.arm && \
#
# Download airspy_adsb arm64 binary
curl \
--location \
--output /tmp/airspy_adsb-linux-arm64.tgz \
"https://airspy.com/?ddownload=3753" \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-arm64.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-arm64.tgz \
-C /tmp \
&& \
# Download airspy_adsb amd64 binary
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.arm64 && \
#
# Download airspy_adsb armv7 binary
curl \
--location \
--output /tmp/airspy_adsb-linux-x86_64.tgz \
"https://airspy.com/?ddownload=3758" \
--output /tmp/airspy_adsb-linux-armv7.tgz \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-armv7.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-armv7.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.armv7 && \
#
# Download airspy_adsb i386 binary
curl \
--location \
--output /tmp/airspy_adsb-linux-i386.tgz \
"https://airspy.com/?ddownload=6063" \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-i386.tgz" \
&& \
# Extract armhf binary
tar \
xvf /tmp/airspy_adsb-linux-arm.tgz \
xvf /tmp/airspy_adsb-linux-i386.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.armhf && \
# Extract arm64 binary
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.i386 && \
#
# Download airspy_adsb nehalem binary
curl \
--location \
--output /tmp/airspy_adsb-linux-nehalem.tgz \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-nehalem.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-arm64.tgz \
xvf /tmp/airspy_adsb-linux-nehalem.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.aarch64 && \
# Extract amd64 binary
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.nehalem && \
#
# Download airspy_adsb x86_64 binary
curl \
--location \
--output /tmp/airspy_adsb-linux-x86_64.tgz \
"https://github.com/wiedehopf/airspy-conf/raw/master/buster/airspy_adsb-linux-x86_64.tgz" \
&& \
tar \
xvf /tmp/airspy_adsb-linux-x86_64.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.x86_64 && \
# Extract i386 binary
tar \
xvf /tmp/airspy_adsb-linux-i386.tgz \
-C /tmp \
&& \
mv -v /tmp/airspy_adsb /usr/local/bin/airspy_adsb.i386 && \
#
# Ensure all binaries are executable
chmod -v a+x /usr/local/bin/airspy_adsb.*

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Docker container running AirSpy's `airspy_adsb` receiver. Designed to work in ta
| `AIRSPY_ADSB_BIAS_TEE` | `-b` | Set to `true` to enable Bias-Tee | *unset* |
| `AIRSPY_ADSB_BIT_PACKING` | `-p` | Set to `true` to enable Bit Packing | *unset* |
| `AIRSPY_ADSB_VERBOSE` | `-v` | Enable Verbose mode | *unset* |
| `AIRSPY_ADSB_ARCH` | N/A | Forces a specific architecture binary. Supports `arm64`, `armv7`, `arm`, `nehalem`, `x86_64` or `i386`. If unset, will auto-detect. | *unset* |


## Using with `readsb`

Expand Down
62 changes: 45 additions & 17 deletions rootfs/etc/services.d/airspy_adsb/run
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,54 @@ if [[ "${AIRSPY_ADSB_VERBOSE^^}" == "TRUE" ]]; then
AIRSPY_ADSB_CMD+=("-v")
fi

# Determine which architecture binary is supported, else fail.
if /usr/local/bin/airspy_adsb.aarch64 -h > /dev/null 2>&1; then
AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.aarch64"
echo "Using aarch64 binary" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
elif /usr/local/bin/airspy_adsb.armhf -h > /dev/null 2>&1; then
AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.armhf"
echo "Using armhf binary" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
elif /usr/local/bin/airspy_adsb.i386 -h > /dev/null 2>&1; then
AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.i386"
echo "Using i386 binary" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
elif /usr/local/bin/airspy_adsb.x86_64 -h > /dev/null 2>&1; then
AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.x86_64"
echo "Using x86_64 binary" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
else
>&2 echo "ERROR: Unsupported architecture: $(uname -m)!" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
sleep infinity
# Handle architecture
if [[ -z "$AIRSPY_ADSB_ARCH" ]]; then

echo "[airspy_adsb] Autodetecting architecture"

# Determine which architecture binary is supported, else fail.
if /usr/local/bin/airspy_adsb.arm64 -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="arm64"

elif /usr/local/bin/airspy_adsb.armv7 -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="armv7"

elif /usr/local/bin/airspy_adsb.arm -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="arm"

elif /usr/local/bin/airspy_adsb.nehalem -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="nehalem"

elif /usr/local/bin/airspy_adsb.x86_64 -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="x86_64"

elif /usr/local/bin/airspy_adsb.i386 -h > /dev/null 2>&1; then
AIRSPY_ADSB_ARCH="i386"

else
>&2 echo "[airspy_adsb] ERROR: Unsupported architecture: $(uname -m)!"
sleep infinity
fi
fi

# Specify binary path
AIRSPY_ADSB_BIN="/usr/local/bin/airspy_adsb.${AIRSPY_ADSB_ARCH}"

# Ensure binary exists
if [[ ! -x "$AIRSPY_ADSB_BIN" ]]; then
>&2 echo "[airspy_adsb] ERROR: Executable binary not found for architecture: $AIRSPY_ADSB_ARCH!"
sleep infinity
fi

# Ensure binary runnable
if ! "$AIRSPY_ADSB_BIN" -h > /dev/null 2>&1; then
>&2 echo "[airspy_adsb] ERROR: Executable $AIRSPY_ADSB_ARCH binary not supported on $(uname -m) architecture!"
sleep infinity
fi

# Execute binary with arguments prepared above
echo "Running: airspy_adsb" "${AIRSPY_ADSB_CMD[@]}" | stdbuf -oL awk '{print "[airspy_adsb] " $0}'
echo "[airspy_adsb] Running $AIRSPY_ADSB_ARCH binary on $(uname -m) architecture."
echo "[airspy_adsb] Running: airspy_adsb" "${AIRSPY_ADSB_CMD[@]}"

#shellcheck disable=SC2016
"${AIRSPY_ADSB_BIN}" "${AIRSPY_ADSB_CMD[@]}" \
Expand Down

0 comments on commit 0fc7e0d

Please sign in to comment.