forked from Illuminux/arm-cross-sysroot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysroot
executable file
·200 lines (156 loc) · 4.42 KB
/
sysroot
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
#
# ARM Cross Sysroot is a script bundle to cross-compile libraries on a
# host computer for an ARM target. This git repo contains just scripts
# to build the libraries for an ARM target. It does not contains any
# of the the source. They will be downloaded during the build process.
#
# Copyright (C) 2014-15 Knut Welzel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#clear
##
## Working directory of the Script
##
GV_base_dir=$(cd "${0%/*}" && pwd -P)
GV_script_name=$(basename $0)
GV_lock_file="/tmp/${GV_script_name%.*}.lock"
##
## Lock the script so that it can not be executed in parallel
##
# If a lock-file exists
if [ -f $GV_lock_file ]; then
# get the pid from lock-file
lock_pid=$(cat $GV_lock_file)
# test if the pid is still running, then abbort, otherwise delete the lock
if [ $(ps -axc | awk '{print $1}' | grep $lock_pid) ]; then
echo "*** Error script is already running ***"
exit 1
else
rm -f $GV_lock_file
fi
else
# create a new lock file
echo $$ > $GV_lock_file
fi
## Build start time
GV_total_start=$(date +%s)
## Build platform
GV_build_os=$(uname -s)
## Make some aliases for gnu commands
if [ $GV_build_os = "Darwin" ]; then
if ! hash "gsed" 2>/dev/null; then
echo "Please run 'brew install gnu-sed'"
exit
fi
if ! hash "gawk" 2>/dev/null; then
echo "Please install 'brew install gawk'"
exit
fi
LIBTOOL=glibtool
SED=gsed
AWK=gawk
else
LIBTOOL=libtool
SED=sed
AWK=awk
fi
#flock -n "/var/run/${GV_script_name}" -c "${GV_base_dir}/${GV_script_name}"
##
## Make sure that we are still in working directory
##
cd $GV_base_dir
##
## Create log dir
##
mkdir -p "${GV_base_dir}/log"
##
## check if config.cfg exists or exit
##
if ! [ -f "${GV_base_dir}/config.cfg" ]; then
echo "Error: The configuration file could not be found!"
echo
echo "Rename or copy the file config.cfg.sample into config.cfg" \
"and customize the variable according to your system settings."
echo " $ cp config.cfg.sample config.cfg"
echo " $ nano config.cfg"
echo
exit 1
fi
##
## Includ library and configuration files
##
source "${GV_base_dir}/config.cfg"
source "${GV_base_dir}/include/update.sh"
source "${GV_base_dir}/include/settings.cfg"
source "${GV_base_dir}/include/system.sh"
source "${GV_base_dir}/include/command.sh"
source "${GV_base_dir}/include/tools.sh"
source "${GV_base_dir}/include/files.sh"
source "${GV_base_dir}/include/build.sh"
##
## Parse the comandline arguments
##
FU_tools_parse_arguments $@
echo "Building an advanced sysroot for ${UV_board}."
echo
##
## test required software for host
##
FU_system_require
##
## test access rights for building the sysroot
##
FU_tools_access_rights
##
## Mac OS X needs an case sensitiv diskimage
## !!! libX11 can only build on a case sensitiv filesystem !!!
##
if [ $GV_build_os = "Darwin" ]; then
FU_tools_create_source_image
else
do_mkdir "${GV_base_dir}/src"
fi
##
## Build and Version information
##
if ! [ -f "${UV_sysroot_dir}/buildinfo.txt" ]; then
touch "${UV_sysroot_dir}/buildinfo.txt"
else
printf "\n\n%s\n\n" "*** Rebuild ***" >> "${UV_sysroot_dir}/buildinfo.txt"
fi
printf "%s\n%s\n%s\n%s\n%s\n\n%s\n" \
"Script Version: ${GV_version}" \
"Script Date: ${GV_build_date}" \
"Build Date: $(date)" \
"Build User: $(whoami)" \
"Build Machine: $(uname -v)" \
"Packages:" >> "${UV_sysroot_dir}/buildinfo.txt"
##
## Execute all formulas.
##
for LV_formula in "${GV_build_formulas[@]}"; do
source "${GV_base_dir}/formula/${LV_formula}.sh"
done
##
## cleanup build dir
##
FU_tools_cleanup_build
GV_total_end=`date +%s`
GV_total_time=`expr $GV_total_end - $GV_total_start`
echo "" | tee -a "${UV_sysroot_dir}/buildinfo.txt"
echo -n "Sysroot successfully build in " | tee -a "${UV_sysroot_dir}/buildinfo.txt"
echo $GV_total_time | $AWK '{print strftime("%H:%M:%S", $1,1)}' | tee -a "${UV_sysroot_dir}/buildinfo.txt"
echo ""