Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions .cloud66/scripts/install-prince-xml.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

if command -v prince >/dev/null 2>&1; then
echo "PrinceXML is already installed: $(command -v prince)"
Expand All @@ -10,19 +10,11 @@ fi
if ! command -v wget >/dev/null 2>&1; then
echo "wget is not installed. Installing wget..."
apt-get update
apt-get install -yy wget
apt-get install -y wget
else
echo "wget is installed: $(command -v wget)"
fi

if ! command -v gdebi >/dev/null 2>&1; then
echo "gdebi is not installed. Installing gdebi..."
apt-get update
apt-get install -yy gdebi
else
echo "gdebi is installed: $(command -v gdebi)"
fi

PRINCE_VERSION="16.1-1"
SYSTEM_ARCH="$(dpkg --print-architecture)"

Expand All @@ -44,28 +36,46 @@ else
exit 1
fi

if [ "${ID:-}" = "ubuntu" ]; then
PRINCE_PLATFORM="ubuntu22.04"
elif [ "${ID:-}" = "debian" ]; then
PRINCE_PLATFORM="debian12"
# PrinceXML ships a separate package per Ubuntu LTS / Debian release whose
# dependencies are pinned to that release (e.g. the ubuntu22.04 build requires
# libavif13, which does not exist on Ubuntu 24.04 "noble" — noble ships
# libavif16). The package MUST match the running release, not a hardcoded one.
if [ "${ID:-}" = "ubuntu" ] && [ -n "${VERSION_ID:-}" ]; then
PRINCE_PLATFORM="ubuntu${VERSION_ID}"
elif [ "${ID:-}" = "debian" ] && [ -n "${VERSION_ID:-}" ]; then
PRINCE_PLATFORM="debian${VERSION_ID%%.*}"
elif echo " ${ID_LIKE:-} " | grep -q " ubuntu "; then
PRINCE_PLATFORM="ubuntu22.04"
elif echo " ${ID_LIKE:-} " | grep -q " debian "; then
PRINCE_PLATFORM="debian12"
else
echo "Unsupported Linux distribution for PrinceXML package: ${ID:-unknown}" >&2
echo "Unsupported Linux distribution for PrinceXML package: ${ID:-unknown} ${VERSION_ID:-}" >&2
exit 1
fi

echo "Detected OS: ${ID:-unknown} ${VERSION_ID:-} -> PrinceXML platform: ${PRINCE_PLATFORM}, arch: ${PRINCE_ARCH}"

PRINCE_DEB_NAME="prince_${PRINCE_VERSION}_${PRINCE_PLATFORM}_${PRINCE_ARCH}.deb"
PRINCE_DEB_URL="https://www.princexml.com/download/${PRINCE_DEB_NAME}"
PRINCE_DEB_FILE="/tmp/${PRINCE_DEB_NAME}"

echo "Downloading PrinceXML package from $PRINCE_DEB_URL"
wget -O "$PRINCE_DEB_FILE" "$PRINCE_DEB_URL"
wget --tries=3 --timeout=60 -O "$PRINCE_DEB_FILE" "$PRINCE_DEB_URL"

# Guard against a server returning an HTML error page with a 200 status.
if ! file "$PRINCE_DEB_FILE" | grep -qi "debian binary package"; then
echo "Downloaded file is not a valid .deb package:" >&2
file "$PRINCE_DEB_FILE" >&2
exit 1
fi

echo "Installing PrinceXML..."
gdebi --non-interactive "$PRINCE_DEB_FILE"
# apt-get installs a local .deb and resolves its dependencies itself
# (apt >= 1.1). This avoids depending on gdebi, whose default package is the
# GTK GUI frontend (gdebi, not gdebi-core) and is unavailable on minimal
# server images.
apt-get update
apt-get install -y "$PRINCE_DEB_FILE"

if command -v prince >/dev/null 2>&1; then
echo "PrinceXML installed successfully: $(command -v prince)"
Expand Down
Loading