From ea6561e64e024728304acafe8ec22f1e61f2b7c3 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sun, 24 Jul 2022 15:07:00 +0100 Subject: [PATCH 1/3] Add support for arm64 --- Dockerfile | 20 -------------- README.md | 4 +-- root/etc/cont-init.d/98-calibre | 49 ++++++++++++++++++++++++++------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8073ac5..46ab765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,26 +8,6 @@ ARG DEBIAN_FRONTEND="noninteractive" LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="chbmb" -RUN \ - echo "**** Install packages ****" && \ - apt-get update && \ - apt-get install -y \ - xz-utils && \ - echo "**** Fetch calibre bin ****" && \ - if [ -z ${CALIBRE_RELEASE+x} ]; then \ - CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - CALIBRE_RELEASE=$(echo "${CALIBRE_RELEASE}" | sed 's/^v//g' ) && \ - mkdir -p \ - /root-layer/app/calibre && \ - curl -o \ - /tmp/calibre.txz -L \ - "https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-x86_64.txz" && \ - tar xf \ - /tmp/calibre.txz \ - -C /root-layer/app/calibre - # copy local files COPY root/ /root-layer/ diff --git a/README.md b/README.md index 2e596b3..15fdc72 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Calibre - Docker mod for Ubuntu-based x86_64 containers +# Calibre - Docker mod for 64-bit Ubuntu-based containers -This mod adds the calibre binary to calibre-web, or other *Ubuntu-based* containers (**x86_64 only**), for ebook conversions. +This mod adds the calibre binary to calibre-web, or other *64-bit Ubuntu-based* containers, for ebook conversions. In calibre-web docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:universal-calibre` to enable. diff --git a/root/etc/cont-init.d/98-calibre b/root/etc/cont-init.d/98-calibre index 5908316..2fbf3c9 100644 --- a/root/etc/cont-init.d/98-calibre +++ b/root/etc/cont-init.d/98-calibre @@ -1,12 +1,12 @@ #!/usr/bin/with-contenv bash -if [[ ! "$(uname -m)" == "x86_64" ]]; then +if [[ "$(uname -m)" == "armv7l" ]]; then cat <<-EOF ******************************************************** ******************************************************** * * * !!!! * - * This mod is only supported on x86_64. * + * This mod is not supported on armhf. * * * ******************************************************** ******************************************************** @@ -31,30 +31,59 @@ fi export DEBIAN_FRONTEND="noninteractive" +PACKAGES+=("xz-utils") + if [ ! -L /usr/lib/x86_64-linux-gnu/libGL.so.1 ]; then - PACKAGES+=("libgl1-mesa-glx") + PACKAGES+=("libgl1-mesa-glx") fi if [ ! -L /usr/lib/x86_64-linux-gnu/libxdamage.so.1 ]; then - PACKAGES+=("libxdamage1") + PACKAGES+=("libxdamage1") fi if [ ! -L /usr/lib/x86_64-linux-gnu/libEGL.so.1 ]; then - PACKAGES+=("libegl1") + PACKAGES+=("libegl1") fi if [ ! -L /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 ]; then - PACKAGES+=("libxkbcommon0") + PACKAGES+=("libxkbcommon0") fi if [ ! -L /usr/lib/x86_64-linux-gnu/libOpenGL.so.0 ]; then - PACKAGES+=("libopengl0") + PACKAGES+=("libopengl0") fi if [ -v "PACKAGES[@]" ]; then - apt-get install -y "${PACKAGES[@]}" + apt-get install -y "${PACKAGES[@]}" fi -if [ ! -e /usr/bin/calibre-server ]; then - /app/calibre/calibre_postinstall +echo "**** Fetching calibre bin ****" +if [ -z ${CALIBRE_RELEASE+x} ]; then + CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ +fi + +CALIBRE_RELEASE=$(echo "${CALIBRE_RELEASE}" | sed 's/^v//g' ) + +mkdir -p \ + /app/calibre + +if [ "$(uname -m)" == "x86_64" ]; then + curl -o \ + /tmp/calibre.txz -L \ + "https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-x86_64.txz" +fi + +if [ "$(uname -m)" == "aarch64" ]; then + curl -o \ + /tmp/calibre.txz -L \ + "https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-arm64.txz" +fi + +tar xf \ + /tmp/calibre.txz \ + -C /app/calibre + +if [ ! -e /usr/bin/calibre-server ]; then + /app/calibre/calibre_postinstall fi From edb64a22b71dfb4db2d15e91e9222eafac8c6113 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sun, 24 Jul 2022 15:28:45 +0100 Subject: [PATCH 2/3] Pull fixed version of calibre based on build time --- Dockerfile | 7 +++++++ root/etc/cont-init.d/98-calibre | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 46ab765..e7cb807 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,13 @@ ARG DEBIAN_FRONTEND="noninteractive" LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="chbmb" +RUN \ + mkdir -p \ + /root-layer && \ + CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's/^v//g') && \ + echo $CALIBRE_RELEASE > /root-layer/CALIBRE_RELEASE + # copy local files COPY root/ /root-layer/ diff --git a/root/etc/cont-init.d/98-calibre b/root/etc/cont-init.d/98-calibre index 2fbf3c9..5ed0a5a 100644 --- a/root/etc/cont-init.d/98-calibre +++ b/root/etc/cont-init.d/98-calibre @@ -31,6 +31,7 @@ fi export DEBIAN_FRONTEND="noninteractive" +CALIBRE_RELEASE="$(cat /CALIBRE_RELEASE)" PACKAGES+=("xz-utils") if [ ! -L /usr/lib/x86_64-linux-gnu/libGL.so.1 ]; then @@ -60,11 +61,9 @@ fi echo "**** Fetching calibre bin ****" if [ -z ${CALIBRE_RELEASE+x} ]; then CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's/^v//g'); \ fi -CALIBRE_RELEASE=$(echo "${CALIBRE_RELEASE}" | sed 's/^v//g' ) - mkdir -p \ /app/calibre From 8666950f482041c8cea6e5911f3d3eedc491ebb1 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sun, 24 Jul 2022 15:34:20 +0100 Subject: [PATCH 3/3] Download from github rather than calibre's own mirror --- Dockerfile | 2 +- root/etc/cont-init.d/98-calibre | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e7cb807..529c581 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN \ mkdir -p \ /root-layer && \ CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's/^v//g') && \ + | awk '/tag_name/{print $4;exit}' FS='[""]') && \ echo $CALIBRE_RELEASE > /root-layer/CALIBRE_RELEASE # copy local files diff --git a/root/etc/cont-init.d/98-calibre b/root/etc/cont-init.d/98-calibre index 5ed0a5a..cd9d71f 100644 --- a/root/etc/cont-init.d/98-calibre +++ b/root/etc/cont-init.d/98-calibre @@ -61,7 +61,7 @@ fi echo "**** Fetching calibre bin ****" if [ -z ${CALIBRE_RELEASE+x} ]; then CALIBRE_RELEASE=$(curl -sX GET "https://api.github.com/repos/kovidgoyal/calibre/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's/^v//g'); \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi mkdir -p \ @@ -70,13 +70,13 @@ mkdir -p \ if [ "$(uname -m)" == "x86_64" ]; then curl -o \ /tmp/calibre.txz -L \ - "https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-x86_64.txz" + "https://github.com/kovidgoyal/calibre/releases/download/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE:1}-x86_64.txz" fi if [ "$(uname -m)" == "aarch64" ]; then curl -o \ /tmp/calibre.txz -L \ - "https://download.calibre-ebook.com/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE}-arm64.txz" + "https://github.com/kovidgoyal/calibre/releases/download/${CALIBRE_RELEASE}/calibre-${CALIBRE_RELEASE:1}-arm64.txz" fi tar xf \