forked from Smoothieware/Smoothieware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux_install
executable file
·112 lines (98 loc) · 3.98 KB
/
linux_install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /usr/bin/env bash
# Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Logs the command to be run and then executes the command while logging the results.
RunAndLog () {
echo `date` Executing $@>>$LOGFILE
$@ 1>>$LOGFILE 2>$ERRORFILE
if [ "$?" != "0" ] ; then
cat $ERRORFILE >>$LOGFILE
echo `date` Failure forced early exit>>$LOGFILE
cat $LOGFILE
rm -f $ERRORFILE
popd >/dev/null
read -n 1 -sp "Press any key to continue..." dummy ; echo
exit 1
fi
}
# Setup script variables.
ROOTDIR=$0
ROOTDIR=${ROOTDIR%/*}
pushd $ROOTDIR
ROOTDIR=$PWD
LOGFILE=$ROOTDIR/linux_install.log
ERRORFILE=$ROOTDIR/linux_install.err
GCC4ARM_VERSION=gcc-arm-none-eabi-4_7-2012q4
GCC4ARM_FILENAME=gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2
GCC4ARM_URL=https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major/+download/$GCC4ARM_FILENAME
GCC4ARM_TAR=$ROOTDIR/$GCC4ARM_FILENAME
GCC4ARM_MD5=475c3283253b872bb576020844046cf2
GCC4ARM_EXTRACT=$ROOTDIR/$GCC4ARM_VERSION
GCC4ARM_DIR=$ROOTDIR/gcc-arm-none-eabi
GCC4ARM_BINDIR=$GCC4ARM_DIR/bin
BUILDSHELL_CMD=$ROOTDIR/BuildShell
echo Logging install results to $LOGFILE
echo `date` Starting $0 $*>$LOGFILE
echo Downloading GNU Tools for ARM Embedded Processors...
rm $GCC4ARM_FILENAME >/dev/null 2>/dev/null
echo `date` Executing wget $GCC4ARM_URL>>$LOGFILE
wget $GCC4ARM_URL
echo Validating md5 signature of GNU Tools for ARM Embedded Processors...
echo `date` Validating md5 signature of GNU Tools for ARM Embedded Processors>>$LOGFILE
archive_match=`md5sum $GCC4ARM_FILENAME | grep -c $GCC4ARM_MD5`
if [ "$archive_match" != "1" ] ; then
echo $GCC4ARM_FILENAME failed MD5 signature check.>>$LOGFILE
echo `date` Failure forced early exit>>$LOGFILE
cat $LOGFILE
rm -f $ERRORFILE
popd >/dev/null
read -n 1 -sp "Press any key to continue..." dummy ; echo
exit 1
fi
echo Extracting GNU Tools for ARM Embedded Processors...
rm -r $GCC4ARM_DIR >/dev/null 2>/dev/null
RunAndLog tar xf $GCC4ARM_TAR
RunAndLog mv $GCC4ARM_EXTRACT $GCC4ARM_DIR
echo Creating helper scripts...
echo "#! /usr/bin/env bash">$BUILDSHELL_CMD
echo "# Modify next line and set destination drive to match mbed device">>$BUILDSHELL_CMD
echo "export LPC_DEPLOY='cp PROJECT.bin /media/MBED/ ; sync'">>$BUILDSHELL_CMD
echo>>$BUILDSHELL_CMD
echo "SCRIPT_PATH=\$0">>$BUILDSHELL_CMD
echo "SCRIPT_PATH=\${SCRIPT_PATH%/*}">>$BUILDSHELL_CMD
echo "cd \$SCRIPT_PATH">>$BUILDSHELL_CMD
echo "SCRIPT_PATH=\$PWD">>$BUILDSHELL_CMD
echo "export PATH=\$SCRIPT_PATH/gcc-arm-none-eabi/bin:\$PATH">>$BUILDSHELL_CMD
echo "exec bash">>$BUILDSHELL_CMD
chmod +x $BUILDSHELL_CMD
echo Cleaning up intermediate files...
RunAndLog rm $GCC4ARM_TAR
echo
echo To build Smoothie, you will first need to run the following script
echo so that your environment variables are set correctly:
echo $BUILDSHELL_CMD
echo You will want to run this each time you start a new Terminal. You
echo can simply double-click on this script file from Finder to launch a
echo bash Terminal that has been properly initialized for building. Feel
echo free to customize it as you desire.
echo
echo You can also just edit your existing setup script such as \~/.profile
echo to update the PATH environment variable to include:
echo $GCC4ARM_BINDIR
# Restore current directory and exit script on success.
echo `date` Finished successfully>>$LOGFILE
echo Finished successfully
rm -f $ERRORFILE
popd >/dev/null
read -n 1 -sp "Press any key to continue..." dummy ; echo