Mercurial > hg > aboriginal
annotate forkbomb.sh @ 346:8a71354d8ceb
Added tag 0.4.0 for changeset 1a70dfe0a436
author  Rob Landley <rob@landley.net> 

date  Fri, 06 Jun 2008 22:08:56 0500 
parents  dd28934bb0c9 
children  1782b77fae15 
rev  line source 

206
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

1 #!/bin/bash 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

2 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

3 # Test script to build every target architecture, logging output. 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

4 # With fork, it builds them in parallel 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

5 # With nofork, it build them sequentially 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

6 # With watch, it displays output from an existing parallel build 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

7 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

8 function buildarch() 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

9 { 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

10 nice n 20 ./crosscompiler.sh $1 && 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

11 nice n 20 ./mininative.sh $1 && 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

12 nice n 20 ./packagemininative.sh $1 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

13 } 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

14 
312
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

15 if [ "$1" != "watch" ] && [ "$1" != "stat" ] 
206
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

16 then 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

17 if [ $# ne 0 ] 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

18 then 
222
8b0d2080707c
Be smarter about extracting tarballs: extract one copy of each tarball
Rob Landley <rob@landley.net>
parents:
212
diff
changeset

19 (nice n 20 ./download.sh && 
262
b2e353ae7566
Have hosttools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents:
258
diff
changeset

20 # hosttools populates one directory with every command the build needs, 
b2e353ae7566
Have hosttools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents:
258
diff
changeset

21 # so we can ditch the old $PATH afterwards. 
253
f93932523a08
Reorder forkbomb build so ./hosttools.sh gets built first. Then toybox
Rob Landley <rob@landley.net>
parents:
222
diff
changeset

22 nice n 20 ./hosttools.sh && 
262
b2e353ae7566
Have hosttools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents:
258
diff
changeset

23 PATH=`pwd`/build/host && 
309
352b71189c93
Save the output of the early steps (including hosttools build) to out.txt.
Rob Landley <rob@landley.net>
parents:
299
diff
changeset

24 nice n 20 ./download.sh extract  touch .kthxbye) 2>&1  tee out.txt 
352b71189c93
Save the output of the early steps (including hosttools build) to out.txt.
Rob Landley <rob@landley.net>
parents:
299
diff
changeset

25 rm .kthxbye 2>/dev/null && exit 1 
206
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

26 fi 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

27 for i in `cd sources/configs; ls` 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

28 do 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

29 if [ "$1" == "nofork" ] 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

30 then 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

31 buildarch $i 2>&1  tee out$i.txt  exit 1 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

32 elif [ "$1" == "fork" ] 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

33 then 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

34 (buildarch $i > out$i.txt 2>&1 &)& 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

35 else 
312
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

36 echo "Usage: forkbomb.sh [fork] [nofork] [watch] [stat]" 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

37 echo e "\tnofork Build all targets one after another." 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

38 echo e "\tfork Build all targets in parallel (needs lots of RAM)." 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

39 echo e "\twatch Restart monitor for nofork." 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

40 echo e "\tstat Grep logfiles for success/failure after build." 
206
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

41 exit 1 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

42 fi 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

43 done 
b328036dbdb1
Of course I'd find a way to make 2 gigs of memory in my new laptop insufficient.
Rob Landley <rob@landley.net>
parents:
diff
changeset

44 fi 
299
dc5f5eeea57d
Fix display glitch with nofork.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset

45 
312
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

46 if [ "$1" == "stat" ] 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

47 then 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

48 echo "Success:" 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

49 grep l qemuimage out*.txt 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

50 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

51 echo "Failed:" 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

52 (ls 1 out*.txt; grep l qemuimage out*.txt)  sort  uniq u 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

53 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

54 exit 0 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

55 fi 
dd28934bb0c9
Add stat option, plus better help text when run with no arguments.
Rob Landley <rob@landley.net>
parents:
309
diff
changeset

56 
299
dc5f5eeea57d
Fix display glitch with nofork.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset

57 if [ "$1" != "nofork" ] 
dc5f5eeea57d
Fix display glitch with nofork.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset

58 then 
dc5f5eeea57d
Fix display glitch with nofork.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset

59 watch n 3 'X=; for i in out*.txt; do /bin/echo e "$X$i"; X="\n"; tail n 1 $i; done' 
dc5f5eeea57d
Fix display glitch with nofork.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset

60 fi 