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 # compile the distro right now
31 # enter a shell inside LFS chroot
32 # may be used to change kernel settings
38 # build the distro in background
39 .
$BASEDIR/tools
/make-batch
54 # show some stats about the compiler(s)
55 .
$BASEDIR/tools
/make-compilers
68 echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
69 for i
in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`
71 $LOSETUP -d $i 2>/dev
/null
74 for i
in `mount | grep $BASEDIR | cut -d " " -f 1`
83 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
84 umount
/dev
/loop
${i} 2>/dev
/null
;
85 losetup
-d /dev
/loop
${i} 2>/dev
/null
;
89 rm -rf $BASEDIR/build_
${MACHINE}
90 rm -rf $BASEDIR/log_
${MACHINE}
91 rm -rf $BASEDIR/packages
93 if [ -h $TOOLS_DIR ]; then
100 LOGFILE
=$BASEDIR/log_
${MACHINE}/_build.preparation.log
102 if [ ! -d $BASEDIR/cache
]; then
105 mkdir
-p $BASEDIR/log_
${MACHINE}
106 echo -e "${BOLD}Preload all source files${NORMAL}" |
tee -a $LOGFILE
109 if [ -f "$i" -a "$i" != "Config" ]; then
110 echo -ne "Loading $i"
111 make -s -f $i LFS_BASEDIR
=$BASEDIR MESSAGE
="$i\t" download
>> $LOGFILE 2>&1
112 if [ $?
-ne 0 ]; then
113 beautify message FAIL
115 beautify message DONE
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.md5
147 if [ ! -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
148 URL_TOOLCHAIN
=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
149 test -d $BASEDIR/cache
/toolchains || mkdir
$BASEDIR/cache
/toolchains
150 echo "Loading toolchain for $MACHINE"
151 cd $BASEDIR/cache
/toolchains
152 wget
-c -nv $URL_TOOLCHAIN/$TOOLCHAINNAME.
tar.bz2
$URL_TOOLCHAIN/$TOOLCHAINNAME.md5
153 if [ $?
-ne 0 ]; then
154 echo -n "ERROR: Downloading toolchain for $MACHINE machine"
155 beautify message FAIL
156 echo "Precompiled toolchain not always available for every machine"
158 if [ "`md5sum $TOOLCHAINNAME.tar.bz2 | awk '{print $1}'`" = "`cat $TOOLCHAINNAME.md5 | awk '{print $1}'`" ]; then
159 beautify message DONE
160 echo "Toolchain md5 ok"
162 exiterror
"$TOOLCHAINNAME.md5 did not match, check downloaded package"
166 echo -n "Toolchain for $MACHINE is already existing"
167 beautify message SKIP
173 echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" |
tee -a $LOGFILE
174 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
175 TERM
=$TERM PS1
='\u:\w\$ ' \
176 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin \
177 VERSION
=$VERSION NAME
="$NAME" SNAME
="$SNAME" MACHINE
=$MACHINE \
178 /bin
/bash
-x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
179 mv $LFS/install
/images
/ipfire-
* $BASEDIR >> $LOGFILE 2>&1
180 if [ $?
-eq "0" ]; then
181 beautify message DONE
183 beautify message FAIL
189 .
$BASEDIR/tools
/make-subversion
214 echo -e "Uploading cache to ftp server:"
216 echo "${i}" | fgrep
-q .md5
&& continue
217 [ -e ${i}.md5
] && continue
218 md5sum ${i} |
tee ${i}.md5
220 ncftpls
-u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp
/ftplist
222 if [ "$(basename $i)" == "toolchains" ]; then continue; fi
223 grep -q $
(basename $i) /tmp
/ftplist
224 if [ "$?" -ne "0" ]; then
225 echo -ne "$(basename $i)"
226 ncftpput
-u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $
(basename $i)
227 if [ "$?" -ne "0" ]; then
228 beautify message FAIL
238 FTP_ISO_PORT
=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
239 FTP_ISO_URL
=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
240 if [ -z $FTP_ISO_PORT ]; then
243 cat <<EOF > .ftp-commands
244 mkdir -p $FTP_ISO_PATH$SVN_REVISION
245 mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
248 ncftp
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
253 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
255 md5sum ipfire-
$VERSION.
$MACHINE-full.iso
> ipfire-
$VERSION.
$MACHINE-full.iso.md5
256 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
258 ncftpput
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
259 if [ "$?" -eq "0" ]; then
260 echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
262 echo "There was an error while uploading the file $i to the ftp server."
267 rm -f ipfire-
$VERSION.
$MACHINE-full.iso.md5
268 if [ "$3" = "--with-sources-cd" ]; then
269 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
273 ncftpput
-u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages
/*
274 if [ "$?" -eq "0" ]; then
275 echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
277 echo -e "There was an error while uploading the packages to the ftp server."
285 cat doc
/make.sh-usage