From 3cb7fe50127b1a8158186b390836ee25ae5a50fd Mon Sep 17 00:00:00 2001 From: gnattu Date: Thu, 8 Dec 2022 00:18:04 +0800 Subject: [PATCH] feat: macOS arm64 build support (#8515) --- build.yaml | 3 +- ...ockerfile.macos => Dockerfile.macos.amd64} | 2 +- deployment/Dockerfile.macos.arm64 | 26 ++++++++++++++++ deployment/{build.macos => build.macos.amd64} | 2 +- deployment/build.macos.arm64 | 31 +++++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) rename deployment/{Dockerfile.macos => Dockerfile.macos.amd64} (90%) create mode 100644 deployment/Dockerfile.macos.arm64 rename deployment/{build.macos => build.macos.amd64} (96%) create mode 100755 deployment/build.macos.arm64 diff --git a/build.yaml b/build.yaml index 3f676a5cf..464caf328 100644 --- a/build.yaml +++ b/build.yaml @@ -13,5 +13,6 @@ packages: - centos.amd64 - linux.amd64 - windows.amd64 - - macos + - macos.amd64 + - macos.arm64 - portable diff --git a/deployment/Dockerfile.macos b/deployment/Dockerfile.macos.amd64 similarity index 90% rename from deployment/Dockerfile.macos rename to deployment/Dockerfile.macos.amd64 index f63dc2906..62f807687 100644 --- a/deployment/Dockerfile.macos +++ b/deployment/Dockerfile.macos.amd64 @@ -17,7 +17,7 @@ RUN apt-get update -yqq \ libfreetype6-dev libssl-dev libssl1.1 liblttng-ust0 # Link to docker-build script -RUN ln -sf ${SOURCE_DIR}/deployment/build.macos /build.sh +RUN ln -sf ${SOURCE_DIR}/deployment/build.macos.amd64 /build.sh VOLUME ${SOURCE_DIR}/ diff --git a/deployment/Dockerfile.macos.arm64 b/deployment/Dockerfile.macos.arm64 new file mode 100644 index 000000000..2dfbab9b3 --- /dev/null +++ b/deployment/Dockerfile.macos.arm64 @@ -0,0 +1,26 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim +# Docker build arguments +ARG SOURCE_DIR=/jellyfin +ARG ARTIFACT_DIR=/dist +# Docker run environment +ENV SOURCE_DIR=/jellyfin +ENV ARTIFACT_DIR=/dist +ENV DEB_BUILD_OPTIONS=noddebs +ENV ARCH=amd64 +ENV IS_DOCKER=YES + +# Prepare Debian build environment +RUN apt-get update -yqq \ + && apt-get install -yqq --no-install-recommends \ + debhelper gnupg devscripts \ + mmv libcurl4-openssl-dev libfontconfig1-dev \ + libfreetype6-dev libssl-dev libssl1.1 liblttng-ust0 + +# Link to docker-build script +RUN ln -sf ${SOURCE_DIR}/deployment/build.macos.arm64 /build.sh + +VOLUME ${SOURCE_DIR}/ + +VOLUME ${ARTIFACT_DIR}/ + +ENTRYPOINT ["/build.sh"] diff --git a/deployment/build.macos b/deployment/build.macos.amd64 similarity index 96% rename from deployment/build.macos rename to deployment/build.macos.amd64 index 01c640c8b..eac353877 100755 --- a/deployment/build.macos +++ b/deployment/build.macos.amd64 @@ -1,6 +1,6 @@ #!/bin/bash -#= MacOS 10.13+ .tar.gz +#= macOS 10.13+ amd64 .tar.gz set -o errexit set -o xtrace diff --git a/deployment/build.macos.arm64 b/deployment/build.macos.arm64 new file mode 100755 index 000000000..42da07e2f --- /dev/null +++ b/deployment/build.macos.arm64 @@ -0,0 +1,31 @@ +#!/bin/bash + +#= macOS 11.0+ arm64 .tar.gz + +set -o errexit +set -o xtrace + +# Move to source directory +pushd ${SOURCE_DIR} + +# Get version +if [[ ${IS_UNSTABLE} == 'yes' ]]; then + version="${BUILD_ID}" +else + version="$( grep "version:" ./build.yaml | sed -E 's/version: "([0-9\.]+.*)"/\1/' )" +fi + +# Build archives +dotnet publish Jellyfin.Server --configuration Release --self-contained --runtime osx-arm64 --output dist/jellyfin-server_${version}/ -p:DebugSymbols=false -p:DebugType=none -p:UseAppHost=true +tar -czf jellyfin-server_${version}_macos-arm64.tar.gz -C dist jellyfin-server_${version} +rm -rf dist/jellyfin-server_${version} + +# Move the artifacts out +mkdir -p ${ARTIFACT_DIR}/ +mv jellyfin[-_]*.tar.gz ${ARTIFACT_DIR}/ + +if [[ ${IS_DOCKER} == YES ]]; then + chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} +fi + +popd