Last active
November 8, 2017 14:57
-
-
Save janjongboom/50cad3f249972247c9dfed3f5d14b899 to your computer and use it in GitHub Desktop.
Mbed CLI install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cwd=$(pwd) | |
DIR=$(dirname $(readlink -f $0)) | |
echo "This application will install Mbed CLI..." | |
sudo apt-get update | |
sudo apt -y install dh-autoreconf build-essential libncurses5-dev | |
if which screen | grep -q 'screen'; then | |
echo "OK - Screen installed" | |
else | |
echo "NOK - Screen not installed, installing..." | |
# extract and build screen | |
tar -xzf "$DIR/Section-1/screen-4.6.1.tar.gz" #q: need v? | |
cd "$DIR/Section-1/screen-4.6.1" | |
./autogen.sh | |
./configure | |
make | |
sudo make install | |
cd $cwd | |
fi | |
if dpkg -s zlib1g-dev | grep -q 'install ok installed'; then | |
echo "OK - zlib1g-dev installed" | |
else | |
echo "NOK - zlib1g-dev installed" | |
sudo apt -y install zlib1g-dev | |
# sudo dpkg -i "$DIR/Section-2/zlib1g-dev_1.2.8.dfsg-5_i386.deb" | |
fi | |
if which python | grep -q 'python'; then | |
echo "OK - Python installed" | |
else | |
echo "NOK - Python not installed, installing..." | |
tar -xvzf "$DIR/Section-2/Python-2.7.11.tgz" | |
cd "$DIR/Section-2/Python-2.7.11" | |
./configure | |
make | |
sudo make install | |
cd $cwd | |
fi | |
python_version=$(python --version 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/') | |
if [ "$python_version" -eq "27" ]; then | |
echo "OK - Python 2.7 configured as default python" | |
else | |
echo "NOK - Python version is not 2.7, did you alias python3 to python? This is a problem that I can't fix." | |
exit 1 | |
fi | |
if which git | grep -q 'git'; then | |
echo "OK - Git installed" | |
else | |
echo "NOK - Git not installed, installing..." | |
cd "$DIR/Section-2" | |
tar -xvzf "$DIR/Section-2/git-2.9.5.tar.gz" | |
cd "$DIR/Section-2/git-2.9.5" | |
./configure | |
make | |
sudo make install | |
cd $cwd | |
fi | |
if which hg | grep -q 'hg'; then | |
echo "OK - Mercurial installed" | |
else | |
echo "NOK - Mercurial not installed, installing..." | |
cd "$DIR/Section-2" | |
tar -xvzf "$DIR/Section-2/mercurial-4.4-rc.tar.gz" | |
cd "$DIR/Section-2/mercurial-4.4-rc" | |
# mercurial needs python-dev... | |
sudo apt -y install python-dev | |
sudo make install | |
cd $cwd | |
fi | |
if which pip | grep -q 'pip'; then | |
echo "OK - Pip installed" | |
else | |
echo "NOK - Pip not installed, installing..." | |
# setuptools | |
unzip "$DIR/Section-2/setuptools-36.6.0.zip" -d "$DIR/Section-2" | |
cd "$DIR/Section-2/setuptools-36.6.0" | |
python bootstrap.py | |
sudo python setup.py install | |
cd $cwd | |
# pip | |
unzip "$DIR/Section-2/pip-9.0.1.zip" -d "$DIR/Section-2" | |
cd "$DIR/Section-2/pip-9.0.1" | |
sudo python setup.py install | |
cd $cwd | |
fi | |
if [ -d "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update" ]; then | |
echo "OK - GCC ARM 6 already extracted" | |
else | |
echo "NOK - GCC ARM 6 not extracted, installing..." | |
cd "$DIR/Section-2" | |
tar xvjf "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2" | |
cd $cwd | |
fi | |
if which mbed | grep -q 'mbed'; then | |
echo "OK - Mbed CLI installed" | |
else | |
echo "NOK - Mbed CLI not installed, installing..." | |
if [ -d "$DIR/Section-2/mbed-cli-1.2.2" ]; then | |
echo "Mbed CLI already extracted..." | |
else | |
unzip "$DIR/Section-2/mbed-cli-1.2.2.zip" -d "$DIR/Section-2" | |
fi | |
cd "$DIR/Section-2/mbed-cli-1.2.2/" | |
sudo python setup.py install | |
cd $cwd | |
echo "Installing Mbed CLI requirements..." | |
sudo pip install "$DIR/../mbed-cli-requirements/setuptools_scm-1.15.6-py2.py3-none-any.whl" | |
sudo pip install --find-links "$DIR/../mbed-cli-requirements/" -r "$DIR/../mbed-connect-blinky/mbed-os/requirements.txt" | |
fi | |
if mbed config -G GCC_ARM_PATH 2>&1 | grep -q 'No global'; then | |
echo "NOK - No global GCC_ARM_PATH set, setting..." | |
mbed config -G GCC_ARM_PATH "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update/bin" | |
else | |
echo "OK - Global GCC_ARM_PATH set" | |
fi | |
# needed for debugging | |
if [ -f /usr/bin/arm-none-eabi-gdb ]; then | |
echo "OK - arm-none-eabi-gdb in /usr/bin" | |
else | |
echo "NOK - arm-none-eabi-gdb not in /usr/bin, linking..." | |
sudo ln -s "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gdb" /usr/bin/arm-none-eabi-gdb | |
fi | |
if which pyocd-gdbserver | grep -q 'pyocd-gdbserver'; then | |
echo "OK - pyocd-gdbserver installed and in PATH" | |
else | |
echo "OK - pyocd-gdbserver not installed, or not in PATH" | |
pip install pyocd | |
fi | |
if which manifest-tool | grep -q 'manifest-tool'; then | |
echo "OK - manifest-tool installed" | |
else | |
echo "OK - manifest-tool not installed" | |
unzip "$DIR/../manifest-tool-restricted-mbed-connect.zip" -d "$DIR/Section-2" | |
cd "$DIR/Section-2/manifest-tool-restricted-mbed-connect" | |
sudo pip install . | |
cd $cwd | |
fi | |
# fix missing packages... (zlib) | |
sudo apt -f install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cwd=$(pwd) | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
echo "This application will install Mbed CLI..." | |
if which python | grep -q 'python'; then | |
echo "OK - Python installed" | |
else | |
echo "NOK - Python not installed, installing..." | |
sudo installer -pkg "$DIR/Section-2/python-2.7.11-macosx10.6.pkg" -target / | |
fi | |
python_version=$(python --version 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/') | |
if [ "$python_version" -eq "27" ]; then | |
echo "OK - Python 2.7 configured as default python" | |
else | |
echo "NOK - Python version is not 2.7, did you alias python3 to python? This is a problem that I can't fix." | |
exit 1 | |
fi | |
if which pip | grep -q 'pip'; then | |
echo "OK - Pip installed" | |
else | |
echo "NOK - Pip not installed, installing..." | |
cd "$DIR/Section-2" | |
unzip "$DIR/Section-2/pip-9.0.1.zip" | |
sudo python "$DIR/Section-2/pip-9.0.1/setup.py" install | |
cd $cwd | |
fi | |
if which git | grep -q 'git'; then | |
echo "OK - Git installed" | |
else | |
echo "NOK - Git not installed, installing..." | |
echo "\tMounting Git dmg" | |
# mount and install git | |
open "$DIR/Section-2/git-2.14.1-intel-universal-mavericks.dmg" | |
sleep 7 | |
sudo installer -pkg "/Volumes/Git 2.14.1 Mavericks Intel Universal/git-2.14.1-intel-universal-mavericks.pkg" -target / | |
fi | |
if which hg | grep -q 'hg'; then | |
echo "OK - Mercurial installed" | |
else | |
echo "NOK - Mercurial not installed, installing..." | |
sudo installer -pkg "$DIR/Section-2/Mercurial-4.3.3-macosx10.12.pkg" -target / | |
fi | |
if [ -d "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update" ]; then | |
echo "OK - GCC ARM 6 already extracted" | |
else | |
echo "NOK - GCC ARM 6 not extracted, installing..." | |
open "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update-mac.tar.bz2" | |
fi | |
if which mbed | grep -q 'mbed'; then | |
echo "OK - Mbed CLI installed" | |
else | |
echo "NOK - Mbed CLI not installed, installing..." | |
if [ -d "$DIR/Section-2/mbed-cli-1.2.2" ]; then | |
echo "Mbed CLI already extracted..." | |
else | |
unzip "$DIR/Section-2/mbed-cli-1.2.2.zip" -d "$DIR/Section-2" | |
fi | |
cd "$DIR/Section-2/mbed-cli-1.2.2/" | |
sudo python setup.py install | |
cd $cwd | |
echo "Installing Mbed CLI requirements..." | |
pip install "$DIR/../mbed-cli-requirements/setuptools_scm-1.15.6-py2.py3-none-any.whl" | |
pip install --find-links "$DIR/../mbed-cli-requirements/" -r "$DIR/../mbed-connect-blinky/mbed-os/requirements.txt" | |
echo "Linking Mbed CLI..." | |
ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/mbed /usr/local/bin/mbed | |
fi | |
if mbed config -G GCC_ARM_PATH 2>&1 | grep -q 'No global'; then | |
echo "NOK - No global GCC_ARM_PATH set, setting..." | |
mbed config -G GCC_ARM_PATH "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update/bin" | |
else | |
echo "OK - Global GCC_ARM_PATH set" | |
fi | |
# needed for debugging | |
if [ -f /usr/local/bin/arm-none-eabi-gdb ]; then | |
echo "OK - arm-none-eabi-gdb in /usr/local/bin" | |
else | |
echo "NOK - arm-none-eabi-gdb not in /usr/local/bin, linking..." | |
ln -s "$DIR/Section-2/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gdb" /usr/local/bin/arm-none-eabi-gdb | |
fi | |
if which pyocd-gdbserver | grep -q 'pyocd-gdbserver'; then | |
echo "OK - pyocd-gdbserver installed and in PATH" | |
else | |
echo "OK - pyocd-gdbserver not installed, or not in PATH" | |
pip install pyocd | |
fi | |
if which manifest-tool | grep -q 'manifest-tool'; then | |
echo "OK - manifest-tool installed" | |
else | |
echo "OK - manifest-tool not installed" | |
unzip "$DIR/../manifest-tool-restricted-mbed-connect.zip" -d "$DIR/Section-2" | |
cd "$DIR/Section-2/manifest-tool-restricted-mbed-connect" | |
pip install . | |
cd $cwd | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment