]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - tools/make-interactive
Added put-key script which allows pushing without typing your password.
[people/ms/ipfire-3.x.git] / tools / make-interactive
CommitLineData
ce85f613
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
cfccf561 5# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
ce85f613
MT
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
22case "$1" in
23build)
4ce0b818
MT
24 # check for prerequisites
25 . $BASEDIR/tools/make-check && check_build
cfccf561
MT
26 # compile the distro right now
27 build
8db8436b
MT
28 # beeps when finished
29 echo -ne '\a'
ce85f613
MT
30 ;;
31
32shell)
33 # enter a shell inside LFS chroot
34 # may be used to change kernel settings
35 prepareenv
36 entershell
37 ;;
cfccf561
MT
38
39batch)
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
55stats)
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 ;;
ce85f613
MT
68
69clean)
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
101downloadsrc)
102 LOGFILE=$BASEDIR/log_${MACHINE}/_build.preparation.log
103
104 if [ ! -d $BASEDIR/cache ]; then
105 mkdir $BASEDIR/cache
106 fi
107 mkdir -p $BASEDIR/log_${MACHINE}
108 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
109 cd $BASEDIR/lfs
110 for i in *; do
111 if [ -f "$i" -a "$i" != "Config" ]; then
112 echo -ne "Loading $i"
113 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t" download >> $LOGFILE 2>&1
114 if [ $? -ne 0 ]; then
115 beautify message FAIL
116 else
117 beautify message DONE
118 fi
119 fi
120 done
121 cd - >/dev/null 2>&1
122 ;;
123
124toolchain)
125 prepareenv
126 # Check if host can build the toolchain
39f6d9ca
MT
127 . tools/make-check
128 check_toolchain
e3d88b86 129
ce85f613 130 toolchain_build
e3d88b86 131
ce85f613 132 stdumount
e3d88b86
MT
133 echo -ne "\ntarball creation "
134 [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains
ce85f613
MT
135 cd $BASEDIR && tar cj \
136 --exclude='log_${MACHINE}/_build.*.log' \
137 --file=cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
138 build_${MACHINE} \
139 log_${MACHINE} >> $LOGFILE
140 beautify message DONE
141 echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
142 md5sum cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
143 > cache/toolchains/$TOOLCHAINNAME.md5
144
145 stdumount
146 ;;
147
148gettoolchain)
149 if [ ! -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
150 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
151 test -d $BASEDIR/cache/toolchains || mkdir $BASEDIR/cache/toolchains
152 echo "Loading toolchain for $MACHINE"
153 cd $BASEDIR/cache/toolchains
154 wget -c -nv $URL_TOOLCHAIN/$TOOLCHAINNAME.tar.bz2 $URL_TOOLCHAIN/$TOOLCHAINNAME.md5
155 if [ $? -ne 0 ]; then
156 echo -n "ERROR: Downloading toolchain for $MACHINE machine"
157 beautify message FAIL
158 echo "Precompiled toolchain not always available for every machine"
159 else
160 if [ "`md5sum $TOOLCHAINNAME.tar.bz2 | awk '{print $1}'`" = "`cat $TOOLCHAINNAME.md5 | awk '{print $1}'`" ]; then
161 beautify message DONE
162 echo "Toolchain md5 ok"
163 else
164 exiterror "$TOOLCHAINNAME.md5 did not match, check downloaded package"
165 fi
166 fi
167 else
168 echo -n "Toolchain for $MACHINE is already existing"
169 beautify message SKIP
170 fi
171 ;;
172
173othersrc)
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
0627b392
MT
190git)
191 . $BASEDIR/tools/make-git
ce85f613 192 case "$2" in
0627b392
MT
193 update|pull)
194 git_pull
ce85f613
MT
195 ;;
196 commit|ci)
0627b392 197 shift 2
ce85f613 198 clear
0627b392 199 git_commit $*
ce85f613 200 ;;
e4cff7fc
MT
201 dist|export|archive)
202 git_export
203 ;;
8e878964
MT
204 push)
205 git_push
206 ;;
ce85f613 207 diff|di)
0627b392 208 git_diff
ce85f613
MT
209 ;;
210 log)
0627b392 211 git_log
ce85f613 212 ;;
3763394e
MT
213 put-key)
214 shift 2
215 ssh_cert $*
216 ;;
ce85f613
MT
217 esac
218 ;;
219
da06a52f
MT
220welcome)
221 clear
222 #. $BASEDIR/tools/make-git
223
224 echo -ne "
225###############################################################################
226#
227# ${FAIL}$NAME${NORMAL} $VERSION
228#
229###############################################################################
230#
231# ${BOLD}You are:${NORMAL} $(git config user.name) <$(git config user.email)>
232#
233# ${BOLD}You are on branch:${NORMAL}
234#
235$(git branch --color)
236#
237###############################################################################
238#
239$(git diff --stat --color)
240#
241###############################################################################
242"
243
244 ;;
245
ce85f613
MT
246uploadsrc)
247 PWD=`pwd`
248 cd $BASEDIR/cache/
249 echo -e "Uploading cache to ftp server:"
250 for i in *; do
251 echo "${i}" | fgrep -q .md5 && continue
252 [ -e ${i}.md5 ] && continue
253 md5sum ${i} | tee ${i}.md5
254 done
255 ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist
256 for i in *; do
257 if [ "$(basename $i)" == "toolchains" ]; then continue; fi
258 grep -q $(basename $i) /tmp/ftplist
259 if [ "$?" -ne "0" ]; then
260 echo -ne "$(basename $i)"
261 ncftpput -u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $(basename $i)
262 if [ "$?" -ne "0" ]; then
263 beautify message FAIL
264 fi
265 fi
266 done
267 rm -f /tmp/ftplist
268 cd $PWD
269 exit 0
270 ;;
271
272upload)
273 FTP_ISO_PORT=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
274 FTP_ISO_URL=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
275 if [ -z $FTP_ISO_PORT ]; then
276 FTP_ISO_PORT=21
277 fi
278 cat <<EOF > .ftp-commands
279mkdir -p $FTP_ISO_PATH$SVN_REVISION
280mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
281quit
282EOF
283 ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
284 rm -f .ftp-commands
285
286 case "$2" in
287 iso)
288 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
289
290 md5sum ipfire-$VERSION.$MACHINE-full.iso > ipfire-$VERSION.$MACHINE-full.iso.md5
291 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
292 if [ -e "$i" ]; then
293 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
294 if [ "$?" -eq "0" ]; then
295 echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
296 else
297 echo "There was an error while uploading the file $i to the ftp server."
298 exit 1
299 fi
300 fi
301 done
302 rm -f ipfire-$VERSION.$MACHINE-full.iso.md5
303 if [ "$3" = "--with-sources-cd" ]; then
304 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
305 fi
306 ;;
307 paks)
308 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages/*
309 if [ "$?" -eq "0" ]; then
310 echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
311 else
312 echo -e "There was an error while uploading the packages to the ftp server."
313 exit 1
314 fi
315 ;;
316 esac
317 ;;
318
ce85f613
MT
319*)
320 cat doc/make.sh-usage
321 ;;
322
323esac