]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ############################################################################ | |
3 | # # | |
4 | # This file is part of the IPFire Firewall. # | |
5 | # # | |
6 | # IPFire is free software; you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation; either version 2 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # IPFire is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with IPFire; if not, write to the Free Software # | |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
19 | # # | |
20 | # Copyright (C) 2006 IPFire-Team <info@ipfire.eu>. # | |
21 | # # | |
22 | ############################################################################ | |
23 | # | |
24 | ||
25 | NAME="IPFire" # Software name | |
26 | SNAME="ipfire" # Short name | |
27 | VERSION="2.0" # Version number | |
28 | SLOGAN="www.ipfire.eu" # Software slogan | |
29 | CONFIG_ROOT=/var/ipfire # Configuration rootdir | |
30 | NICE=10 # Nice level | |
31 | MAX_RETRIES=1 # prefetch/check loop | |
32 | KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'` | |
33 | MACHINE=`uname -m` | |
34 | SVN_REVISION=`svn info | grep Revision | cut -c 11-` | |
35 | ||
36 | IPFVER="full" # Which version should be compiled? (full|light|voice) | |
37 | ||
38 | # Set an information about the build number | |
39 | if [ -e ./.svn ]; then | |
40 | FIREBUILD=`cat .svn/entries |sed -n 's/^[ \t]*revision=\"// p' | sed -n 's/\".*$// p'` | |
41 | fi | |
42 | ||
43 | # Debian specific settings | |
44 | if [ ! -e /etc/debian_version ]; then | |
45 | FULLPATH=`which $0` | |
46 | else | |
47 | if [ -x /usr/bin/realpath ]; then | |
48 | FULLPATH=`/usr/bin/realpath $0` | |
49 | else | |
50 | echo "ERROR: Need to do apt-get install realpath" | |
51 | exit 1 | |
52 | fi | |
53 | fi | |
54 | ||
55 | PWD=`pwd` | |
56 | BASENAME=`basename $0` | |
57 | BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"` | |
58 | LOGFILE=$BASEDIR/log/_build.preparation.log | |
59 | export BASEDIR LOGFILE | |
60 | DIR_CHK=$BASEDIR/cache/check | |
61 | mkdir $BASEDIR/log/ 2>/dev/null | |
62 | ||
63 | # Include funtions | |
64 | . tools/make-functions | |
65 | ||
66 | if [ -f .config ]; then | |
67 | . .config | |
68 | else | |
69 | echo -e "${BOLD}No configuration found!${NORMAL}" | |
70 | echo -ne "Do you want to create one (y/N)?" | |
71 | read CREATE_CONFIG | |
72 | echo "" | |
73 | if [ "$CREATE_CONFIG" == "y" ]; then | |
74 | make_config | |
75 | fi | |
76 | fi | |
77 | ||
78 | prepareenv() { | |
79 | ############################################################################ | |
80 | # # | |
81 | # Are we running the right shell? # | |
82 | # # | |
83 | ############################################################################ | |
84 | if [ ! "$BASH" ]; then | |
85 | exiterror "BASH environment variable is not set. You're probably running the wrong shell." | |
86 | fi | |
87 | ||
88 | if [ -z "${BASH_VERSION}" ]; then | |
89 | exiterror "Not running BASH shell." | |
90 | fi | |
91 | ||
92 | ||
93 | ############################################################################ | |
94 | # # | |
95 | # Trap on emergency exit # | |
96 | # # | |
97 | ############################################################################ | |
98 | trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT | |
99 | ||
100 | ||
101 | ############################################################################ | |
102 | # # | |
103 | # Resetting our nice level # | |
104 | # # | |
105 | ############################################################################ | |
106 | echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE | |
107 | renice $NICE $$ > /dev/null | |
108 | if [ `nice` != "$NICE" ]; then | |
109 | beautify message FAIL | |
110 | exiterror "Failed to set correct nice level" | |
111 | else | |
112 | beautify message DONE | |
113 | fi | |
114 | ||
115 | ||
116 | ############################################################################ | |
117 | # # | |
118 | # Checking if running as root user # | |
119 | # # | |
120 | ############################################################################ | |
121 | echo -ne "Checking if we're running as root user" | tee -a $LOGFILE | |
122 | if [ `id -u` != 0 ]; then | |
123 | beautify message FAIL | |
124 | exiterror "Not building as root" | |
125 | else | |
126 | beautify message DONE | |
127 | fi | |
128 | ||
129 | ||
130 | ############################################################################ | |
131 | # # | |
132 | # Checking for necessary temporary space # | |
133 | # # | |
134 | ############################################################################ | |
135 | echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE | |
136 | BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'` | |
137 | BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'` | |
138 | if (( 2202000 > $BASE_ASPACE )); then | |
139 | BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'` | |
140 | if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then | |
141 | beautify message FAIL | |
142 | exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV" | |
143 | fi | |
144 | else | |
145 | beautify message DONE | |
146 | fi | |
147 | ||
148 | ############################################################################ | |
149 | # # | |
150 | # Building Linux From Scratch system # | |
151 | # # | |
152 | ############################################################################ | |
153 | # Set umask | |
154 | umask 022 | |
155 | ||
156 | # Set LFS Directory | |
157 | LFS=$BASEDIR/build | |
158 | ||
159 | # Check /tools symlink | |
160 | if [ -h /tools ]; then | |
161 | rm -f /tools | |
162 | fi | |
163 | if [ ! -a /tools ]; then | |
164 | ln -s $BASEDIR/build/tools / | |
165 | fi | |
166 | if [ ! -h /tools ]; then | |
167 | exiterror "Could not create /tools symbolic link." | |
168 | fi | |
169 | ||
170 | # Setup environment | |
171 | set +h | |
172 | LC_ALL=POSIX | |
173 | MAKETUNING="-j8" | |
174 | export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING | |
175 | unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD | |
176 | ||
177 | # Make some extra directories | |
178 | mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null | |
179 | mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys} | |
180 | mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null | |
181 | mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache} | |
182 | ||
183 | mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null | |
184 | mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null | |
185 | ||
186 | # Make all sources and proc available under lfs build | |
187 | mount --bind /dev $BASEDIR/build/dev | |
188 | mount --bind /dev/pts $BASEDIR/build/dev/pts | |
189 | mount --bind /dev/shm $BASEDIR/build/dev/shm | |
190 | mount --bind /proc $BASEDIR/build/proc | |
191 | mount --bind /sys $BASEDIR/build/sys | |
192 | mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache | |
193 | mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache | |
194 | mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config | |
195 | mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc | |
196 | mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html | |
197 | mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs | |
198 | mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs | |
199 | mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log | |
200 | mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src | |
201 | ||
202 | # This is a temporary hack!!! | |
203 | if [ ! -f /tools/bin/hostname ]; then | |
204 | cp -f /bin/hostname /tools/bin/hostname 2>/dev/null | |
205 | fi | |
206 | ||
207 | # Run LFS static binary creation scripts one by one | |
208 | export CCACHE_DIR=$BASEDIR/ccache | |
209 | export CCACHE_HASHDIR=1 | |
210 | ||
211 | # Remove pre-install list of installed files in case user erase some files before rebuild | |
212 | rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null | |
213 | } | |
214 | ||
215 | buildtoolchain() { | |
216 | LOGFILE="$BASEDIR/log/_build.toolchain.log" | |
217 | export LOGFILE | |
218 | ORG_PATH=$PATH | |
219 | NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}` | |
220 | export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1} | |
221 | lfsmake1 ccache | |
222 | lfsmake1 binutils PASS=1 | |
223 | lfsmake1 gcc PASS=1 | |
224 | export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH | |
225 | lfsmake1 linux-libc-header | |
226 | lfsmake1 glibc | |
227 | lfsmake1 cleanup-toolchain PASS=1 | |
228 | lfsmake1 tcl | |
229 | lfsmake1 expect | |
230 | lfsmake1 dejagnu | |
231 | lfsmake1 gcc PASS=2 | |
232 | lfsmake1 binutils PASS=2 | |
233 | lfsmake1 ncurses | |
234 | lfsmake1 bash | |
235 | lfsmake1 bzip2 | |
236 | lfsmake1 coreutils | |
237 | lfsmake1 diffutils | |
238 | lfsmake1 findutils | |
239 | lfsmake1 gawk | |
240 | lfsmake1 gettext | |
241 | lfsmake1 grep | |
242 | lfsmake1 gzip | |
243 | lfsmake1 m4 | |
244 | lfsmake1 make | |
245 | lfsmake1 patch | |
246 | lfsmake1 perl | |
247 | lfsmake1 sed | |
248 | lfsmake1 tar | |
249 | lfsmake1 texinfo | |
250 | lfsmake1 util-linux | |
251 | lfsmake1 cleanup-toolchain PASS=2 | |
252 | export PATH=$ORG_PATH | |
253 | } | |
254 | ||
255 | buildbase() { | |
256 | LOGFILE="$BASEDIR/log/_build.base.log" | |
257 | export LOGFILE | |
258 | lfsmake2 stage2 | |
259 | # lfsmake2 makedev | |
260 | lfsmake2 linux-libc-header | |
261 | lfsmake2 man-pages | |
262 | lfsmake2 glibc | |
263 | lfsmake2 cleanup-toolchain PASS=3 | |
264 | lfsmake2 binutils | |
265 | lfsmake2 gcc | |
266 | lfsmake2 berkeley | |
267 | lfsmake2 coreutils | |
268 | lfsmake2 iana-etc | |
269 | lfsmake2 m4 | |
270 | lfsmake2 bison | |
271 | lfsmake2 ncurses | |
272 | lfsmake2 procps | |
273 | lfsmake2 sed | |
274 | lfsmake2 libtool | |
275 | lfsmake2 perl | |
276 | lfsmake2 readline | |
277 | lfsmake2 zlib | |
278 | lfsmake2 autoconf | |
279 | lfsmake2 automake | |
280 | lfsmake2 bash | |
281 | lfsmake2 bzip2 | |
282 | lfsmake2 diffutils | |
283 | lfsmake2 e2fsprogs | |
284 | lfsmake2 file | |
285 | lfsmake2 findutils | |
286 | lfsmake2 flex | |
287 | lfsmake2 grub | |
288 | lfsmake2 gawk | |
289 | lfsmake2 gettext | |
290 | lfsmake2 grep | |
291 | lfsmake2 groff | |
292 | lfsmake2 gzip | |
293 | lfsmake2 inetutils | |
294 | lfsmake2 iproute2 | |
295 | lfsmake2 kbd | |
296 | lfsmake2 less | |
297 | lfsmake2 make | |
298 | lfsmake2 man | |
299 | lfsmake2 mktemp | |
300 | lfsmake2 modutils | |
301 | lfsmake2 patch | |
302 | lfsmake2 psmisc | |
303 | lfsmake2 shadow | |
304 | lfsmake2 sysklogd | |
305 | lfsmake2 sysvinit | |
306 | lfsmake2 tar | |
307 | lfsmake2 texinfo | |
308 | lfsmake2 udev | |
309 | lfsmake2 util-linux | |
310 | lfsmake2 vim | |
311 | } | |
312 | ||
313 | buildipfire() { | |
314 | LOGFILE="$BASEDIR/log/_build.ipfire.log" | |
315 | export LOGFILE | |
316 | ipfiremake inetutils | |
317 | ipfiremake net-tools | |
318 | ipfiremake ed | |
319 | ipfiremake configroot | |
320 | ipfiremake dhcp | |
321 | ipfiremake dhcpcd | |
322 | ipfiremake libusb | |
323 | ipfiremake libpcap | |
324 | # Temporary disabled. | |
325 | # ipfiremake linux-atm | |
326 | ipfiremake ppp | |
327 | ipfiremake rp-pppoe | |
328 | ipfiremake unzip | |
329 | ipfiremake linux PASS=I | |
330 | ipfiremake linux PASS=S | |
331 | # ipfiremake 3cp4218 PASS=SMP | |
332 | # ipfiremake amedyn PASS=SMP | |
333 | # ipfiremake cxacru PASS=SMP | |
334 | # ipfiremake eagle PASS=SMP | |
335 | # ipfiremake cnx_pci PASS=SMP | |
336 | # ipfiremake fcdsl PASS=SMP | |
337 | # ipfiremake fcdsl2 PASS=SMP | |
338 | # ipfiremake fcdslsl PASS=SMP | |
339 | # ipfiremake fcdslusb PASS=SMP | |
340 | # ipfiremake fcdslslusb PASS=SMP | |
341 | # ipfiremake fcpci PASS=SMP | |
342 | # ipfiremake fcclassic PASS=SMP | |
343 | # ipfiremake pulsar PASS=SMP | |
344 | # ipfiremake unicorn PASS=SMP | |
345 | # ipfiremake promise-sata-300-tx PASS=SMP | |
346 | ipfiremake linux | |
347 | # ipfiremake 3cp4218 | |
348 | # ipfiremake amedyn | |
349 | # ipfiremake cxacru | |
350 | # ipfiremake eciadsl | |
351 | # ipfiremake eagle | |
352 | # ipfiremake speedtouch | |
353 | # ipfiremake cnx_pci | |
354 | # ipfiremake fcdsl | |
355 | # ipfiremake fcdsl2 | |
356 | # ipfiremake fcdslsl | |
357 | # ipfiremake fcdslusb | |
358 | # ipfiremake fcdslslusb | |
359 | # ipfiremake fcpci | |
360 | # ipfiremake fcclassic | |
361 | # ipfiremake pulsar | |
362 | # ipfiremake unicorn | |
363 | # ipfiremake promise-sata-300-tx | |
364 | # ipfiremake pcmciautils | |
365 | ipfiremake expat | |
366 | ipfiremake gdbm | |
367 | ipfiremake gmp | |
368 | ipfiremake openssl | |
369 | ipfiremake python | |
370 | ipfiremake libnet | |
371 | ipfiremake libjpeg | |
372 | ipfiremake libpng | |
373 | ipfiremake libtiff | |
374 | ipfiremake lcms | |
375 | ipfiremake libmng | |
376 | ipfiremake freetype | |
377 | ipfiremake gd | |
378 | ipfiremake popt | |
379 |