]>
Commit | Line | Data |
---|---|---|
df5e82b3 | 1 | #!/bin/bash |
df5e82b3 MT |
2 | ############################################################################ |
3 | # # | |
f8e5510c | 4 | # This file is part of the IPFire Firewall. # |
df5e82b3 | 5 | # # |
f8e5510c | 6 | # IPFire is free software; you can redistribute it and/or modify # |
df5e82b3 MT |
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 | # # | |
f8e5510c | 11 | # IPFire is distributed in the hope that it will be useful, # |
df5e82b3 MT |
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 # | |
f8e5510c | 17 | # along with IPFire; if not, write to the Free Software # |
df5e82b3 MT |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # |
19 | # # | |
06209efc | 20 | # Copyright (C) 2007 IPFire-Team <info@ipfire.org>. # |
df5e82b3 MT |
21 | # # |
22 | ############################################################################ | |
df5e82b3 MT |
23 | # |
24 | ||
06209efc MT |
25 | NAME="IPFire" # Software name |
26 | SNAME="ipfire" # Short name | |
ca8da28e MT |
27 | VERSION="2.9" # Version number |
28 | TOOLCHAINVERSION="${VERSION}" # Toolchain | |
06209efc | 29 | SLOGAN="www.ipfire.org" # Software slogan |
df5e82b3 | 30 | |
15679d9f | 31 | # Include funtions |
ca8da28e | 32 | . tools/make-include |
df5e82b3 | 33 | |
df5e82b3 | 34 | |
ca8da28e MT |
35 | ################################################################################ |
36 | # This builds the entire stage "toolchain" # | |
37 | ################################################################################ | |
38 | toolchain_build() { | |
df5e82b3 | 39 | |
ca8da28e MT |
40 | ORG_PATH=$PATH |
41 | export PATH=$BASEDIR/build_${MACHINE}/usr/local/ccache/bin:$BASEDIR/build_${MACHINE}/usr/local/distcc/bin:$BASEDIR/build_${MACHINE}/$TOOLS_DIR/bin:$PATH | |
42 | STAGE_ORDER=01 | |
43 | STAGE=toolchain | |
df5e82b3 | 44 | |
ca8da28e MT |
45 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.toolchain.log" |
46 | export LOGFILE | |
47 | ||
48 | NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}` | |
49 | export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1} | |
50 | ||
51 | # make distcc first so that CCACHE_PREFIX works immediately | |
0e61af85 | 52 | [ -z "$DISTCC_HOSTS" ] || toolchain_make distcc |
ca8da28e MT |
53 | toolchain_make ccache |
54 | ||
be472d5a MT |
55 | toolchain_make binutils PASS=1 |
56 | toolchain_make gcc PASS=1 | |
57 | toolchain_make linux | |
ca8da28e | 58 | toolchain_make glibc |
be472d5a | 59 | toolchain_make adjust-toolchain |
ca8da28e MT |
60 | toolchain_make tcl |
61 | toolchain_make expect | |
62 | toolchain_make dejagnu | |
be472d5a MT |
63 | toolchain_make gcc PASS=2 |
64 | toolchain_make binutils PASS=2 | |
ca8da28e MT |
65 | toolchain_make ncurses |
66 | toolchain_make bash | |
67 | toolchain_make bzip2 | |
68 | toolchain_make coreutils | |
69 | toolchain_make diffutils | |
70 | toolchain_make findutils | |
71 | toolchain_make gawk | |
72 | toolchain_make gettext | |
73 | toolchain_make grep | |
74 | toolchain_make gzip | |
ca8da28e MT |
75 | toolchain_make make |
76 | toolchain_make patch | |
77 | toolchain_make perl | |
78 | toolchain_make sed | |
79 | toolchain_make tar | |
80 | toolchain_make texinfo | |
81 | toolchain_make util-linux | |
3888140c | 82 | # toolchain_make strip |
ca8da28e MT |
83 | export PATH=$ORG_PATH |
84 | } | |
df5e82b3 | 85 | |
ca8da28e MT |
86 | ################################################################################ |
87 | # This builds the entire stage "base" # | |
88 | ################################################################################ | |
89 | base_build() { | |
90 | ||
91 | PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/bin:/usr/bin:/sbin:/usr/sbin:$TOOLS_DIR/bin | |
92 | STAGE_ORDER=02 | |
93 | STAGE=base | |
94 | ||
95 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.base.log" | |
96 | export LOGFILE | |
3888140c | 97 | |
ca8da28e | 98 | ipfire_make stage2 |
3888140c | 99 | ipfire_make linux |
ca8da28e MT |
100 | ipfire_make man-pages |
101 | ipfire_make glibc | |
3888140c | 102 | ipfire_make adjust-toolchain |
ca8da28e MT |
103 | ipfire_make binutils |
104 | ipfire_make gcc | |
105 | ipfire_make berkeley | |
3888140c MT |
106 | ipfire_make sed |
107 | ipfire_make e2fsprogs | |
ca8da28e MT |
108 | ipfire_make coreutils |
109 | ipfire_make iana-etc | |
110 | ipfire_make m4 | |
111 | ipfire_make bison | |
112 | ipfire_make ncurses | |
113 | ipfire_make procps | |
ca8da28e MT |
114 | ipfire_make libtool |
115 | ipfire_make perl | |
116 | ipfire_make readline | |
117 | ipfire_make zlib | |
118 | ipfire_make autoconf | |
119 | ipfire_make automake | |
120 | ipfire_make bash | |
121 | ipfire_make bzip2 | |
122 | ipfire_make diffutils | |
ca8da28e MT |
123 | ipfire_make file |
124 | ipfire_make findutils | |
125 | ipfire_make flex | |
0e61af85 | 126 | ipfire_make grub |
ca8da28e MT |
127 | ipfire_make gawk |
128 | ipfire_make gettext | |
129 | ipfire_make grep | |
130 | ipfire_make groff | |
131 | ipfire_make gzip | |
132 | ipfire_make inetutils | |
133 | ipfire_make iproute2 | |
134 | ipfire_make kbd | |
135 | ipfire_make less | |
ca8da28e | 136 | ipfire_make make |
0e61af85 | 137 | ipfire_make man-db |
ca8da28e | 138 | ipfire_make mktemp |
0e61af85 | 139 | ipfire_make module-init-tools |
ca8da28e MT |
140 | ipfire_make patch |
141 | ipfire_make psmisc | |
ca8da28e MT |
142 | ipfire_make shadow |
143 | ipfire_make sysklogd | |
144 | ipfire_make sysvinit | |
145 | ipfire_make tar | |
146 | ipfire_make texinfo | |
246556fe | 147 | ipfire_make udev ## NEED TO INSTALL CONFIG |
ca8da28e MT |
148 | ipfire_make util-linux |
149 | ipfire_make vim | |
ca8da28e | 150 | } |
df5e82b3 | 151 | |
ca8da28e MT |
152 | ################################################################################ |
153 | # This builds the entire stage "ipfire" # | |
154 | ################################################################################ | |
155 | ipfire_build() { | |
156 | PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/${MACHINE_REAL}-linux/bin | |
157 | STAGE_ORDER=03 | |
158 | STAGE=ipfire | |
159 | ||
160 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.ipfire.log" | |
161 | export LOGFILE | |
246556fe MT |
162 | |
163 | ### Building the configuration dirs and files | |
164 | # | |
165 | ipfire_make stage3 | |
166 | ||
167 | ### Building the kernel stuff | |
168 | # | |
f76aefec | 169 | ipfire_make linux |
246556fe MT |
170 | #ipfire_make zaptel |
171 | ||
172 | ### Building some network stuff | |
173 | # | |
174 | ipfire_make libpcap | |
175 | ipfire_make linux-atm | |
176 | ipfire_make ppp | |
177 | ipfire_make rp-pppoe | |
178 | ipfire_make dhcp | |
179 | ipfire_make iptables | |
180 | ipfire_make dnsmasq | |
181 | #ipfire_make l7-protocols | |
182 | #ipfire_make iptstate | |
183 | #ipfire_make bridge-utils | |
184 | #ipfire_make vlan | |
185 | ||
186 | ### Building some general stuff | |
187 | # | |
188 | ipfire_make openssl | |
189 | ipfire_make pam PASS=1 | |
190 | ipfire_make shadow | |
191 | ipfire_make pam PASS=2 | |
192 | ||
193 | ipfire_make libidn ### Do we need this? | |
194 | ipfire_make pcre | |
195 | ipfire_make popt | |
196 | ipfire_make python | |
197 | ipfire_make libxml2 | |
198 | ipfire_make libxslt | |
199 | ipfire_make slang | |
200 | ipfire_make newt | |
201 | ipfire_make cyrus-sasl | |
202 | ipfire_make openldap | |
203 | ipfire_make sqlite | |
204 | ipfire_make curl | |
205 | ipfire_make libusb | |
206 | ipfire_make gnupg | |
207 | ipfire_make sudo | |
208 | #ipfire_make libjpeg ### Do we need this? | |
209 | ipfire_make libpng | |
210 | ipfire_make libtiff | |
211 | ipfire_make libart | |
212 | ipfire_make freetype | |
213 | ipfire_make lzo | |
214 | #ipfire_make whatmask | |
215 | #ipfire_make lsof | |
216 | #ipfire_make br2684ctl | |
217 | #ipfire_make etherwake | |
218 | #ipfire_make htop | |
219 | #ipfire_make beep | |
220 | ||
221 | ### Building filesystem stuff | |
222 | # | |
223 | ipfire_make reiserfsprogs | |
224 | ipfire_make libaal | |
225 | ipfire_make reiser4progs | |
226 | #ipfire_make xfsprogs ### This is missing. | |
227 | ||
228 | ### Building hardware utils | |
229 | # | |
230 | ipfire_make pciutils | |
231 | ipfire_make usbutils | |
232 | ipfire_make hdparm | |
233 | ipfire_make kudzu | |
234 | #ipfire_make smartmontools | |
235 | ||
236 | ### Building some important tools | |
237 | # | |
238 | ipfire_make fcron | |
239 | ipfire_make which | |
240 | ipfire_make nano | |
241 | ipfire_make screen | |
242 | ipfire_make rrdtool | |
243 | ipfire_make ntp ### Needs config. | |
244 | ipfire_make openssh | |
245 | #ipfire_make ez-ipupdate | |
246 | #ipfire_make noip_updater | |
247 | #ipfire_make apache2 ### Marked to be removed | |
248 | #ipfire_make apache2 PASS=C | |
249 | ||
250 | ### Programs that are still for discussion | |
251 | # package or in the standard system | |
252 | # | |
253 | ## NTFS | |
254 | #ipfire_make fuse | |
255 | #ipfire_make ntfs-3g | |
256 | # | |
257 | ## Net tools | |
258 | #ipfire_make bwm-ng | |
259 | #ipfire_make openvpn | |
260 | # | |
261 | ## UPNP | |
262 | #ipfire_make libupnp | |
263 | #ipfire_make linux-igd | |
264 | ||
265 | #ipfire_make pakfire | |
266 | #ipfire_make initscripts | |
267 | ||
f76aefec | 268 | exiterror "Stop here." |
246556fe | 269 | |
ca8da28e | 270 | ipfire_make backup |
ca8da28e | 271 | ipfire_make unzip |
ca8da28e | 272 | ipfire_make pkg-config |
ca8da28e | 273 | ipfire_make cpio |
ca8da28e | 274 | ipfire_make expat |
ca8da28e | 275 | ipfire_make gmp |
ca8da28e | 276 | ipfire_make gd |
ca8da28e | 277 | ipfire_make libcap |
246556fe | 278 | |
ca8da28e MT |
279 | ipfire_make bind |
280 | ipfire_make cdrtools | |
ca8da28e | 281 | ipfire_make dosfstools |
ca8da28e | 282 | ipfire_make sysfsutils |
ca8da28e | 283 | ipfire_make mtools |
ca8da28e | 284 | ipfire_make mISDN |
ca8da28e MT |
285 | ipfire_make logrotate |
286 | ipfire_make logwatch | |
ca8da28e | 287 | ipfire_make nasm |
ca8da28e | 288 | ipfire_make glib |
246556fe | 289 | |
ca8da28e MT |
290 | ipfire_make wireless |
291 | ipfire_make libsafe | |
246556fe MT |
292 | } |
293 | ||
294 | ################################################################################ | |
295 | # This builds the entire stage "misc" # | |
296 | ################################################################################ | |
297 | misc_build() { | |
298 | ||
299 | PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/${MACHINE_REAL}-linux/bin | |
300 | STAGE_ORDER=04 | |
301 | STAGE=misc | |
302 | ||
303 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.misc.log" | |
304 | export LOGFILE | |
305 | ||
306 | ipfire_make stage4 | |
307 | ||
308 | #ipfire_make snort | |
309 | #ipfire_make oinkmaster | |
310 | #ipfire_make squid | |
311 | #ipfire_make squid-graph | |
312 | #ipfire_make squidguard | |
313 | #ipfire_make calamaris | |
314 | ipfire_make tcpdump | |
315 | ipfire_make traceroute | |
316 | ipfire_make vsftpd | |
317 | ipfire_make centerim | |
318 | ipfire_make ncftp | |
319 | ipfire_make tripwire | |
320 | ipfire_make java | |
ca8da28e | 321 | ipfire_make spandsp |
ca8da28e MT |
322 | ipfire_make cups |
323 | ipfire_make ghostscript | |
324 | ipfire_make foomatic | |
325 | ipfire_make hplip | |
326 | ipfire_make samba | |
ca8da28e MT |
327 | ipfire_make mc |
328 | ipfire_make wget | |
ca8da28e MT |
329 | ipfire_make postfix |
330 | ipfire_make fetchmail | |
331 | ipfire_make cyrus-imapd | |
ca8da28e | 332 | ipfire_make clamav |
ca8da28e MT |
333 | ipfire_make alsa |
334 | ipfire_make mpg123 | |
335 | ipfire_make mpfire | |
336 | ipfire_make guardian | |
337 | ipfire_make libid3tag | |
338 | ipfire_make libmad | |
339 | ipfire_make libogg | |
340 | ipfire_make libvorbis | |
341 | ipfire_make lame | |
342 | ipfire_make sox | |
343 | ipfire_make libshout | |
344 | ipfire_make icecast | |
345 | ipfire_make icegenerator | |
346 | ipfire_make mpd | |
347 | ipfire_make mpc | |
348 | ipfire_make xvid | |
349 | ipfire_make libmpeg2 | |
350 | ipfire_make videolan | |
351 | ipfire_make libpri | |
352 | ipfire_make asterisk | |
353 | ipfire_make gnump3d | |
354 | ipfire_make libsigc++ | |
355 | ipfire_make applejuice | |
356 | ipfire_make ocaml | |
357 | ipfire_make mldonkey | |
358 | ipfire_make libtorrent | |
359 | ipfire_make rtorrent | |
360 | ipfire_make ipfireseeder | |
361 | ipfire_make rsync | |
ca8da28e MT |
362 | ipfire_make nfs |
363 | ipfire_make nmap | |
ca8da28e | 364 | |
ca8da28e MT |
365 | ipfire_make cdrtools |
366 | ipfire_make syslinux | |
367 | ipfire_make parted | |
368 | ipfire_make slang | |
369 | ipfire_make newt | |
df5e82b3 MT |
370 | } |
371 | ||
ca8da28e MT |
372 | ################################################################################ |
373 | # This builds the entire stage "installer" # | |
374 | ################################################################################ | |
375 | installer_build() { | |
376 | ||
377 | PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/${MACHINE_REAL}-linux/bin | |
378 | STAGE_ORDER=05 | |
379 | STAGE=installer | |
380 | ||
381 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.installer.log" | |
382 | export LOGFILE | |
246556fe MT |
383 | |
384 | #ipfire_make klibc ##### Maybe this will be in the installer | |
385 | #ipfire_make mkinitcpio | |
386 | #ipfire_make udev KLIBC=1 | |
ca8da28e MT |
387 | |
388 | ipfire_make as86 | |
389 | ipfire_make mbr | |
390 | ipfire_make memtest | |
391 | ipfire_make linux-libc-header | |
392 | ipfire_make binutils | |
393 | ipfire_make uClibc PASS=1 | |
394 | ipfire_make gcc INST=1 | |
395 | ipfire_make uClibc PASS=2 | |
396 | ipfire_make gcc INST=2 | |
397 | ipfire_make uClibc PASS=3 | |
398 | ipfire_make busybox | |
399 | ipfire_make udev | |
400 | ipfire_make gettext | |
401 | ipfire_make kbd | |
402 | ipfire_make popt | |
403 | ipfire_make sysvinit | |
404 | ipfire_make misc-progs | |
405 | ipfire_make libaal | |
406 | ipfire_make reiser4progs | |
407 | ipfire_make reiserfsprogs | |
408 | ipfire_make sysfsutils | |
409 | ipfire_make util-linux | |
410 | ipfire_make pciutils | |
411 | ipfire_make zlib | |
412 | ipfire_make mtd | |
413 | ipfire_make wget | |
414 | ipfire_make hwdata | |
415 | ipfire_make kudzu | |
416 | ipfire_make installer | |
417 | ipfire_make initrd | |
df5e82b3 MT |
418 | } |
419 | ||
ca8da28e MT |
420 | ################################################################################ |
421 | # This builds the entire stage "packages" # | |
422 | ################################################################################ | |
423 | packages_build() { | |
df5e82b3 | 424 | |
ca8da28e MT |
425 | PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/${MACHINE_REAL}-linux/bin |
426 | STAGE_ORDER=06 | |
427 | STAGE=packages | |
df5e82b3 | 428 | |
ca8da28e MT |
429 | LOGFILE="$BASEDIR/log_${MACHINE}/_build.packages.log" |
430 | export LOGFILE | |
431 | ||
df5e82b3 | 432 | echo "... see detailed log in _build.*.log files" >> $LOGFILE |
0fbb45e9 | 433 | |
ca8da28e | 434 | ipfire_make strip |
df5e82b3 MT |
435 | |
436 | # Generating list of packages used | |
0fbb45e9 | 437 | echo -n "Generating packages list from logs" | tee -a $LOGFILE |
df5e82b3 MT |
438 | rm -f $BASEDIR/doc/packages-list |
439 | for i in `ls -1tr $BASEDIR/log/[^_]*`; do | |
440 | if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then | |
7471f6ab | 441 | echo "* `basename $i`" >>$BASEDIR/doc/packages-list |
df5e82b3 MT |
442 | fi |
443 | done | |
7471f6ab | 444 | echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt |
4fe9acb2 | 445 | grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \ |
df5e82b3 MT |
446 | $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt |
447 | rm -f $BASEDIR/doc/packages-list | |
c9673262 | 448 | # packages-list.txt is ready to be displayed for wiki page |
0fbb45e9 | 449 | beautify message DONE |
df5e82b3 | 450 | |
9607771a | 451 | # Create images for install |
ca8da28e | 452 | ipfire_make cdrom ED=full |
74dbbc36 | 453 | |
4dc82852 | 454 | # Check if there is a loop device for building in virtual environments |
eedc26d9 | 455 | if [ -e /dev/loop/0 ] || [ -e /dev/loop0 ]; then |
ca8da28e | 456 | ipfire_make usb-stick |
4dc82852 | 457 | fi |
4dc82852 | 458 | mv $LFS/install/images/{*.iso,*.tgz,*.img.gz} $BASEDIR >> $LOGFILE 2>&1 |
c9673262 | 459 | |
0d909a4a | 460 | ipfirepackages |
e67a57fe MT |
461 | |
462 | # Cleanup | |
463 | stdumount | |
464 | rm -rf $BASEDIR/build/tmp/* | |
465 | ||
466 | # Generating total list of files | |
0d909a4a | 467 | echo -n "Generating files list from logs" | tee -a $LOGFILE |
e67a57fe MT |
468 | rm -f $BASEDIR/log/FILES |
469 | for i in `ls -1tr $BASEDIR/log/[^_]*`; do | |
470 | if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then | |
471 | echo "##" >>$BASEDIR/log/FILES | |
472 | echo "## `basename $i`" >>$BASEDIR/log/FILES | |
473 | echo "##" >>$BASEDIR/log/FILES | |
474 | cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES | |
475 | fi | |
476 | done | |
0d909a4a | 477 | beautify message DONE |
e67a57fe MT |
478 | |
479 | cd $PWD | |
e67a57fe MT |
480 | } |
481 | ||
482 | ipfirepackages() { | |
ca8da28e | 483 | ipfire_make core-updates |
fe7fe395 | 484 | for i in $(ls -1 $BASEDIR/config/rootfiles/packages); do |
453b418b | 485 | if [ -e $BASEDIR/lfs/$i ]; then |
ca8da28e | 486 | ipfire_dist $i |
453b418b MT |
487 | else |
488 | echo -n $i | |
489 | beautify message SKIP | |
490 | fi | |
fe7fe395 | 491 | done |
78331e30 | 492 | test -d $BASEDIR/packages || mkdir $BASEDIR/packages |
5c8cfc99 | 493 | mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1 |
483f59cd | 494 | rm -rf $BASEDIR/build/install/packages/* |
df5e82b3 MT |
495 | } |
496 | ||
497 | # See what we're supposed to do | |
498 | case "$1" in | |
499 | build) | |
9729e787 | 500 | clear |
ca8da28e MT |
501 | #a prebuilt toolchain package is only used if found in cache |
502 | if [ ! -d $BASEDIR/cache ]; then | |
503 | exiterror "Use make.sh downloadsrc first!" | |
504 | fi | |
505 | cd $BASEDIR/cache | |
506 | PACKAGE=`ls -v -r $TOOLCHAINNAME.tar.gz 2> /dev/null | head -n 1` | |
df5e82b3 | 507 | #only restore on a clean disk |
ca8da28e MT |
508 | |
509 | echo -ne "Building for ${BOLD}${MACHINE} on ${MACHINE_REAL}${NORMAL}\n" | |
510 | ||
3888140c | 511 | if [ -f $BASEDIR/log_${MACHINE}/02_base/stage2-LFS ]; then |
ca8da28e MT |
512 | prepareenv |
513 | echo "Using installed toolchain" >> $LOGFILE | |
514 | beautify message DONE "Stage toolchain already built or extracted" | |
515 | else | |
516 | if [ -z "$PACKAGE" ]; then | |
517 | echo "Full toolchain compilation" | tee -a $LOGFILE | |
df5e82b3 | 518 | prepareenv |
ca8da28e MT |
519 | |
520 | # Check if host can build the toolchain | |
521 | check_toolchain_prerequisites | |
522 | ||
523 | beautify build_stage "Building toolchain" | |
524 | toolchain_build | |
df5e82b3 | 525 | else |
ca8da28e MT |
526 | echo "Restore from $PACKAGE" | tee -a $LOGFILE |
527 | if [ `md5sum $BASEDIR/cache/$PACKAGE | awk '{print $1}'` == `cat $BASEDIR/cache/$TOOLCHAINNAME.md5 | awk '{print $1}'` ]; then | |
528 | cd $BASEDIR && tar zxf $BASEDIR/cache/$PACKAGE | |
df5e82b3 MT |
529 | prepareenv |
530 | else | |
ca8da28e | 531 | exiterror "$TOOLCHAINNAME md5 did not match, check downloaded package" |
df5e82b3 MT |
532 | fi |
533 | fi | |
ca8da28e MT |
534 | fi |
535 | ||
3888140c | 536 | if [ ! -e $BASEDIR/log_${MACHINE}/03_ipfire/stage3-LFS ]; then |
ca8da28e MT |
537 | beautify build_stage "Building base" |
538 | base_build | |
df5e82b3 | 539 | else |
ca8da28e | 540 | beautify message DONE "Stage base already built" |
df5e82b3 | 541 | fi |
5cfe86e6 | 542 | |
3888140c | 543 | if [ ! -e $BASEDIR/log_${MACHINE}/04_misc/stage4-LFS ]; then |
ca8da28e MT |
544 | beautify build_stage "Building $NAME" |
545 | ipfire_build | |
546 | else | |
547 | beautify message DONE "Stage ipfire already built" | |
548 | fi | |
5cfe86e6 | 549 | |
3888140c | 550 | if [ ! -e $BASEDIR/log_${MACHINE}/05_installer/stage5-LFS ]; then |
ca8da28e MT |
551 | beautify build_stage "Building miscellaneous" |
552 | misc_build | |
5cfe86e6 | 553 | else |
ca8da28e | 554 | beautify message DONE "Stage misc already built" |
5cfe86e6 HS |
555 | fi |
556 | ||
0b59f25c | 557 | beautify build_stage "Building installer" |
ca8da28e | 558 | installer_build |
15679d9f | 559 | |
0b59f25c | 560 | beautify build_stage "Building packages" |
ca8da28e MT |
561 | packages_build |
562 | ||
563 | echo "" | |
564 | echo "Burn a CD (floppy is too big) or use pxe to boot." | |
565 | echo "... and all this hard work for this:" | |
566 | du -bsh $BASEDIR/${SNAME}-${VERSION}*.${MACHINE}.iso | |
df5e82b3 | 567 | ;; |
ca8da28e | 568 | |
df5e82b3 MT |
569 | shell) |
570 | # enter a shell inside LFS chroot | |
571 | # may be used to changed kernel settings | |
572 | prepareenv | |
573 | entershell | |
574 | ;; | |
ca8da28e | 575 | |
df5e82b3 | 576 | changelog) |
d1dd6669 | 577 | echo -n "Loading new Changelog from SVN: " |
223ad6a4 | 578 | svn log http://svn.ipfire.org/svn/ipfire > doc/ChangeLog |
a50d04ab | 579 | beautify message DONE |
df5e82b3 | 580 | ;; |
ca8da28e | 581 | |
df5e82b3 | 582 | clean) |
ca8da28e MT |
583 | echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree" |
584 | for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'` | |
585 | do | |
df5e82b3 MT |
586 | $LOSETUP -d $i 2>/dev/null |
587 | done | |
ca8da28e MT |
588 | |
589 | for i in `mount | grep $BASEDIR | cut -d " " -f 1` | |
590 | do | |
df5e82b3 MT |
591 | umount $i |
592 | done | |
ca8da28e | 593 | |
df5e82b3 | 594 | stdumount |
ca8da28e MT |
595 | |
596 | for i in `seq 0 7` | |
597 | do | |
598 | if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then | |
599 | umount /dev/loop${i} 2>/dev/null; | |
600 | losetup -d /dev/loop${i} 2>/dev/null; | |
601 | fi; | |
df5e82b3 | 602 | done |
ca8da28e MT |
603 | |
604 | rm -rf $BASEDIR/build_${MACHINE} | |
605 | rm -rf $BASEDIR/log_${MACHINE} | |
f9315063 | 606 | rm -rf $BASEDIR/packages |
ca8da28e MT |
607 | |
608 | if [ -h $TOOLS_DIR ]; then | |
609 | rm -f $TOOLS_DIR | |
df5e82b3 | 610 | fi |
a50d04ab | 611 | beautify message DONE |
df5e82b3 | 612 | ;; |
ca8da28e | 613 | |
c3db995c | 614 | downloadsrc) |
be472d5a MT |
615 | LOGFILE=$BASEDIR/log_${MACHINE}/_build.preparation.log |
616 | ||
df5e82b3 MT |
617 | if [ ! -d $BASEDIR/cache ]; then |
618 | mkdir $BASEDIR/cache | |
619 | fi | |
be472d5a | 620 | mkdir -p $BASEDIR/log_${MACHINE} |
857d9bf2 | 621 | echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE |
df5e82b3 MT |
622 | FINISHED=0 |
623 | cd $BASEDIR/lfs | |
624 | for c in `seq $MAX_RETRIES`; do | |
625 | if (( FINISHED==1 )); then | |
626 | break | |
627 | fi | |
628 | FINISHED=1 | |
629 | cd $BASEDIR/lfs | |
630 | for i in *; do | |
631 | if [ -f "$i" -a "$i" != "Config" ]; then | |
e22c7973 | 632 | echo -ne "Loading $i" |
df5e82b3 MT |
633 | make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1 |
634 | if [ $? -ne 0 ]; then | |
e22c7973 | 635 | beautify message FAIL |
df5e82b3 MT |
636 | FINISHED=0 |
637 | else | |
638 | if [ $c -eq 1 ]; then | |
e22c7973 | 639 | beautify message DONE |
df5e82b3 MT |
640 | fi |
641 | fi | |
642 | fi | |
643 | done | |
644 | done | |
e22c7973 | 645 | cd - >/dev/null 2>&1 |
df5e82b3 | 646 | ;; |
ca8da28e | 647 | |
df5e82b3 MT |
648 | toolchain) |
649 | prepareenv | |
ca8da28e MT |
650 | # Check if host can build the toolchain |
651 | check_toolchain_prerequisites | |
652 | toolchain_build | |
3888140c | 653 | echo "Create toolchain tar.bz for $MACHINE" | tee -a $LOGFILE |
ca8da28e MT |
654 | # Safer inside the chroot |
655 | echo -ne "Stripping lib" | |
656 | chroot $LFS $TOOLS_DIR/bin/find $TOOLS_DIR/lib \ | |
657 | -type f \( -name '*.so' -o -name '*.so[\.0-9]*' \) \ | |
658 | -exec $TOOLS_DIR/bin/strip --strip-debug {} \; 2>/dev/null | |
659 | beautify message DONE | |
660 | echo -ne "Stripping binaries" | |
661 | chroot $LFS $TOOLS_DIR/bin/find /usr/local /usr/src/binutils-build $TOOLS_DIR/bin $TOOLS_DIR/sbin \ | |
662 | -type f \ | |
663 | -exec $TOOLS_DIR/bin/strip --strip-all {} \; 2> /dev/null | |
664 | beautify message DONE | |
665 | stdumount | |
666 | echo -ne "Tar creation " | |
667 | cd $BASEDIR && tar cvj \ | |
668 | --exclude='log_${MACHINE}/_build.*.log' \ | |
669 | --file=cache/$TOOLCHAINNAME.tar.bz2 \ | |
670 | build_${MACHINE} \ | |
671 | log_${MACHINE} >> $LOGFILE | |
672 | beautify message DONE | |
673 | echo `ls -sh cache/$TOOLCHAINNAME.tar.bz2` | |
674 | md5sum cache/$TOOLCHAINNAME.tar.bz2 \ | |
675 | > cache/$TOOLCHAINNAME.md5 | |
676 | ||
df5e82b3 MT |
677 | stdumount |
678 | ;; | |
ca8da28e | 679 | |
df5e82b3 | 680 | gettoolchain) |
ca8da28e | 681 | if [ ! -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then |
5bd13f01 | 682 | URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'` |
712d859c | 683 | test -d $BASEDIR/cache/toolchains || mkdir $BASEDIR/cache/toolchains |
ca8da28e | 684 | echo "Load toolchain tar.bz2 for $MACHINE" | tee -a $LOGFILE |
712d859c | 685 | cd $BASEDIR/cache/toolchains |
ca8da28e | 686 | wget -c -nv $URL_TOOLCHAIN/$TOOLCHAINNAME.tar.bz2 $URL_TOOLCHAIN/$TOOLCHAINNAME.md5 |
712d859c | 687 | if [ $? -ne 0 ]; then |
ca8da28e MT |
688 | echo -ne "Error downloading toolchain for $MACHINE machine" | tee -a $LOGFILE |
689 | beautify message FAIL | |
690 | echo "Precompiled toolchain not always available for every MACHINE" | tee -a $LOGFILE | |
40a4ea4c | 691 | else |
ca8da28e MT |
692 | if [ "`md5sum $TOOLCHAINNAME.tar.bz2 | awk '{print $1}'`" = "`cat $TOOLCHAINNAME.md5 | awk '{print $1}'`" ]; then |
693 | beautify message DONE | |
694 | echo "Toolchain md5 ok" | tee -a $LOGFILE | |
712d859c | 695 | else |
ca8da28e | 696 | exiterror "$TOOLCHAINNAME.md5 did not match, check downloaded package" |
712d859c | 697 | fi |
40a4ea4c | 698 | fi |
712d859c | 699 | else |
ca8da28e MT |
700 | echo "Toolchain tar.bz2 for $MACHINE is already downloaded" | tee -a $LOGFILE |
701 | beautify message SKIP | |
df5e82b3 MT |
702 | fi |
703 | ;; | |
ca8da28e | 704 | |
15679d9f | 705 | othersrc) |
ce56e927 | 706 | prepareenv |
15679d9f | 707 | echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" | tee -a $LOGFILE |
ce56e927 MT |
708 | chroot $LFS /tools/bin/env -i HOME=/root \ |
709 | TERM=$TERM PS1='\u:\w\$ ' \ | |
710 | PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \ | |
711 | VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" MACHINE=$MACHINE \ | |
712 | /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 | |
713 | mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1 | |
15679d9f MT |
714 | if [ $? -eq "0" ]; then |
715 | beautify message DONE | |
716 | else | |
717 | beautify message FAIL | |
718 | fi | |
ce56e927 MT |
719 | stdumount |
720 | ;; | |
ca8da28e | 721 | |
c6cb9d25 MT |
722 | svn) |
723 | case "$2" in | |
724 | update|up) | |
cc0e56be | 725 | # clear |
15679d9f | 726 | echo -ne "Loading the latest source files...\n" |
7471f6ab MT |
727 | if [ $3 ]; then |
728 | svn update -r $3 | tee -a $PWD/log/_build.svn.update.log | |
729 | else | |
730 | svn update | tee -a $PWD/log/_build.svn.update.log | |
731 | fi | |
15679d9f MT |
732 | if [ $? -eq "0" ]; then |
733 | beautify message DONE | |
c6cb9d25 | 734 | else |
15679d9f | 735 | beautify message FAIL |
c6cb9d25 MT |
736 | exit 1 |
737 | fi | |
15679d9f | 738 | echo -ne "Writing the svn-info to a file" |
c6cb9d25 | 739 | svn info > $PWD/svn_status |
15679d9f MT |
740 | if [ $? -eq "0" ]; then |
741 | beautify message DONE | |
c6cb9d25 | 742 | else |
15679d9f | 743 | beautify message FAIL |
c6cb9d25 MT |
744 | exit 1 |
745 | fi | |
712d859c | 746 | chmod 755 $0 |
cc0e56be | 747 | exit 0 |
c6cb9d25 MT |
748 | ;; |
749 | commit|ci) | |
750 | clear | |
6b8cff41 MT |
751 | if [ -f /usr/bin/mcedit ]; then |
752 | export EDITOR=/usr/bin/mcedit | |
73d9a908 MT |
753 | fi |
754 | if [ -f /usr/bin/nano ]; then | |
755 | export EDITOR=/usr/bin/nano | |
6b8cff41 MT |
756 | fi |
757 | echo -ne "Selecting editor $EDITOR..." | |
758 | beautify message DONE | |
d79b46cb | 759 | if [ -e /sbin/yast ]; then |
028698e8 MT |
760 | if [ "`echo $SVN_REVISION | cut -c 3`" -eq "0" ]; then |
761 | $0 changelog | |
762 | fi | |
d79b46cb | 763 | fi |
8a5f0f44 | 764 | update_langs |
15679d9f | 765 | svn commit |
c6cb9d25 | 766 | $0 svn up |
1065bfea MT |
767 | if [ -n "$FTP_CACHE_URL" ]; then |
768 | $0 uploadsrc | |
769 | fi | |
c6cb9d25 MT |
770 | ;; |
771 | dist) | |
7471f6ab MT |
772 | if [ $3 ]; then |
773 | SVN_REVISION=$3 | |
774 | fi | |
775 | if [ -f ipfire-source-r$SVN_REVISION.tar.gz ]; then | |
776 | echo -ne "REV $SVN_REVISION: SKIPPED!\n" | |
777 | exit 0 | |
778 | fi | |
779 | echo -en "REV $SVN_REVISION: Downloading..." | |
223ad6a4 MT |
780 | svn export http://svn.ipfire.org/svn/ipfire/trunk ipfire-source/ --force > /dev/null |
781 | svn log http://svn.ipfire.org/svn/ipfire/trunk -r 1:$SVN_REVISION > ipfire-source/Changelog | |
782 | #svn info http://svn.ipfire.org/svn/ipfire/trunk -r $SVN_REVISION > ipfire-source/svn_status | |
15679d9f MT |
783 | evaluate 1 |
784 | ||
7471f6ab MT |
785 | echo -en "REV $SVN_REVISION: Compressing files..." |
786 | if [ -e ipfire-source/trunk/make.sh ]; then | |
787 | chmod 755 ipfire-source/trunk/make.sh | |
788 | fi | |
9dc02b38 | 789 | tar cfz ipfire-source-r$SVN_REVISION.tar.gz ipfire-source |
15679d9f | 790 | evaluate 1 |
7471f6ab | 791 | echo -en "REV $SVN_REVISION: Cleaning up..." |
c6cb9d25 | 792 | rm ipfire-source/ -r |
15679d9f | 793 | evaluate 1 |
7471f6ab | 794 | ;; |
028698e8 | 795 | diff|di) |
1a8688ba | 796 | update_langs |
15679d9f | 797 | echo -ne "Make a local diff to last svn revision" |
c6cb9d25 | 798 | svn diff > ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff |
15679d9f | 799 | evaluate 1 |
c6cb9d25 | 800 | echo "Diff was successfully saved to ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff" |
bf7c473f | 801 | svn status |
c6cb9d25 MT |
802 | ;; |
803 | esac | |
f9315063 | 804 | ;; |
ca8da28e | 805 | |
15679d9f MT |
806 | uploadsrc) |
807 | PWD=`pwd` | |
808 | cd $BASEDIR/cache/ | |
809 | echo -e "Uploading cache to ftp server:" | |
3888140c MT |
810 | for i in *; do |
811 | echo "${i}" | fgrep -q .md5 && continue | |
812 | [ -e ${i}.md5 ] && continue | |
813 | md5sum ${i} | tee ${i}.md5 | |
814 | done | |
fd1b8061 | 815 | ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist |
15679d9f | 816 | for i in *; do |
fd1b8061 MT |
817 | if [ "$(basename $i)" == "toolchains" ]; then continue; fi |
818 | grep -q $(basename $i) /tmp/ftplist | |
0eab8e84 | 819 | if [ "$?" -ne "0" ]; then |
fd1b8061 MT |
820 | echo -ne "$(basename $i)" |
821 | ncftpput -u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $(basename $i) | |
6fb8ec08 | 822 | if [ "$?" -ne "0" ]; then |
15679d9f | 823 | beautify message FAIL |
0eab8e84 MT |
824 | fi |
825 | fi | |
826 | done | |
6fb8ec08 | 827 | rm -f /tmp/ftplist |
15679d9f MT |
828 | cd $PWD |
829 | exit 0 | |
0eab8e84 | 830 | ;; |
ca8da28e | 831 | |
cc0e56be | 832 | upload) |
b2c64f8c MT |
833 | FTP_ISO_PORT=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'` |
834 | FTP_ISO_URL=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'` | |
835 | if [ -z $FTP_ISO_PORT ]; then | |
836 | FTP_ISO_PORT=21 | |
837 | fi | |
838 | cat <<EOF > .ftp-commands | |
de2c999d | 839 | mkdir -p $FTP_ISO_PATH$SVN_REVISION |
b2c64f8c | 840 | mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks |
9dc02b38 MT |
841 | quit |
842 | EOF | |
b2c64f8c MT |
843 | ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands |
844 | rm -f .ftp-commands | |
845 | ||
846 | case "$2" in | |
847 | iso) | |
848 | echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION." | |
849 | ||
8f55c54e | 850 | md5sum ipfire-$VERSION.$MACHINE-full.iso > ipfire-$VERSION.$MACHINE-full.iso.md5 |
dff9df9d MT |
851 | for i in svn_status ipfire-source-r$SVN_REVISION.tar.gz ipfire-$VERSION.$MACHINE-full.iso ipfire-$VERSION.$MACHINE-full.iso.md5 ipfire-$VERSION.$MACHINE-devel.iso ipfire-$VERSION.$MACHINE-devel.iso.md5; do |
852 | if [ -e "$i" ]; then | |
b2c64f8c MT |
853 | ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i |
854 | if [ "$?" -eq "0" ]; then | |
855 | echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/." | |
856 | else | |
857 | echo "There was an error while uploading the file $i to the ftp server." | |
858 | exit 1 | |
859 | fi | |
dff9df9d | 860 | fi |
b2c64f8c | 861 | done |
a4c9c660 | 862 | rm -f ipfire-$VERSION.$MACHINE-full.iso.md5 |
6aae8d61 | 863 | if [ "$3" = "--with-sources-cd" ]; then |
b2c64f8c | 864 | ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH/$SVN_REVISION/ ipfire-sources-cd-$VERSION.$MACHINE.iso |
6aae8d61 | 865 | fi |
cc0e56be MT |
866 | ;; |
867 | paks) | |
b2c64f8c | 868 | ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages/* |
cc0e56be | 869 | if [ "$?" -eq "0" ]; then |
822c5bd0 | 870 | echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/." |
cc0e56be MT |
871 | else |
872 | echo -e "There was an error while uploading the packages to the ftp server." | |
712d859c | 873 | exit 1 |
cc0e56be MT |
874 | fi |
875 | ;; | |
876 | esac | |
0d0521b6 | 877 | ;; |
ca8da28e | 878 | |
cc0e56be | 879 | batch) |
c8582074 | 880 | if [ "$2" = "--background" ]; then |
15679d9f MT |
881 | batch_script |
882 | exit $? | |
883 | fi | |
27ac55bf | 884 | if [ `screen -ls | grep -q ipfire` ]; then |
712d859c MT |
885 | echo "Build is already running, sorry!" |
886 | exit 1 | |
887 | else | |
27ac55bf MT |
888 | if [ "$2" = "--rebuild" ]; then |
889 | export IPFIRE_REBUILD=1 | |
890 | echo "REBUILD!" | |
891 | else | |
892 | export IPFIRE_REBUILD=0 | |
893 | fi | |
15679d9f MT |
894 | echo -en "${BOLD}***IPFire-Batch-Build is starting...${NORMAL}" |
895 | screen -dmS ipfire $0 batch --background | |
896 | evaluate 1 | |
712d859c MT |
897 | exit 0 |
898 | fi | |
cc0e56be | 899 | ;; |
ca8da28e MT |
900 | |
901 | watch|attach) | |
15679d9f | 902 | watch_screen |
028698e8 | 903 | ;; |
ca8da28e | 904 | |
6b8cff41 | 905 | *) |
6b8cff41 MT |
906 | cat doc/make.sh-usage |
907 | ;; | |
ca8da28e | 908 | |
3ea75603 | 909 | esac |