From 03b290eba7876ceae460a1fedf53c683b3af21fe Mon Sep 17 00:00:00 2001 From: Googol Lee Date: Wed, 20 Aug 2025 21:29:03 +0200 Subject: [PATCH] Update API with Debian trixie (#1286) Fix #1273. - Cleanup `libatlas-base-dev` `ATLAS` is an optimized BLAS implementation. Today, the project looks dead. The last stable release (3.10.3) happened in 2016. The last development release (3.11.41, not packaged) was in 2018. The git repository has seen no commit since 2019. Debian decided to [remove all `libatlas` packages](https://lists.debian.org/debian-science/2023/07/msg00010.html), including `libatlas-base-dev` from `trixie`. `libatlas-base-dev` provides a unique `cblas` package with `pkg-config`. Debian provides [`blas`](https://lists.debian.org/debian-science/2023/07/msg00012.html) to cover all the feature in `cblas`. `go-face` already depends on [`blas`](https://github.com/Kagami/go-face/blob/0c14797b4d0e0a8ff4e183ddbd93cab35a42f0f8/face.go#L4), and it's safe to remove `cblas`. Maybe we should fork `go-face` and put those changes in the foked repo. - Renaming `exiftool` In `trixie`, `exiftool` package is renamed as `libimage-exiftool-perl`. --- Dockerfile | 7 ++++--- README.md | 17 +++++++++++++---- scripts/install_build_dependencies.sh | 2 +- scripts/install_runtime_dependencies.sh | 10 +++++----- scripts/set_compiler_env.sh | 2 +- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3de800d4..e5e1bc20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ RUN export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%S+00:00(UTC)'); \ npm run build -- --base="${UI_PUBLIC_URL}" ### Build API ### -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.25-bookworm AS api +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.25-trixie AS api ARG TARGETPLATFORM # See for details: https://github.com/hadolint/hadolint/wiki/DL4006 @@ -61,7 +61,7 @@ RUN chmod +x /app/scripts/*.sh \ && /app/scripts/install_runtime_dependencies.sh # hadolint ignore=DL3022 -COPY --from=photoview/dependencies:latest /artifacts.tar.gz /dependencies/ +COPY --from=photoview/dependencies:trixie /artifacts.tar.gz /dependencies/ WORKDIR /dependencies RUN set -a && source /env && set +a \ && git config --global --add safe.directory /app \ @@ -81,6 +81,7 @@ RUN set -a && source /env && set +a \ && go mod download \ # Patch go-face && sed -i 's/-march=native//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go \ + && sed -i 's/-lcblas//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go \ # Build dependencies that use CGO && go install \ github.com/mattn/go-sqlite3 \ @@ -92,7 +93,7 @@ RUN set -a && source /env && set +a \ && go build -v -o photoview . ### Build release image ### -FROM debian:bookworm-slim AS release +FROM debian:trixie-slim AS release ARG TARGETPLATFORM # See for details: https://github.com/hadolint/hadolint/wiki/DL4006 diff --git a/README.md b/README.md index f5bd7b87..f57456a9 100644 --- a/README.md +++ b/README.md @@ -270,14 +270,14 @@ We can't keep verifying below commands on each environment. People may need to s - Required packages: - `golang` >= 1.22 - `g++` - - `libc-dev` - `libheif` >= 1.15.1 - [go-face Requirements](https://github.com/Kagami/go-face#requirements) - `dlib` - `libjpeg` - `libblas` - - `libcblas`, recommended using `libatlas-base` in Debian. - `liblapack` + - `libmagic` + - `libmagickwand` - Optional tools during developing: - [`reflex`](https://github.com/cespare/reflex): a source code monitoring tool, which automatically rebuilds and restarts the server, running from the code in development. - `sqlite`: the SQLite DBMS, useful to interact with Photoview's SQLite DB directly if you use it in your development environment. @@ -289,7 +289,7 @@ In Debian/Ubuntu, install dependencies: ```sh $ sudo apt update # Update the package list -$ sudo apt install golang g++ libc-dev libheif-dev libdlib-dev libjpeg-dev libblas-dev libatlas-base-dev liblapack-dev # For API requirement +$ sudo apt install golang g++ libheif-dev libdlib-dev libjpeg-dev libblas-dev liblapack-dev libmagic-dev libmagickwand-dev # For API requirement $ sudo apt install reflex sqlite3 # For API optional tools ``` @@ -331,14 +331,23 @@ Then run the following commands: ```bash # Optional: Set the compiler environment in Debian/Ubuntu $ source ./scripts/set_compiler_env.sh + # Set the compiler environment with `homebrew` $ export CPLUS_INCLUDE_PATH="$(brew --prefix)/opt/jpeg/include:$(brew --prefix)/opt/dlib/include:${CPLUS_INCLUDE_PATH:-}" $ export C_INCLUDE_PATH="$(brew --prefix)/opt/libmagic/include:$(brew --prefix)/opt/libheif/include:${C_INCLUDE_PATH:-}" $ export DYLD_LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib:$(brew --prefix)/opt/libmagic/lib:$(brew --prefix)/opt/libheif/lib:${DYLD_LIBRARY_PATH:-}" $ export LIBRARY_PATH="$(brew --prefix)/opt/jpeg/lib:$(brew --prefix)/opt/dlib/lib:$(brew --prefix)/opt/libmagic/lib:$(brew --prefix)/opt/libheif/lib:${LIBRARY_PATH:-}" $ export CGO_CFLAGS_ALLOW=-Xpreprocessor -# Start API server + $ cd ./api +$ go mod download + +# Update go-face dependencies +$ sed -i 's/-lcblas//g' $(go env GOMODCACHE)/github.com/\!kagami/go-face*/face.go # Linux +# Or +$ sed -i '' 's/-lcblas//g' $(go env GOMODCACHE)/github.com/\!kagami/go-face*/face.go # macOS + +# Start API server $ go run . ``` diff --git a/scripts/install_build_dependencies.sh b/scripts/install_build_dependencies.sh index 3a0a2054..f2166f8b 100755 --- a/scripts/install_build_dependencies.sh +++ b/scripts/install_build_dependencies.sh @@ -15,7 +15,7 @@ apt-get install -y --no-install-recommends libjpeg62-turbo-dev:${DEB_HOST_ARCH} apt-get install -y --no-install-recommends libjxl-dev:${DEB_HOST_ARCH} liblcms2-dev:${DEB_HOST_ARCH} liblqr-1-0-dev:${DEB_HOST_ARCH} libdjvulibre-dev:${DEB_HOST_ARCH} libjpeg62-turbo-dev:${DEB_HOST_ARCH} libopenjp2-7-dev:${DEB_HOST_ARCH} libopenexr-dev:${DEB_HOST_ARCH} libpng-dev:${DEB_HOST_ARCH} libtiff-dev:${DEB_HOST_ARCH} libwebp-dev:${DEB_HOST_ARCH} libxml2-dev:${DEB_HOST_ARCH} libfftw3-dev:${DEB_HOST_ARCH} zlib1g-dev:${DEB_HOST_ARCH} liblzma-dev:${DEB_HOST_ARCH} libbz2-dev:${DEB_HOST_ARCH} # Install go-face dependencies -apt-get install -y --no-install-recommends libdlib-dev:${DEB_HOST_ARCH} libblas-dev:${DEB_HOST_ARCH} libatlas-base-dev:${DEB_HOST_ARCH} liblapack-dev:${DEB_HOST_ARCH} libjpeg62-turbo-dev:${DEB_HOST_ARCH} +apt-get install -y --no-install-recommends libdlib-dev:${DEB_HOST_ARCH} libblas-dev:${DEB_HOST_ARCH} liblapack-dev:${DEB_HOST_ARCH} libjpeg62-turbo-dev:${DEB_HOST_ARCH} # Install gomagic dependencies apt-get install -y --no-install-recommends libmagic-dev:${DEB_HOST_ARCH} diff --git a/scripts/install_runtime_dependencies.sh b/scripts/install_runtime_dependencies.sh index db6dfa95..0cae49ce 100755 --- a/scripts/install_runtime_dependencies.sh +++ b/scripts/install_runtime_dependencies.sh @@ -2,19 +2,19 @@ set -eu apt-get update -apt-get install -y --no-install-recommends curl exiftool +apt-get install -y --no-install-recommends curl libimage-exiftool-perl # libheif dependencies -apt-get install -y --no-install-recommends libdav1d6 librav1e0 libde265-0 libx265-199 libjpeg62-turbo libopenh264-7 libpng16-16 libnuma1 zlib1g +apt-get install -y --no-install-recommends libdav1d7 librav1e0.7 libde265-0 libx265-215 libjpeg62-turbo libopenh264-8 libpng16-16t64 libnuma1 zlib1g # libraw dependencies apt-get install -y --no-install-recommends libjpeg62-turbo liblcms2-2 zlib1g libgomp1 # ImageMagick dependencies -apt-get install -y --no-install-recommends libjxl0.7 liblcms2-2 liblqr-1-0 libdjvulibre21 libjpeg62-turbo libopenjp2-7 libopenexr-3-1-30 libpng16-16 libtiff6 libwebpmux3 libwebpdemux2 libwebp7 libxml2 zlib1g liblzma5 libbz2-1.0 libgomp1 +apt-get install -y --no-install-recommends libjxl0.11 liblcms2-2 liblqr-1-0 libdjvulibre21 libjpeg62-turbo libopenjp2-7 libopenexr-3-1-30 libpng16-16t64 libtiff6 libwebpmux3 libwebpdemux2 libwebp7 libxml2 zlib1g liblzma5 libbz2-1.0 libgomp1 # go-face dependencies -apt-get install -y --no-install-recommends libdlib19.1 libblas3 liblapack3 libjpeg62-turbo +apt-get install -y --no-install-recommends libdlib19.2 libblas3 liblapack3 libjpeg62-turbo # gomagic dependencies -apt-get install -y --no-install-recommends libmagic1 +apt-get install -y --no-install-recommends libmagic1t64 diff --git a/scripts/set_compiler_env.sh b/scripts/set_compiler_env.sh index 00880f93..54450e57 100755 --- a/scripts/set_compiler_env.sh +++ b/scripts/set_compiler_env.sh @@ -21,7 +21,7 @@ fi dpkg --add-architecture $DEBIAN_ARCH apt-get update -apt-get install -y git curl crossbuild-essential-${DEBIAN_ARCH} libc-dev:${DEBIAN_ARCH} autoconf automake libtool m4 pkg-config cmake +apt-get install -y git curl crossbuild-essential-${DEBIAN_ARCH} libc-dev:${DEBIAN_ARCH} autoconf automake libtool m4 pkg-config cmake dpkg-dev dpkg-architecture -a $DEBIAN_ARCH >/env export $(cat /env)