Subversion Repositories HelenOS

Rev

Rev 3672 | Details | Compare with Previous | Last modification | View Log | RSS feed

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