jellyfin-packaging/portable/build.sh

111 lines
3.4 KiB
Bash
Raw Normal View History

2024-02-11 19:21:47 +00:00
#!/bin/bash
2024-02-11 21:47:03 +00:00
#= Generic portable builder (portable, linux, macos, windows)
2024-02-11 19:21:47 +00:00
set -o errexit
set -o xtrace
2024-05-07 14:47:11 +00:00
# Set global variables
REPOSITORY_URI="https://repo.jellyfin.org"
FFMPEG_VERSION="7.x"
2024-05-07 14:47:11 +00:00
2024-02-11 19:21:47 +00:00
# Create the intermediate build dir
BUILD_DIR="/build"
2024-03-03 07:04:47 +00:00
mkdir -p ${BUILD_DIR}/jellyfin
2024-02-11 19:21:47 +00:00
# Move to source directory
pushd "${SOURCE_DIR}"
# Build server
pushd jellyfin-server
2024-03-03 06:21:34 +00:00
case ${BUILD_TYPE} in
2024-02-11 21:47:03 +00:00
portable)
RUNTIME=""
APPHOST="-p:UseAppHost=false"
;;
*)
2024-02-15 06:23:51 +00:00
RUNTIME="--self-contained --runtime ${DOTNET_TYPE}-${DOTNET_ARCH}"
2024-02-11 21:47:03 +00:00
APPHOST="-p:UseAppHost=true"
;;
esac
2024-03-03 07:04:47 +00:00
dotnet publish Jellyfin.Server --configuration Release ${RUNTIME} --output ${BUILD_DIR}/jellyfin/ -p:DebugSymbols=false -p:DebugType=none ${APPHOST}
2024-02-11 19:21:47 +00:00
popd
# Build web
pushd jellyfin-web
npm ci --no-audit --unsafe-perm
npm run build:production
2024-03-03 07:04:47 +00:00
mv dist ${BUILD_DIR}/jellyfin/jellyfin-web
2024-02-11 19:21:47 +00:00
popd
mkdir -p "${ARTIFACT_DIR}/"
2024-02-15 06:23:51 +00:00
if [[ -n ${PACKAGE_ARCH} ]]; then
2024-03-03 06:46:51 +00:00
VERSION_SUFFIX="${JELLYFIN_VERSION}-${PACKAGE_ARCH}"
2024-02-15 05:54:10 +00:00
else
2024-03-03 06:46:51 +00:00
VERSION_SUFFIX="${JELLYFIN_VERSION}"
2024-02-15 05:54:10 +00:00
fi
2024-02-11 19:21:47 +00:00
pushd ${BUILD_DIR}
2024-05-07 14:47:11 +00: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 14:47:11 +00: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 14:47:11 +00:00
curl --location --output ffmpeg.zip ${REPOSITORY_URI}${FFMPEG_PATH}
unzip ffmpeg.zip
rm ffmpeg.zip
;;
*)
true
;;
esac
popd
2024-02-11 19:21:47 +00:00
for ARCHIVE_TYPE in $( tr ',' '\n' <<<"${ARCHIVE_TYPES}" ); do
case ${ARCHIVE_TYPE} in
targz)
2024-03-03 07:04:47 +00:00
tar -czf "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.tar.gz jellyfin/
2024-02-11 19:21:47 +00:00
;;
2024-03-03 06:47:02 +00:00
tarxz)
2024-03-03 07:04:47 +00:00
tar -cJf "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.tar.xz jellyfin/
2024-03-03 06:47:02 +00:00
;;
2024-02-11 19:21:47 +00:00
zip)
2024-03-03 07:04:47 +00:00
zip -qr "${ARTIFACT_DIR}"/jellyfin_${VERSION_SUFFIX}.zip jellyfin/
2024-02-11 19:21:47 +00:00
;;
esac
done
popd
# Clean up any lingering artifacts
make -f debian/rules clean
rm -rf ${BUILD_DIR}
popd