32 Commits

Author SHA1 Message Date
e5e85eac48 Prep for 1.0-rc2 2022-12-21 10:56:01 -05:00
f5eb145667 Make X11 service vars distro-specific 2022-12-21 10:40:02 -05:00
64c3c168a4 Make add-apt-repository quieter 2022-12-20 22:54:38 -05:00
54ba3423ff Always allow downgrades on Debian 2022-12-20 17:02:49 -05:00
976abf9040 Only install mesa on rhel 2022-12-20 16:57:34 -05:00
447e712de8 Don't warn on universe repo 2022-12-20 16:52:19 -05:00
24d707831d Use debian slim image 2022-12-20 16:44:40 -05:00
7f0f2615ed Install mesa-va-drivers-freeworld separately 2022-12-20 16:37:46 -05:00
dcd930af40 Install mesa-va-drivers-freeworld separately 2022-12-20 16:34:26 -05:00
39b7da2648 Remove debug 2022-12-20 12:59:56 -05:00
e6a8e8d77c Show mediacenter install on RHEL 2022-12-20 12:59:14 -05:00
53fbb2ebdc Fix package filter 2022-12-20 12:32:35 -05:00
fc13233b46 Temp debug 2022-12-20 12:26:31 -05:00
70fdb51758 Temp debug 2022-12-20 12:23:58 -05:00
1634caf8aa Temp debug 2022-12-20 12:21:55 -05:00
c7bd17778e Temp debug 2022-12-20 12:18:57 -05:00
2a37aacddb Pesky ;; 2022-12-20 12:16:48 -05:00
9e4109c70d Standardize installPackage flags 2022-12-20 12:11:26 -05:00
aabd17db9a Remove redundant check 2022-12-20 12:09:35 -05:00
fe794e874f Fix cert symlinks 2022-12-20 11:56:22 -05:00
bea86308c5 Quiet 2022-12-20 11:54:00 -05:00
48f1cc132a echo 2022-12-20 11:50:26 -05:00
37a1ac35ac Add rpmfusion and mesa-freeworld on RHEL 2022-12-20 11:38:32 -05:00
b3148f822f Improve startup experience 2022-12-19 17:49:26 -05:00
92b70e3a4a Install mesa-va-drivers-freeworld on rhel 2022-12-19 17:41:00 -05:00
4bef3bdab0 Remove X11 service vars 2022-12-04 14:05:12 -05:00
b577fc1155 Force copy library 2022-11-07 08:33:08 -05:00
d43cc9f6c8 Silence gpg key 2022-11-06 10:17:44 -05:00
e25bab1031 revert git -x 2022-10-13 14:28:24 -04:00
7d4e771a57 Replace some debugging with set -x 2022-10-13 14:20:02 -04:00
e1e0a55101 Use a variable for fallback mcversion 2022-10-12 13:02:37 -04:00
5e70364ec9 Raise MC version variables and refactor installPackage 2022-10-12 10:45:41 -04:00

View File

@@ -16,8 +16,13 @@
shopt -s extglob
declare -g SCRIPTVERSION="1.0-rc1"
declare -g SCRIPTVERSION="1.0-rc2"
declare -g OUTPUTDIR="$PWD/output"
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30 (Buster)
declare -g DEBIANBASE="buster"
declare -g MCVERSION_HARDCODE="30.0.44" # Hardcoded fallback
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
declare -g USER="${SUDO_USER:-$USER}"
declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6)
@@ -41,7 +46,7 @@ printHelp() {
--compat
Build/install MC locally without minimum library specifiers
--mcversion VERSION
Specify the MC version, ex. "30.0.17" (Default: latest)
Specify the MC version, ex. "30.0.17" (Default: latest version)
--outputdir PATH
Generate rpmbuild output in this directory (Default: ./output)
--restorefile RESTOREFILE
@@ -158,7 +163,7 @@ parseInput() {
shift && OUTPUTDIR="$1"
;;
--mcversion)
shift && MCVERSION="$1"
shift && declare -g MCVERSION_INPUT="$1"
;;
--restorefile)
shift && RESTOREFILE="$1"
@@ -235,13 +240,16 @@ init() {
declare -g ID RPM_MGR
echo "Starting installJRMC"
debug || echo "To enable debugging output, use --debug or -d"
if [[ -e "/etc/os-release" ]]; then
source "/etc/os-release"
else
err "/etc/os-release not found"
err "Your OS is unsupported"
printHelp
exit 1
exit 1
fi
debug "Detected host platform: $ID $VERSION_ID"
@@ -250,8 +258,8 @@ init() {
case "$ID" in
arch|debian)
;;
centos|fedora)
if hash dnf &>/dev/null; then
centos|fedora)
if hash dnf &>/dev/null; then
RPM_MGR="dnf"
elif hash yum &>/dev/null; then
RPM_MGR="yum"
@@ -294,6 +302,7 @@ init() {
pkg_install_local() { installMCRPM; }
pkg_remove(){ sudo "$RPM_MGR" remove -y "$@"; }
pkg_update(){ sudo "$RPM_MGR" makecache; }
pkg_swap() { sudo dnf swap -y "$1" "$2"; }
pkg_query(){ rpm -q "$@"; }
firewall_cmd(){ sudo firewall-cmd "$@"; }
;;
@@ -327,51 +336,55 @@ init() {
#######################################
# Uses several methods to determine the latest JRiver MC version
# TODO but how to determine build distro `$BASE=buster`?
# TODO but how to determine build distro `$DEBIANBASE=buster`?
#######################################
getVersion() {
setMCVersion() {
debug "Running: ${FUNCNAME[0]}"
declare -g MCVERSION VERSION_SOURCE MVERSION MCPKG MCRPM BASE="buster" #BASE_NEXT="bullseye"
declare boardurl="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30 (Buster)
declare -g MCVERSION MCVERSION_SOURCE MVERSION MCPKG MCRPM
declare cnt
# User input
if [[ -v MCVERSION && "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
VERSION_SOURCE="user input"
if [[ -v MCVERSION_INPUT ]]; then
if ! [[ "$MCVERSION_INPUT" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
err "Incorrect --mcversion format provided"
printHelp && exit 1
fi
MCVERSION="$MCVERSION_INPUT"
MCVERSION_SOURCE="user input"
# Containerized package manager
elif installPackage --silent buildah &&
cnt=$(buildah from --quiet debian:$BASE) &>/dev/null &&
cnt=$(buildah from --quiet debian:$DEBIANBASE-slim) &>/dev/null &&
buildah run "$cnt" -- bash -c \
"echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main' > /etc/apt/sources.list 2>&1" &>/dev/null &&
"echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $DEBIANBASE main' > /etc/apt/sources.list 2>&1" &>/dev/null &&
buildah run "$cnt" -- bash -c \
"apt update --allow-insecure-repositories &>/dev/null" &>/dev/null &&
MCVERSION=$(buildah run "$cnt" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1) &>/dev/null &&
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]] &&
VERSION_SOURCE="containerized package manager"; then
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
MCVERSION_SOURCE="containerized package manager"
buildah rm "$cnt" &>/dev/null
# Webscrape
elif installPackage wget && MCVERSION=$(wget -qO- "$boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) &&
elif installPackage wget && MCVERSION=$(wget -qO- "$BOARDURL" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) &&
[[ "$MCVERSION" =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
VERSION_SOURCE="webscrape"
MCVERSION_SOURCE="webscrape"
# Hardcoded
else
MCVERSION="30.0.17"
VERSION_SOURCE="hardcoded version"
err "Warning! Using hardcoded version number"
MCVERSION="$MCVERSION_HARDCODE"
MCVERSION_SOURCE="hardcoded version"
err "Warning! Using hardcoded version number."
fi
MVERSION="${MCVERSION%%.*}"
MCPKG="mediacenter$MVERSION"
MCRPM="$OUTPUTDIR/RPMS/x86_64/mediacenter$MVERSION-$MCVERSION.x86_64.rpm"
if [[ "$VERSION_SOURCE" == "user input" ]]; then
if [[ "$MCVERSION_SOURCE" == "user input" ]]; then
# Append explicit package version when user provides --mcversion
[[ "$ID" =~ ^(fedora|centos|suse)$ ]] && MCPKG+="-$MCVERSION"
[[ "$ID" =~ ^(debian|ubuntu)$ ]] && MCPKG+="=$MCVERSION"
else
echo "To override, use --mcversion"
fi
echo "Using MC version $MCVERSION determined by $VERSION_SOURCE"
echo "Using MC version $MCVERSION determined by $MCVERSION_SOURCE."
[[ "$MCVERSION_SOURCE" == "user input" ]] || echo "To override, use --mcversion."
debug "MVERSION: $MVERSION, MCVERSION: $MCVERSION, MCPKG: $MCPKG, MCRPM: $MCRPM"
}
@@ -382,38 +395,32 @@ getVersion() {
# One or more package names
# Options:
# --skip-check-installed: Do not check if package is already installed
# --nogpgcheck: Disable GPG checks for RPM based distros
# --allow-downgrades: Useful for installing compatability versions on DEB based distros
# --no-gpg-check: Disable GPG checks for RPM based distros
# --allow-downgrades: Useful for installing specific MC versions
# --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy)
#######################################
installPackage() {
debug "Running: ${FUNCNAME[0]}" "$@"
declare -a pkg_array install_flags
declare pkg skip_check_installed silent _return pkg_install_cmd
declare input pkg skip_check_installed silent pkg_install_cmd refresh allow_downgrades no_gpg_check
declare -A pkg_aliases
if _input=$(getopt -o +s -l skip-check-installed,allow-erasing,allow-downgrades,nogpgcheck,silent -- "$@"); then
eval set -- "$_input"
if input=$(getopt -o +s -l skip-check-installed,allow-downgrades,no-gpg-check,refresh,silent -- "$@"); then
eval set -- "$input"
while true; do
case "$1" in
--skip-check-installed)
skip_check_installed=1
;;
--allow-downgrades)
[[ "$ID" =~ ^(debian|ubuntu)$ ]] &&
install_flags+=(--allow-downgrades)
allow_downgrades=1
;;
--allow-erasing)
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
install_flags+=(--allowerasing)
fi
--no-gpg-check)
no_gpg_check=1
;;
--nogpgcheck)
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
install_flags+=(--nogpgcheck)
elif [[ "$ID" == "suse" ]]; then
install_flags+=(--allow-unsigned-rpm)
fi
--refresh)
refresh=1
;;
--silent|-s)
silent=1
@@ -430,25 +437,42 @@ installPackage() {
exit 1
fi
# Aliases
if [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
declare -A PKG_ALIASES
PKG_ALIASES["xorg-x11-utils"]="xorg-x11"
PKG_ALIASES["rpm-build"]="rpm"
PKG_ALIASES["createrepo_c"]="createrepo"
PKG_ALIASES["tigervnc-server"]="tigervnc-standalone-server"
fi
# Package aliases
case "$ID" in
debian|ubuntu)
pkg_aliases["rpm-build"]="rpm"
pkg_aliases["createrepo_c"]="createrepo"
pkg_aliases["tigervnc-server"]="tigervnc-standalone-server"
;;
esac
# Filter installed packages
for pkg in "$@"; do
if [[ ! -v skip_check_installed && -v PKG_ALIASES[$pkg] ]]; then
pkg=${PKG_ALIASES[$pkg]}
if [[ -v pkg_aliases[$pkg] ]]; then
pkg=${pkg_aliases[$pkg]}
fi
# Check if already installed
if (( skip_check_installed )) || ! (hash $pkg &>/dev/null || pkg_query "$pkg" &>/dev/null); then
if (( skip_check_installed )) || ! (hash "$pkg" &>/dev/null || pkg_query "$pkg" &>/dev/null); then
pkg_array+=("$pkg")
else
debug "$pkg already installed, skipping installation"
fi
done
# Generate distro-specific install flags
case "$ID" in
debian|ubuntu)
(( allow_downgrades )) && install_flags+=(--allow-downgrades)
;;
fedora|centos)
(( allow_downgrades )) && install_flags+=(--allowerasing)
(( no_gpg_check )) && install_flags+=(--nogpgcheck)
(( refresh )) && install_flags+=(--refresh)
;;
suse)
(( no_gpg_check )) && install_flags+=(--allow-unsigned-rpm)
;;
esac
# Install packages from package array
if [[ ${#pkg_array[@]} -ge 1 ]]; then
pkg_install_cmd="pkg_install ${install_flags[*]} ${pkg_array[*]}"
@@ -486,9 +510,9 @@ installMCFromRepo() {
sudo rm -rf "$repo_dir"/mediacenter*.list
installPackage wget
sudo bash -c "cat <<-EOF > $repo_dir/jriver.list
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $DEBIANBASE main
EOF"
wget -qO- "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | sudo tee /etc/apt/trusted.gpg.d/jriver.asc
wget -qO- "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" | sudo tee /etc/apt/trusted.gpg.d/jriver.asc &>/dev/null
;;
*)
err "An MC repository for $ID is not yet available."
@@ -504,8 +528,11 @@ installMCFromRepo() {
return 1
fi
declare pkg_install_cmd="installPackage --skip-check-installed --allow-erasing --nogpgcheck $MCPKG"
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
# Install mesa-va-drivers-freeworld separately from the RPM for dnf swap
installMesa
declare pkg_install_cmd="installPackage --skip-check-installed --allow-downgrades --no-gpg-check $MCPKG"
debug "$pkg_install_cmd"
if ! eval "$pkg_install_cmd"; then
err "Package install failed!"
return 1
@@ -622,6 +649,7 @@ buildRPM() {
requires=("${requires[@]/libvulkan1/vulkan-loader}")
requires=("${requires[@]/libepoxy0/libepoxy}")
requires=("${requires[@]/python/python3}")
recommends+=(mesa-va-drivers-freeworld)
;;
suse)
requires=("${requires[@]/libc6/glibc}")
@@ -710,7 +738,6 @@ buildRPM() {
# Run rpmbuild
echo "Building MC $MCVERSION RPM, this may take awhile"
(( DEBUG )) || echo "Use --debug for verbose output"
rpmbuild_cmd="rpmbuild --define=\"%_topdir $OUTPUTDIR\" --define=\"%_libdir /usr/lib\" -bb"
rpmbuild_cmd+=" $OUTPUTDIR/SPECS/mediacenter.spec"
debug "$rpmbuild_cmd" || rpmbuild_cmd+=" &>/dev/null"
@@ -732,7 +759,7 @@ buildRPM() {
installMCDEB() {
debug "Running: ${FUNCNAME[0]}"
declare pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck"
declare pkg_install_cmd="installPackage --skip-check-installed --no-gpg-check --allow-downgrades"
if (( COMPAT_SWITCH )); then
declare extract_dir && extract_dir="$(mktemp -d)"
pushd "$extract_dir" &>/dev/null || return
@@ -748,7 +775,6 @@ installMCDEB() {
ar rcs "$MCDEB" "debian-binary" "control.tar.xz" "data.tar.xz"
popd &>/dev/null || return
rm -rf "$extract_dir"
pkg_install_cmd+=" --allow-downgrades"
fi
pkg_install_cmd+=" $MCDEB"
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
@@ -761,10 +787,41 @@ installMCDEB() {
#######################################
installMCRPM() {
debug "Running: ${FUNCNAME[0]}"
installPackage --skip-check-installed --nogpgcheck --allow-erasing "$MCRPM"
# Install mesa-va-freeworld separately from the RPM for dnf swap
installMesa
installPackage --skip-check-installed --no-gpg-check --allow-downgrades "$MCRPM"
}
#######################################
# Installs mesa-va-drivers-freeworld
#######################################
installMesa() {
debug "Running: ${FUNCNAME[0]}"
# Currently only necessary in Fedora/CentOS
case "$ID" in
fedora|centos)
if ! pkg_query mesa-va-drivers-freeworld &>/dev/null; then
if pkg_query mesa-va-drivers &>/dev/null; then
declare pkg_swap_cmd="pkg_swap mesa-va-drivers mesa-va-drivers-freeworld"
debug "$pkg_swap_cmd" || pkg_swap_cmd+=" &>/dev/null"
if ! eval "$pkg_swap_cmd"; then
err "Package swap failed!"
return 1
fi
else
pkg_install mesa-va-drivers-freeworld
fi
fi
;;
esac
}
#######################################
# Installs local Media Center PKGBUILD
#######################################
@@ -845,9 +902,9 @@ symlinkCerts() {
# Have to use command array instead of eval because of whitespace in $mc_cert_link
if [[ -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then
ln_cmd="sudo ln -fs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem $mc_cert_link" # For RHEL
ln_cmd="sudo ln -fs /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \"$mc_cert_link\"" # For RHEL
elif [[ -f /var/lib/ca-certificates/ca-bundle.pem ]]; then
ln_cmd="sudo ln -fs /var/lib/ca-certificates/ca-bundle.pem $mc_cert_link" # For SUSE
ln_cmd="sudo ln -fs /var/lib/ca-certificates/ca-bundle.pem \"$mc_cert_link\"" # For SUSE
fi
debug "$ln_cmd" || ln_cmd+=" &>/dev/null"
@@ -1014,7 +1071,7 @@ setDisplay() {
setServiceVars() {
debug "Running: ${FUNCNAME[0]}"
declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING GRAPHICAL_TARGET
declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING DISPLAY_STRING GRAPHICAL_TARGET
declare -g SERVICE_TYPE="${SERVICE_TYPE:-system}"
declare service_dir="/usr/lib/systemd/$SERVICE_TYPE"
@@ -1036,12 +1093,23 @@ setServiceVars() {
systemctl_enable_cmd(){ systemctl --user enable --now "$@"; }
systemctl_disable_cmd(){ systemctl --user disable --now "$@"; }
systemctl_is_enabled_cmd(){ systemctl --user is-enabled -q "$@"; }
systemctl_is_active(){ sudo systemctl is-active -q "$@"; }
systemctl_is_active_cmd(){ systemctl --user is-active -q "$@"; }
GRAPHICAL_TARGET="default.target"
fi
[[ ! -d "$service_dir" ]] && sudo mkdir -p "$service_dir"
# TODO Ubuntu needs these in the service file, fedora (and others?) does not
case "$ID" in
ubuntu|debian)
DISPLAY_STRING="Environment=DISPLAY=$DISPLAY"
DISPLAY_STRING+=$'\n'"Environment=XAUTHORITY=$XAUTHORITY"
;;
*)
DISPLAY_STRING=""
;;
esac
if [[ "$SERVICE_TYPE" == "system" && "$USER" != "root" ]]; then
SERVICE_FNAME="$service_dir/${1}@.service"
TIMER_FNAME="$service_dir/${1}@.timer"
@@ -1075,6 +1143,7 @@ service_jriver-mediacenter() {
[Service]
$USER_STRING
$DISPLAY_STRING
Type=simple
Environment=DISPLAY=$DISPLAY
Environment=XAUTHORITY=$XAUTHORITY
@@ -1168,15 +1237,6 @@ service_jriver-x11vnc() {
setVNCPass x11vnc
# Get current desktop resolution
# TODO: may need to break this out into its own function and get smarter at identifying multi-monitors
# _getResolution() {
# debug "Running: ${FUNCNAME[0]}"
# installPackage xorg-x11-utils
# _res=$(xdpyinfo | grep dimensions | awk '{print $2}')
# }
# _getResolution
# If .Xauthority file is missing, generate a dummy for x11vnc -auth guess
if [[ ! -f "$HOME/.Xauthority" ]]; then
[[ "$XDG_SESSION_TYPE" == "wayland" ]] && ask_ok "Unsupported Wayland session detected for x11vnc, continue?" || return 1
@@ -1275,7 +1335,7 @@ service_jriver-createrepo() {
# installPackage buildah podman
# # Eventually try to switch to Debian
# # if ! CNT=$(buildah from debian:$BASE); then
# # if ! CNT=$(buildah from debian:$DEBIANBASE); then
# # echo "Bad base image for container $CNAME, skipping"
# # continue
# # fi
@@ -1424,7 +1484,7 @@ disableCoW() {
declare mc_system_path="/usr/lib/jriver"
declare mc_user_path="$HOME/.jriver"
[[ -d "$mc_user_path" ]] || mkdir -p "$mc_user_path"
[[ -d "$mc_user_path" ]] || mkdir -p "$mc_user_path"
for dir in "$mc_system_path" "$mc_user_path"; do
[[ -d "$dir" ]] || return
@@ -1451,7 +1511,7 @@ migrateLibrary() {
[[ -d "$previous_config_path" ]] &&
mkdir -p "$current_config_path"; then
echo "Migrating $previous_config_path to $current_config_path"
cp -a "$previous_config_path"/* "$current_config_path" &>/dev/null
cp -fa "$previous_config_path"/* "$current_config_path" &>/dev/null
fi
}
@@ -1534,7 +1594,7 @@ uninstall() {
tests() {
# To test on Mint/16.04: sudo apt install -y spice-vdagent ca-certificates git; export GIT_SSL_NO_VERIFY=1
exit $?
: # TODO
}
@@ -1555,7 +1615,7 @@ main() {
exit
fi
getVersion
setMCVersion
if (( UNINSTALL_SWITCH )); then
if askOk "Do you really want to uninstall JRiver Media Center?"; then
@@ -1566,12 +1626,16 @@ main() {
exit
fi
# Install external repos, if required
# Install external repos
case "$ID" in
ubuntu)
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
echo "Adding universe repository"
sudo add-apt-repository universe
declare add_universe_cmd="sudo add-apt-repository -y universe"
debug "$add_universe_cmd" || add_universe_cmd+=" &>/dev/null"
if ! exec "$add_universe_cmd"; then
err "Adding universe repository failed"
fi
fi
;;
centos)
@@ -1579,6 +1643,16 @@ main() {
echo "Adding EPEL repository"
installPackage epel-release
fi
if ! pkg_query rpmfusion-free-release &>/dev/null; then
installPackage --skip-check-installed \
"https://download1.rpmfusion.org/free/el/rpmfusion-free-release-$VERSION_ID.noarch.rpm"
fi
;;
fedora)
if ! pkg_query rpmfusion-free-release &>/dev/null; then
installPackage --skip-check-installed \
"https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$VERSION_ID.noarch.rpm"
fi
;;
esac