Immich: some cleanup

This commit is contained in:
vhsdream
2025-05-06 15:02:04 -04:00
parent 74aa2b599e
commit aa3be7403e
2 changed files with 52 additions and 51 deletions

View File

@@ -157,7 +157,7 @@ $STD apt-get install -t testing --no-install-recommends -y \
libdav1d-dev \
libhwy-dev \
libwebp-dev
if [[ "$intel_hw" = 1 ]]; then
if [[ -f ~/.openvino ]]; then
$STD apt-get install -t testing -y patchelf
fi
msg_ok "Packages from Testing Repo Installed"
@@ -176,19 +176,19 @@ SOURCE_DIR=${STAGING_DIR}/image-source
$STD git clone -b main "$BASE_REPO" "$BASE_DIR"
mkdir -p "$SOURCE_DIR"
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
SOURCE=${SOURCE_DIR}/libjxl
JPEGLI_LIBJPEG_LIBRARY_SOVERSION="62"
JPEGLI_LIBJPEG_LIBRARY_VERSION="62.3.0"
: "${LIBJXL_REVISION:=$(jq -cr '.sources[] | select(.name == "libjxl").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libjxl/libjxl.git "$SOURCE"
cd "$SOURCE" || exit
cd "$SOURCE"
$STD git reset --hard "$LIBJXL_REVISION"
$STD git submodule update --init --recursive --depth 1 --recommend-shallow
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-empty-dht-marker.patch
$STD git apply "$BASE_DIR"/server/bin/patches/jpegli-icc-warning.patch
mkdir build
cd build || exit
cd build
$STD cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
@@ -211,16 +211,16 @@ $STD cmake --build . -- -j"$(nproc)"
$STD cmake --install .
ldconfig /usr/local/lib
$STD make clean
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
rm -rf "$SOURCE"/{build,third_party}
SOURCE=${SOURCE_DIR}/libheif
: "${LIBHEIF_REVISION:=$(jq -cr '.sources[] | select(.name == "libheif").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/strukturag/libheif.git "$SOURCE"
cd "$SOURCE" || exit
cd "$SOURCE"
$STD git reset --hard "$LIBHEIF_REVISION"
mkdir build
cd build || exit
cd build
$STD cmake --preset=release-noplugins \
-DWITH_DAV1D=ON \
-DENABLE_PARALLEL_TILE_DECODING=ON \
@@ -234,13 +234,13 @@ $STD cmake --preset=release-noplugins \
$STD make install -j "$(nproc)"
ldconfig /usr/local/lib
$STD make clean
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
rm -rf "$SOURCE"/build
SOURCE=${SOURCE_DIR}/libraw
: "${LIBRAW_REVISION:=$(jq -cr '.sources[] | select(.name == "libraw").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libraw/libraw.git "$SOURCE"
cd "$SOURCE" || exit
cd "$SOURCE"
$STD git reset --hard "$LIBRAW_REVISION"
$STD autoreconf --install
$STD ./configure
@@ -248,30 +248,30 @@ $STD make -j"$(nproc)"
$STD make install
ldconfig /usr/local/lib
$STD make clean
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
SOURCE=$SOURCE_DIR/imagemagick
: "${IMAGEMAGICK_REVISION:=$(jq -cr '.sources[] | select(.name == "imagemagick").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE"
cd "$SOURCE" || exit
cd "$SOURCE"
$STD git reset --hard "$IMAGEMAGICK_REVISION"
$STD ./configure --with-modules
$STD make -j"$(nproc)"
$STD make install
ldconfig /usr/local/lib
$STD make clean
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
SOURCE=$SOURCE_DIR/libvips
: "${LIBVIPS_REVISION:=$(jq -cr '.sources[] | select(.name == "libvips").revision' $BASE_DIR/server/bin/build-lock.json)}"
$STD git clone https://github.com/libvips/libvips.git "$SOURCE"
cd "$SOURCE" || exit
cd "$SOURCE"
$STD git reset --hard "$LIBVIPS_REVISION"
$STD meson setup build --buildtype=release --libdir=lib -Dintrospection=disabled -Dtiff=disabled
cd build || exit
cd build
$STD ninja install
ldconfig /usr/local/lib
cd "$STAGING_DIR" || exit
cd "$STAGING_DIR"
rm -rf "$SOURCE"/build
{
echo "$IMAGEMAGICK_REVISION"
@@ -297,25 +297,25 @@ mkdir -p "$INSTALL_DIR"
mv "$APPLICATION-$RELEASE"/ "$SRC_DIR"
mkdir -p {"${APP_DIR}","${UPLOAD_DIR}","${GEO_DIR}","${ML_DIR}","${INSTALL_DIR}"/cache}
cd "$SRC_DIR"/server || exit
cd "$SRC_DIR"/server
$STD npm install -g node-gyp node-pre-gyp
$STD npm ci
$STD npm run build
$STD npm prune --omit=dev --omit=optional
cd "$SRC_DIR"/open-api/typescript-sdk || exit
cd "$SRC_DIR"/open-api/typescript-sdk
$STD npm ci
$STD npm run build
cd "$SRC_DIR"/web || exit
cd "$SRC_DIR"/web
$STD npm ci
$STD npm run build
cd "$SRC_DIR" || exit
cd "$SRC_DIR"
cp -a server/{node_modules,dist,bin,resources,package.json,package-lock.json,start*.sh} "$APP_DIR"/
cp -a web/build "$APP_DIR"/www
cp LICENSE "$APP_DIR"
cp "$BASE_DIR"/server/bin/build-lock.json "$APP_DIR"
msg_ok "Installed Immich Web Components"
cd "$SRC_DIR"/machine-learning || exit
cd "$SRC_DIR"/machine-learning
$STD python3 -m venv "$ML_DIR/ml-venv"
if [[ -f ~/.openvino ]]; then
msg_info "Installing HW-accelerated machine-learning"
@@ -335,14 +335,14 @@ else
)
msg_ok "Installed machine-learning"
fi
cd "$SRC_DIR" || exit
cd "$SRC_DIR"
cp -a machine-learning/{ann,immich_ml} "$ML_DIR"
if [[ "$intel_hw" = 1 ]]; then
if [[ -f ~/.openvino ]]; then
sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py
fi
ln -sf "$APP_DIR"/resources "$INSTALL_DIR"
cd "$APP_DIR" || exit
cd "$APP_DIR"
grep -Rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g"
grep -RlE "'/build'" | xargs -n1 sed -i "s|'/build'|'$APP_DIR'|g"
sed -i "s@\"/cache\"@\"$INSTALL_DIR/cache\"@g" "$ML_DIR"/immich_ml/config.py
@@ -356,7 +356,7 @@ $STD npm i -g @immich/cli
msg_ok "Installed Immich CLI"
msg_info "Installing GeoNames data"
cd "$GEO_DIR" || exit
cd "$GEO_DIR"
URL_LIST=(
https://download.geonames.org/export/dump/admin1CodesASCII.txt
https://download.geonames.org/export/dump/admin2Codes.txt
@@ -367,7 +367,7 @@ echo "${URL_LIST[@]}" | xargs -n1 -P 8 wget -q
unzip -q cities500.zip
date --iso-8601=seconds | tr -d "\n" >geodata-date.txt
rm cities500.zip
cd "$INSTALL_DIR" || exit
cd "$INSTALL_DIR"
ln -s "$GEO_DIR" "$APP_DIR"
msg_ok "Installed GeoNames data"
@@ -378,7 +378,7 @@ msg_ok "Installed ${APPLICATION}"
msg_info "Creating user, env file, scripts & services"
$STD useradd -U -s /usr/sbin/nologin -r -M -d "$INSTALL_DIR" immich
if [[ "$intel_hw" = 1 ]]; then
if [[ -f ~/.openvino ]]; then
usermod -aG video,render immich
fi
cat <<EOF >"${INSTALL_DIR}"/.env