]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - tools/make-interactive
Renewed downloadscript.
[people/ms/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 # check for prerequisites
25 . $BASEDIR/tools/make-check && check_build
26 # compile the distro right now
27 build
28 # beeps when finished
29 echo -ne '\a'
30 ;;
31
32 shell)
33 # enter a shell inside LFS chroot
34 # may be used to change kernel settings
35 prepareenv
36 entershell
37 ;;
38
39 batch)
40 # build the distro in background
41 . $BASEDIR/tools/make-batch
42 case "$2" in
43 start)
44 batch_start
45 ;;
46 _run)
47 batch_run
48 ;;
49 attach|watch)
50 batch_attach
51 ;;
52 esac
53 ;;
54
55 stats)
56 # show some stats about the compiler(s)
57 . $BASEDIR/tools/make-compilers
58
59 case "$2" in
60 ccache)
61 ccache_stats
62 ;;
63 distcc)
64 distcc_mon
65 ;;
66 esac
67 ;;
68
69 clean)
70 echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
71 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`
72 do
73 $LOSETUP -d $i 2>/dev/null
74 done
75
76 for i in `mount | grep $BASEDIR | cut -d " " -f 1`
77 do
78 umount $i
79 done
80
81 stdumount
82
83 for i in `seq 0 7`
84 do
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;
88 fi;
89 done
90
91 rm -rf $BASEDIR/build_${MACHINE}
92 rm -rf $BASEDIR/log_${MACHINE}
93 rm -rf $BASEDIR/packages
94
95 if [ -h $TOOLS_DIR ]; then
96 rm -f $TOOLS_DIR
97 fi
98 beautify message DONE
99 ;;
100
101 downloadsrc)
102 LOGFILE=$BASEDIR/log_${MACHINE}/_build.00-preparation.log
103
104 if [ ! -d $BASEDIR/cache ]; then
105 mkdir -p $BASEDIR/cache/{tarballs,patches}
106 fi
107 mkdir -p $BASEDIR/log_${MACHINE}
108 echo -e "${BOLD}Preload all source files${NORMAL}"
109 cd $BASEDIR/lfs
110 for i in *; do
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
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.tar.bz2.md5
142 stdumount
143 ;;
144
145 gettoolchain)
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"
149
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
153
154 if [ $? -eq 0 ]; then
155 echo -n "Toolchain was successfully downloaded"
156 beautify message DONE
157 else
158 echo -n "ERROR: Downloading toolchain \"$TOOLCHAINNAME\""
159 beautify message FAIL
160 echo "Precompiled toolchain not always available for every machine"
161 fi
162 else
163 echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
164 beautify message SKIP
165 fi
166 ;;
167
168 check)
169 . tools/make-check
170 check_sanity $2
171 ;;
172
173 othersrc)
174 prepareenv
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
184 else
185 beautify message FAIL
186 fi
187 stdumount
188 ;;
189
190 g[iu]t)
191 . $BASEDIR/tools/make-git
192 COMMAND=$2
193 shift 2
194 case "$COMMAND" in
195 update|pull)
196 git_pull $*
197 ;;
198 commit|ci)
199 clear
200 git_commit $*
201 ;;
202 dist|export|archive)
203 git_export $*
204 ;;
205 push)
206 git_push $*
207 ;;
208 diff|di)
209 git_diff $*
210 ;;
211 log)
212 git_log $*
213 ;;
214 put-key)
215 ssh_cert $*
216 ;;
217 *) # If no command matches run git directly
218 git $*
219 ;;
220 esac
221 ;;
222
223 uploadsrc)
224 PWD=`pwd`
225 cd $BASEDIR/cache/
226 echo -e "Uploading cache to ftp server:"
227 for i in *; do
228 echo "${i}" | fgrep -q .md5 && continue
229 [ -e ${i}.md5 ] && continue
230 md5sum ${i} | tee ${i}.md5
231 done
232 ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist
233 for i in *; do
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
241 fi
242 fi
243 done
244 rm -f /tmp/ftplist
245 cd $PWD
246 exit 0
247 ;;
248
249 upload)
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
253 FTP_ISO_PORT=21
254 fi
255 cat <<EOF > .ftp-commands
256 mkdir -p $FTP_ISO_PATH$SVN_REVISION
257 mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
258 quit
259 EOF
260 ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
261 rm -f .ftp-commands
262
263 case "$2" in
264 iso)
265 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
266
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
269 if [ -e "$i" ]; then
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/."
273 else
274 echo "There was an error while uploading the file $i to the ftp server."
275 exit 1
276 fi
277 fi
278 done
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
282 fi
283 ;;
284 paks)
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/."
288 else
289 echo -e "There was an error while uploading the packages to the ftp server."
290 exit 1
291 fi
292 ;;
293 esac
294 ;;
295
296 *)
297 cat doc/make.sh-usage
298 ;;
299
300 esac