| 1 |
#! /bin/bash |
| 2 |
|
| 3 |
# Script to bundle data using previously-built digiKam installation. |
| 4 |
# and create a PKG file with Packages application (http://s.sudre.free.fr/Software/Packages/about.html) |
| 5 |
# This script must be run as sudo |
| 6 |
# |
| 7 |
# SPDX-FileCopyrightText: 2015 by Shanti, <listaccount at revenant dot org> |
| 8 |
# SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 9 |
# SPDX-FileCopyrightText: 2024 by Michael Miller, <michael underscore miller at msn dot com> |
| 10 |
# |
| 11 |
# SPDX-License-Identifier: BSD-3-Clause |
| 12 |
# |
| 13 |
# This script is used to move binaries from a local build directory (I use temp.digikam) to the bundle |
| 14 |
# directory for testing. This can be run only after steps 01-04 have been completed. |
| 15 |
# |
| 16 |
|
| 17 |
# Ask to run as root |
| 18 |
(( EUID != 0 )) && exec sudo -- "$0" "$@" |
| 19 |
|
| 20 |
# Halt and catch errors |
| 21 |
set -eE |
| 22 |
trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG |
| 23 |
trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR |
| 24 |
|
| 25 |
ORIG_WD="`pwd`" |
| 26 |
|
| 27 |
COPY_MAIN=1 |
| 28 |
COPY_EDITOR_PLUGINS=0 |
| 29 |
COPY_BQM_PLUGINS=0 |
| 30 |
COPY_GENERIC_PLUGINS=0 |
| 31 |
|
| 32 |
cd .. |
| 33 |
. ./config.sh |
| 34 |
. ./common.sh |
| 35 |
|
| 36 |
StartScript |
| 37 |
|
| 38 |
# Directory where this script is located (default - current directory) |
| 39 |
BUILDDIR="$PWD" |
| 40 |
|
| 41 |
# Directory where Packages project files are located |
| 42 |
PROJECTDIR="$BUILDDIR/installer" |
| 43 |
|
| 44 |
# Staging area where files to be packaged will be copied |
| 45 |
TEMPROOT="$BUILDDIR/$RELOCATE_PREFIX" |
| 46 |
|
| 47 |
DK_APP_CONTENTS="digikam.app/Contents" |
| 48 |
|
| 49 |
# local binary directory |
| 50 |
LOCAL_BINS="temp.digikam" |
| 51 |
|
| 52 |
if [ $COPY_MAIN -eq 1 ]; then |
| 53 |
# copy binaries to bundle location |
| 54 |
cp "$PWD/$LOCAL_BINS/bin/digikam.app/Contents/MacOS/digikam" "$TEMPROOT/$DK_APP_CONTENTS/MacOS" |
| 55 |
|
| 56 |
# copy main binaries |
| 57 |
rsync -av --include="*/" --include="libdigikam*.dylib" --exclude="*" "$PWD/$LOCAL_BINS/bin/" "$TEMPROOT/$DK_APP_CONTENTS/lib" |
| 58 |
fi |
| 59 |
|
| 60 |
# copy Editor, BQM, and Generic plugins |
| 61 |
if [ $COPY_EDITOR_PLUGINS -eq 1 ]; then |
| 62 |
rsync -av --include="*/" --include="Editor_*.so" --exclude="*" "$PWD/$LOCAL_BINS/bin/" "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/editor" |
| 63 |
fi |
| 64 |
if [ $COPY_BQM_PLUGINS -eq 1 ]; then |
| 65 |
rsync -av --include="*/" --include="BQM_*.so" --exclude="*" "$PWD/$LOCAL_BINS/bin/" "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/bqm" |
| 66 |
fi |
| 67 |
if [ $COPY_GENERIC_PLUGINS -eq 1 ]; then |
| 68 |
rsync -av --include="*/" --include="Generic_*.so" --exclude="*" "$PWD/$LOCAL_BINS/bin/" "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/generic" |
| 69 |
fi |
| 70 |
|
| 71 |
if [ $COPY_MAIN -eq 1 ]; then |
| 72 |
# relocate main binaries |
| 73 |
FILES=`find "$TEMPROOT/$DK_APP_CONTENTS/lib" -name "libdigikam*.dylib"` |
| 74 |
for FILE in $FILES ; do |
| 75 |
copy_lib="$INSTALL_PREFIX/bin/python3 $PWD/package_lib.py --file="$FILE" --bundle-root=$TEMPROOT/$DK_APP_CONTENTS --homebrew=$INSTALL_PREFIX --processed-cache=use --found-cache=use --signed-cache=use --update-binary=1 --copy=0 --preserve_rpath=0 --force=1" |
| 76 |
eval "$copy_lib" |
| 77 |
done |
| 78 |
fi |
| 79 |
|
| 80 |
# relocate Editor binaries |
| 81 |
if [ $COPY_EDITOR_PLUGINS -eq 1 ]; then |
| 82 |
echo "Relocating Editor plugins" |
| 83 |
FILES=`find "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/editor" -name "Editor_*.so"` |
| 84 |
for FILE in $FILES ; do |
| 85 |
copy_lib="$INSTALL_PREFIX/bin/python3 $PWD/package_lib.py --file="$FILE" --bundle-root=$TEMPROOT/$DK_APP_CONTENTS --homebrew=$INSTALL_PREFIX --processed-cache=use --found-cache=use --signed-cache=use --update-binary=1 --copy=0 --preserve_rpath=0 --force=1" |
| 86 |
eval "$copy_lib" |
| 87 |
done |
| 88 |
fi |
| 89 |
|
| 90 |
# relocate BQM binaries |
| 91 |
if [ $COPY_BQM_PLUGINS -eq 1 ]; then |
| 92 |
echo "Relocating BQM plugins" |
| 93 |
FILES=`find "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/bqm" -name "BQM_*.so"` |
| 94 |
for FILE in $FILES ; do |
| 95 |
copy_lib="$INSTALL_PREFIX/bin/python3 $PWD/package_lib.py --file="$FILE" --bundle-root=$TEMPROOT/$DK_APP_CONTENTS --homebrew=$INSTALL_PREFIX --processed-cache=use --found-cache=use --signed-cache=use --update-binary=1 --copy=0 --preserve_rpath=0 --force=1" |
| 96 |
eval "$copy_lib" |
| 97 |
done |
| 98 |
fi |
| 99 |
|
| 100 |
# relocate Generic binaries |
| 101 |
if [ $COPY_GENERIC_PLUGINS -eq 1 ]; then |
| 102 |
echo "Relocating Generic plugins" |
| 103 |
FILES=`find "$TEMPROOT/$DK_APP_CONTENTS/share/qt/plugins/digikam/generic" -name "Generic_*.so"` |
| 104 |
for FILE in $FILES ; do |
| 105 |
copy_lib="$INSTALL_PREFIX/bin/python3 $PWD/package_lib.py --file="$FILE" --bundle-root=$TEMPROOT/$DK_APP_CONTENTS --homebrew=$INSTALL_PREFIX --processed-cache=use --found-cache=use --signed-cache=use --update-binary=1 --copy=0 --preserve_rpath=0 --force=1" |
| 106 |
eval "$copy_lib" |
| 107 |
done |
| 108 |
fi |
| 109 |
|
| 110 |
copy_lib="$INSTALL_PREFIX/bin/python3 $PWD/package_lib.py --file="$TEMPROOT/$DK_APP_CONTENTS/MacOS/digikam" --bundle-root=$TEMPROOT/$DK_APP_CONTENTS --homebrew=$INSTALL_PREFIX --processed-cache=use --found-cache=use --signed-cache=use --update-binary=1 --copy=0 --preserve_rpath=0 --force=1" |
| 111 |
eval "$copy_lib" |
| 112 |
|
| 113 |
cp $PWD/../../../core/data/dnnmodels/dnnmodels.conf $TEMPROOT/$DK_APP_CONTENTS/Resources/digikam/dnnmodels |
| 114 |
|
| 115 |
# check if digikam dir exists |
| 116 |
if [ ! -d "$HOME/Library/Application Support/digikam" ]; then |
| 117 |
mkdir -p "$HOME/Library/Application Support/digikam/" |
| 118 |
fi |
| 119 |
cp -r "$PWD/Applications/digiKam.org/digikam.app/Contents/Resources/digikam" "$HOME/Library/Application Support/" |
| 120 |
|
| 121 |
# check if dnnmodels dir exists |
| 122 |
if [ ! -d "$HOME/Library/Application Support/digikam/dnnmodels" ]; then |
| 123 |
mkdir -p "$HOME/Library/Application Support/digikam/dnnmodels" |
| 124 |
fi |
| 125 |
cp $PWD/../../../core/data/dnnmodels/dnnmodels.conf "$HOME/Library/Application Support/digikam/dnnmodels/" |
| 126 |
|
| 127 |
#check if dir exists |
| 128 |
if [ ! -d "$HOME/Library/Application Support/digikam/database" ]; then |
| 129 |
mkdir -p "$HOME/Library/Application Support/digikam/database" |
| 130 |
fi |
| 131 |
|
| 132 |
#copy dbconfig/xml |
| 133 |
cp $PWD/temp.digikam/core/data/database/dbconfig.xml "$HOME/Library/Application Support/digikam/database/dbconfig.xml" |
| 134 |
|
| 135 |
TerminateScript |
| 136 |
|
| 137 |
cd "$ORIG_WD" |
| 138 |
|
| 139 |
date |