Rev 3365 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3365 | Rev 3672 | ||
---|---|---|---|
1 | #!/bin/bash |
1 | #!/bin/bash |
2 | 2 | ||
3 | # Download SILO and patch it so that it can be used to create a bootable CD |
3 | # Download SILO and patch it so that it can be used to create a bootable CD |
4 | # for the Serengeti machine |
4 | # for the Serengeti machine |
5 | # by Pavel Rimsky <rimskyp@seznam.cz> |
5 | # by Pavel Rimsky <rimskyp@seznam.cz> |
6 | # portions by Martin Decky <martin@decky.cz> |
6 | # portions by Martin Decky <martin@decky.cz> |
7 | # |
7 | # |
8 | # GPL'ed, copyleft |
8 | # GPL'ed, copyleft |
9 | # |
9 | # |
10 | 10 | ||
11 | # stuff to be downloaded |
11 | # stuff to be downloaded |
12 | SILO_DOWNLOAD_FILE='silo-loaders-1.4.11.tar.gz' |
12 | SILO_DOWNLOAD_FILE='silo-loaders-1.4.11.tar.gz' |
13 | SILO_DOWNLOAD_URL='http://silo.auxio.org/pub/silo/old/'$SILO_DOWNLOAD_FILE |
13 | SILO_DOWNLOAD_URL='http://silo.auxio.org/pub/silo/old/'$SILO_DOWNLOAD_FILE |
14 | 14 | ||
15 | # check whether the last command failed, if so, write an error message and exit |
15 | # check whether the last command failed, if so, write an error message and exit |
16 | check_error() { |
16 | check_error() { |
17 | if [ "$1" -ne "0" ]; then |
17 | if [ "$1" -ne "0" ]; then |
18 | echo |
18 | echo |
19 | echo "Script failed: $2" |
19 | echo "Script failed: $2" |
20 | exit |
20 | exit |
21 | fi |
21 | fi |
22 | } |
22 | } |
23 | 23 | ||
24 | # temporary files are to be stored in /tmp |
24 | # temporary files are to be stored in /tmp |
25 | # the resulting file in the current directory |
25 | # the resulting file in the current directory |
26 | WD=`pwd` |
26 | WD=`pwd` |
27 | cd /tmp |
27 | cd /tmp |
28 | 28 | ||
29 | # download SILO from its official website |
29 | # download SILO from its official website |
30 | echo ">>> Downloading SILO" |
30 | echo ">>> Downloading SILO" |
31 | wget $SILO_DOWNLOAD_URL |
31 | wget $SILO_DOWNLOAD_URL |
32 | check_error $? "Error downloading SILO." |
32 | check_error $? "Error downloading SILO." |
33 | 33 | ||
34 | # unpack the downloaded file |
34 | # unpack the downloaded file |
35 | echo ">>> Unpacking tarball" |
35 | echo ">>> Unpacking tarball" |
36 | tar xvzf $SILO_DOWNLOAD_FILE |
36 | tar xvzf $SILO_DOWNLOAD_FILE |
37 | check_error $? "Error unpacking tarball." |
37 | check_error $? "Error unpacking tarball." |
38 | 38 | ||
39 | # CD to the unpacked directory |
39 | # CD to the unpacked directory |
40 | echo ">>> Changing to the unpacked SILO directory" |
40 | echo ">>> Changing to the unpacked SILO directory" |
41 | cd boot |
41 | cd boot |
42 | check_error $? "Changing directory failed." |
42 | check_error $? "Changing directory failed." |
43 | 43 | ||
44 | # patch it - remove bytes 512 to 512 + 32 (counted from 0), which belong to |
44 | # patch it - remove bytes 512 to 512 + 32 (counted from 0), which belong to |
45 | # the ELF header which is not recognized by the Serengeti firmware |
45 | # the ELF header which is not recognized by the Serengeti firmware |
46 | echo ">>> Patching SILO" |
46 | echo ">>> Patching SILO" |
47 | (((xxd -p -l 512 isofs.b) && (xxd -p -s 544 isofs.b)) | xxd -r -p) \ |
47 | (((xxd -p -l 512 isofs.b) && (xxd -p -s 544 isofs.b)) | xxd -r -p) \ |
48 | > isofs.b.patched |
48 | > isofs.b.patched |
49 | check_error $? "Patching SILO failed" |
49 | check_error $? "Patching SILO failed" |
50 | mv isofs.b.patched isofs.b |
50 | mv isofs.b.patched isofs.b |
51 | 51 | ||
52 | # get rid of files which are not needed for creating the bootable CD |
52 | # get rid of files which are not needed for creating the bootable CD |
53 | echo ">>> Purging SILO directory" |
53 | echo ">>> Purging SILO directory" |
54 | for file in `ls`; do |
54 | for file in `ls`; do |
55 | if [ \( -f $file \) -a \( $file != "isofs.b" \) -a \( $file != "second.b" \) ]; |
55 | if [ \( -f $file \) -a \( $file != "isofs.b" \) -a \( $file != "second.b" \) ]; |
56 | then |
56 | then |
57 | rm -fr $file; |
57 | rm -fr $file; |
58 | fi |
58 | fi |
59 | done |
59 | done |
60 | check_error $? "Purging SILO directory failed" |
60 | check_error $? "Purging SILO directory failed" |
61 | 61 | ||
62 | # create the gzipped tarball with patched SILO |
62 | # create the gzipped tarball with patched SILO |
63 | echo ">>> Creating tarball with patched SILO" |
63 | echo ">>> Creating tarball with patched SILO" |
64 | tar cvzf silo.patched.tar.gz *.b |
64 | tar cvzf silo.patched.tar.gz *.b |
65 | check_error $? "Creating tarball with patched SILO failed" |
65 | check_error $? "Creating tarball with patched SILO failed" |
66 | 66 | ||
67 | # and move it to the directory where the user expects it to be |
67 | # and move it to the directory where the user expects it to be |
68 | echo ">>> Moving the tarball with patched SILO to the current directory" |
68 | echo ">>> Moving the tarball with patched SILO to the current directory" |
69 | mv silo.patched.tar.gz $WD |
69 | mv silo.patched.tar.gz $WD |
70 | check_error $? "Moving the tarball with patched SILO failed" |
70 | check_error $? "Moving the tarball with patched SILO failed" |
71 | 71 | ||
72 | # move back to the working directory from /tmp |
72 | # move back to the working directory from /tmp |
73 | cd $WD |
73 | cd $WD |
74 | 74 | ||
75 | 75 |