Update Debian package build
This commit is contained in:
parent
546f4cd46f
commit
c846da4f9e
|
@ -1,23 +1,40 @@
|
|||
FROM debian:9
|
||||
ARG SOURCEDIR=/repo
|
||||
# Docker build arguments
|
||||
ARG SOURCE_DIR=/jellyfin
|
||||
ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-x64
|
||||
ARG ARTIFACT_DIR=/dist
|
||||
ARG SDK_VERSION=2.2
|
||||
# Docker run environment
|
||||
ENV SOURCE_DIR=/jellyfin
|
||||
ENV ARTIFACT_DIR=/dist
|
||||
ENV DEB_BUILD_OPTIONS=noddebs
|
||||
|
||||
# https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current
|
||||
# Prepare Debian build environment
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y apt-transport-https debhelper gnupg wget devscripts \
|
||||
&& wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \
|
||||
&& apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv libc6-dev libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev
|
||||
|
||||
# Install dotnet repository
|
||||
# https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current
|
||||
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \
|
||||
&& mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \
|
||||
&& wget -q https://packages.microsoft.com/config/debian/9/prod.list \
|
||||
&& mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \
|
||||
&& chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg \
|
||||
&& chown root:root /etc/apt/sources.list.d/microsoft-prod.list \
|
||||
&& apt-get update
|
||||
&& apt-get update \
|
||||
&& apt-get install -y dotnet-sdk-${SDK_VERSION}
|
||||
|
||||
WORKDIR ${SOURCEDIR}
|
||||
COPY . .
|
||||
COPY ./deployment/debian-package-x64/pkg-src ./debian
|
||||
# Link to docker-build script
|
||||
RUN ln -sf ${PLATFORM_DIR}/docker-build.sh /docker-build.sh
|
||||
|
||||
RUN yes | mk-build-deps -i debian/control \
|
||||
&& dpkg-buildpackage -us -uc
|
||||
# Link to Debian source dir; mkdir needed or it fails, can't force dest
|
||||
RUN mkdir -p ${SOURCE_DIR} && ln -sf ${PLATFORM_DIR}/pkg-src ${SOURCE_DIR}/debian
|
||||
|
||||
WORKDIR /
|
||||
# Prepare artifact volume
|
||||
VOLUME ${ARTIFACT_DIR}/
|
||||
|
||||
# Copy repository
|
||||
COPY . ${SOURCE_DIR}/
|
||||
|
||||
# Set docker-build entrypoint
|
||||
ENTRYPOINT ["/docker-build.sh"]
|
||||
|
|
|
@ -2,6 +2,29 @@
|
|||
|
||||
source ../common.build.sh
|
||||
|
||||
VERSION=`get_version ../..`
|
||||
keep_artifacts="${1}"
|
||||
|
||||
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION}
|
||||
WORKDIR="$( pwd )"
|
||||
VERSION="$( grep '^jellyfin' ${WORKDIR}/pkg-src/changelog | head -1 | awk -F '[()]' '{ print $2 }' )"
|
||||
|
||||
package_temporary_dir="${WORKDIR}/pkg-dist-tmp"
|
||||
output_dir="${WORKDIR}/pkg-dist"
|
||||
current_user="$( whoami )"
|
||||
image_name="jellyfin-debian-build"
|
||||
|
||||
rm -rf "${package_temporary_dir}" &>/dev/null \
|
||||
|| sudo rm -rf "${package_temporary_dir}" &>/dev/null
|
||||
|
||||
rm -rf "${output_dir}" &>/dev/null \
|
||||
|| sudo rm -rf "${output_dir}" &>/dev/null
|
||||
|
||||
if [[ ${keep_artifacts} == 'n' ]]; then
|
||||
docker_sudo=""
|
||||
if [[ ! -z $(id -Gn | grep -q 'docker') ]] \
|
||||
&& [[ ! ${EUID:-1000} -eq 0 ]] \
|
||||
&& [[ ! ${USER} == "root" ]] \
|
||||
&& [[ ! -z $( echo "${OSTYPE}" | grep -q "darwin" ) ]]; then
|
||||
docker_sudo=sudo
|
||||
fi
|
||||
${docker_sudo} docker image rm ${image_name} --force
|
||||
fi
|
||||
|
|
16
deployment/debian-package-x64/docker-build.sh
Executable file
16
deployment/debian-package-x64/docker-build.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Builds the DEB inside the Docker container
|
||||
|
||||
set -o errexit
|
||||
set -o xtrace
|
||||
|
||||
# Move to source directory
|
||||
pushd ${SOURCE_DIR}
|
||||
|
||||
# Build DEB
|
||||
dpkg-buildpackage -us -uc
|
||||
|
||||
# Move the artifacts out
|
||||
mkdir -p ${ARTIFACT_DIR}/deb
|
||||
mv /jellyfin_* ${ARTIFACT_DIR}/deb/
|
|
@ -2,30 +2,31 @@
|
|||
|
||||
source ../common.build.sh
|
||||
|
||||
VERSION=`get_version ../..`
|
||||
WORKDIR="$( pwd )"
|
||||
VERSION="$( grep '^jellyfin' ${WORKDIR}/pkg-src/changelog | head -1 | awk -F '[()]' '{ print $2 }' )"
|
||||
|
||||
# TODO get the version in the package automatically. And using the changelog to decide the debian package suffix version.
|
||||
package_temporary_dir="${WORKDIR}/pkg-dist-tmp"
|
||||
output_dir="${WORKDIR}/pkg-dist"
|
||||
current_user="$( whoami )"
|
||||
image_name="jellyfin-debian-build"
|
||||
|
||||
# Build a Jellyfin .deb file with Docker on Linux
|
||||
# Places the output .deb file in the parent directory
|
||||
# Determine if sudo should be used for Docker
|
||||
if [[ ! -z $(id -Gn | grep -q 'docker') ]] \
|
||||
&& [[ ! ${EUID:-1000} -eq 0 ]] \
|
||||
&& [[ ! ${USER} == "root" ]] \
|
||||
&& [[ ! -z $( echo "${OSTYPE}" | grep -q "darwin" ) ]]; then
|
||||
docker_sudo="sudo"
|
||||
else
|
||||
docker_sudo=""
|
||||
fi
|
||||
|
||||
package_temporary_dir="`pwd`/pkg-dist-tmp"
|
||||
output_dir="`pwd`/pkg-dist"
|
||||
current_user="`whoami`"
|
||||
image_name="jellyfin-debuild"
|
||||
|
||||
cleanup() {
|
||||
set +o errexit
|
||||
docker image rm $image_name --force
|
||||
rm -rf "$package_temporary_dir"
|
||||
}
|
||||
trap cleanup EXIT INT
|
||||
|
||||
docker build ../.. -t "$image_name" -f ./Dockerfile --build-arg SOURCEDIR="/jellyfin-${VERSION}"
|
||||
mkdir -p "$package_temporary_dir"
|
||||
mkdir -p "$output_dir"
|
||||
docker run --rm -v "$package_temporary_dir:/temp" "$image_name" sh -c 'find / -maxdepth 1 -type f -name "jellyfin*" -exec mv {} /temp \;'
|
||||
chown -R "$current_user" "$package_temporary_dir" \
|
||||
|| sudo chown -R "$current_user" "$package_temporary_dir"
|
||||
|
||||
mv "$package_temporary_dir"/* "$output_dir"
|
||||
# Set up the build environment Docker image
|
||||
${docker_sudo} docker build ../.. -t "${image_name}" -f ./Dockerfile
|
||||
# Build the DEBs and copy out to ${package_temporary_dir}
|
||||
${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}"
|
||||
# Correct ownership on the DEBs (as current user, then as root if that fails)
|
||||
chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \
|
||||
|| sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null
|
||||
# Move the DEBs to the output directory
|
||||
mkdir -p "${output_dir}"
|
||||
mv "${package_temporary_dir}"/deb/* "${output_dir}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user