| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # SPDX-FileCopyrightText: 2013-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | ######################################################################## |
| 9 | # Check if run as root |
| 10 | ChecksRunAsRootscip-shell shell digikam 4:9.1.0-1 ChecksRunAsRoot().() |
| 11 | { |
| 12 | |
| 13 | if [[ $EUID -ne 0 ]]; then |
| 14 | echoscip-shell system . . echo. "This script should be run as root using sudo command." |
| 15 | exit 1 |
| 16 | else |
| 17 | echoscip-shell system . . echo. "Check run as root passed..." |
| 18 | fi |
| 19 | |
| 20 | } |
| 21 | |
| 22 | ######################################################################## |
| 23 | # Check CPU core available (Linux or MacOS) |
| 24 | ChecksCPUCoresscip-shell shell digikam 4:9.1.0-1 ChecksCPUCores().() |
| 25 | { |
| 26 | |
| 27 | CPU_CORES=$(grepscip-shell system . . grep. -c ^processor /proc/cpuinfoscip-shell filesystem . . `/proc/cpuinfo`. 2>/dev/nullscip-shell filesystem . . `/dev/null`. || sysctlscip-shell system . . sysctl. -n hw.ncpu) |
| 28 | |
| 29 | if [[ $CPU_CORES -gt 1 ]]; then |
| 30 | CPU_CORES=$((CPU_CORES-1)) |
| 31 | fi |
| 32 | |
| 33 | echoscip-shell system . . echo. "CPU Cores to use : $CPU_CORES" |
| 34 | |
| 35 | } |
| 36 | |
| 37 | ######################################################################## |
| 38 | # For time execution measurement ; startup |
| 39 | StartScriptscip-shell shell digikam 4:9.1.0-1 StartScript().() |
| 40 | { |
| 41 | |
| 42 | BEGIN_SCRIPT=$(datescip-shell system . . date. +"%s") |
| 43 | |
| 44 | } |
| 45 | |
| 46 | ######################################################################## |
| 47 | # For time execution measurement : shutdown |
| 48 | TerminateScriptscip-shell shell digikam 4:9.1.0-1 TerminateScript().() |
| 49 | { |
| 50 | |
| 51 | TERMIN_SCRIPT=$(datescip-shell system . . date. +"%s") |
| 52 | difftimelps=$(($TERMIN_SCRIPT-$BEGIN_SCRIPT)) |
| 53 | echoscip-shell system . . echo. "Elaspsed time for script execution : $(($difftimelps / 3600 )) hours $((($difftimelps % 3600) / 60)) minutes $(($difftimelps % 60)) seconds" |
| 54 | |
| 55 | } |
| 56 | |
| 57 | ######################################################################## |
| 58 | # Copy dependencies with dumpbin analysis |
| 59 | # arg1 : dumpbin program full path. |
| 60 | # arg2 : original file path to parse. |
| 61 | # arg3 : target path to copy dependencies. |
| 62 | # arg4 : dependencies path (only copy shared libs from this path). |
| 63 | CopyReccursiveDependenciesscip-shell shell digikam 4:9.1.0-1 CopyReccursiveDependencies().() |
| 64 | { |
| 65 | |
| 66 | echoscip-shell system . . echo. "Scan dependencies for $2" |
| 67 | |
| 68 | FILES=$("$1" -DEPENDENTS "$2" | grepscip-shell system . . grep. ".dll" | awkscip-shell system . . awk. '{print $1}') |
| 69 | #echo "deps: $FILES" |
| 70 | for FILE in $FILES ; do |
| 71 | if [[ -f "$4/$FILE" && ! -f "$3/$FILE" ]] ; then |
| 72 | cpscip-shell system . . cp. -u "$4/$FILE" "$3" 2> /dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true. |
| 73 | # echo " ==> $4/$FILE" |
| 74 | CopyReccursiveDependenciesscip-shell shell digikam 4:9.1.0-1 CopyReccursiveDependencies(). "$1" "$4/$FILE" "$3" "$4" |
| 75 | fi |
| 76 | done |
| 77 | |
| 78 | } |
| 79 | |
| 80 | ######################################################################## |
| 81 | # Automatically register the remote servers has know hosts |
| 82 | RegisterRemoteServersscip-shell shell digikam 4:9.1.0-1 RegisterRemoteServers().() |
| 83 | { |
| 84 | |
| 85 | SERVER_LIST="\ |
| 86 | invent.kde.org \ |
| 87 | tinami.kde.org \ |
| 88 | " |
| 89 | |
| 90 | if [[ ! -f ~/.ssh/known_hosts ]] ; then |
| 91 | touchscip-shell system . . touch. ~/.ssh/known_hosts |
| 92 | fi |
| 93 | |
| 94 | for server in $SERVER_LIST; do |
| 95 | |
| 96 | echoscip-shell system . . echo. "Register $server" |
| 97 | |
| 98 | ssh-keygenscip-shell system . . ssh-keygen. -R $server |
| 99 | ssh-keyscanscip-shell system . . ssh-keyscan. -H $server >> ~/.ssh/known_hosts |
| 100 | |
| 101 | done |
| 102 | |
| 103 | } |
| 104 | |
| 105 | ######################################################################## |
| 106 | # Append paths to the wanted VCPKG binary tools |
| 107 | AppendVCPKGPathsscip-shell shell digikam 4:9.1.0-1 AppendVCPKGPaths().() |
| 108 | { |
| 109 | |
| 110 | ORIG_PATH="$PATH" |
| 111 | |
| 112 | export PATH="\ |
| 113 | $PATH:\ |
| 114 | /c/bison:\ |
| 115 | /c/icoutils/bin:\ |
| 116 | $VCPKG_INSTALL_PREFIX/tools/gettext/bin:\ |
| 117 | $VCPKG_INSTALL_PREFIX/tools/gperf:\ |
| 118 | $VCPKG_INSTALL_PREFIX/tools/curl:\ |
| 119 | $VCPKG_INSTALL_PREFIX/tools/pkgconf:\ |
| 120 | $VCPKG_INSTALL_PREFIX/bin:\ |
| 121 | $DOWNLOAD_DIR/tools/python/python-3.14.2-x64-1:\ |
| 122 | $DOWNLOAD_DIR/tools/ninja-1.13.2-windows:\ |
| 123 | " |
| 124 | |
| 125 | if [[ $DK_QTVERSION = 6 ]] ; then |
| 126 | |
| 127 | export PATH="\ |
| 128 | $PATH:\ |
| 129 | $VCPKG_INSTALL_PREFIX/tools/Qt6/bin\ |
| 130 | " |
| 131 | |
| 132 | else |
| 133 | |
| 134 | export PATH="\ |
| 135 | $PATH:\ |
| 136 | $VCPKG_INSTALL_PREFIX/tools/qt5/bin\ |
| 137 | " |
| 138 | |
| 139 | fi |
| 140 | |
| 141 | echoscip-shell system . . echo. "PATH=$PATH" |
| 142 | |
| 143 | export PKG_CONFIG_PATH=$VCPKG_INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH |
| 144 | |
| 145 | } |
| 146 | |
| 147 | ######################################################################## |
| 148 | # Upload a large file to a remote server with retry if failure |
| 149 | # arg1 : local file path to upload. |
| 150 | # arg2 : remote ssh url. |
| 151 | # arg3 : remote directory. |
| 152 | # arg4 : pause between retry. |
| 153 | UploadWithRetryscip-shell shell digikam 4:9.1.0-1 UploadWithRetry().() |
| 154 | { |
| 155 | |
| 156 | # Disable errors exception handling |
| 157 | set +e |
| 158 | |
| 159 | MAX_RETRIES=10 |
| 160 | i=0 |
| 161 | RC=1 |
| 162 | |
| 163 | while [[ $RC -ne 0 ]] ; do |
| 164 | |
| 165 | i=$(($i+1)) |
| 166 | |
| 167 | if [scip-shell system . . `[`. $i -eq $MAX_RETRIES ] ; then |
| 168 | echoscip-shell system . . echo. -e "Hit maximum number of retries, giving up." |
| 169 | exit -1 |
| 170 | fi |
| 171 | |
| 172 | sleepscip-shell system . . sleep. $4 |
| 173 | echoscip-shell system . . echo. -e "Try $i/$MAX_RETRIES :: rsync -r -v --progress -e ssh $1 $2:$3" |
| 174 | bashscip-shell system . . bash. -c "rsync -r -v --progress -e ssh $1 $2:$3" |
| 175 | RC=$? |
| 176 | echoscip-shell system . . echo. "rsync return code: $RC" |
| 177 | |
| 178 | done |
| 179 | |
| 180 | # Re-enable halt and catch errors |
| 181 | set -eE |
| 182 | |
| 183 | } |
| 184 | |
| 185 | ChecksCmakeBinscip-shell shell digikam 4:9.1.0-1 ChecksCmakeBin().() |
| 186 | { |
| 187 | |
| 188 | # Check if the Cmake CLI tool is installed with Visual Studio. |
| 189 | |
| 190 | CMAKE_BIN="`findscip-shell system . . find. "/c/Program Files/Microsoft Visual Studio/scip-shell filesystem . . `/c/Program Files/Microsoft Visual Studio/`." -name "cmake.exe" -type f -executable`" |
| 191 | echoscip-shell system . . echo. "$CMAKE_BIN" |
| 192 | |
| 193 | if [scip-shell system . . `[`. ! -f "$CMAKE_BIN" ] ; then |
| 194 | echoscip-shell system . . echo. "CMake CLI tool is not installed" |
| 195 | echoscip-shell system . . echo. "Install VSCommunity C++ CMake tools component." |
| 196 | exit 1 |
| 197 | else |
| 198 | echoscip-shell system . . echo. "Check CMake CLI tools passed..." |
| 199 | fi |
| 200 | |
| 201 | } |