File indexing completed on 2024-06-16 04:06:49

0001 #! /bin/bash
0002 
0003 # Script to build a bundle HomeBrew installation with all digiKam dependencies in a dedicated directory
0004 # This script must be run as sudo
0005 #
0006 # SPDX-FileCopyrightText: 2015      by Shanti <listaccount at revenant dot org>
0007 # SPDX-FileCopyrightText: 2015-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0008 #
0009 # SPDX-License-Identifier: BSD-3-Clause
0010 #
0011 
0012 # Ask to run as root
0013 #(( EUID != 0 )) && exec sudo -- "$0" "$@"
0014 
0015 # Halt and catch errors
0016 set -eE
0017 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG
0018 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR
0019 
0020 #################################################################################################
0021 # Manage script traces to log file
0022 
0023 mkdir -p ./logs
0024 exec > >(tee ./logs/build-homebrew.full.log) 2>&1
0025 
0026 #################################################################################################
0027 
0028 echo "01-build-homebrew.sh : build a bundle HomeBrew install with digiKam dependencies."
0029 echo "---------------------------------------------------------------------------------"
0030 
0031 #################################################################################################
0032 # Pre-processing checks
0033 
0034 . ./config.sh
0035 . ./common.sh
0036 StartScript
0037 #ChecksRunAsRoot
0038 ChecksXCodeCLI
0039 ChecksCPUCores
0040 OsxCodeName
0041 #RegisterRemoteServers
0042 
0043 #################################################################################################
0044 
0045 # Paths rules
0046 ORIG_PATH="$PATH"
0047 ORIG_WD="`pwd`"
0048 
0049 export PATH=$INSTALL_PREFIX/bin:/$INSTALL_PREFIX/sbin:/$INSTALL_PREFIX/opt/qt6/bin:$ORIG_PATH
0050 
0051 #################################################################################################
0052 # Check if a previous bundle already exist
0053 
0054 CONTINUE_INSTALL=0
0055 
0056 if [ -d "$INSTALL_PREFIX" ] ; then
0057 
0058     read -p "$INSTALL_PREFIX already exist. Do you want to remove it or to continue an aborted previous installation ? [(r)emove/(c)ontinue/(s)top] " answer
0059 
0060     if echo "$answer" | grep -iq "^r" ;then
0061 
0062         echo "---------- Removing existing $INSTALL_PREFIX"
0063         mv $INSTALL_PREFIX $INSTALL_PREFIX.old || true
0064         rm -rf $INSTALL_PREFIX.old || true
0065 
0066     elif echo "$answer" | grep -iq "^c" ;then
0067 
0068         echo "---------- Continue aborted previous installation in $INSTALL_PREFIX"
0069         CONTINUE_INSTALL=1
0070 
0071     else
0072 
0073         echo "---------- Aborting..."
0074         exit;
0075 
0076     fi
0077 
0078 fi
0079 
0080 if [[ $CONTINUE_INSTALL == 0 ]]; then
0081 
0082     #################################################################################################
0083     # Install HomeBrew
0084 
0085     NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
0086     (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/gilles/.zprofile
0087     eval "$(/opt/homebrew/bin/brew shellenv)"
0088 
0089 fi
0090 
0091 #################################################################################################
0092 # Macports update
0093 
0094 echo -e "\n"
0095 echo "---------- Updating HomeBrew"
0096 #brew -v selfupdate
0097 
0098 if [[ $CONTINUE_INSTALL == 0 ]]; then
0099 
0100 #    brew -v upgrade outdated
0101     echo -e "\n"
0102 
0103 fi
0104 
0105 #################################################################################################
0106 # Dependencies build and installation
0107 
0108 echo -e "\n"
0109 echo "---------- Building digiKam dependencies with Macports"
0110 
0111 echo -e "\n"
0112 
0113 brew install \
0114              cmake \
0115              ccache \
0116              libpng \
0117              jpeg \
0118              libtiff \
0119              boost \
0120              eigen \
0121              mesa \
0122              gettext \
0123              gperf \
0124              libusb \
0125              libgphoto2 \
0126              jasper \
0127              little-cms2 \
0128              expat \
0129              libxml2 \
0130              libxslt \
0131              libical \
0132              bison \
0133              python-lxml \
0134              x265 \
0135              libde265 \
0136              libheif \
0137              aom \
0138              ffmpeg \
0139              wget \
0140              qt \
0141              qt-mariadb \
0142              opencv \
0143              imagemagick \
0144              jpeg-xl \
0145              libavif \
0146              fftw \
0147              exiv2 \
0148              lensfun
0149 
0150 echo -e "\n"
0151 
0152 #################################################################################################
0153 
0154 # Create the build dir for the 3rdparty deps
0155 
0156 if [ ! -d $BUILDING_DIR ] ; then
0157 
0158     mkdir $BUILDING_DIR
0159 
0160 fi
0161 
0162 if [ ! -d $DOWNLOAD_DIR ] ; then
0163 
0164     mkdir $DOWNLOAD_DIR
0165 
0166 fi
0167 
0168 cd $BUILDING_DIR
0169 
0170 rm -rf $BUILDING_DIR/* || true
0171 
0172 #cmake $ORIG_WD/../3rdparty \
0173 #       -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX \
0174 #       -DINSTALL_ROOT=$INSTALL_PREFIX \
0175 #       -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOAD_DIR \
0176 #       -DKA_VERSION=$DK_KA_VERSION \
0177 #       -DKP_VERSION=$DK_KP_VERSION \
0178 #       -DKDE_VERSION=$DK_KDE_VERSION \
0179 #       -DENABLE_QTVERSION=$DK_QTVERSION \
0180 #       -DENABLE_QTWEBENGINE=$DK_QTWEBENGINE \
0181 #       -Wno-dev
0182 #
0183 #cmake --build . --config RelWithDebInfo --target ext_libjxl      -- -j$CPU_CORES
0184 
0185 #################################################################################################
0186 
0187 export PATH=$ORIG_PATH
0188 
0189 TerminateScript