85_rtems.sh 2.73 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
    if [ "$OLD_RTEMS_MTIME" -ne "$NEW_RTEMS_MTIME" ] ; then
16 17
        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
    GR712_FOLDER="$(find $FINAL_RTEMS_FOLDER -maxdepth 2 -type d -name gr712rc)"
52
    echo Adding RTEMS_MAKEFILE_PATH_LEON env var to settings.
53
    echo "export RTEMS_MAKEFILE_PATH_LEON=\"$GR712_FOLDER\"" >> $HOME/.bashrc.taste
54
}
55

56 57 58 59 60
# Remove obsolete "hack" around test-era compiler
sudo rm -f /opt/rtems-4.11.2-SMP-FPU-2017.07.13 2>/dev/null

# We have moved to RTEMS4.12, the officially SMP-supporting implementation.
# Add a replace for it, and for the default target BSP
61 62
TMPCFG=$HOME/.bashrc.taste.new
cat $HOME/.bashrc.taste | \
63
    sed "s,/opt/rtems-4.[^/]*/sparc-rtems4.[^/]*/leon.,${NEW_RTEMS_FOLDER}/sparc-rtems4.12/gr712rc," \
64 65
    > ${TMPCFG}
mv ${TMPCFG} $HOME/.bashrc.taste
66 67 68

# For Dockerfiles and chroots, the LEON3 simulator depends on these i386 libraries
apt-get install libcurl3-gnutls:i386 libbz2-1.0:i386 libncurses5:i386 libglib2.0-0:i386