Debian Codegraph @

project/bundles/macports/04-build-installer.sh

raw
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 #
10 # SPDX-License-Identifier: BSD-3-Clause
11 #
12
13 # Ask to run as root
14 (( EUID != 0 )) && exec sudo -- "$0" "$@"
15
16 # Halt and catch errors
17 set -eE
18 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG
19 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR
20
21 #################################################################################################
22 # Manage script traces to log file
23
24 mkdir -p ./logs
25 exec > >(tee ./logs/build-installer.full.log) 2>&1
26
27 #################################################################################################
28
29 echo "04-build-installer.sh : build digiKam bundle PKG."
30 echo "-------------------------------------------------"
31
32 #################################################################################################
33 # Pre-processing checks
34
35 . ./config.sh
36 . ./common.sh
37 StartScript
38 ChecksRunAsRoot
39 ChecksXCodeCLI
40 ChecksCPUCores
41 OsxCodeName
42 #RegisterRemoteServers
43
44 #################################################################################################
45
46 # Paths rules
47 ORIG_PATH="$PATH"
48 ORIG_WD="`pwd`"
49
50 export PATH=$INSTALL_PREFIX/bin:/$INSTALL_PREFIX/sbin:$ORIG_PATH
51
52 DKRELEASEID=`cat $ORIG_WD/data/RELEASEID.txt`
53
54 #################################################################################################
55 # Configurations
56
57 # Directory where this script is located (default - current directory)
58 BUILDDIR="$PWD"
59
60 # Directory where Packages project files are located
61 PROJECTDIR="$BUILDDIR/installer"
62
63 # Staging area where files to be packaged will be copied
64 TEMPROOT="$BUILDDIR/$RELOCATE_PREFIX"
65
66 # Applications to be launched directly by user (create launch scripts)
67 KDE_MENU_APPS="\
68 digikam \
69 showfoto \
70 "
71
72 # Paths to search for applications above
73 KDE_APP_PATHS="\
74 Applications/digiKam.org \
75 "
76
77 # Other apps - non-MacOS binaries & libraries to be included with required dylibs
78
79 if [[ $TARGET_ARCH = "x86_64" ]] ; then
80 QT_PLUGIN_EXT="so"
81 else
82 QT_PLUGIN_EXT="dylib"
83 fi
84
85 # Note: lib/plugins/styles/ files are *.so in both architectures. Why this mess?
86
87 OTHER_APPS="\
88 lib/plugins/imageformats/*.$QT_PLUGIN_EXT \
89 lib/plugins/styles/*.so \
90 lib/plugins/digikam/bqm/*.so \
91 lib/plugins/digikam/generic/*.so \
92 lib/plugins/digikam/editor/*.so \
93 lib/plugins/digikam/dimg/*.so \
94 lib/plugins/digikam/rawimport/*.so \
95 lib/mariadb$MARIADB_SUFFIX/bin/mysql \
96 lib/mariadb$MARIADB_SUFFIX/bin/mysqld \
97 lib/mariadb$MARIADB_SUFFIX/bin/my_print_defaults \
98 lib/mariadb$MARIADB_SUFFIX/bin/mysqladmin \
99 lib/mariadb$MARIADB_SUFFIX/bin/mysqltest \
100 lib/mariadb$MARIADB_SUFFIX/mysql/*.dylib \
101 lib/mariadb$MARIADB_SUFFIX/plugin/*.so \
102 bin/kbuildsycoca$DK_QTVERSION \
103 bin/solid-hardware$DK_QTVERSION \
104 bin/ffmpeg \
105 libexec/qt$DK_QTVERSION/plugins/imageformats/*.dylib \
106 libexec/qt$DK_QTVERSION/plugins/sqldrivers/*.dylib \
107 libexec/qt$DK_QTVERSION/plugins/platforms/*.dylib \
108 libexec/qt$DK_QTVERSION/plugins/iconengines/*.dylib \
109 libexec/qt$DK_QTVERSION/plugins/generic/*.dylib \
110 libexec/qt$DK_QTVERSION/plugins/styles/*.dylib \
111 "
112
113 if [[ $DK_QTVERSION == 5 ]] ; then
114
115 # Qt5 specific plugins
116
117 OTHER_APPS=$OTHER_APPS"\
118 libexec/qt$DK_QTVERSION/plugins/audio/*.dylib \
119 libexec/qt$DK_QTVERSION/plugins/bearer/*.dylib \
120 libexec/qt$DK_QTVERSION/plugins/printsupport/*.dylib \
121 libexec/qt$DK_QTVERSION/plugins/platformthemes/*.dylib \
122 "
123
124 else
125
126 # Qt6 specific plugins
127
128 OTHER_APPS=$OTHER_APPS"\
129 libexec/qt$DK_QTVERSION/plugins/multimedia/*.dylib \
130 libexec/qt$DK_QTVERSION/plugins/tls/*.dylib \
131 "
132
133 fi
134
135 #lib/sane/*.so \
136
137 binaries="$OTHER_APPS"
138
139 # Additional Files/Directories - to be copied recursively but not checked for dependencies
140 #
141 # NOTE: dSYM directories are copied as well and cleaned later if debug symbols must be removed in final bundle.
142 #
143 # QtWebEngine runtime process and binary archives (.pak) are located in libexec/qt$DK_QTVERSION/lib/QtWebEngineCore.framework/
144 #
145 OTHER_DIRS="\
146 libexec/qt$DK_QTVERSION/translations \
147 lib/libdigikam*.dSYM \
148 lib/plugins \
149 lib/libgphoto2 \
150 lib/libgphoto2_port \
151 lib/mariadb$MARIADB_SUFFIX \
152 lib/ImageMagick* \
153 share/mariadb$MARIADB_SUFFIX \
154 share/ImageMagick* \
155 etc/xdg \
156 etc/ImageMagick* \
157 etc/mariadb$MARIADB_SUFFIX \
158 "
159
160 if [[ $DK_QTVERSION == 6 ]] ; then
161
162 OTHER_DIRS=$OTHER_DIRS"\
163 libexec/qt$DK_QTVERSION/lib/QtWebEngineCore.framework \
164 "
165
166 fi
167
168 # Additional Data Directories - to be copied recursively
169 OTHER_DATA="\
170 share/opencv4 \
171 share/k* \
172 share/mime \
173 Library/Application/ \
174 share/applications \
175 lensfun \
176 "
177
178 if [[ $DK_QTVERSION == 6 ]] ; then
179
180 # NOTE: Qt5Curve is located in Library/Application
181
182 OTHER_DATA=$OTHER_DATA"\
183 share/QtCurve
184 "
185
186 fi
187
188 # Packaging tool paths
189 PACKAGESBUILD="/usr/local/bin/packagesbuild"
190 RECURSIVE_LIBRARY_LISTER="$BUILDDIR/rll.py"
191
192 echo "digiKam version: $DKRELEASEID"
193
194 # ./installer sub-dir must be writable by root
195 chmod 777 ${PROJECTDIR}
196
197 #################################################################################################
198 # Check if Packages CLI tools are installed
199
200 if [[ (! -f "$PACKAGESBUILD") ]] ; then
201 echo "Packages CLI tool is not installed"
202 echo "See http://s.sudre.free.fr/Software/Packages/about.html for details."
203 exit 1
204 else
205 echo "Check Packages CLI tool passed..."
206 fi
207
208 #################################################################################################
209 # Create temporary dir to build package contents
210
211 if [ -d "$TEMPROOT" ] ; then
212 echo "---------- Removing temporary packaging directory $TEMPROOT"
213 rm -rf "$TEMPROOT"
214 fi
215
216 echo "Creating $TEMPROOT"
217 mkdir -p "$TEMPROOT"
218
219 #################################################################################################
220 # Prepare applications for MacOS
221
222 echo "---------- Preparing Applications for MacOS"
223
224 for app in $KDE_MENU_APPS ; do
225 echo " $app"
226
227 # Look for application
228
229 for searchpath in $KDE_APP_PATHS ; do
230
231 # Copy the application if it is found (create directory if necessary)
232
233 if [ -d "$INSTALL_PREFIX/$searchpath/$app.app" ] ; then
234
235 echo " Found $app in $INSTALL_PREFIX/$searchpath"
236
237 # Copy application directory
238
239 echo " Copying $app"
240 cp -pr "$INSTALL_PREFIX/$searchpath/$app.app" "$TEMPROOT"
241
242 # Add executable to list of binaries for which we need to collect dependencies for
243
244 binaries="$binaries $searchpath/$app.app/Contents/MacOS/$app"
245
246 chmod 755 "$TEMPROOT/$app.app"
247
248 fi
249
250 done
251
252 done
253
254 #################################################################################################
255 # Collect dylib dependencies for all binaries,
256 # then copy them to the staging area (creating directories as required)
257
258 echo "---------- Collecting dependencies for applications, binaries, and libraries..."
259
260 cd "$INSTALL_PREFIX"
261
262 "$RECURSIVE_LIBRARY_LISTER" $binaries | sort -u | \
263 while read lib ; do
264 lib="`echo $lib | sed "s:$INSTALL_PREFIX/::"`"
265
266 if [ ! -e "$TEMPROOT/$lib" ] ; then
267 dir="${lib%/*}"
268
269 if [ ! -d "$TEMPROOT/$dir" ] ; then
270 echo " Creating $TEMPROOT/$dir"
271 mkdir -p "$TEMPROOT/$dir"
272 fi
273
274 echo " Copying $INSTALL_PREFIX/$lib to $TEMPROOT/$dir/"
275 cp -aH "$INSTALL_PREFIX/$lib" "$TEMPROOT/$dir/"
276 fi
277 done
278
279 #################################################################################################
280 # Copy non-binary files and directories, creating parent directories if needed
281
282 echo "---------- Copying binary files..."
283
284 for path in $OTHER_APPS ; do
285 dir="${path%/*}"
286
287 if [ ! -d "$TEMPROOT/$dir" ] ; then
288 echo " Creating $TEMPROOT/$dir"
289 mkdir -p "$TEMPROOT/$dir"
290 fi
291
292 echo " Copying $INSTALL_PREFIX/$path to $TEMPROOT/$dir/"
293 cp -aH "$INSTALL_PREFIX/$path" "$TEMPROOT/$dir/"
294 done
295
296 echo "---------- Copying directory contents..."
297
298 for path in $OTHER_DIRS ; do
299 dir="${path%/*}"
300
301 if [ ! -d "$TEMPROOT/$dir" ] ; then
302 echo " Creating $TEMPROOT/$dir"
303 mkdir -p "$TEMPROOT/$dir"
304 fi
305
306 echo " Copying $INSTALL_PREFIX/$path to $TEMPROOT/$dir/"
307 cp -aH "$INSTALL_PREFIX/$path" "$TEMPROOT/$dir/"
308 done
309
310 echo -e "------------- Move libgphoto2 drivers\n"
311
312 find "$TEMPROOT/lib/libgphoto2" -name "*.so" -type f -exec mv {} "$TEMPROOT/lib/libgphoto2" \;
313 find "$TEMPROOT/lib/libgphoto2_port" -name "*.so" -type f -exec mv {} "$TEMPROOT/lib/libgphoto2_port" \;
314
315 echo "---------- Copying data files..."
316
317 # Special case with data dirs. QStandardPaths::GenericDataLocation was patched everywhere
318 # in source code by QStandardPaths::AppDataLocation
319
320 for path in $OTHER_DATA ; do
321 echo " Copying $path"
322 cp -a "$INSTALL_PREFIX/$path" "$TEMPROOT/digikam.app/Contents/Resources/"
323 done
324
325 # Copy digiKam hi-colors PNG icons-set to the bundle
326
327 mkdir -p "$TEMPROOT/digikam.app/Contents/Resources/icons/"
328 cp -a "$INSTALL_PREFIX/share/icons/hicolor" "$TEMPROOT/digikam.app/Contents/Resources/icons/"
329
330 # Copy the Qt configuration ini file
331
332 if [[ $DK_QTVERSION = 5 ]] ; then
333
334 cp $ORIG_WD/data/qt.conf.qt5 "$TEMPROOT/digikam.app/Contents/Resources/qt.conf"
335
336 else
337
338 cp $ORIG_WD/data/qt.conf.qt6 "$TEMPROOT/digikam.app/Contents/Resources/qt.conf"
339
340 fi
341
342 echo "---------- Copying i18n..."
343
344 i18nprefix=$INSTALL_PREFIX/share/
345 cd $i18nprefix
346
347 FILES=$(cat $ORIG_WD/logs/build-extralibs.full.log | grep "$INSTALL_PREFIX/share/locale/" | cut -d' ' -f3 | awk '{sub("'"$i18nprefix"'","")}1')
348
349 for FILE in $FILES ; do
350 rsync -R "./$FILE" "$TEMPROOT/digikam.app/Contents/Resources/"
351 done
352
353 FILES=$(cat $ORIG_WD/logs/build-digikam.full.log | grep "$INSTALL_PREFIX/share/locale/" | cut -d' ' -f3 | awk '{sub("'"$i18nprefix"'","")}1')
354
355 for FILE in $FILES ; do
356 rsync -R "./$FILE" "$TEMPROOT/digikam.app/Contents/Resources/"
357 done
358
359 # Move Qt translation data files at the right place in the bundle. See Bug #438701.
360
361 mv -v $TEMPROOT/libexec/qt$DK_QTVERSION/translations $TEMPROOT/digikam.app/Contents/Resources/
362
363 # To support localized system menu entries from MacOS. See bug #432650.
364
365 FILES=$(find "$TEMPROOT/digikam.app/Contents/Resources/locale" -type d -depth 1)
366
367 for FILE in $FILES ; do
368 BASE=$(basename $FILE)
369 echo "Create localized system menu entry for $BASE"
370 mkdir "$TEMPROOT/digikam.app/Contents/Resources/$BASE.lproj"
371 done
372
373 # Showfoto resources dir must be merged with digiKam.
374
375 cp -a "$TEMPROOT/showfoto.app/Contents/Resources/" "$TEMPROOT/digikam.app/Contents/Resources/"
376 rm -rf "$TEMPROOT/showfoto.app/Contents/Resources"
377
378 cd "$ORIG_WD"
379
380 #################################################################################################
381 # Move digiKam and KF run-time plugins to the right place
382
383 cp -a $TEMPROOT/lib/plugins $TEMPROOT/libexec/qt$DK_QTVERSION/
384 rm -rf $TEMPROOT/lib/plugins
385
386 # See bug #476290
387 rm -fr $TEMPROOT/libexec/qt$DK_QTVERSION/plugins/imageformats/libqjp2.dylib
388
389 #################################################################################################
390 # Merge Manifest files
391
392 echo "---------- Copy Git Revisions Manifest\n"
393
394 touch $TEMPROOT/digikam.app/Contents/Resources/MANIFEST.txt
395
396 FILES=$(ls $ORIG_WD/data/*_manifest.txt)
397
398 for FILE in $FILES ; do
399 echo $FILE
400 cat $FILE >> $TEMPROOT/digikam.app/Contents/Resources/MANIFEST.txt
401 done
402
403 #################################################################################################
404 # Create package pre-install script
405
406 echo "---------- Create package pre-install script"
407
408 # Delete /Applications entries, delete existing installation
409
410 cat << EOF > "$PROJECTDIR/preinstall"
411 #!/bin/bash
412
413 # SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
414 #
415 # SPDX-License-Identifier: BSD-3-Clause
416 #
417
418 # Store script traces in a log file.
419
420 exec &> >(tee $HOME/digiKam_install.log) 2>&1
421
422 echo "digiKam ${DK_VERSION} installation done at $(date)."
423
424 echo "Pre-install operations:"
425
426 # This is the legacy install paths
427 # TODO: remove this legacy rules in the future
428
429 if [ -d /Applications/digiKam ] ; then
430 echo "Removing digiKam directory from Applications folder"
431 rm -r /Applications/digiKam
432 fi
433
434 if [ -d /Applications/digikam.app ] ; then
435 echo "Removing legacy digikam.app from Applications folder"
436 rm -r /Applications/digikam.app
437 fi
438
439 if [ -d /Applications/showfoto.app ] ; then
440 echo "Removing legacy showfoto.app from Applications folder"
441 rm -r /Applications/showfoto.app
442 fi
443
444 if [ -d "/opt/digikam" ] ; then
445 echo "Removing legacy /opt/digikam"
446 rm -rf "/opt/digikam"
447 fi
448
449 if [ -d /Applications/digiKam.org ] ; then
450 echo "Removing digiKam.org from Applications folder"
451 rm -r /Applications/digiKam.org
452 fi
453
454 EOF
455
456 # Pre-install script need to be executable
457
458 chmod 755 "$PROJECTDIR/preinstall"
459
460 #################################################################################################
461 # Create package post-install script
462
463 echo "---------- Create package post-install script"
464
465 # Creates Applications menu icons
466
467 cat << EOF > "$PROJECTDIR/postinstall"
468 #!/bin/bash
469
470 # SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
471 #
472 # SPDX-License-Identifier: BSD-3-Clause
473 #
474
475 # Store script traces in a log file.
476
477 exec &> >(tee -a $HOME/digiKam_install.log) 2>&1
478
479 echo "Post-install operations:"
480
481 # See bug https://bugs.kde.org/show_bug.cgi?id=496380
482
483 sudo codesign --verbose --force --deep --sign - /Applications/digiKam.org/digikam.app/Contents/MacOS/digikam
484 sudo codesign --verbose --force --deep --sign - /Applications/digiKam.org/showfoto.app/Contents/MacOS/showfoto
485 EOF
486
487 # Post-install script need to be executable
488
489 chmod 755 "$PROJECTDIR/postinstall"
490
491 #################################################################################################
492 # Copy icons-set resource files.
493
494 # See https://bugs.kde.org/show_bug.cgi?id=487799#c54
495
496 if [[ $DK_QTVERSION = 6 ]] ; then
497
498 cp $INSTALL_PREFIX/share/icons/breeze/breeze-icons.rcc $TEMPROOT/digikam.app/Contents/Resources/breeze.rcc
499
500 else
501
502 cp $ORIG_WD/../common/breeze.rcc $TEMPROOT/digikam.app/Contents/Resources/breeze.rcc
503 cp $ORIG_WD/../common/breeze-dark.rcc $TEMPROOT/digikam.app/Contents/Resources/breeze-dark.rcc
504
505 fi
506
507 #################################################################################################
508 # Cleanup symbols in binary files to free space.
509
510 echo -e "\n---------- Strip symbols in binary files\n"
511
512 if [[ $DK_DEBUG = 1 ]] ; then
513
514 find $TEMPROOT -name "*.so" | grep -Ev '(digikam|showfoto)' | xargs strip -SXx
515 find $TEMPROOT -name "*.dylib" | grep -Ev '(digikam|showfoto)' | xargs strip -SXx
516
517 else
518
519 # no debug symbols at all.
520
521 find $TEMPROOT -perm +111 -type f | xargs strip -SXx 2>/dev/null
522
523 # Under MacOS, all debug symbols are stored to separated dSYM sub directories near binary files.
524
525 DSYMDIRS=`find $TEMPROOT -type d -name "*.dSYM"`
526
527 for dsym in $DSYMDIRS ; do
528
529 rm -fr $dsym
530 echo "Remove debug symbols from $dsym"
531
532 done
533
534 fi
535
536 if [[ $DK_DEBUG = 1 ]] ; then
537
538 DEBUG_SUF="-debug"
539
540 fi
541
542 #################################################################################################
543 # Relocatable binary files. For details, see these urls:
544 #
545 # https://stackoverflow.com/questions/9263256/can-you-please-help-me-understand-how-mach-o-libraries-work-in-mac-os-x
546 # https://matthew-brett.github.io/docosx/mac_runtime_link.html
547 # https://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/
548
549 echo -e "\n---------- Relocatable binary files"
550
551 # Relocatable dynamic libraries with rpath
552
553 echo -e "\n--- Relocatable dynamic library files"
554
555 DYLIBFILES=(`find $TEMPROOT -name "*.dylib"`)
556
557 RelocatableBinaries DYLIBFILES[@]
558
559 # Relocatable system objects with rpath
560
561 echo -e "\n--- Relocatable system object files"
562
563 SOFILES=(`find $TEMPROOT -name "*.so"`)
564
565 RelocatableBinaries SOFILES[@]
566
567 # Relocatable executables with rpath and patch relative search path.
568
569 echo -e "\n--- Relocatable executable files"
570
571 EXECFILES=(`find $TEMPROOT -type f -perm +ugo+x ! -name "*.dylib" ! -name "*.so"`)
572
573 RelocatableBinaries EXECFILES[@]
574
575 echo -e "\n--- Patch RPATH in executable files"
576
577 for APP in ${EXECFILES[@]} ; do
578
579 ISBINARY=`file "$APP" | grep "Mach-O" || true`
580
581 # Do not touch debug extension
582 ISDSYM=`file "$APP" | grep "dSYM" || true`
583
584 # Do not patch applet files which are pure Apple API binaries
585 BASENAME=`basename "$APP"`
586
587 if [[ $ISBINARY ]] && [[ ! $ISDSYM ]] && [[ $BASENAME != "applet" ]] ; then
588
589 install_name_tool -add_rpath @executable_path/.. $APP
590 install_name_tool -add_rpath @executable_path/../.. $APP
591 install_name_tool -add_rpath @executable_path/../../.. $APP
592 install_name_tool -add_rpath @executable_path/../../../.. $APP
593 install_name_tool -add_rpath @executable_path/../../../../.. $APP
594 install_name_tool -add_rpath @executable_path/../../../../../.. $APP
595 install_name_tool -add_rpath @executable_path/../../../../../../.. $APP
596 install_name_tool -add_rpath @executable_path/../../../../../../../.. $APP
597 install_name_tool -add_rpath @executable_path/../../../../../../../../.. $APP
598 install_name_tool -add_rpath @executable_path/../../../../../../../../../.. $APP
599
600 echo "Patch $APP"
601
602 fi
603
604 done
605
606 #################################################################################################
607 # Final stage to manage file places in bundle
608
609 echo -e "\n---------- Finalize files in bundle"
610
611 mv -v $TEMPROOT/bin $TEMPROOT/digikam.app/Contents/
612 mv -v $TEMPROOT/share $TEMPROOT/digikam.app/Contents/
613 mv -v $TEMPROOT/etc $TEMPROOT/digikam.app/Contents/
614 mv -v $TEMPROOT/lib $TEMPROOT/digikam.app/Contents/
615 mv -v $TEMPROOT/libexec $TEMPROOT/digikam.app/Contents/
616
617 ln -sv "../../digikam.app/Contents/bin" "$TEMPROOT/showfoto.app/Contents/bin"
618 ln -sv "../../digikam.app/Contents/etc" "$TEMPROOT/showfoto.app/Contents/etc"
619 ln -sv "../../digikam.app/Contents/lib" "$TEMPROOT/showfoto.app/Contents/lib"
620 ln -sv "../../digikam.app/Contents/libexec" "$TEMPROOT/showfoto.app/Contents/libexec"
621 ln -sv "../../digikam.app/Contents/share" "$TEMPROOT/showfoto.app/Contents/share"
622 ln -sv "../../digikam.app/Contents/Resources" "$TEMPROOT/showfoto.app/Contents/Resources"
623
624 # Specific plugin paths need to be linked in the bundle
625
626 # For digiKam
627
628 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/designer" "$TEMPROOT/digikam.app/Contents/MacOS/designer"
629 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/generic" "$TEMPROOT/digikam.app/Contents/MacOS/generic"
630 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/imageformats" "$TEMPROOT/digikam.app/Contents/MacOS/imageformats"
631 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/platforms" "$TEMPROOT/digikam.app/Contents/MacOS/platforms"
632 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/styles" "$TEMPROOT/digikam.app/Contents/MacOS/styles"
633 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/iconengines" "$TEMPROOT/digikam.app/Contents/MacOS/iconengines"
634 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/sqldrivers" "$TEMPROOT/digikam.app/Contents/MacOS/sqldrivers"
635 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/kf$DK_QTVERSION" "$TEMPROOT/digikam.app/Contents/MacOS/kf$DK_QTVERSION"
636
637 if [[ $DK_QTVERSION = 6 ]] ; then
638
639 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/multimedia" "$TEMPROOT/digikam.app/Contents/MacOS/multimedia"
640 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/tls" "$TEMPROOT/digikam.app/Contents/MacOS/tls"
641 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/kiconthemes$DK_QTVERSION" "$TEMPROOT/digikam.app/Contents/MacOS/kiconthemes$DK_QTVERSION"
642
643 else
644
645 # Qt5 only
646
647 ln -sv "../../../digikam.app/Contents/libexec/qt$DK_QTVERSION/plugins/kauth" "$TEMPROOT/digikam.app/Contents/MacOS/kauth"
648
649 fi
650
651 # For Showfoto
652
653 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/designer" "$TEMPROOT/showfoto.app/Contents/MacOS/designer"
654 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/generic" "$TEMPROOT/showfoto.app/Contents/MacOS/generic"
655 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/imageformats" "$TEMPROOT/showfoto.app/Contents/MacOS/imageformats"
656 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/platforms" "$TEMPROOT/showfoto.app/Contents/MacOS/platforms"
657 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/styles" "$TEMPROOT/showfoto.app/Contents/MacOS/styles"
658 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/iconengines" "$TEMPROOT/showfoto.app/Contents/MacOS/iconengines"
659 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/sqldrivers" "$TEMPROOT/showfoto.app/Contents/MacOS/sqldrivers"
660 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/kf$DK_QTVERSION" "$TEMPROOT/showfoto.app/Contents/MacOS/kf$DK_QTVERSION"
661
662 if [[ $DK_QTVERSION = 6 ]] ; then
663
664 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/multimedia" "$TEMPROOT/showfoto.app/Contents/MacOS/multimedia"
665 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/tls" "$TEMPROOT/showfoto.app/Contents/MacOS/tls"
666 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/kiconthemes$DK_QTVERSION" "$TEMPROOT/showfoto.app/Contents/MacOS/kiconthemes$DK_QTVERSION"
667
668 else
669
670 # Qt5 only
671
672 ln -sv "../../../showfoto.app/Contents/libexec/qt$DK_QTVERSION/plugins/kauth" "$TEMPROOT/showfoto.app/Contents/MacOS/kauth"
673
674 fi
675
676 echo -e "\n---------- Cleanup files in bundle"
677
678 # Last cleanup
679
680 HEADERFILES=(`find $TEMPROOT -name "*.h" -o -name "*.hpp"`)
681
682 for HPP in ${HEADERFILES[@]} ; do
683
684 rm -fv $HPP
685
686 done
687
688 rm -rfv $TEMPROOT/digikam.app/Contents/share/mariadb$MARIADB_SUFFIX/mysql-test
689 rm -rfv $TEMPROOT/digikam.app/Contents/share/mariadb$MARIADB_SUFFIX/sql-bench
690
691 echo -e "\n---------- Patch config and script files in bundle"
692
693 MARIADBDIRS=(`find $TEMPROOT -type d -name "mariadb$MARIADB_SUFFIX"`)
694
695 for DIR in ${MARIADBDIRS[@]} ; do
696
697 MARIADBFILES=(`find $DIR -type f ! -name "*.dylib" ! -name "*.so"`)
698
699 for FILE in ${MARIADBFILES[@]} ; do
700
701 # to handle only text files
702 ISTEXT=`file "$FILE" | grep "text" || true`
703
704 if [[ $ISTEXT ]] ; then
705
706 NEEDPATCH=`grep "$INSTALL_PREFIX" "$FILE" || true`
707
708 if [[ $NEEDPATCH ]] ; then
709
710 echo -e "--- Patching $FILE..."
711 sed -i '' "s|$INSTALL_PREFIX/var|$RELOCATE_PREFIX/digikam.app/Contents/var|g" $FILE
712 sed -i '' "s|$INSTALL_PREFIX/lib|$RELOCATE_PREFIX/digikam.app/Contents/lib|g" $FILE
713 sed -i '' "s|$INSTALL_PREFIX/share|$RELOCATE_PREFIX/digikam.app/Contents/share|g" $FILE
714 sed -i '' "s|$INSTALL_PREFIX/etc|$RELOCATE_PREFIX/digikam.app/Contents/etc|g" $FILE
715 sed -i '' "s|$INSTALL_PREFIX|$RELOCATE_PREFIX/digikam.app/Contents/|g" $FILE
716
717 fi
718
719 fi
720
721 done
722
723 done
724
725 #################################################################################################
726 # See bug #436624: move mariadb shared files at basedir (this must be done after patch operations)
727
728 rsync -a "$TEMPROOT/digikam.app/Contents/share/mariadb$MARIADB_SUFFIX" "$TEMPROOT/digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX/share/"
729 rm -fr "$TEMPROOT/digikam.app/Contents/share/mariadb$MARIADB_SUFFIX"
730
731 # At run time, digiKam will check for mariadb folder-name without revision numbers.
732
733 ln -sv "../../../../../digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX/share/mariadb$MARIADB_SUFFIX" "$TEMPROOT/digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX/share/mariadb"
734 ln -sv "../../../digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX" "$TEMPROOT/digikam.app/Contents/lib/mariadb"
735 ln -sv "../../../digikam.app/Contents/etc/mariadb$MARIADB_SUFFIX" "$TEMPROOT/digikam.app/Contents/etc/mariadb"
736
737 ln -sv "../../../../digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX" "$TEMPROOT/digikam.app/Contents/lib/mariadb/lib"
738 ln -sv "../../../../digikam.app/Contents/lib/mariadb" "$TEMPROOT/digikam.app/Contents/lib/mariadb$MARIADB_SUFFIX"
739
740 #################################################################################################
741 # Install ExifTool binary.
742
743 cd $DOWNLOAD_DIR
744
745 #if [ ! -f "$DOWNLOAD_DIR/Image-ExifTool.tar.gz" ] ; then
746 wget https://mirrors.xtom.de/kde-application/digikam/exiftool/Image-ExifTool.tar.gz -O Image-ExifTool.tar.gz
747 #fi
748
749 tar -xvf "$DOWNLOAD_DIR/Image-ExifTool.tar.gz" -C "$TEMPROOT/digikam.app/Contents/bin"
750 cd $TEMPROOT/digikam.app/Contents/bin
751 EXIFTOOL_DIR=$(ls -d Image-ExifTool*)
752 ln -sv "./$EXIFTOOL_DIR" "./Image-ExifTool"
753 ln -sv "./Image-ExifTool/exiftool" "exiftool"
754
755 #################################################################################################
756 # Build PKG file
757
758 echo "---------- Create MacOS package for digiKam $DKRELEASEID"
759
760 mkdir -p $ORIG_WD/bundle
761 rm -f $ORIG_WD/bundle/*$DEBUG_SUF* || true
762
763 if [[ $DK_VERSION != v* ]] ; then
764
765 # with non-official release version, use build time-stamp as sub-version string.
766 DK_SUBVER="-`cat $ORIG_WD/data/BUILDDATE.txt`"
767
768 else
769
770 # with official release version, disable upload to KDE server, as this break check for new version function.
771 echo -e "Official release version detected, upload is disabled.\n"
772 DK_UPLOAD=0
773
774 fi
775
776 if [[ $DK_QTVERSION == 5 ]] ; then
777
778 QT_SUF="-Qt5"
779
780 else
781
782 QT_SUF="-Qt6"
783
784 fi
785
786 TARGET_INSTALLER=digiKam-$DKRELEASEID$DK_SUBVER$QT_SUF-MacOS-$TARGET_ARCH$DEBUG_SUF.pkg
787 TARGET_PKG_FILE=$BUILDDIR/bundle/$TARGET_INSTALLER
788 echo -e "Target PKG file : $TARGET_PKG_FILE"
789
790 chmod 666 $PROJECTDIR/digikam.pkgproj
791
792 $PACKAGESBUILD -v "$PROJECTDIR/digikam.pkgproj" --package-version "$DKRELEASEID"
793
794 mv "$PROJECTDIR/build/digikam.pkg" "$TARGET_PKG_FILE"
795
796 #################################################################################################
797 # Show resume information and future instructions to host PKG file to remote server
798
799 echo -e "\n---------- Compute package checksums for digiKam $DKRELEASEID\n" > $TARGET_PKG_FILE.sum
800 echo "File : $TARGET_PKG_FILE" >> $TARGET_PKG_FILE.sum
801 echo -n "Size : " >> $TARGET_PKG_FILE.sum
802 du -h "$TARGET_PKG_FILE" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum
803 echo -n "SHA256 sum : " >> $TARGET_PKG_FILE.sum
804 shasum -a256 "$TARGET_PKG_FILE" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum
805
806 # Checksums to post on Phabricator at release time.
807 shasum -a256 "$TARGET_PKG_FILE" > $BUILDDIR/bundle/sha256_release.sum
808
809 if [[ $DK_SIGN = 1 ]] ; then
810
811 cat ~/.gnupg/dkorg-gpg-pwd.txt | gpg --batch --yes --passphrase-fd 0 -sabv "$TARGET_PKG_FILE"
812 mv -f $TARGET_PKG_FILE.asc $TARGET_PKG_FILE.sig
813
814 echo "File : $TARGET_PKG_FILE.sig" >> $TARGET_PKG_FILE.sum
815 echo -n "Size : " >> $TARGET_PKG_FILE.sum
816 du -h "$TARGET_PKG_FILE.sig" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum
817 echo -n "SHA256 sum : " >> $TARGET_PKG_FILE.sum
818 shasum -a256 "$TARGET_PKG_FILE.sig" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum
819
820 # Checksums to post on Phabricator at release time.
821 shasum -a256 "$TARGET_PKG_FILE.sig" >> $BUILDDIR/bundle/sha256_release.sum
822
823 fi
824
825 cat $TARGET_PKG_FILE.sum
826
827 if [[ $DK_UPLOAD = 1 ]] ; then
828
829 echo -e "---------- Cleanup older bundle Package files from files.kde.org repository \n"
830
831 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "rm *-MacOS*$DEBUG_SUF.pkg*"
832
833 echo -e "---------- Upload new bundle Package files to files.kde.org repository \n"
834
835 rsync -r -v --progress -e ssh $BUILDDIR/bundle/$TARGET_INSTALLER $DK_UPLOADURL:$DK_UPLOADDIR
836
837 if [[ $DK_SIGN = 1 ]] ; then
838 scp $BUILDDIR/bundle/$TARGET_INSTALLER.sig $DK_UPLOADURL:$DK_UPLOADDIR
839 fi
840
841 # update remote files list
842
843 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "ls digi*" > $ORIG_WD/bundle/ls.txt
844 tail -n +2 $ORIG_WD/bundle/ls.txt > $ORIG_WD/bundle/ls.tmp
845 cat $ORIG_WD/bundle/ls.tmp | grep -E '(.pkg |.appimage |.exe )' | grep -Ev '(debug)' > $ORIG_WD/bundle/FILES
846 rm $ORIG_WD/bundle/ls.tmp
847 rm $ORIG_WD/bundle/ls.txt
848 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "rm FILES"
849 rsync -r -v --progress -e ssh $BUILDDIR/bundle/FILES $DK_UPLOADURL:$DK_UPLOADDIR
850
851 else
852 echo -e "\n------------------------------------------------------------------"
853 curl https://download.kde.org/README_UPLOAD
854 echo -e "------------------------------------------------------------------\n"
855 fi
856
857 #################################################################################################
858
859 TerminateScript