Files

115 lines
3.5 KiB
Bash
Raw Permalink Normal View History

2024-02-11 14:21:47 -05:00
#!/bin/bash
2024-02-11 16:47:03 -05:00
#= Generic portable builder (portable, linux, macos, windows)
2024-02-11 14:21:47 -05:00
set -o errexit
set -o xtrace
2024-05-07 10:47:11 -04:00
# Set global variables
REPOSITORY_URI="https://repo.jellyfin.org"
FFMPEG_VERSION="7.x"
2024-05-07 10:47:11 -04:00
2024-02-11 14:21:47 -05:00
# Create the intermediate build dir
BUILD_DIR="/build"
2024-03-03 02:04:47 -05:00
mkdir -p ${BUILD_DIR}/jellyfin
2024-02-11 14:21:47 -05:00
# Move to source directory
pushd "${SOURCE_DIR}"
# Build server
pushd jellyfin-server
2024-03-03 01:21:34 -05:00
case ${BUILD_TYPE} in
2024-02-11 16:47:03 -05:00
portable)
RUNTIME=""
APPHOST="-p:UseAppHost=false"
;;
*)
2024-02-15 01:23:51 -05:00
RUNTIME="--self-contained --runtime ${DOTNET_TYPE}-${DOTNET_ARCH}"
2024-02-11 16:47:03 -05:00
APPHOST="-p:UseAppHost=true"
;;
esac
export DOTNET_CLI_TELEMETRY_OPTOUT=1
if [[ -z ${CONFIG} ]]; then
CONFIG="Release"
fi
dotnet publish Jellyfin.Server --configuration ${CONFIG} ${RUNTIME} --output ${BUILD_DIR}/jellyfin/ -p:DebugSymbols=false -p:DebugType=none ${APPHOST}
2024-02-11 14:21:47 -05:00
popd
# Build web
pushd jellyfin-web
npm ci --no-audit --unsafe-perm
npm run build:production
2024-03-03 02:04:47 -05:00
mv dist ${BUILD_DIR}/jellyfin/jellyfin-web
2024-02-11 14:21:47 -05:00
popd
mkdir -p "${ARTIFACT_DIR}/"
2024-02-15 01:23:51 -05:00
if [[ -n ${PACKAGE_ARCH} ]]; then
2024-03-03 01:46:51 -05:00
VERSION_SUFFIX="${JELLYFIN_VERSION}-${PACKAGE_ARCH}"
2024-02-15 00:54:10 -05:00
else
2024-03-03 01:46:51 -05:00
VERSION_SUFFIX="${JELLYFIN_VERSION}"
2024-02-15 00:54:10 -05:00
fi
2024-02-11 14:21:47 -05:00
pushd ${BUILD_DIR}
2024-05-07 10:47:11 -04:00
pushd jellyfin
# Fetch any additional package(s) needed here (i.e. FFmpeg)
# This is a hack because the ffmpeg naming is very inconsistent and we need to find the right URL(s) from the repo browser
case ${BUILD_TYPE}-${PACKAGE_ARCH} in
# linux-amd64*)
# FFMPEG_PATH=$( curl ${REPOSITORY_URI}/?path=/ffmpeg/linux/latest-${FFMPEG_VERSION}/amd64 | grep -o "/files/.*_portable_linux64-gpl.tar.xz'" | sed "s/'$//" )
# curl --location --output ffmpeg.tar.xz ${REPOSITORY_URI}${FFMPEG_PATH}
# tar -xvJf ffmpeg.tar.xz
# rm ffmpeg.tar.xz
# ;;
# linux-arm64*)
# FFMPEG_PATH=$( curl ${REPOSITORY_URI}/?path=/ffmpeg/linux/latest-${FFMPEG_VERSION}/arm64 | grep -o "/files/.*_portable_linuxarm64-gpl.tar.xz'" | sed "s/'$//" )
# curl --location --output ffmpeg.tar.xz ${REPOSITORY_URI}${FFMPEG_PATH}
# tar -xvJf ffmpeg.tar.xz
# rm ffmpeg.tar.xz
# ;;
# macos-amd64)
# FFMPEG_PATH=$( curl ${REPOSITORY_URI}/?path=/ffmpeg/macos/latest-${FFMPEG_VERSION}/x86_64 | grep -o "/files/.*_portable_mac64-gpl.tar.xz'" | sed "s/'$//" )
# curl --location --output ffmpeg.tar.xz ${REPOSITORY_URI}${FFMPEG_PATH}
# tar -xvJf ffmpeg.tar.xz
# rm ffmpeg.tar.xz
# ;;
# macos-arm64)
# FFMPEG_PATH=$( curl ${REPOSITORY_URI}/?path=/ffmpeg/macos/latest-${FFMPEG_VERSION}/arm64 | grep -o "/files/.*_portable_macarm64-gpl.tar.xz'" | sed "s/'$//" )
# curl --location --output ffmpeg.tar.xz ${REPOSITORY_URI}${FFMPEG_PATH}
# tar -xvJf ffmpeg.tar.xz
# rm ffmpeg.tar.xz
# ;;
2024-05-07 10:47:11 -04:00
windows-amd64)
FFMPEG_PATH=$( curl ${REPOSITORY_URI}/?path=/ffmpeg/windows/latest-${FFMPEG_VERSION}/win64 | grep -o "/files/.*_portable_win64-clang-gpl.zip'" | sed "s/'$//" )
2024-05-07 10:47:11 -04:00
curl --location --output ffmpeg.zip ${REPOSITORY_URI}${FFMPEG_PATH}
unzip ffmpeg.zip
rm ffmpeg.zip
;;
*)
true
;;
esac
popd
2024-02-11 14:21:47 -05:00
for ARCHIVE_TYPE in $( tr ',' '\n' <<<"${ARCHIVE_TYPES}" ); do
case ${ARCHIVE_TYPE} in
targz)
2024-03-03 02:04:47 -05:00
tar -czf "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.tar.gz jellyfin/
2024-02-11 14:21:47 -05:00
;;
2024-03-03 01:47:02 -05:00
tarxz)
2024-03-03 02:04:47 -05:00
tar -cJf "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.tar.xz jellyfin/
2024-03-03 01:47:02 -05:00
;;
2024-02-11 14:21:47 -05:00
zip)
2024-03-03 02:04:47 -05:00
zip -qr "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.zip jellyfin/
2024-02-11 14:21:47 -05:00
;;
esac
done
popd
# Clean up any lingering artifacts
make -f debian/rules clean
rm -rf ${BUILD_DIR}
popd