Debian Codegraph @

project/bundles/homebrew/01-build-homebrew.sh

raw
1 #! /bin/bash
2
3 # Script to build a bundle HomeBrew installation with all digiKam dependencies in a dedicated directory
4 # This script must be run as sudo
5 #
6 # SPDX-FileCopyrightText: 2015 by Shanti <listaccount at revenant dot org>
7 # SPDX-FileCopyrightText: 2015-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
8 #
9 # SPDX-License-Identifier: BSD-3-Clause
10 #
11
12 # Ask to run as root
13 #(( EUID != 0 )) && exec sudo -- "$0" "$@"
14
15 # Halt and catch errors
16 set -eE
17 trap 'PREVIOUS_COMMAND=$THIS_COMMAND; THIS_COMMAND=$BASH_COMMAND' DEBUG
18 trap 'echo "FAILED COMMAND: $PREVIOUS_COMMAND"' ERR
19
20 #################################################################################################
21 # Manage script traces to log file
22
23 mkdir -p ./logs
24 exec > >(tee ./logs/build-homebrew.full.log) 2>&1
25
26 #################################################################################################
27
28 echo "01-build-homebrew.sh : build a bundle HomeBrew install with digiKam dependencies."
29 echo "---------------------------------------------------------------------------------"
30
31 #################################################################################################
32 # Pre-processing checks
33
34 . ./config.sh
35 . ./common.sh
36 StartScript
37 #ChecksRunAsRoot
38 ChecksXCodeCLI
39 ChecksCPUCores
40 OsxCodeName
41 #RegisterRemoteServers
42
43 #################################################################################################
44
45 # Paths rules
46 ORIG_PATH="$PATH"
47 ORIG_WD="`pwd`"
48
49 export PATH=$INSTALL_PREFIX/bin:/$INSTALL_PREFIX/sbin:/$INSTALL_PREFIX/opt/qt6/bin:$ORIG_PATH
50
51 #################################################################################################
52 # Homebrew settings
53
54 #export HOMEBREW_NO_INSTALL_FROM_API=1
55 export HOMEBREW_NO_AUTO_UPDATE=1
56
57 export HOMEBREW_CELLAR="$INSTALL_PREFIX/Cellar"
58 export HOMEBREW_PREFIX="$INSTALL_PREFIX"
59 export HOMEBREW_REPOSITORY="$INSTALL_PREFIX"
60 export HOMEBREW_CACHE="$INSTALL_PREFIX/cache"
61 export QT_AVOID_CMAKE_ARCHIVING_API=ON
62
63 sudo dseditgroup -o edit -a ${USER} -t user admin
64
65 #################################################################################################
66 # Check if a previous bundle already exist
67
68 CONTINUE_INSTALL=0
69
70 if [ -d "$INSTALL_PREFIX" ] ; then
71
72 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
73
74 if echo "$answer" | grep -iq "^r" ;then
75
76 echo "---------- Removing existing $INSTALL_PREFIX"
77 mv $INSTALL_PREFIX $INSTALL_PREFIX.old || true
78 rm -rf $INSTALL_PREFIX.old || true
79
80 elif echo "$answer" | grep -iq "^c" ;then
81
82 echo "---------- Continue aborted previous installation in $INSTALL_PREFIX"
83 CONTINUE_INSTALL=1
84
85 else
86
87 echo "---------- Aborting..."
88 exit;
89
90 fi
91
92 fi
93
94 if [[ $CONTINUE_INSTALL == 0 ]]; then
95
96 #################################################################################################
97 # Install HomeBrew
98
99 # Use this section if you want to install Homebrew to a custom location
100
101 # sudo mkdir $INSTALL_PREFIX
102 # sudo chown -R ${USER} $INSTALL_PREFIX
103 # git clone https://github.com/Homebrew/brew $INSTALL_PREFIX
104 # eval "$($INSTALL_PREFIX/bin/brew shellenv)"
105
106 export HOMEBREW_NO_AUTO_UPDATE=1
107
108 # export HOMEBREW_CELLAR="$INSTALL_PREFIX/Cellar"
109 # export HOMEBREW_PREFIX="$INSTALL_PREFIX"
110 # export HOMEBREW_REPOSITORY="$INSTALL_PREFIX"
111 # export HOMEBREW_CACHE="$INSTALL_PREFIX/cache"
112
113 # brew update --force
114 # chmod -R go-w "$(brew --prefix)/share/zsh"
115
116
117 # Use this section to do a default Homebrew installation - not recommended
118
119 NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
120 # (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/${USER}/.zprofile
121 # #eval "$(/opt/homebrew/bin/brew shellenv)"
122
123 fi
124
125 #################################################################################################
126 # Homebrew update
127
128 # removed to keep build dependencies stable
129
130 # echo -e "\n"
131 # echo "---------- Updating HomeBrew"
132 # brew -v update
133
134 # if [[ $CONTINUE_INSTALL == 0 ]]; then
135
136 # # brew -v upgrade outdated
137 # echo -e "\n"
138
139 # fi
140
141 #################################################################################################
142 # Dependencies build and installation
143
144 echo -e "\n"
145 echo "---------- Building digiKam dependencies with Homebrew"
146
147 echo -e "\n"
148
149 # Homebrew supports Qt6 only
150 if [[ $DK_QTVERSION = 5 ]] ; then
151 # brew install qt@5
152 export PATH=$ORIG_PATH
153 TerminateScript
154 exit
155 fi
156
157 ${INSTALL_PREFIX}/bin/brew install \
158 cmake \
159 ccache \
160 libpng \
161 jpeg \
162 libtiff \
163 boost \
164 eigen \
165 mesa \
166 gettext \
167 gperf \
168 libusb \
169 libgphoto2 \
170 jasper \
171 little-cms2 \
172 expat \
173 libxml2 \
174 libxslt \
175 libical \
176 bison \
177 x264 \
178 x265 \
179 libde265 \
180 libheif \
181 aom \
182 ffmpeg \
183 wget \
184 dbus \
185 dbus-glib \
186 imagemagick \
187 jpeg-xl \
188 libavif \
189 fftw \
190 exiv2 \
191 lensfun \
192 opencv \
193 qt \
194 qt-mariadb
195 # sane-backends
196
197 echo -e "\n"
198
199 # use pip instead of Homebrew to install lxml
200 ${INSTALL_PREFIX}/bin/python3 -m venv ${INSTALL_PREFIX}
201 source ${INSTALL_PREFIX}/bin/activate
202 python3 -m pip install --upgrade lxml
203
204 #################################################################################################
205
206 # Create the build dir for the 3rdparty deps
207
208 if [ ! -d $BUILDING_DIR ] ; then
209
210 mkdir $BUILDING_DIR
211
212 fi
213
214 if [ ! -d $DOWNLOAD_DIR ] ; then
215
216 mkdir $DOWNLOAD_DIR
217
218 fi
219
220 cd $BUILDING_DIR
221
222 rm -rf $BUILDING_DIR/* || true
223
224 #################################################################################################
225
226 CopyDebugSymbols
227
228 export PATH=$ORIG_PATH
229
230 TerminateScript