File indexing completed on 2024-06-16 04:06:49
0001 #! /bin/bash 0002 0003 # Script to bundle data using previously-built digiKam installation. 0004 # and create a PKG file with Packages application (http://s.sudre.free.fr/Software/Packages/about.html) 0005 # This script must be run as sudo 0006 # 0007 # SPDX-FileCopyrightText: 2015 by Shanti, <listaccount at revenant dot org> 0008 # SPDX-FileCopyrightText: 2015-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0009 # 0010 # SPDX-License-Identifier: BSD-3-Clause 0011 # 0012 0013 # Ask to run as root 0014 (( EUID != 0 )) && exec sudo -- "$0" "$@" 0015 0016 # Halt and catch errors 0017 set -eE 0018 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG 0019 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR 0020 0021 ################################################################################################# 0022 # Manage script traces to log file 0023 0024 mkdir -p ./logs 0025 exec > >(tee ./logs/build-installer.full.log) 2>&1 0026 0027 ################################################################################################# 0028 0029 echo "04-build-installer.sh : build digiKam bundle PKG." 0030 echo "-------------------------------------------------" 0031 0032 ################################################################################################# 0033 # Pre-processing checks 0034 0035 . ./config.sh 0036 . ./common.sh 0037 StartScript 0038 ChecksRunAsRoot 0039 ChecksXCodeCLI 0040 ChecksCPUCores 0041 OsxCodeName 0042 #RegisterRemoteServers 0043 0044 ################################################################################################# 0045 0046 # Paths rules 0047 ORIG_PATH="$PATH" 0048 ORIG_WD="`pwd`" 0049 0050 export PATH=$INSTALL_PREFIX/bin:/$INSTALL_PREFIX/sbin:$ORIG_PATH 0051 0052 DKRELEASEID=`cat $ORIG_WD/data/RELEASEID.txt` 0053 0054 ################################################################################################# 0055 # Configurations 0056 0057 # Directory where this script is located (default - current directory) 0058 BUILDDIR="$PWD" 0059 0060 # Directory where Packages project files are located 0061 PROJECTDIR="$BUILDDIR/installer" 0062 0063 # Staging area where files to be packaged will be copied 0064 TEMPROOT="$BUILDDIR/$RELOCATE_PREFIX" 0065 0066 # Applications to be launched directly by user (create launch scripts) 0067 KDE_MENU_APPS="\ 0068 digikam \ 0069 showfoto \ 0070 " 0071 0072 # Paths to search for applications above 0073 KDE_APP_PATHS="\ 0074 bin \ 0075 " 0076 0077 # Other apps - non-MacOS binaries & libraries to be included with required dylibs 0078 OTHER_APPS="\ 0079 share/qt/plugins/imageformats/*.dylib \ 0080 share/qt/plugins/styles/* \ 0081 share/qt/plugins/digikam/bqm/*.so \ 0082 share/qt/plugins/digikam/generic/*.so \ 0083 share/qt/plugins/digikam/editor/*.so \ 0084 share/qt/plugins/digikam/dimg/*.so \ 0085 share/qt/plugins/digikam/rawimport/*.so \ 0086 opt/mariadb/bin/mysql \ 0087 opt/mariadb/bin/mysqld \ 0088 opt/mariadb/bin/my_print_defaults \ 0089 opt/mariadb/bin/mysqladmin \ 0090 opt/mariadb/bin/mysqltest \ 0091 opt/mariadb/lib/*.dylib \ 0092 opt/mariadb/lib/plugin/*.so \ 0093 bin/kbuildsycoca6 \ 0094 bin/solid-hardware6 \ 0095 bin/ffmpeg \ 0096 opt/qt-mariadb/share/qt/plugins/sqldrivers/*.dylib \ 0097 opt/qt6/share/qt/plugins/sqldrivers/*.dylib \ 0098 opt/qt6/share/qt/plugins/imageformats/*.dylib \ 0099 opt/qt6/share/qt/plugins/platforms/*.dylib \ 0100 opt/qt6/share/qt/plugins/iconengines/*.dylib \ 0101 opt/qt6/share/qt/plugins/generic/*.dylib \ 0102 opt/qt6/share/qt/plugins/styles/*.dylib \ 0103 " 0104 #FIXME: recompile HomeBrew Qt6 with missing plugins 0105 #opt/qt6/share/qt/plugins/bearer/*.dylib \ 0106 #opt/qt6/share/qt/plugins/printsupport/*.dylib \ 0107 #opt/qt6/share/qt/plugins/platformthemes/*.dylib \ 0108 0109 #lib/sane/*.so \ 0110 0111 binaries="$OTHER_APPS" 0112 0113 # Additional Files/Directories - to be copied recursively but not checked for dependencies 0114 # Note: dSYM directories are copied as well and cleaned later if debug symbols must be removed in final bundle. 0115 OTHER_DIRS="\ 0116 opt/qt6/share/qt/translations \ 0117 lib/libdigikam*.dSYM \ 0118 lib/libgphoto2 \ 0119 lib/libgphoto2_port \ 0120 opt/mariadb \ 0121 lib/ImageMagick* \ 0122 share/ImageMagick* \ 0123 etc/ImageMagick* \ 0124 etc/my.cnf 0125 etc/my.cnf.default 0126 etc/my.cnf.d 0127 " 0128 0129 #etc/xdg \ 0130 #etc/mariadb$MARIADB_SUFFIX \ 0131 0132 #etc/sane.d \ 0133 0134 # Additional Data Directories - to be copied recursively 0135 OTHER_DATA="\ 0136 share/applications \ 0137 share/opencv4 \ 0138 share/k* \ 0139 share/lensfun \ 0140 share/mime \ 0141 Library/Application/ \ 0142 " 0143 0144 # Packaging tool paths 0145 PACKAGESBUILD="/usr/local/bin/packagesbuild" 0146 0147 echo "digiKam version: $DKRELEASEID" 0148 0149 # ./installer sub-dir must be writable by root 0150 chmod 777 ${PROJECTDIR} 0151 0152 ################################################################################################# 0153 # Check if Packages CLI tools are installed 0154 0155 if [[ (! -f "$PACKAGESBUILD") ]] ; then 0156 echo "Packages CLI tool is not installed" 0157 echo "See http://s.sudre.free.fr/Software/Packages/about.html for details." 0158 exit 1 0159 else 0160 echo "Check Packages CLI tool passed..." 0161 fi 0162 0163 ################################################################################################# 0164 # Create temporary dir to build package contents 0165 0166 if [ -d "$TEMPROOT" ] ; then 0167 echo "---------- Removing temporary packaging directory $TEMPROOT" 0168 rm -rf "$TEMPROOT" 0169 fi 0170 0171 echo "Creating $TEMPROOT" 0172 mkdir -p "$TEMPROOT" 0173 0174 ################################################################################################# 0175 # Prepare applications for MacOS 0176 0177 echo "---------- Preparing Applications for MacOS" 0178 0179 for app in $KDE_MENU_APPS ; do 0180 echo " $app" 0181 0182 # Look for application 0183 0184 for searchpath in $KDE_APP_PATHS ; do 0185 0186 # Copy the application if it is found (create directory if necessary) 0187 0188 if [ -d "$INSTALL_PREFIX/$searchpath/$app.app" ] ; then 0189 0190 echo " Found $app in $INSTALL_PREFIX/$searchpath" 0191 0192 # Copy application directory 0193 0194 echo " Copying $app" 0195 cp -pr "$INSTALL_PREFIX/$searchpath/$app.app" "$TEMPROOT" 0196 0197 # Add executable to list of binaries for which we need to collect dependencies for 0198 0199 binaries="$binaries $searchpath/$app.app/Contents/MacOS/$app" 0200 0201 chmod 755 "$TEMPROOT/$app.app" 0202 0203 fi 0204 0205 done 0206 0207 done 0208 0209 ################################################################################################# 0210 # Collect dylib dependencies for all binaries, 0211 # then copy them to the staging area (creating directories as required) 0212 0213 echo "---------- Collecting dependencies for applications, binaries, and libraries..." 0214 0215 cd "$INSTALL_PREFIX" 0216 0217 binary_paths=$(ls $binaries | sort -u) 0218 0219 for bin in $binary_paths ; do 0220 0221 echo "Scan dependencies for $bin" 0222 0223 # Copy original with parsing 0224 0225 lib="${bin/$INSTALL_PREFIX\//}" 0226 0227 if [ ! -e "$TEMPROOT/$lib" ] ; then 0228 dir="${lib%/*}" 0229 0230 if [ ! -d "$TEMPROOT/$dir" ] ; then 0231 mkdir -p "$TEMPROOT/$dir" 0232 fi 0233 0234 cp -aH "$INSTALL_PREFIX/$lib" "$TEMPROOT/$dir/" 0235 fi 0236 0237 CopyReccursiveDependencies "$bin" "$TEMPROOT" 0238 0239 done 0240 0241 ################################################################################################# 0242 # Copy non-binary files and directories, creating parent directories if needed 0243 0244 echo "---------- Copying binary files..." 0245 0246 for path in $OTHER_APPS ; do 0247 dir="${path%/*}" 0248 0249 if [ ! -d "$TEMPROOT/$dir" ] ; then 0250 echo " Creating $TEMPROOT/$dir" 0251 mkdir -p "$TEMPROOT/$dir" 0252 fi 0253 0254 echo " Copying $INSTALL_PREFIX/$path to $TEMPROOT/$dir/" 0255 cp -aH "$INSTALL_PREFIX/$path" "$TEMPROOT/$dir/" 0256 done 0257 0258 echo "---------- Copying directory contents..." 0259 0260 for path in $OTHER_DIRS ; do 0261 dir="${path%/*}" 0262 0263 if [ ! -d "$TEMPROOT/$dir" ] ; then 0264 echo " Creating $TEMPROOT/$dir" 0265 mkdir -p "$TEMPROOT/$dir" 0266 fi 0267 0268 echo " Copying $INSTALL_PREFIX/$path to $TEMPROOT/$dir/" 0269 cp -aHL "$INSTALL_PREFIX/$path" "$TEMPROOT/$dir/" 0270 done 0271 0272 0273 echo "---------- Copying data files..." 0274 0275 # Special case with data dirs. QStandardPaths::GenericDataLocation was patched everywhere 0276 # in source code by QStandardPaths::AppDataLocation 0277 0278 for path in $OTHER_DATA ; do 0279 echo " Copying $path" 0280 cp -aL "$INSTALL_PREFIX/$path" "$TEMPROOT/digikam.app/Contents/Resources/" 0281 done 0282 0283 # Copy digiKam hi-colors PNG icons-set to the bundle 0284 0285 mkdir -p "$TEMPROOT/digikam.app/Contents/Resources/icons/" 0286 cp -a "$INSTALL_PREFIX/share/icons/hicolor" "$TEMPROOT/digikam.app/Contents/Resources/icons/" 0287 0288 echo "---------- Copying Qt Web Backend files..." 0289 0290 # Qt Web framework bin data files. 0291 # NOTE: QtWebEngine runtime process is now located in 0292 # opt/qt6/lib/QtWebEngineCore.framework/Versions/current/Helpers/QtWebEngineProcess.app/Contents/MacOS 0293 # instead of opt/qt6/libexec/. No needs to make extra rules for this runtime process. 0294 0295 echo "---------- Copying i18n..." 0296 0297 i18nprefix=$INSTALL_PREFIX/share/ 0298 cd $i18nprefix 0299 0300 FILES=$(cat $ORIG_WD/logs/build-extralibs.full.log | grep "$INSTALL_PREFIX/share/locale/" | cut -d' ' -f3 | awk '{sub("'"$i18nprefix"'","")}1') 0301 0302 for FILE in $FILES ; do 0303 rsync -R "./$FILE" "$TEMPROOT/digikam.app/Contents/Resources/" 0304 done 0305 0306 FILES=$(cat $ORIG_WD/logs/build-digikam.full.log | grep "$INSTALL_PREFIX/share/locale/" | cut -d' ' -f3 | awk '{sub("'"$i18nprefix"'","")}1') 0307 0308 for FILE in $FILES ; do 0309 rsync -R "./$FILE" "$TEMPROOT/digikam.app/Contents/Resources/" 0310 done 0311 0312 # Move Qt translation data files at the right place in the bundle. See Bug #438701. 0313 0314 mv -v $TEMPROOT/opt/qt6/share/qt/translations $TEMPROOT/digikam.app/Contents/Resources/ 0315 0316 # To support localized system menu entries from MacOS. See bug #432650. 0317 0318 FILES=$(find "$TEMPROOT/digikam.app/Contents/Resources/locale" -type d -depth 1) 0319 0320 for FILE in $FILES ; do 0321 BASE=$(basename $FILE) 0322 echo "Create localized system menu entry for $BASE" 0323 mkdir "$TEMPROOT/digikam.app/Contents/Resources/$BASE.lproj" 0324 done 0325 0326 # Showfoto resources dir must be merged with digiKam. 0327 0328 cp -a "$TEMPROOT/showfoto.app/Contents/Resources/" "$TEMPROOT/digikam.app/Contents/Resources/" 0329 rm -rf "$TEMPROOT/showfoto.app/Contents/Resources" 0330 0331 cd "$ORIG_WD" 0332 0333 ################################################################################################# 0334 # Move digiKam and KF6 run-time plugins to the right place 0335 0336 rm -fr $TEMPROOT/bin/digikam.app 0337 rm -fr $TEMPROOT/bin/showfoto.app 0338 0339 mkdir -p $TEMPROOT/libexec/qt6/ 0340 cp -a $TEMPROOT/share/qt/plugins $TEMPROOT/libexec/qt6/ 0341 rm -rf $TEMPROOT/share/qt/plugins 0342 cp -a $TEMPROOT/opt/qt6/share/qt/plugins $TEMPROOT/libexec/qt6/ 0343 rm -rf $TEMPROOT/opt/qt6/ 0344 0345 ################################################################################################# 0346 # Merge Manifest files 0347 0348 echo "---------- Copy Git Revisions Manifest\n" 0349 0350 touch $TEMPROOT/digikam.app/Contents/Resources/MANIFEST.txt 0351 0352 FILES=$(ls $ORIG_WD/data/*_manifest.txt) 0353 0354 for FILE in $FILES ; do 0355 echo $FILE 0356 cat $FILE >> $TEMPROOT/digikam.app/Contents/Resources/MANIFEST.txt 0357 done 0358 0359 ################################################################################################# 0360 # Create package pre-install script 0361 0362 echo "---------- Create package pre-install script" 0363 0364 # Delete /Applications entries, delete existing installation 0365 0366 cat << EOF > "$PROJECTDIR/preinstall" 0367 #!/bin/bash 0368 0369 if [ -d /Applications/digiKam ] ; then 0370 echo "Removing digiKam directory from Applications folder" 0371 rm -r /Applications/digiKam 0372 fi 0373 0374 if [ -d /Applications/digikam.app ] ; then 0375 echo "Removing legacy digikam.app from Applications folder" 0376 rm -r /Applications/digikam.app 0377 fi 0378 0379 if [ -d /Applications/showfoto.app ] ; then 0380 echo "Removing legacy showfoto.app from Applications folder" 0381 rm -r /Applications/showfoto.app 0382 fi 0383 0384 if [ -d "/opt/digikam" ] ; then 0385 echo "Removing legacy /opt/digikam" 0386 rm -rf "/opt/digikam" 0387 fi 0388 EOF 0389 0390 # Pre-install script need to be executable 0391 0392 chmod 755 "$PROJECTDIR/preinstall" 0393 0394 ################################################################################################# 0395 # Create package post-install script 0396 0397 echo "---------- Create package post-install script" 0398 0399 # Creates Applications menu icons 0400 0401 cat << EOF > "$PROJECTDIR/postinstall" 0402 #!/bin/bash 0403 0404 # NOTE: Disabled with relocate bundle 0405 #for app in $INSTALL_PREFIX/Applications/digiKam/*.app ; do 0406 # ln -s "\$app" /Applications/\${app##*/} 0407 #done 0408 EOF 0409 0410 # Post-install script need to be executable 0411 0412 chmod 755 "$PROJECTDIR/postinstall" 0413 0414 ################################################################################################# 0415 # Copy icons-set resource files. 0416 0417 cp $INSTALL_PREFIX/share/icons/breeze/breeze-icons.rcc $TEMPROOT/digikam.app/Contents/Resources/breeze.rcc 0418 cp $INSTALL_PREFIX/share/icons/breeze-dark/breeze-icons-dark.rcc $TEMPROOT/digikam.app/Contents/Resources/breeze-dark.rcc 0419 0420 ################################################################################################# 0421 # Cleanup symbols in binary files to free space. 0422 0423 echo -e "\n---------- Strip symbols in binary files\n" 0424 0425 if [[ $DK_DEBUG = 1 ]] ; then 0426 0427 find $TEMPROOT -name "*.so" | grep -Ev '(digikam|showfoto)' | xargs strip -SXx 0428 find $TEMPROOT -name "*.dylib" | grep -Ev '(digikam|showfoto)' | xargs strip -SXx 0429 0430 else 0431 0432 # no debug symbols at all. 0433 0434 find $TEMPROOT -perm +111 -type f | xargs strip -SXx 2>/dev/null 0435 0436 # Under MacOS, all debug symbols are stored to separated dSYM sub directories near binary files. 0437 0438 DSYMDIRS=`find $TEMPROOT -type d -name "*.dSYM"` 0439 0440 for dsym in $DSYMDIRS ; do 0441 0442 rm -fr $dsym 0443 echo "Remove debug symbols from $dsym" 0444 0445 done 0446 0447 fi 0448 0449 if [[ $DK_DEBUG = 1 ]] ; then 0450 0451 DEBUG_SUF="-debug" 0452 0453 fi 0454 0455 ################################################################################################# 0456 # Relocatable binary files. For details, see these urls: 0457 # 0458 # https://stackoverflow.com/questions/9263256/can-you-please-help-me-understand-how-mach-o-libraries-work-in-mac-os-x 0459 # https://matthew-brett.github.io/docosx/mac_runtime_link.html 0460 # https://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/ 0461 0462 echo -e "\n---------- Relocatable binary files" 0463 0464 # Relocatable dynamic libraries with rpath 0465 0466 echo -e "\n--- Relocatable dynamic library files" 0467 0468 DYLIBFILES=(`find $TEMPROOT -name "*.dylib"`) 0469 0470 RelocatableBinaries DYLIBFILES[@] 0471 0472 # Relocatable system objects with rpath 0473 0474 echo -e "\n--- Relocatable system object files" 0475 0476 SOFILES=(`find $TEMPROOT -name "*.so"`) 0477 0478 RelocatableBinaries SOFILES[@] 0479 0480 # Relocatable executables with rpath and patch relative search path. 0481 0482 echo -e "\n--- Relocatable executable files" 0483 0484 EXECFILES=(`find $TEMPROOT -type f ! -name "*.dylib" ! -name "*.so" -print0 | xargs -0 -n 10 file | grep "Mach-O" | cut -d ':' -f 1`) 0485 0486 RelocatableBinaries EXECFILES[@] 0487 0488 echo -e "\n--- Patch RPATH in executable files" 0489 0490 for APP in ${EXECFILES[@]} ; do 0491 0492 ISBINARY=`file "$APP" | grep "Mach-O" || true` 0493 0494 # Do not touch debug extension 0495 ISDSYM=`file "$APP" | grep "dSYM" || true` 0496 0497 # Do not patch applet files which are pure Apple API binaries 0498 BASENAME=`basename "$APP"` 0499 0500 if [[ $ISBINARY ]] && [[ ! $ISDSYM ]] && [[ $BASENAME != "applet" ]] ; then 0501 0502 install_name_tool -add_rpath @executable_path/.. $APP 0503 install_name_tool -add_rpath @executable_path/../.. $APP 0504 # install_name_tool -add_rpath @executable_path/../../.. $APP 0505 # install_name_tool -add_rpath @executable_path/../../../.. $APP 0506 # install_name_tool -add_rpath @executable_path/../../../../.. $APP 0507 # install_name_tool -add_rpath @executable_path/../../../../../.. $APP 0508 # install_name_tool -add_rpath @executable_path/../../../../../../.. $APP 0509 # install_name_tool -add_rpath @executable_path/../../../../../../../.. $APP 0510 # install_name_tool -add_rpath @executable_path/../../../../../../../../.. $APP 0511 # install_name_tool -add_rpath @executable_path/../../../../../../../../../.. $APP 0512 codesign --force -s - $APP 0513 0514 echo "Patch $APP" 0515 0516 fi 0517 0518 done 0519 0520 ################################################################################################# 0521 # Final stage to manage file places in bundle 0522 0523 echo -e "\n---------- Finalize files in bundle" 0524 0525 mv -v $TEMPROOT/bin $TEMPROOT/digikam.app/Contents/ 0526 mv -v $TEMPROOT/share $TEMPROOT/digikam.app/Contents/ 0527 mv -v $TEMPROOT/etc $TEMPROOT/digikam.app/Contents/ 0528 mv -v $TEMPROOT/lib $TEMPROOT/digikam.app/Contents/ 0529 mv -v $TEMPROOT/libexec $TEMPROOT/digikam.app/Contents/ 0530 mv -v $TEMPROOT/opt $TEMPROOT/digikam.app/Contents/ 0531 mv -v $TEMPROOT/Cellar $TEMPROOT/digikam.app/Contents/ 0532 0533 ln -sv "../../digikam.app/Contents/bin" "$TEMPROOT/showfoto.app/Contents/bin" 0534 ln -sv "../../digikam.app/Contents/etc" "$TEMPROOT/showfoto.app/Contents/etc" 0535 ln -sv "../../digikam.app/Contents/lib" "$TEMPROOT/showfoto.app/Contents/lib" 0536 ln -sv "../../digikam.app/Contents/libexec" "$TEMPROOT/showfoto.app/Contents/libexec" 0537 ln -sv "../../digikam.app/Contents/share" "$TEMPROOT/showfoto.app/Contents/share" 0538 ln -sv "../../digikam.app/Contents/Resources" "$TEMPROOT/showfoto.app/Contents/Resources" 0539 ln -sv "../../digikam.app/Contents/opt" "$TEMPROOT/showfoto.app/Contents/opt" 0540 ln -sv "../../digikam.app/Contents/Cellar" "$TEMPROOT/showfoto.app/Contents/Cellar" 0541 0542 echo -e "\n---------- Cleanup files in bundle" 0543 0544 # Last cleanup 0545 0546 HEADERFILES=(`find $TEMPROOT -name "*.h" -o -name "*.hpp"`) 0547 0548 for HPP in ${HEADERFILES[@]} ; do 0549 0550 rm -fv $HPP 0551 0552 done 0553 0554 rm -rfv $TEMPROOT/digikam.app/Contents/opt/mariadb/bin/mysql-test 0555 0556 echo -e "\n---------- Patch config and script files in bundle" 0557 0558 MARIADBDIRS=(`find $TEMPROOT -type d -name "mariadb"`) 0559 0560 for DIR in ${MARIADBDIRS[@]} ; do 0561 0562 MARIADBFILES=(`find $DIR -type f ! -name "*.dylib" ! -name "*.so"`) 0563 0564 for FILE in ${MARIADBFILES[@]} ; do 0565 0566 # to handle only text files 0567 ISTEXT=`file "$FILE" | grep "ASCII text" || true` 0568 0569 if [[ $ISTEXT ]] ; then 0570 0571 NEEDPATCH=`grep "$INSTALL_PREFIX" "$FILE" || true` 0572 0573 if [[ $NEEDPATCH ]] ; then 0574 0575 echo -e "--- Patching $FILE..." 0576 sed -i '' "s|$INSTALL_PREFIX/var|$RELOCATE_PREFIX/digikam.app/Contents/var|g" $FILE 0577 sed -i '' "s|$INSTALL_PREFIX/lib|$RELOCATE_PREFIX/digikam.app/Contents/lib|g" $FILE 0578 sed -i '' "s|$INSTALL_PREFIX/share|$RELOCATE_PREFIX/digikam.app/Contents/share|g" $FILE 0579 sed -i '' "s|$INSTALL_PREFIX/etc|$RELOCATE_PREFIX/digikam.app/Contents/etc|g" $FILE 0580 sed -i '' "s|$INSTALL_PREFIX|$RELOCATE_PREFIX/digikam.app/Contents/|g" $FILE 0581 0582 fi 0583 0584 fi 0585 0586 done 0587 0588 done 0589 0590 ################################################################################################# 0591 # See bug #436624: move mariadb share files at basedir (this must be done after patch operations) 0592 0593 mkdir -p "$TEMPROOT/digikam.app/Contents/lib/mariadb" 0594 rsync -a "$TEMPROOT/digikam.app/Contents/opt/mariadb/share" "$TEMPROOT/digikam.app/Contents/lib/mariadb" 0595 rm -fr "$TEMPROOT/digikam.app/Contents/opt/mariadb/share" 0596 0597 ################################################################################################# 0598 # Install ExifTool binary. 0599 0600 cd $DOWNLOAD_DIR 0601 0602 #if [ ! -f "$DOWNLOAD_DIR/Image-ExifTool.tar.gz" ] ; then 0603 wget https://files.kde.org/digikam/exiftool/Image-ExifTool.tar.gz -O Image-ExifTool.tar.gz 0604 #fi 0605 0606 tar -xvf "$DOWNLOAD_DIR/Image-ExifTool.tar.gz" -C "$TEMPROOT/digikam.app/Contents/bin" 0607 cd $TEMPROOT/digikam.app/Contents/bin 0608 EXIFTOOL_DIR=$(ls -d Image-ExifTool*) 0609 ln -sv "./$EXIFTOOL_DIR" "./Image-ExifTool" 0610 ln -sv "./Image-ExifTool/exiftool" "exiftool" 0611 0612 ################################################################################################# 0613 # Build PKG file 0614 0615 echo "---------- Create MacOS package for digiKam $DKRELEASEID" 0616 0617 mkdir -p $ORIG_WD/bundle 0618 rm -f $ORIG_WD/bundle/*arm64$DEBUG_SUF* || true 0619 0620 if [[ $DK_VERSION != v* ]] ; then 0621 0622 # with non-official release version, use build time-stamp as sub-version string. 0623 DK_SUBVER="-`cat $ORIG_WD/data/BUILDDATE.txt`" 0624 0625 else 0626 0627 # with official release version, disable upload to KDE server, as this break check for new version function. 0628 echo -e "Official release version detected, upload is disabled.\n" 0629 DK_UPLOAD=0 0630 0631 fi 0632 0633 TARGET_INSTALLER=digiKam-$DKRELEASEID$DK_SUBVER-MacOS-arm64$DEBUG_SUF.pkg 0634 TARGET_PKG_FILE=$BUILDDIR/bundle/$TARGET_INSTALLER 0635 echo -e "Target PKG file : $TARGET_PKG_FILE" 0636 0637 chmod 666 $PROJECTDIR/digikam.pkgproj 0638 0639 $PACKAGESBUILD -v "$PROJECTDIR/digikam.pkgproj" --package-version "$DKRELEASEID" 0640 0641 mv "$PROJECTDIR/build/digikam.pkg" "$TARGET_PKG_FILE" 0642 0643 ################################################################################################# 0644 # Show resume information and future instructions to host PKG file to remote server 0645 0646 echo -e "\n---------- Compute package checksums for digiKam $DKRELEASEID\n" > $TARGET_PKG_FILE.sum 0647 echo "File : $TARGET_PKG_FILE" >> $TARGET_PKG_FILE.sum 0648 echo -n "Size : " >> $TARGET_PKG_FILE.sum 0649 du -h "$TARGET_PKG_FILE" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum 0650 echo -n "SHA256 sum : " >> $TARGET_PKG_FILE.sum 0651 shasum -a256 "$TARGET_PKG_FILE" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum 0652 0653 # Checksums to post on Phabricator at release time. 0654 shasum -a256 "$TARGET_PKG_FILE" > $BUILDDIR/bundle/sha256_release.sum 0655 0656 if [[ $DK_SIGN = 1 ]] ; then 0657 0658 cat ~/.gnupg/dkorg-gpg-pwd.txt | gpg --batch --yes --passphrase-fd 0 -sabv "$TARGET_PKG_FILE" 0659 mv -f $TARGET_PKG_FILE.asc $TARGET_PKG_FILE.sig 0660 0661 echo "File : $TARGET_PKG_FILE.sig" >> $TARGET_PKG_FILE.sum 0662 echo -n "Size : " >> $TARGET_PKG_FILE.sum 0663 du -h "$TARGET_PKG_FILE.sig" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum 0664 echo -n "SHA256 sum : " >> $TARGET_PKG_FILE.sum 0665 shasum -a256 "$TARGET_PKG_FILE.sig" | { read first rest ; echo $first ; } >> $TARGET_PKG_FILE.sum 0666 0667 # Checksums to post on Phabricator at release time. 0668 shasum -a256 "$TARGET_PKG_FILE.sig" >> $BUILDDIR/bundle/sha256_release.sum 0669 0670 fi 0671 0672 cat $TARGET_PKG_FILE.sum 0673 0674 if [[ $DK_UPLOAD = 1 ]] ; then 0675 0676 echo -e "---------- Cleanup older bundle Package files from files.kde.org repository \n" 0677 0678 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "rm *-MacOS-arm64$DEBUG_SUF.pkg*" 0679 0680 echo -e "---------- Upload new bundle Package files to files.kde.org repository \n" 0681 0682 rsync -r -v --progress -e ssh $BUILDDIR/bundle/$TARGET_INSTALLER $DK_UPLOADURL:$DK_UPLOADDIR 0683 0684 if [[ $DK_SIGN = 1 ]] ; then 0685 scp $BUILDDIR/bundle/$TARGET_INSTALLER.sig $DK_UPLOADURL:$DK_UPLOADDIR 0686 fi 0687 0688 # update remote files list 0689 0690 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "ls digi*" > $ORIG_WD/bundle/ls.txt 0691 tail -n +2 $ORIG_WD/bundle/ls.txt > $ORIG_WD/bundle/ls.tmp 0692 cat $ORIG_WD/bundle/ls.tmp | grep -E '(.pkg |.appimage |.exe )' | grep -Ev '(debug)' > $ORIG_WD/bundle/FILES 0693 rm $ORIG_WD/bundle/ls.tmp 0694 rm $ORIG_WD/bundle/ls.txt 0695 sftp -q $DK_UPLOADURL:$DK_UPLOADDIR <<< "rm FILES" 0696 rsync -r -v --progress -e ssh $BUILDDIR/bundle/FILES $DK_UPLOADURL:$DK_UPLOADDIR 0697 0698 else 0699 echo -e "\n------------------------------------------------------------------" 0700 curl https://download.kde.org/README_UPLOAD 0701 echo -e "------------------------------------------------------------------\n" 0702 fi 0703 0704 ################################################################################################# 0705 0706 TerminateScript