2
0

package.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. source ../common.build.sh
  3. ARCH="$( arch )"
  4. WORKDIR="$( pwd )"
  5. package_temporary_dir="${WORKDIR}/pkg-dist-tmp"
  6. output_dir="${WORKDIR}/pkg-dist"
  7. current_user="$( whoami )"
  8. image_name="jellyfin-ubuntu_armhf-build"
  9. # Determine if sudo should be used for Docker
  10. if [[ ! -z $(id -Gn | grep -q 'docker') ]] \
  11. && [[ ! ${EUID:-1000} -eq 0 ]] \
  12. && [[ ! ${USER} == "root" ]] \
  13. && [[ ! -z $( echo "${OSTYPE}" | grep -q "darwin" ) ]]; then
  14. docker_sudo="sudo"
  15. else
  16. docker_sudo=""
  17. fi
  18. # Determine which Dockerfile to use
  19. case $ARCH in
  20. 'x86_64')
  21. DOCKERFILE="Dockerfile.amd64"
  22. ;;
  23. 'armv7l')
  24. DOCKERFILE="Dockerfile.armhf"
  25. ;;
  26. esac
  27. # Set up the build environment Docker image
  28. ${docker_sudo} docker build ../.. -t "${image_name}" -f ./${DOCKERFILE}
  29. # Build the DEBs and copy out to ${package_temporary_dir}
  30. ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}"
  31. # Correct ownership on the DEBs (as current user, then as root if that fails)
  32. chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \
  33. || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null
  34. # Move the DEBs to the output directory
  35. mkdir -p "${output_dir}"
  36. mv "${package_temporary_dir}"/deb/* "${output_dir}"