2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # check for prerequisites
25 .
$BASEDIR/tools
/make-check
&& check_build
26 # compile the distro right now
33 # enter a shell inside LFS chroot
34 # may be used to change kernel settings
40 # build the distro in background
41 .
$BASEDIR/tools
/make-batch
56 # show some stats about the compiler(s)
57 .
$BASEDIR/tools
/make-compilers
70 echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
71 for i
in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`
73 $LOSETUP -d $i 2>/dev
/null
76 for i
in `mount | grep $BASEDIR | cut -d " " -f 1`
85 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
86 umount
/dev
/loop
${i} 2>/dev
/null
;
87 losetup
-d /dev
/loop
${i} 2>/dev
/null
;
91 rm -rf $BASEDIR/build_
${MACHINE}
92 rm -rf $BASEDIR/log_
${MACHINE}
93 rm -rf $BASEDIR/packages
95 if [ -h $TOOLS_DIR ]; then
102 LOGFILE
=$BASEDIR/log_
${MACHINE}/_build
.00-preparation.log
104 if [ ! -d $BASEDIR/cache
]; then
105 mkdir
-p $BASEDIR/cache
/{tarballs
,patches
}
107 mkdir
-p $BASEDIR/log_
${MACHINE}
108 echo -e "${BOLD}Preload all source files${NORMAL}"
111 if [ -f "$i" -a "$i" != "Config" ]; then
112 make -s -f $i LFS_BASEDIR
=$BASEDIR MESSAGE
="$i\t" download
2>> $LOGFILE
113 if [ $?
-ne 0 ]; then
114 echo -ne "Couldn't download all files for ${BOLD}${i}${NORMAL}"
115 beautify message FAIL
124 # Check if host can build the toolchain
131 echo -ne "\ntarball creation "
132 [ -d $BASEDIR/cache
/toolchains
] || mkdir
$BASEDIR/cache
/toolchains
133 cd $BASEDIR && tar cj \
134 --exclude='log_${MACHINE}/_build.*.log' \
135 --file=cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2 \
137 log_
${MACHINE} >> $LOGFILE
138 beautify message DONE
139 echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
140 md5sum cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2 \
141 > cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2.md5
146 if [ ! -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
147 URL_TOOLCHAIN
=$
(grep URL_TOOLCHAIN lfs
/Config |
awk '{ print $3 }')
148 DIR_TOOLCHAIN
="$BASEDIR/cache/toolchains"
150 echo "Loading toolchain for $MACHINE"
151 BASEDIR
=$BASEDIR DIR_TMP
=/tmp DIR_DL
=$DIR_TOOLCHAIN \
152 sh
$BASEDIR/tools
/downloader
$URL_TOOLCHAIN $TOOLCHAINNAME.
tar.bz2
154 if [ $?
-eq 0 ]; then
155 echo -n "Toolchain was successfully downloaded"
156 beautify message DONE
158 echo -n "ERROR: Downloading toolchain \"$TOOLCHAINNAME\""
159 beautify message FAIL
160 echo "Precompiled toolchain not always available for every machine"
163 echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
164 beautify message SKIP
175 echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" |
tee -a $LOGFILE
176 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
177 TERM
=$TERM PS1
='\u:\w\$ ' \
178 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin \
179 VERSION
=$VERSION NAME
="$NAME" SNAME
="$SNAME" MACHINE
=$MACHINE \
180 /bin
/bash
-x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
181 mv $LFS/install
/images
/ipfire-
* $BASEDIR >> $LOGFILE 2>&1
182 if [ $?
-eq "0" ]; then
183 beautify message DONE
185 beautify message FAIL
191 .
$BASEDIR/tools
/make-git
217 *) # If no command matches run git directly
226 echo -e "Uploading cache to ftp server:"
228 echo "${i}" | fgrep
-q .md5
&& continue
229 [ -e ${i}.md5
] && continue
230 md5sum ${i} |
tee ${i}.md5
232 ncftpls
-u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp
/ftplist
234 if [ "$(basename $i)" == "toolchains" ]; then continue; fi
235 grep -q $
(basename $i) /tmp
/ftplist
236 if [ "$?" -ne "0" ]; then
237 echo -ne "$(basename $i)"
238 ncftpput
-u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $
(basename $i)
239 if [ "$?" -ne "0" ]; then
240 beautify message FAIL
250 FTP_ISO_PORT
=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
251 FTP_ISO_URL
=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
252 if [ -z $FTP_ISO_PORT ]; then
255 cat <<EOF > .ftp-commands
256 mkdir -p $FTP_ISO_PATH$SVN_REVISION
257 mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
260 ncftp
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
265 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
267 md5sum ipfire-
$VERSION.
$MACHINE-full.iso
> ipfire-
$VERSION.
$MACHINE-full.iso.md5
268 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
270 ncftpput
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
271 if [ "$?" -eq "0" ]; then
272 echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
274 echo "There was an error while uploading the file $i to the ftp server."
279 rm -f ipfire-
$VERSION.
$MACHINE-full.iso.md5
280 if [ "$3" = "--with-sources-cd" ]; then
281 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
285 ncftpput
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages
/*
286 if [ "$?" -eq "0" ]; then
287 echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
289 echo -e "There was an error while uploading the packages to the ftp server."
297 cat doc
/make.sh-usage