Add cross-architecture rpmbuild

This commit is contained in:
2025-04-22 23:51:56 -04:00
parent 4ac4bc09ad
commit e24ba4ea0f

View File

@@ -16,9 +16,10 @@
# #
# NOTES # NOTES
# * Be careful with tabs in heredocs # * Be careful with tabs in heredocs
# * Avoid execute() for stdout
shopt -s extglob shopt -s extglob
declare -g SCRIPT_VERSION="1.5.3" declare -g SCRIPT_VERSION="1.5.4-dev"
declare -g MC_REPO="bullseye" # should match the MC_VERSION declare -g MC_REPO="bullseye" # should match the MC_VERSION
# declare -g MC_REPO="bookworm" # should match the MC_VERSION # declare -g MC_REPO="bookworm" # should match the MC_VERSION
declare -g MC_VERSION="33.0.72" # do find all replace declare -g MC_VERSION="33.0.72" # do find all replace
@@ -120,7 +121,7 @@ parse_input() {
declare -gi BUILD_SWITCH REPO_INSTALL_SWITCH LOCAL_INSTALL_SWITCH \ declare -gi BUILD_SWITCH REPO_INSTALL_SWITCH LOCAL_INSTALL_SWITCH \
CONTAINER_INSTALL_SWITCH CREATEREPO_SWITCH SNAP_INSTALL_SWITCH \ CONTAINER_INSTALL_SWITCH CREATEREPO_SWITCH SNAP_INSTALL_SWITCH \
APPIMAGE_INSTALL_SWITCH COMPAT_SWITCH UNINSTALL_SWITCH YES_SWITCH DEBUG=0 APPIMAGE_INSTALL_SWITCH COMPAT_SWITCH UNINSTALL_SWITCH YES_SWITCH DEBUG=0
declare -g USER_MC_VERSION USER_MC_RELEASE USER_MC_REPO MJR_FILE \ declare -g USER_MC_VERSION USER_MC_RELEASE USER_MC_REPO USER_ARCH MJR_FILE \
BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY BUILD_TARGET CREATEREPO_TARGET BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY BUILD_TARGET CREATEREPO_TARGET
local long_opts short_opts input local long_opts short_opts input
long_opts="install:,build::,outputdir:,mcversion:,arch:,mcrepo:,compat," long_opts="install:,build::,outputdir:,mcversion:,arch:,mcrepo:,compat,"
@@ -176,7 +177,7 @@ parse_input() {
err "Bad --mcversion"; print_help; exit 1 err "Bad --mcversion"; print_help; exit 1
fi fi
;; ;;
--arch) shift; echo "Switching arch from $ARCH to $1"; ARCH="$1" ;; --arch) shift; USER_ARCH="$1" ;;
--mcrepo) shift; USER_MC_REPO="$1" ;; --mcrepo) shift; USER_MC_REPO="$1" ;;
--restorefile) shift; MJR_FILE="$1" ;; --restorefile) shift; MJR_FILE="$1" ;;
--betapass) shift; BETAPASS="$1" ;; --betapass) shift; BETAPASS="$1" ;;
@@ -223,9 +224,9 @@ parse_input() {
echo "If the MC package is unavailable, try using --mcrepo to select another repository" echo "If the MC package is unavailable, try using --mcrepo to select another repository"
fi fi
if [[ -n $CONTAINER_INSTALL_SWITCH ]] && ((LOCAL_INSTALL_SWITCH || REPO_INSTALL_SWITCH)); then # if [[ -n $CONTAINER_INSTALL_SWITCH ]] && ((LOCAL_INSTALL_SWITCH || REPO_INSTALL_SWITCH)); then
err "Some --install methods are incompatible" # err "Some --install methods are incompatible"
fi # fi
} }
# @description Perform OS detection and generate OS-specific functions # @description Perform OS detection and generate OS-specific functions
@@ -238,7 +239,7 @@ init() {
declare -g OUTPUT_DIR="$SCRIPT_DIR/output" declare -g OUTPUT_DIR="$SCRIPT_DIR/output"
declare -g CREATEREPO_WEBROOT="/var/www/jriver" declare -g CREATEREPO_WEBROOT="/var/www/jriver"
declare -g CREATEREPO_USER="$USER" # can be root declare -g CREATEREPO_USER="$USER" # can be root
declare -g ID VERSION_ID ARCH NAME declare -g ID VERSION_ID ARCH MC_ARCH NAME
declare -g MC_MVERSION MC_RELEASE MC_PKG MC_RPM MC_ROOT declare -g MC_MVERSION MC_RELEASE MC_PKG MC_RPM MC_ROOT
declare -ga PKG_INSTALL PKG_REMOVE PKG_UPDATE PKG_QUERY declare -ga PKG_INSTALL PKG_REMOVE PKG_UPDATE PKG_QUERY
declare -ga SERVICES CONTAINERS declare -ga SERVICES CONTAINERS
@@ -263,18 +264,31 @@ init() {
# Get host information # Get host information
[[ -f /etc/os-release ]] && source /etc/os-release [[ -f /etc/os-release ]] && source /etc/os-release
# Detect architecture and translate to MC convention # Detect host architecture and translate to MC convention
if ARCH=$(uname -m); then if ARCH=$(uname -m); then
case $ARCH in case $ARCH in
x86_64) ARCH="amd64" ;; x86_64) MC_ARCH="amd64" ;;
aarch64) ARCH="arm64" ;; aarch64) MC_ARCH="arm64" ;;
*) MC_ARCH="$ARCH" ;;
esac esac
else else
ARCH="amd64" ARCH="x86_64"
MC_ARCH="amd64"
err "Failed to detect host arch, using default: $ARCH" err "Failed to detect host arch, using default: $ARCH"
fi fi
debug "Detected host platform: $ID $VERSION_ID $ARCH" debug "Host: $ID $VERSION_ID $ARCH"
# Parse user-provided architecture, allow either convention
if [[ -n $USER_ARCH ]]; then
case $USER_ARCH in
x86_64|amd64) ARCH="x86_64"; MC_ARCH="amd64" ;;
aarch64|arm64) ARCH="aarch64"; MC_ARCH="arm64" ;;
*) ARCH="$USER_ARCH" ;;
esac
fi
debug "Target: $ARCH ($MC_ARCH)"
# Normalize ID and set host-specific vars # Normalize ID and set host-specific vars
case $ID in case $ID in
@@ -408,7 +422,6 @@ init() {
esac esac
fi fi
debug "Host platform: $ID $VERSION_ID"
debug "MC repository: $MC_REPO" debug "MC repository: $MC_REPO"
} }
@@ -576,7 +589,7 @@ install_external_repos() {
# Install mesa-va-drivers-freeworld separately from the RPM using dnf swap # Install mesa-va-drivers-freeworld separately from the RPM using dnf swap
install_mesa_freeworld install_mesa_freeworld
;; ;;
suse) : # TODO may eventually be needed if X11_XOrg is not available by default suse) : # TODO may be needed if X11_XOrg is unavailable in default repos
# if ! zypper repos | grep -q "X11_XOrg"; then # if ! zypper repos | grep -q "X11_XOrg"; then
# echo "Installing the X11 repository" # echo "Installing the X11 repository"
# execute sudo zypper --non-interactive --quiet addrepo \ # execute sudo zypper --non-interactive --quiet addrepo \
@@ -705,9 +718,9 @@ acquire_deb() {
# Usually JRiver excludes the release number from the filename # Usually JRiver excludes the release number from the filename
# but in some cases (test builds) it may be included # but in some cases (test builds) it may be included
if [[ $MC_RELEASE -gt 1 ]]; then if [[ $MC_RELEASE -gt 1 ]]; then
fname="MediaCenter-$MC_VERSION-$MC_RELEASE-$ARCH.deb" fname="MediaCenter-$MC_VERSION-$MC_RELEASE-$MC_ARCH.deb"
else else
fname="MediaCenter-$MC_VERSION-$ARCH.deb" fname="MediaCenter-$MC_VERSION-$MC_ARCH.deb"
fi fi
declare -g MC_DEB="$OUTPUT_DIR/SOURCES/$fname" declare -g MC_DEB="$OUTPUT_DIR/SOURCES/$fname"
@@ -870,7 +883,7 @@ build_rpm() {
Summary: JRiver Media Center Summary: JRiver Media Center
Group: Applications/Media Group: Applications/Media
Source0: $MC_SOURCE Source0: $MC_SOURCE
BuildArch: x86_64 BuildArch: $ARCH
%define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}-%%{release}.%%{ARCH}.rpm %define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}-%%{release}.%%{ARCH}.rpm
AutoReq: 0 AutoReq: 0
@@ -1032,7 +1045,7 @@ install_mc_arch() {
'vorbis-tools: ogg vorbis support' 'vorbis-tools: ogg vorbis support'
'musepack-tools: musepack support' 'musepack-tools: musepack support'
) )
source=("http://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/latest/MediaCenter-$MC_VERSION-$ARCH.deb") source=("http://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/latest/MediaCenter-$MC_VERSION-$MC_ARCH.deb")
package() { package() {
cd "\$srcdir" cd "\$srcdir"