]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-interactive
Added a new command: ./make.sh batch cron, which is for calling the build system...
[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 usage() {
23 cat doc/make.sh-usage
24 exit 1
25 }
26
27 case "$1" in
28 build)
29 # check for prerequisites
30 check_build
31 # check for sanity of code
32 check_sanity
33 # compile the distro right now
34 build
35 # beeps when finished
36 echo -ne '\a'
37 ;;
38
39 shell)
40 # enter a shell inside LFS chroot
41 # may be used to change kernel settings
42 prepareenv
43 entershell
44 ;;
45
46 batch)
47 # build the distro in background
48 case "$2" in
49 cron)
50 cron_run
51 ;;
52 start)
53 batch_start $3
54 ;;
55 _run)
56 batch_run
57 ;;
58 attach|watch)
59 batch_attach
60 ;;
61 *)
62 usage
63 ;;
64 esac
65 ;;
66
67 ccache)
68 # ccache options
69 case "$2" in
70 stats)
71 ccache_stats
72 ;;
73 esac
74 ;;
75
76 distcc|distccd)
77 # distcc(d) commands
78 case "$2" in
79 start)
80 distccd_start
81 ;;
82 stop)
83 distccd_stop
84 ;;
85 restart)
86 distccd_restart
87 ;;
88 stats|mon)
89 distcc_mon
90 ;;
91 esac
92 ;;
93
94 clean)
95 for i in $(mount | grep $BASEDIR | cut -d " " -f 1); do
96 umount $i
97 done
98
99 stdumount
100
101 WHAT=${TARGET}
102 [ "$2" = "--all" ] && WHAT="${POSSIBLE_TARGETS}"
103
104 for i in ${WHAT}; do
105 echo -ne "Cleaning ${BOLD}$i${NORMAL} buildtree"
106 rm -rf $BASEDIR/build_$i
107 rm -rf $BASEDIR/log_$i
108 rm -rf $BASEDIR/packages_$i
109 beautify message DONE
110 done
111 echo -ne "Removing ${BOLD}general files${NORMAL}"
112 rm -f $FAILED $RUNNING 2>/dev/null
113 beautify message DONE
114 ;;
115
116 source|src)
117 LOGFILE=$BASEDIR/log_${TARGET}/_build.00-preparation.log
118 case "$2" in
119 get|pull|download)
120 getsource
121 ;;
122 put|push|upload)
123 putsource
124 ;;
125 list)
126 software_list | tee -a $BASEDIR/doc/packages-list.txt
127 ;;
128 esac
129 ;;
130
131 toolchain)
132 case "$2" in
133 get|pull|download)
134 gettoolchain
135 ;;
136 put|push|upload)
137 puttoolchain
138 ;;
139 ""|-*)
140 prepareenv
141 # Check if host can build the toolchain
142 check_toolchain
143
144 toolchain_build
145
146 stdumount
147 echo -ne "\ntarball creation "
148 [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains
149 cd $BASEDIR && tar cj --exclude='log_${TARGET}/_build.*.log' \
150 --file=cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
151 build_${TARGET} log_${TARGET} >> $LOGFILE
152 beautify message DONE
153 echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
154
155 stdumount
156
157 [ "$2" = "--put" ] && puttoolchain
158 ;;
159 *)
160 usage
161 ;;
162 esac
163 ;;
164
165 toolchains)
166 for i in $(check_supported_targets); do
167 TARGET=$i $0 clean
168 TARGET=$i $0 toolchain --put
169 done
170 ;;
171
172 target)
173 case "$2" in
174 put|push|upload)
175 puttarget
176 ;;
177 *)
178 usage
179 ;;
180 esac
181 ;;
182
183 check)
184 case "$2" in
185 cpu)
186 [ -z "$3" ] && usage
187 if check_cpu $3; then
188 echo -n "CPU has flag $3"
189 beautify message DONE
190 else
191 dialogerror "CPU hasn't got flag $3"
192 exit 1
193 fi
194 ;;
195 rootfiles)
196 check_rootfiles $3
197 ;;
198 sanity)
199 check_sanity $3
200 ;;
201 target*)
202 check_supported_targets
203 ;;
204 *)
205 usage
206 ;;
207 esac
208 ;;
209
210 g[iu]t)
211 COMMAND=$2
212 shift 2
213 case "$COMMAND" in
214 update|pull)
215 git_pull $*
216 ;;
217 commit|ci)
218 git_commit $*
219 ;;
220 dist|export|archive)
221 git_export $*
222 ;;
223 push)
224 git_push $*
225 ;;
226 diff|di)
227 git_diff $*
228 ;;
229 log)
230 git_log $*
231 ;;
232 gc)
233 git_gc
234 ;;
235 put-key)
236 ssh_cert $*
237 ;;
238 *) # If no command matches run git directly
239 git $*
240 ;;
241 esac
242 ;;
243
244 package*|pkg)
245 case "$2" in
246 list|show|ls)
247 pkg_list_packages
248 ;;
249 info)
250 shift 2
251 format_desc() {
252 MAX_LENGTH=38
253 INPUT=$@
254
255 LINE=""
256 LENGTH=0
257 for word in $INPUT; do
258 LENGTH=$(expr $LENGTH + ${#word})
259 if [ "$LENGTH" -ge "$MAX_LENGTH" ]; then
260 printf "$LINE\n"
261 LINE=" ${word} "
262 LENGTH=${#word}
263 else
264 LINE="$LINE${word} "
265 fi
266 #echo "-- ($word) $LINE"
267 done
268 printf "$LINE\n"
269 }
270 for pkg in $@; do
271 (
272 eval "$(pkg_info ${pkg})"
273 echo "############################################################"
274 echo -e "# ${CLR_BOLD_RED}PACKAGE INFO${NORMAL}"
275 echo "############################################################"
276 for val in NAME VERSION RELEASE break GROUP MAINTAINER break URL LICENSE; do
277 if [ "${val}" == "break" ]; then
278 echo " ---------------------------------------- "
279 else
280 printf "${CLR_BOLD_RED}%-12s${NORMAL}: ${!val}\n" ${val}
281 fi
282 done
283 for val in SHORT DESC; do
284 printf "${CLR_BOLD_RED}%-12s${NORMAL}: " ${val}
285 format_desc ${!val}
286 done
287 )
288 done
289 ;;
290 group*)
291 echo "====== All available groups of packages in ${NAME}-${VERSION} ======"
292 echo
293 for group in $(pkg_list_groups); do
294 echo " * ${group}"
295 done
296 ;;
297 esac
298 ;;
299
300 push)
301 putsource
302 git_push
303 ;;
304
305 pull)
306 LOGFILE=$BASEDIR/log_${TARGET}/_build.00-preparation.log
307 git_pull
308 check_sanity
309 getsource
310 ;;
311
312 vm|qemu)
313 case "$2" in
314 boot|start|run)
315 shift 2
316 qemu_start $*
317 ;;
318
319 clean)
320 rm -rf $BASEDIR/vm
321 ;;
322 esac
323 ;;
324
325 *)
326 usage
327 ;;
328
329 esac