85_rtems.sh 2.1 KB
Newer Older
1
2
3
#!/bin/bash
INSTALLED_RTEMS_INFO="/opt/rtems_LATEST"
if [ -f "$INSTALLED_RTEMS_INFO" ] ; then
4
    read OLD_RTEMS_MTIME OLD_RTEMS_FOLDER <<< $(cat "$INSTALLED_RTEMS_INFO")
5
6
7
8
9
10
else
    OLD_RTEMS_MTIME=0
    OLD_RTEMS_FOLDER=""
fi

echo Checking for new version of the RTEMS compiler...
11
12
URL_OF_NEW_RTEMS_INFO=http://download.tuxfamily.org/taste/RTEMS/LATEST
if wget -q -O /tmp/syncup.$$ "$URL_OF_NEW_RTEMS_INFO" ; then
13
14
    read NEW_RTEMS_MTIME NEW_RTEMS_FOLDER NEW_RTEMS_URL <<< $(cat /tmp/syncup.$$)
    rm -f /tmp/syncup.$$
15
16
17
    if [ "$OLD_RTEMS_MTIME" -lt "$NEW_RTEMS_MTIME" ] ; then
        echo Downloading updated version of the RTEMS compiler...
        cd /opt
18
        NEW_COMPILER_TARBALL=/tmp/newCompiler.$$.tar.bz2
19
        if wget -O $NEW_COMPILER_TARBALL "$NEW_RTEMS_URL" ; then
20
21
22
23
            if [ ! -z "$OLD_RTEMS_FOLDER" ] ; then
                echo Removing old RTEMS compiler...
                sudo rm -rf "$OLD_RTEMS_FOLDER"
            fi
24
25
26
27
28
            sudo tar jxvf $NEW_COMPILER_TARBALL || {
                echo Failed to extract $NEW_COMPILER_TARBALL...
                echo Aborting.
                exit 1
            }
29
            rm -f $NEW_COMPILER_TARBALL
30
            NEWBIN=$NEW_RTEMS_FOLDER/bin
31
            if ! grep "^export PATH=.*$NEWBIN" $HOME/.bashrc.taste ; then
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
32
                echo Adding new compiler "$NEWBIN" to PATH...
33
                echo "export PATH=\$PATH:$NEWBIN" >> "$HOME/.bashrc.taste"
34
            fi
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
35
            echo $NEW_RTEMS_MTIME $NEW_RTEMS_FOLDER | \
Thanassis Tsiodras's avatar
Thanassis Tsiodras committed
36
                sudo tee "$INSTALLED_RTEMS_INFO"
37
38
39
        else
            echo Failed to download the new compiler... Aborting.
            exit 1
40
41
42
        fi
    fi
else
43
    echo Failed to get "$URL_OF_NEW_RTEMS_INFO"  ...
44
45
46
    echo Aborting.
    exit 1
fi
47
48
49
50

# Make sure the RTEMS_MAKEFILE_PATH_LEON is set
grep RTEMS_MAKEFILE_PATH_LEON $HOME/.bashrc.taste >/dev/null || {
    read UNUSED FINAL_RTEMS_FOLDER <<< $(cat "$INSTALLED_RTEMS_INFO")
51
    LEON3_FOLDER="$(find $FINAL_RTEMS_FOLDER -type d -name leon3)"
52
    echo Adding RTEMS_MAKEFILE_PATH_LEON env var to settings.
53
    echo "export RTEMS_MAKEFILE_PATH_LEON=\"$LEON3_FOLDER\"" >> $HOME/.bashrc.taste
54
}