File indexing completed on 2025-01-05 04:00:16

0001 #!/bin/bash
0002 
0003 # Script to build a Linux Host installation to compile an AppImage bundle of digiKam.
0004 # This script must be run as sudo
0005 #
0006 # SPDX-FileCopyrightText: 2015-2024 by Gilles Caulier  <caulier dot gilles at gmail dot com>
0007 #
0008 # SPDX-License-Identifier: BSD-3-Clause
0009 #
0010 
0011 # Halt and catch errors
0012 set -eE
0013 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG
0014 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR
0015 
0016 #################################################################################################
0017 # Manage script traces to log file
0018 
0019 mkdir -p ./logs
0020 exec > >(tee ./logs/build-host.full.log) 2>&1
0021 
0022 #################################################################################################
0023 
0024 echo "01-build-host.sh : build a Linux host installation to compile an AppImage bundle."
0025 echo "---------------------------------------------------------------------------------"
0026 
0027 #################################################################################################
0028 # Pre-processing checks
0029 
0030 . ./common.sh
0031 . ./config.sh
0032 ChecksRunAsRoot
0033 StartScript
0034 ChecksCPUCores
0035 HostAdjustments
0036 RegisterRemoteServers
0037 ORIG_WD="`pwd`"
0038 
0039 #################################################################################################
0040 
0041 . ./host_ubuntu.inc
0042 
0043 # Clean up previous openssl and libicu install
0044 
0045 rm -fr /usr/local/lib/libssl.a       || true
0046 rm -fr /usr/local/lib/libcrypto.a    || true
0047 rm -fr /usr/local/include/openssl    || true
0048 
0049 rm -fr /usr/local/lib/libicu*.a      || true
0050 rm -fr /usr/local/lib/icu            || true
0051 rm -fr /usr/local/lib/pkgconfig/icu* || true
0052 rm -fr /usr/local/include/unicode    || true
0053 
0054 #################################################################################################
0055 
0056 echo -e "---------- Prepare Linux host to Compile Extra Dependencies\n"
0057 
0058 # Make sure we build from the /, parts of this script depends on that. We also need to run as root...
0059 cd /
0060 
0061 # Create the build dir for the 3rdparty deps
0062 if [ ! -d $BUILDING_DIR ] ; then
0063     mkdir -p $BUILDING_DIR
0064 fi
0065 
0066 if [ ! -d $DOWNLOAD_DIR ] ; then
0067     mkdir -p $DOWNLOAD_DIR
0068 fi
0069 
0070 #################################################################################################
0071 
0072 cd $BUILDING_DIR
0073 
0074 rm -rf $BUILDING_DIR/* || true
0075 
0076 cmake $ORIG_WD/../3rdparty \
0077       -DCMAKE_INSTALL_PREFIX:PATH=/usr \
0078       -DINSTALL_ROOT=/usr \
0079       -DENABLE_QTVERSION=$DK_QTVERSION \
0080       -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOAD_DIR \
0081       -DKA_VERSION=$DK_KA_VERSION \
0082       -DKP_VERSION=$DK_KP_VERSION \
0083       -DKDE_VERSION=$DK_KDE_VERSION \
0084       -DENABLE_QTVERSION=$DK_QTVERSION \
0085       -DENABLE_QTWEBENGINE=$DK_QTWEBENGINE
0086 
0087 # Install new cmake recent version and shared lib
0088 
0089 cmake --build . --config RelWithDebInfo --target ext_cmake           -- -j$CPU_CORES
0090 cmake --build . --config RelWithDebInfo --target ext_jasper          -- -j$CPU_CORES
0091 cmake --build . --config RelWithDebInfo --target ext_libde265        -- -j$CPU_CORES
0092 cmake --build . --config RelWithDebInfo --target ext_libjxl          -- -j$CPU_CORES
0093 cmake --build . --config RelWithDebInfo --target ext_libaom          -- -j$CPU_CORES
0094 cmake --build . --config RelWithDebInfo --target ext_libavif         -- -j$CPU_CORES
0095 cmake --build . --config RelWithDebInfo --target ext_ffmpeg          -- -j$CPU_CORES
0096 
0097 #################################################################################################
0098 
0099 cd $BUILDING_DIR
0100 
0101 rm -rf $BUILDING_DIR/* || true
0102 
0103 cmake $ORIG_WD/../3rdparty \
0104       -DCMAKE_INSTALL_PREFIX:PATH=/usr \
0105       -DINSTALL_ROOT=/usr \
0106       -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOAD_DIR \
0107       -DKA_VERSION=$DK_KA_VERSION \
0108       -DKP_VERSION=$DK_KP_VERSION \
0109       -DKDE_VERSION=$DK_KDE_VERSION \
0110       -DENABLE_QTVERSION=$DK_QTVERSION \
0111       -DENABLE_QTWEBENGINE=$DK_QTWEBENGINE \
0112       -DQTWEBENGINE_VERSION=$DK_QTWEBENGINEVERSION
0113 
0114 # Low level libraries and Qt dependencies
0115 # NOTE: The order to compile each component here is very important.
0116 
0117 # TODO: more recent libicu do not link yet with Qt6
0118 #cmake --build . --config RelWithDebInfo --target ext_libicu        -- -j$CPU_CORES
0119 
0120 cmake --build . --config RelWithDebInfo --target ext_openssl         -- -j$CPU_CORES
0121 
0122 cmake --build . --config RelWithDebInfo --target ext_qt$DK_QTVERSION -- -j$CPU_CORES    # depend of tiff, png, jpeg
0123 
0124 if [[ $DK_QTWEBENGINE = 0 ]] ; then
0125     cmake --build . --config RelWithDebInfo --target ext_qtwebkit    -- -j$CPU_CORES    # depend of Qt and libicu
0126 fi
0127 
0128 # Clean up previous openssl install
0129 
0130 rm -fr /usr/local/lib/libssl.a    || true
0131 rm -fr /usr/local/lib/libcrypto.a || true
0132 rm -fr /usr/local/include/openssl || true
0133 
0134 cmake --build . --config RelWithDebInfo --target ext_imagemagick     -- -j$CPU_CORES
0135 cmake --build . --config RelWithDebInfo --target ext_opencv          -- -j$CPU_CORES
0136 cmake --build . --config RelWithDebInfo --target ext_heif            -- -j$CPU_CORES
0137 
0138 #################################################################################################
0139 
0140 TerminateScript