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