HEIF: Improve build-libheif.sh and add install-libheif.sh script #2726

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-10-07 11:48:59 +02:00
parent e60c02228b
commit 810f01f0ae
4 changed files with 84 additions and 19 deletions

View file

@ -52,13 +52,12 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
x264 x265 libde265-dev libjpeg8 libvpx7 libwebm1 \ x264 x265 libde265-dev libjpeg8 libvpx7 libwebm1 \
&& \ && \
/scripts/install-darktable.sh && \ /scripts/install-darktable.sh && \
/scripts/install-libheif.sh && \
echo 'alias ll="ls -alh"' >> /etc/skel/.bashrc && \ echo 'alias ll="ls -alh"' >> /etc/skel/.bashrc && \
echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/skel/.bashrc && \ echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/skel/.bashrc && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: /scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: /scripts/entrypoint-init.sh" >> /etc/sudoers.d/init && \
cp /etc/skel/.bashrc /root/.bashrc && \ cp /etc/skel/.bashrc /root/.bashrc && \
/scripts/create-users.sh && \ /scripts/create-users.sh && \
(wget --inet4-only -c "https://dl.photoprism.app/dist/libheif/libheif.jammy.tar.gz" -O - | tar -xz -C /usr/local) && \
ldconfig && \
install -d -m 0777 -o 1000 -g 1000 \ install -d -m 0777 -o 1000 -g 1000 \
/photoprism/originals \ /photoprism/originals \
/photoprism/import \ /photoprism/import \

View file

@ -68,6 +68,7 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-nodejs.sh && \ /scripts/install-nodejs.sh && \
/scripts/install-tensorflow.sh && \ /scripts/install-tensorflow.sh && \
/scripts/install-darktable.sh && \ /scripts/install-darktable.sh && \
/scripts/install-libheif.sh && \
/scripts/install-chrome.sh && \ /scripts/install-chrome.sh && \
/scripts/install-go.sh && \ /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \
@ -76,8 +77,6 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
cp /etc/skel/.bashrc /root/.bashrc && \ cp /etc/skel/.bashrc /root/.bashrc && \
/scripts/create-users.sh && \ /scripts/create-users.sh && \
(wget --inet4-only -c "https://dl.photoprism.app/dist/libheif/libheif.jammy.tar.gz" -O - | tar -xz -C /usr/local) && \
ldconfig && \
install -d -m 0777 -o 1000 -g 1000 \ install -d -m 0777 -o 1000 -g 1000 \
/photoprism/originals \ /photoprism/originals \
/photoprism/import \ /photoprism/import \

View file

@ -1,31 +1,58 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Abort if not executed as root.
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
exit 1
fi
# Build "heif-convert", "heif-enc", "heif-info", and "heif-thumbnailer" from source. # Build "heif-convert", "heif-enc", "heif-info", and "heif-thumbnailer" from source.
CURRENT_DIR=$(pwd) CURRENT_DIR=$(pwd)
apt-get update
apt-get -qq install git autoconf automake cmake libtool libjpeg8 libjpeg8-dev libde265-dev # Query architecture.
if [[ $PHOTOPRISM_ARCH ]]; then
SYSTEM_ARCH=$PHOTOPRISM_ARCH
else
SYSTEM_ARCH=$(uname -m)
fi
. /etc/os-release
LATEST=$(curl --silent "https://api.github.com/repos/strukturag/libheif/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
LIBHEIF_VERSION=${1:-$LATEST}
DESTARCH=${2:-$SYSTEM_ARCH}
BUILD="libheif-$VERSION_CODENAME-$DESTARCH-$LIBHEIF_VERSION"
DESTDIR="${CURRENT_DIR}/build/$BUILD"
mkdir -p "$DESTDIR"
ARCHIVE="${CURRENT_DIR}/build/$BUILD.tar.gz"
echo "------------------------------------------------"
echo "VERSION: $LIBHEIF_VERSION"
echo "LATEST : $LATEST"
echo "ARCHIVE: $ARCHIVE"
echo "------------------------------------------------"
echo "Installing build deps..."
sudo apt-get -qq update
sudo apt-get -qq install build-essential gcc g++ gettext git autoconf automake cmake libtool libjpeg8 libjpeg8-dev libde265-dev
cd "/tmp" || exit cd "/tmp" || exit
rm -rf "/tmp/libheif" rm -rf "/tmp/libheif"
git clone https://github.com/strukturag/libheif.git
echo "Cloning git repository..."
git clone -c advice.detachedHead=false -b "$LIBHEIF_VERSION" --depth 1 https://github.com/strukturag/libheif.git libheif
cd libheif || exit cd libheif || exit
./autogen.sh ./autogen.sh
./configure ./configure
make make
# Install "heif-convert", "heif-enc", "heif-info", and "heif-thumbnailer" in "/usr/local". # Install "heif-convert", "heif-enc", "heif-info", and "heif-thumbnailer" in "/usr/local".
make install-exec echo "Installing binaries..."
DESTDIR=$DESTDIR make install-exec
cd "$CURRENT_DIR" || exit cd "$CURRENT_DIR" || exit
rm -rf "/tmp/libheif" rm -rf "/tmp/libheif"
# Create a tar archive to distribute the binaries on demand. # Create a tar archive to distribute the binaries.
if [[ $1 ]]; then echo "Creating $ARCHIVE..."
echo "creating $1..." tar -czf "$ARCHIVE" -C "$DESTDIR/usr/local" bin lib
(cd /usr/local && tar -czf "$1" lib/libheif.* bin/heif-convert bin/heif-enc bin/heif-info bin/heif-thumbnailer)
fi
echo "Done."

40
scripts/dist/install-libheif.sh vendored Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -e
LIBHEIF_VERSION=${1:-v1.13.0}
DESTDIR=$(realpath "${2:-/usr/local}")
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
DESTARCH=${DESTARCH:-$SYSTEM_ARCH}
. /etc/os-release
# abort if not executed as root
if [[ $(id -u) != "0" ]] && [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]]; then
echo "Error: Run ${0##*/} as root to install in a system directory!" 1>&2
exit 1
fi
mkdir -p "$DESTDIR"
ARCHIVE="libheif-${VERSION_CODENAME}-${DESTARCH}-${LIBHEIF_VERSION}.tar.gz"
URL="https://dl.photoprism.app/dist/libheif/${ARCHIVE}"
echo "------------------------------------------------"
echo "VERSION: $LIBHEIF_VERSION"
echo "ARCHIVE: $ARCHIVE"
echo "DESTDIR: $DESTDIR"
echo "------------------------------------------------"
echo "Extracting \"$URL\" to \"$DESTDIR\"."
wget --inet4-only -c "$URL" -O - | tar --overwrite --mode=755 -xz -C "$DESTDIR"
if [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]]; then
echo "Running \"ldconfig\"."
ldconfig
else
echo "Running \"ldconfig -n $DESTDIR/lib\"."
ldconfig -n "$DESTDIR/lib"
fi
echo "Done."