Debian Codegraph @

project/bundles/macports/03-build-digikam.sh

raw
1 #! /bin/bash
2
3 # Script to build digiKam using MacPorts
4 # This script must be run as sudo
5 #
6 # SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
7 #
8 # SPDX-License-Identifier: BSD-3-Clause
9 #
10
11 # Ask to run as root
12 (( EUID != 0 )) && exec sudo -- "$0" "$@"
13
14 # Halt and catch errors
15 set -eE
16 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG
17 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR
18
19 #################################################################################################
20 # Manage script traces to log file
21
22 mkdir -p ./logs
23 exec > >(tee ./logs/build-digikam.full.log) 2>&1
24
25 #################################################################################################
26
27 echo "03-build-digikam.sh : build digiKam using MacPorts."
28 echo "---------------------------------------------------"
29
30 #################################################################################################
31 # Pre-processing checks
32
33 . ./config.sh
34 . ./common.sh
35 StartScript
36 ChecksRunAsRoot
37 ChecksXCodeCLI
38 ChecksCPUCores
39 OsxCodeName
40 #RegisterRemoteServers
41
42 #################################################################################################
43
44 # Paths rules
45 ORIG_PATH="$PATH"
46 ORIG_WD="`pwd`"
47
48 export PATH=$INSTALL_PREFIX/bin:/$INSTALL_PREFIX/sbin:/$INSTALL_PREFIX/libexec/qt$DK_QTVERSION/bin:$ORIG_PATH
49
50 #################################################################################################
51 # Install out-dated dependencies
52
53 cd $BUILDING_DIR
54
55 rm -rf $BUILDING_DIR/* || true
56
57 cmake $ORIG_WD/../3rdparty \
58 -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX \
59 -DINSTALL_ROOT=$INSTALL_PREFIX \
60 -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOAD_DIR \
61 -DKP_VERSION=$DK_KP_VERSION \
62 -DKA_VERSION=$DK_KA_VERSION \
63 -DKDE_VERSION=$DK_KDE_VERSION \
64 -DENABLE_QTVERSION=$DK_QTVERSION \
65 -DMACOSX_DEPLOYMENT_TARGET=$OSX_MIN_TARGET \
66 -DARCH_TARGET=$TARGET_ARCH \
67 -DDK_APPLE_PACKAGE_MANAGER=$DK_APPLE_PACKAGE_MANAGER \
68 -Wno-dev
69
70 cmake --build . --config RelWithDebInfo --target ext_exiv2 -- -j$CPU_CORES
71 cp $DOWNLOAD_DIR/exiv2_manifest.txt $ORIG_WD/data/
72 cmake --build . --config RelWithDebInfo --target ext_lensfun -- -j$CPU_CORES
73 cp $DOWNLOAD_DIR/lensfun_manifest.txt $ORIG_WD/data/
74
75 #################################################################################################
76 # Build digiKam in temporary directory and installation
77
78 # Clean up previous install (see bug #459276)
79
80 cd "$INSTALL_PREFIX"
81
82 # This is odd: grep -E under macOS return an error if nothing is found
83 touch digikam.txt
84
85 FILES=$(find . | grep -E '(digikam|showfoto)')
86
87 for FILE in $FILES ; do
88 if [[ -f ${FILE} || -d ${FILE} ]] ; then
89 echo -e " ==> $INSTALL_PREFIX/${FILE} will be removed from previous install"
90 rm -fr $INSTALL_PREFIX/${FILE}
91 fi
92 done
93
94 cd $BUILDING_DIR
95
96 if [ -d "$DK_BUILDTEMP/digikam-$DK_VERSION" ] ; then
97
98 echo "---------- Updating existing $DK_BUILDTEMP"
99
100 cd "$DK_BUILDTEMP"
101 cd digikam-$DK_VERSION
102
103 git reset --hard
104 git pull
105
106 rm -fr build
107 mkdir -p build
108
109 else
110
111 echo "---------- Creating $DK_BUILDTEMP"
112 mkdir -p "$DK_BUILDTEMP"
113
114 if [ $? -ne 0 ] ; then
115 echo "---------- Cannot create $DK_BUILDTEMP directory."
116 echo "---------- Aborting..."
117 exit;
118 fi
119
120 cd "$DK_BUILDTEMP"
121 echo -e "\n\n"
122 echo "---------- Downloading digiKam $DK_VERSION"
123
124 git clone --progress --verbose --branch $DK_VERSION --single-branch $DK_GITURL digikam-$DK_VERSION
125 cd digikam-$DK_VERSION
126
127 if [ $? -ne 0 ] ; then
128 echo "---------- Cannot clone repositories."
129 echo "---------- Aborting..."
130 exit;
131 fi
132
133 mkdir build
134
135 fi
136
137 echo -e "\n\n"
138 echo "---------- Configure digiKam $DK_VERSION"
139
140 sed -e "s/DIGIKAMSC_COMPILE_PO=OFF/DIGIKAMSC_COMPILE_PO=ON/g" ./bootstrap.macports > ./tmp.macports ; mv -f ./tmp.macports ./bootstrap.macports
141 sed -e "s/DBUILD_TESTING=ON/DBUILD_TESTING=OFF/g" ./bootstrap.macports > ./tmp.macports ; mv -f ./tmp.macports ./bootstrap.macports
142 sed -e "s/DENABLE_DBUS=ON/DENABLE_DBUS=OFF/g" ./bootstrap.macports > ./tmp.macports ; mv -f ./tmp.macports ./bootstrap.macports
143 sed -e "s/DENABLE_APPSTYLES=OFF/DENABLE_APPSTYLES=ON/g" ./bootstrap.macports > ./tmp.macports ; mv -f ./tmp.macports ./bootstrap.macports
144
145 if [[ $DK_QTVERSION = 6 ]] ; then
146
147 sed -e "s/DBUILD_WITH_QT6=OFF/DBUILD_WITH_QT6=ON/g" ./bootstrap.macports > ./tmp.macports ; mv -f ./tmp.macports ./bootstrap.macports
148
149 fi
150
151 chmod +x ./bootstrap.macports
152
153 cp -f $ORIG_WD/fixbundledatapath.sh $DK_BUILDTEMP/digikam-$DK_VERSION
154
155 ./fixbundledatapath.sh
156
157 ./bootstrap.macports "$INSTALL_PREFIX" "Debug" "$TARGET_ARCH" "-Wno-dev"
158
159 if [ $? -ne 0 ]; then
160 echo "---------- Cannot configure digiKam $DK_VERSION."
161 echo "---------- Aborting..."
162 exit;
163 fi
164
165 echo -e "\n\n"
166 echo "---------- Building digiKam $DK_VERSION"
167
168 cd build
169 make -j$CPU_CORES
170
171 if [ $? -ne 0 ]; then
172 echo "---------- Cannot compile digiKam $DK_VERSION."
173 echo "---------- Aborting..."
174 exit;
175 fi
176
177 cat $DK_BUILDTEMP/digikam-$DK_VERSION/build/core/app/utils/digikam_version.h | grep "digikam_version\[\]" | awk '{print $6}' | tr -d '";' > $ORIG_WD/data/RELEASEID.txt
178 cat $DK_BUILDTEMP/digikam-$DK_VERSION/build/core/app/utils/digikam_builddate.h | grep "define BUILD_DATE" | awk '{print $3}' | tr -d '"\n' > $ORIG_WD/data/BUILDDATE.txt
179
180 # Copy manifests for rolling release codes included in digiKam core.
181 cp $DK_BUILDTEMP/digikam-$DK_VERSION/core/libs/dimg/filters/transform/lqr/liblqr_manifest.txt $ORIG_WD/data
182 cp $DK_BUILDTEMP/digikam-$DK_VERSION/core/libs/rawengine/libraw/libraw_manifest.txt $ORIG_WD/data
183 cp $DK_BUILDTEMP/digikam-$DK_VERSION/core/libs/dplugins/webservices/o2/o2_manifest.txt $ORIG_WD/data
184
185 echo -e "\n\n"
186 echo "---------- Installing digiKam $DK_VERSION"
187 echo -e "\n\n"
188
189 make install/fast && cd "$ORIG_WD"
190
191 if [ $? -ne 0 ]; then
192 echo "---------- Cannot install digiKam $DK_VERSION."
193 echo "---------- Aborting..."
194 exit;
195 fi
196
197 if [[ $DK_QTVERSION == 6 ]] ; then
198
199 # Qt6 install of .../Applications/... binaries is done at the wrong place.
200
201 mkdir -p $INSTALL_PREFIX/$RELOCATE_PREFIX/
202 mv $INSTALL_PREFIX/bin/digikam.* $INSTALL_PREFIX/$RELOCATE_PREFIX/
203 mv $INSTALL_PREFIX/bin/showfoto.* $INSTALL_PREFIX/$RELOCATE_PREFIX/
204
205 fi
206
207 ################################################################################################
208 # Install Extra Plugins
209
210 cd $BUILDING_DIR
211
212 rm -rf $BUILDING_DIR/* || true
213
214 cmake $ORIG_WD/../3rdparty \
215 -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX \
216 -DINSTALL_ROOT=$INSTALL_PREFIX \
217 -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOAD_DIR \
218 -DKP_VERSION=$DK_KP_VERSION \
219 -DKA_VERSION=$DK_KA_VERSION \
220 -DKDE_VERSION=$DK_KDE_VERSION \
221 -DENABLE_QTVERSION=$DK_QTVERSION \
222 -DMACOSX_DEPLOYMENT_TARGET=$OSX_MIN_TARGET \
223 -DARCH_TARGET=$TARGET_ARCH \
224 -DDK_APPLE_PACKAGE_MANAGER=$DK_APPLE_PACKAGE_MANAGER \
225 -Wno-dev
226
227 cmake --build . --config RelWithDebInfo --target ext_gmic_qt -- -j$CPU_CORES
228 cmake --build . --config RelWithDebInfo --target ext_mosaicwall -- -j$CPU_CORES
229 cmake --build . --config RelWithDebInfo --target ext_flowview -- -j$CPU_CORES
230
231 mv -f $INSTALL_PREFIX/libexec/qt$DK_QTVERSION/plugins/digikam/editor/*.so* $INSTALL_PREFIX/lib/plugins/digikam/editor/
232 mv -f $INSTALL_PREFIX/libexec/qt$DK_QTVERSION/plugins/digikam/bqm/*.so* $INSTALL_PREFIX/lib/plugins/digikam/bqm/
233 mv -f $INSTALL_PREFIX/libexec/qt$DK_QTVERSION/plugins/digikam/generic/*.so* $INSTALL_PREFIX/lib/plugins/digikam/generic/
234
235 #################################################################################################
236
237 export PATH=$ORIG_PATH
238
239 TerminateScript