]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-interactive
Merge branch 'master' of git://git.ipfire.org/ipfire-3.x
[ipfire-3.x.git] / tools / make-interactive
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21
22 case "$1" in
23 build)
24 # compile the distro right now
25 build
26 # beeps when finished
27 echo -ne '\a'
28 ;;
29
30 shell)
31 # enter a shell inside LFS chroot
32 # may be used to change kernel settings
33 prepareenv
34 entershell
35 ;;
36
37 batch)
38 # build the distro in background
39 . $BASEDIR/tools/make-batch
40 case "$2" in
41 start)
42 batch_start
43 ;;
44 _run)
45 batch_run
46 ;;
47 attach|watch)
48 batch_attach
49 ;;
50 esac
51 ;;
52
53 stats)
54 # show some stats about the compiler(s)
55 . $BASEDIR/tools/make-compilers
56
57 case "$2" in
58 ccache)
59 ccache_stats
60 ;;
61 distcc)
62 distcc_mon
63 ;;
64 esac
65 ;;
66
67 clean)
68 echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
69 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`
70 do
71 $LOSETUP -d $i 2>/dev/null
72 done
73
74 for i in `mount | grep $BASEDIR | cut -d " " -f 1`
75 do
76 umount $i
77 done
78
79 stdumount
80
81 for i in `seq 0 7`
82 do
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;
86 fi;
87 done
88
89 rm -rf $BASEDIR/build_${MACHINE}
90 rm -rf $BASEDIR/log_${MACHINE}
91 rm -rf $BASEDIR/packages
92
93 if [ -h $TOOLS_DIR ]; then
94 rm -f $TOOLS_DIR
95 fi
96 beautify message DONE
97 ;;
98
99 downloadsrc)
100 LOGFILE=$BASEDIR/log_${MACHINE}/_build.preparation.log
101
102 if [ ! -d $BASEDIR/cache ]; then
103 mkdir $BASEDIR/cache
104 fi
105 mkdir -p $BASEDIR/log_${MACHINE}
106 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
107 cd $BASEDIR/lfs
108 for i in *; do
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
114 else
115 beautify message DONE
116 fi
117 fi
118 done
119 cd - >/dev/null 2>&1
120 ;;
121
122 toolchain)
123 prepareenv
124 # Check if host can build the toolchain
125 . tools/make-check
126 check_toolchain
127
128 toolchain_build
129
130 stdumount
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 \
136 build_${MACHINE} \
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
142
143 stdumount
144 ;;
145
146 gettoolchain)
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"
157 else
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"
161 else
162 exiterror "$TOOLCHAINNAME.md5 did not match, check downloaded package"
163 fi
164 fi
165 else
166 echo -n "Toolchain for $MACHINE is already existing"
167 beautify message SKIP
168 fi
169 ;;
170
171 othersrc)
172 prepareenv
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
182 else
183 beautify message FAIL
184 fi
185 stdumount
186 ;;
187
188 git)
189 . $BASEDIR/tools/make-git
190 case "$2" in
191 update|pull)
192 git_pull
193 ;;
194 commit|ci)
195 shift 2
196 clear
197 git_commit $*
198 ;;
199 dist|export|archive)
200 git_export
201 ;;
202 push)
203 git_push
204 ;;
205 diff|di)
206 git_diff
207 ;;
208 log)
209 git_log
210 ;;
211 esac
212 ;;
213
214 welcome)
215 clear
216 #. $BASEDIR/tools/make-git
217
218 echo -ne "
219 ###############################################################################
220 #
221 # ${FAIL}$NAME${NORMAL} $VERSION
222 #
223 ###############################################################################
224 #
225 # ${BOLD}You are:${NORMAL} $(git config user.name) <$(git config user.email)>
226 #
227 # ${BOLD}You are on branch:${NORMAL}
228 #
229 $(git branch --color)
230 #
231 ###############################################################################
232 #
233 $(git diff --stat --color)
234 #
235 ###############################################################################
236 "
237
238 ;;
239
240 uploadsrc)
241 PWD=`pwd`
242 cd $BASEDIR/cache/
243 echo -e "Uploading cache to ftp server:"
244 for i in *; do
245 echo "${i}" | fgrep -q .md5 && continue
246 [ -e ${i}.md5 ] && continue
247 md5sum ${i} | tee ${i}.md5
248 done
249 ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist
250 for i in *; do
251 if [ "$(basename $i)" == "toolchains" ]; then continue; fi
252 grep -q $(basename $i) /tmp/ftplist
253 if [ "$?" -ne "0" ]; then
254 echo -ne "$(basename $i)"
255 ncftpput -u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $(basename $i)
256 if [ "$?" -ne "0" ]; then
257 beautify message FAIL
258 fi
259 fi
260 done
261 rm -f /tmp/ftplist
262 cd $PWD
263 exit 0
264 ;;
265
266 upload)
267 FTP_ISO_PORT=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
268 FTP_ISO_URL=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
269 if [ -z $FTP_ISO_PORT ]; then
270 FTP_ISO_PORT=21
271 fi
272 cat <<EOF > .ftp-commands
273 mkdir -p $FTP_ISO_PATH$SVN_REVISION
274 mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
275 quit
276 EOF
277 ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
278 rm -f .ftp-commands
279
280 case "$2" in
281 iso)
282 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
283
284 md5sum ipfire-$VERSION.$MACHINE-full.iso > ipfire-$VERSION.$MACHINE-full.iso.md5
285 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
286 if [ -e "$i" ]; then
287 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
288 if [ "$?" -eq "0" ]; then
289 echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
290 else
291 echo "There was an error while uploading the file $i to the ftp server."
292 exit 1
293 fi
294 fi
295 done
296 rm -f ipfire-$VERSION.$MACHINE-full.iso.md5
297 if [ "$3" = "--with-sources-cd" ]; then
298 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
299 fi
300 ;;
301 paks)
302 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages/*
303 if [ "$?" -eq "0" ]; then
304 echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
305 else
306 echo -e "There was an error while uploading the packages to the ftp server."
307 exit 1
308 fi
309 ;;
310 esac
311 ;;
312
313 *)
314 cat doc/make.sh-usage
315 ;;
316
317 esac