blob: 3d46dbb2756638cc223a1b9e3402e34d819233fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2021 René de Hesselle <dehesselle@web.de>
#
# SPDX-License-Identifier: GPL-2.0-or-later
### description ################################################################
# This script bootstraps JHBuild so it's ready to build any module.
### shellcheck #################################################################
# Nothing here.
### dependencies ###############################################################
#------------------------------------------------------ source jhb configuration
# You can install a custom configuration file by passing it as first
# argument. It has to be named '*.conf.sh'.
source "$(dirname "${BASH_SOURCE[0]}")"/../../etc/jhb.conf.sh "$1"
#------------------------------------------- source common functions from bash_d
# bash_d is already available (it's part of jhb configuration)
bash_d_include error
### variables ##################################################################
SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1; pwd)
FORCE_BUILD_FROM_SOURCE=${FORCE_BUILD_FROM_SOURCE:-false}
### functions ##################################################################
function is_release_usable
{
local url=$1
local partial_download="$TMP_DIR/${FUNCNAME[0]}".tar.xz
local rc=1
# download at least 100 kb of data
curl -L "$url" 2>/dev/null | head -c 100000 > "$partial_download"
# if we got 100 kb, it's not a "404 file not found"
if [ "$(stat -f%z "$partial_download")" -eq 100000 ]; then
# look inside: dir needs to match our VER_DIR to be usable
local dir
dir=$(basename "$(tar -tvJf "$partial_download" 2>/dev/null |
head -n 1 | awk '{ print $NF }')")
if [ "$dir" = "$(basename "$VER_DIR")" ]; then
rc=0
fi
fi
rm "$partial_download"
return $rc
}
### main #######################################################################
error_trace_enable
#-------------------------------------------------------- print main directories
echo_i "WRK_DIR = $WRK_DIR"
echo_i "VER_DIR = $VER_DIR"
#--------------------------------------------------------- perform system checks
if sys_wrkdir_is_usable &&
sdkroot_exists &&
sys_usrlocal_is_clean; then
# these checks may issue warnings but have have no consequences otherwise
sys_macos_is_recommended || true
sys_sdk_is_recommended || true
else
exit 1 # cannot continue
fi
#--------------------------------------------------- initialize directory layout
if [ "$SELF_DIR" = "$USR_DIR"/bin ]; then
: # we are already running inside target directory layout
else
# sync repository into target structure, remove everything git-related
rsync -a "$SELF_DIR"/../../../jhb/ "$VER_DIR"/
find "$VER_DIR" -type f -name ".gitignore" -delete
rm -rf "$VER_DIR"/.git
rm "$VER_DIR"/.gitmodules
fi
#------------------------------------------- check if binary release can be used
for URL in "${RELEASE_URLS[@]}"; do
if is_release_usable "$URL" && ! $FORCE_BUILD_FROM_SOURCE; then
echo_i "using $URL"
curl -L "$URL" | tar -C "$WRK_DIR" -xJ
exit $? # we can quit here and now, nothing further to do
fi
done
echo_i "building everything from scratch"
#---------------------------------------------------------------- install ccache
ccache_install
ccache_configure
#------------------------------------------ log relevant versions to release.log
sys_create_log
#------------------------------------------------- install and configure JHBuild
jhbuild_install
jhbuild_configure
#------------------------------------------------------- run bootstrap procedure
jhbuild bootstrap-gtk-osx
#--------------------------------------------------------- install GNU utilities
# GNU versions of various utilites make life significantly easier on macOS.
jhbuild build coreutils findutils sed tar
#-------------------------------------------------------------- install dmgbuild
dmgbuild_install
|