]> git.ipfire.org Git - ipfire-2.x.git/blame - make.sh
Zwischencommit fuer LFS.
[ipfire-2.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# #
15679d9f 20# Copyright (C) 2006 IPFire-Team <info@ipfire.eu>. #
df5e82b3
MT
21# #
22############################################################################
df5e82b3
MT
23#
24
15679d9f
MT
25NAME="IPFire" # Software name
26SNAME="ipfire" # Short name
27VERSION="2.0" # Version number
28SLOGAN="www.ipfire.eu" # Software slogan
29CONFIG_ROOT=/var/ipfire # Configuration rootdir
30NICE=10 # Nice level
857d9bf2 31MAX_RETRIES=1 # prefetch/check loop
15679d9f
MT
32KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
33MACHINE=`uname -m`
34SVN_REVISION=`svn info | grep Revision | cut -c 11-`
35
03ad5f93
MT
36IPFVER="full" # Which version should be compiled? (full|light|voice)
37
38# Set an information about the build number
15679d9f
MT
39if [ -e ./.svn ]; then
40 FIREBUILD=`cat .svn/entries |sed -n 's/^[ \t]*revision=\"// p' | sed -n 's/\".*$// p'`
41fi
42
43# Debian specific settings
44if [ ! -e /etc/debian_version ]; then
df5e82b3 45 FULLPATH=`which $0`
15679d9f 46else
df5e82b3
MT
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
15679d9f 53fi
df5e82b3 54
15679d9f
MT
55PWD=`pwd`
56BASENAME=`basename $0`
57BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
58LOGFILE=$BASEDIR/log/_build.preparation.log
59export BASEDIR LOGFILE
60DIR_CHK=$BASEDIR/cache/check
61mkdir $BASEDIR/log/ 2>/dev/null
df5e82b3 62
15679d9f
MT
63# Include funtions
64. tools/make-functions
df5e82b3 65
15679d9f
MT
66if [ -f .config ]; then
67 . .config
68else
6b8cff41
MT
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
15679d9f 76fi
df5e82b3
MT
77
78prepareenv() {
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 ############################################################################
9b0ff0a0 106 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
df5e82b3
MT
107 renice $NICE $$ > /dev/null
108 if [ `nice` != "$NICE" ]; then
15679d9f 109 beautify message FAIL
df5e82b3 110 exiterror "Failed to set correct nice level"
15679d9f
MT
111 else
112 beautify message DONE
df5e82b3
MT
113 fi
114
15679d9f 115
df5e82b3
MT
116 ############################################################################
117 # #
118 # Checking if running as root user #
119 # #
120 ############################################################################
9b0ff0a0 121 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
df5e82b3 122 if [ `id -u` != 0 ]; then
15679d9f 123 beautify message FAIL
df5e82b3 124 exiterror "Not building as root"
15679d9f
MT
125 else
126 beautify message DONE
df5e82b3
MT
127 fi
128
129
130 ############################################################################
131 # #
132 # Checking for necessary temporary space #
133 # #
134 ############################################################################
9b0ff0a0 135 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
df5e82b3
MT
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
15679d9f 141 beautify message FAIL
df5e82b3
MT
142 exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV"
143 fi
15679d9f
MT
144 else
145 beautify message DONE
df5e82b3
MT
146 fi
147
148 ############################################################################
149 # #
150 # Building Linux From Scratch system #
151 # #
152 ############################################################################
df5e82b3
MT
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
dd714b8a
MT
173 MAKETUNING="-j8"
174 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
df5e82b3
MT
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
90d372c4 179 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
df5e82b3 180 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
90d372c4
MT
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
df5e82b3
MT
185
186 # Make all sources and proc available under lfs build
90d372c4 187 mount --bind /dev $BASEDIR/build/dev
857d9bf2
MT
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
df5e82b3
MT
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
119ee469 202 # This is a temporary hack!!!
6b8cff41
MT
203 if [ ! -f /tools/bin/hostname ]; then
204 cp -f /bin/hostname /tools/bin/hostname 2>/dev/null
205 fi
119ee469 206
df5e82b3
MT
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
df5e82b3
MT
215buildtoolchain() {
216 LOGFILE="$BASEDIR/log/_build.toolchain.log"
217 export LOGFILE
df5e82b3
MT
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
15679d9f
MT
222 lfsmake1 binutils PASS=1
223 lfsmake1 gcc PASS=1
df5e82b3 224 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
dd714b8a
MT
225 lfsmake1 linux-libc-header
226 lfsmake1 glibc
9b0ff0a0 227 lfsmake1 cleanup-toolchain PASS=1
df5e82b3
MT
228 lfsmake1 tcl
229 lfsmake1 expect
df5e82b3 230 lfsmake1 dejagnu
15679d9f
MT
231 lfsmake1 gcc PASS=2
232 lfsmake1 binutils PASS=2
dd714b8a
MT
233 lfsmake1 ncurses
234 lfsmake1 bash
df5e82b3 235 lfsmake1 bzip2
dd714b8a 236 lfsmake1 coreutils
df5e82b3
MT
237 lfsmake1 diffutils
238 lfsmake1 findutils
dd714b8a 239 lfsmake1 gawk
df5e82b3 240 lfsmake1 gettext
dd714b8a
MT
241 lfsmake1 grep
242 lfsmake1 gzip
243 lfsmake1 m4
244 lfsmake1 make
df5e82b3 245 lfsmake1 patch
dd714b8a
MT
246 lfsmake1 perl
247 lfsmake1 sed
df5e82b3
MT
248 lfsmake1 tar
249 lfsmake1 texinfo
df5e82b3 250 lfsmake1 util-linux
9b0ff0a0 251 lfsmake1 cleanup-toolchain PASS=2
df5e82b3
MT
252 export PATH=$ORG_PATH
253}
254
255buildbase() {
256 LOGFILE="$BASEDIR/log/_build.base.log"
257 export LOGFILE
df5e82b3 258 lfsmake2 stage2
9b0ff0a0
MT
259# lfsmake2 makedev
260 lfsmake2 linux-libc-header
df5e82b3
MT
261 lfsmake2 man-pages
262 lfsmake2 glibc
9b0ff0a0 263 lfsmake2 cleanup-toolchain PASS=3
df5e82b3
MT
264 lfsmake2 binutils
265 lfsmake2 gcc
9b0ff0a0 266 lfsmake2 berkeley
df5e82b3 267 lfsmake2 coreutils
df5e82b3 268 lfsmake2 iana-etc
df5e82b3
MT
269 lfsmake2 m4
270 lfsmake2 bison
9b0ff0a0
MT
271 lfsmake2 ncurses
272 lfsmake2 procps
df5e82b3 273 lfsmake2 sed
9b0ff0a0 274 lfsmake2 libtool
df5e82b3 275 lfsmake2 perl
9b0ff0a0
MT
276 lfsmake2 readline
277 lfsmake2 zlib
df5e82b3
MT
278 lfsmake2 autoconf
279 lfsmake2 automake
280 lfsmake2 bash
df5e82b3
MT
281 lfsmake2 bzip2
282 lfsmake2 diffutils
df5e82b3 283 lfsmake2 e2fsprogs
9b0ff0a0
MT
284 lfsmake2 file
285 lfsmake2 findutils
286 lfsmake2 flex
15679d9f 287 lfsmake2 grub
9b0ff0a0
MT
288 lfsmake2 gawk
289 lfsmake2 gettext
290 lfsmake2 grep
291 lfsmake2 groff
df5e82b3 292 lfsmake2 gzip
9b0ff0a0
MT
293 lfsmake2 inetutils
294 lfsmake2 iproute2
295 lfsmake2 kbd
296 lfsmake2 less
df5e82b3 297 lfsmake2 make
9b0ff0a0
MT
298 lfsmake2 man
299 lfsmake2 mktemp
df5e82b3
MT
300 lfsmake2 modutils
301 lfsmake2 patch
df5e82b3
MT
302 lfsmake2 psmisc
303 lfsmake2 shadow
304 lfsmake2 sysklogd
305 lfsmake2 sysvinit
306 lfsmake2 tar
90d372c4
MT
307 lfsmake2 texinfo
308 lfsmake2 udev
df5e82b3 309 lfsmake2 util-linux
90d372c4 310 lfsmake2 vim
df5e82b3
MT
311}
312
15679d9f 313buildipfire() {
907cd036 314 LOGFILE="$BASEDIR/log/_build.ipfire.log"
df5e82b3 315 export LOGFILE
a5ee5623
MT
316 ipfiremake inetutils
317 ipfiremake net-tools
318 ipfiremake ed
15679d9f
MT
319 ipfiremake configroot
320 ipfiremake dhcp
321 ipfiremake dhcpcd
322 ipfiremake libusb
323 ipfiremake libpcap
d316437b
MT
324# Temporary disabled.
325# ipfiremake linux-atm
15679d9f
MT
326 ipfiremake ppp
327 ipfiremake rp-pppoe
328 ipfiremake unzip
6b8cff41
MT
329 ipfiremake linux PASS=I
330 ipfiremake linux PASS=S
c3e36980
MT
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
6b8cff41
MT
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
f59e1e88
MT
359# ipfiremake fcpci
360# ipfiremake fcclassic
6b8cff41 361# ipfiremake pulsar
f59e1e88
MT
362# ipfiremake unicorn
363# ipfiremake promise-sata-300-tx
6b8cff41 364# ipfiremake pcmciautils
15679d9f
MT
365 ipfiremake expat
366 ipfiremake gdbm
367 ipfiremake gmp
368 ipfiremake openssl
369 ipfiremake python
370 ipfiremake libnet
ddac6087 371 ipfiremake libjpeg
15679d9f
MT
372 ipfiremake libpng
373 ipfiremake libtiff
15679d9f
MT
374 ipfiremake lcms
375 ipfiremake libmng
376 ipfiremake freetype
377 ipfiremake gd
378 ipfiremake popt
ddac6087 379