Skip to content

Commit af9face

Browse files
Refactor QSV installation by creating a dedicated script for architecture detection and installation, improving maintainability and clarity.
1 parent c71a406 commit af9face

File tree

2 files changed

+85
-20
lines changed

2 files changed

+85
-20
lines changed

kdiff-snapshots/Dockerfile

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,15 @@ ENV QSV_VER="8.1.1"
1111
USER root
1212
RUN apt-get update -y \
1313
&& apt-get install -y wget gpg \
14-
&& wget -O - https://dathere.github.io/qsv-deb-releases/qsv-deb.gpg | sudo gpg --dearmor -o /usr/share/keyrings/qsv-deb.gpg \
15-
&& echo "deb [signed-by=/usr/share/keyrings/qsv-deb.gpg] https://dathere.github.io/qsv-deb-releases ./" | sudo tee /etc/apt/sources.list.d/qsv.list \
16-
&& apt-get update -y \
1714
&& apt-get install -y \
1815
inotify-tools ca-certificates \
1916
curl git unzip jq \
2017
&& apt-get clean \
2118
&& rm -rf /var/lib/apt/lists/*
2219

23-
24-
2520
# Install qsv depending on architecture
26-
RUN set -eux; \
27-
echo "Detected platform: ${TARGETPLATFORM}"; \
28-
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
29-
apt-get update -y && apt-get install -y qsv; \
30-
elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
31-
QSV_VER="8.1.1"; \
32-
QSV_DOWNLOAD_URL="https://github.com/dathere/qsv/releases/download/${QSV_VER}/qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"; \
33-
echo "Downloading QSV from $QSV_DOWNLOAD_URL"; \
34-
wget -q "$QSV_DOWNLOAD_URL"; \
35-
unzip "qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"; \
36-
ls -R; \
37-
rm "qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"; \
38-
else \
39-
echo "Unsupported platform: ${TARGETPLATFORM}" && exit 1; \
40-
fi
21+
COPY --chown=steampipe:steampipe install-qsv.sh .
22+
RUN bash install-qsv.sh
4123

4224
# # Install qsv
4325
# RUN echo "architecture = $(dpkg --print-architecture)" \

kdiff-snapshots/install-qsv.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env bash
2+
#
3+
# install-qsv.sh — Install qsv depending on CPU architecture (amd64 or arm64)
4+
#
5+
# This script installs qsv using the appropriate method for your platform.
6+
# Requires: bash, wget, unzip, sudo, apt
7+
#
8+
# Usage:
9+
# chmod +x install-qsv.sh
10+
# ./install-qsv.sh
11+
#
12+
13+
set -euo pipefail
14+
IFS=$'\n\t'
15+
16+
# --- Functions ---------------------------------------------------------------
17+
18+
log() {
19+
# Simple logging helper
20+
echo "[INFO] $*"
21+
}
22+
23+
error_exit() {
24+
echo "[ERROR] $*" >&2
25+
exit 1
26+
}
27+
28+
install_qsv_amd64() {
29+
log "Detected amd64 architecture. Installing qsv via APT repository..."
30+
31+
# Import GPG key and add repository
32+
wget -qO- https://dathere.github.io/qsv-deb-releases/qsv-deb.gpg \
33+
| sudo gpg --dearmor -o /usr/share/keyrings/qsv-deb.gpg
34+
35+
echo "deb [signed-by=/usr/share/keyrings/qsv-deb.gpg] https://dathere.github.io/qsv-deb-releases ./" \
36+
| sudo tee /etc/apt/sources.list.d/qsv.list > /dev/null
37+
38+
# Update and install qsv
39+
sudo apt update -y
40+
sudo apt install -y qsv
41+
42+
log "qsv installation complete (amd64)."
43+
}
44+
45+
install_qsv_arm64() {
46+
log "Detected arm64 architecture. Installing qsv manually..."
47+
48+
QSV_VER="8.1.1"
49+
QSV_DOWNLOAD_URL="https://github.com/dathere/qsv/releases/download/${QSV_VER}/qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"
50+
51+
log "Downloading QSV version ${QSV_VER} from ${QSV_DOWNLOAD_URL}"
52+
53+
wget -q "${QSV_DOWNLOAD_URL}"
54+
unzip -q "qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"
55+
rm "qsv-${QSV_VER}-aarch64-unknown-linux-gnu.zip"
56+
57+
log "Listing extracted files:"
58+
ls -R
59+
60+
log "qsv installation complete (arm64)."
61+
}
62+
63+
# --- Main --------------------------------------------------------------------
64+
65+
main() {
66+
ARCH="$(uname -m)"
67+
log "Detected architecture: ${ARCH}"
68+
69+
case "${ARCH}" in
70+
x86_64|amd64)
71+
install_qsv_amd64
72+
;;
73+
arm64|aarch64)
74+
install_qsv_arm64
75+
;;
76+
*)
77+
error_exit "Unsupported architecture: ${ARCH}"
78+
;;
79+
esac
80+
}
81+
ls -R
82+
main "$@"
83+
ls -R

0 commit comments

Comments
 (0)