Skip to content

Commit

Permalink
[Draft] env installation script for linux/macos
Browse files Browse the repository at this point in the history
  • Loading branch information
tangzz98 authored and mysterywolf committed Nov 3, 2022
1 parent 6494848 commit c060a8e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
41 changes: 41 additions & 0 deletions install_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

RTT_PYTHON=python

for p_cmd in python3 python; do
$p_cmd --version >/dev/null 2>&1 || continue
RTT_PYTHON=$p_cmd
break
done

$RTT_PYTHON --version 2 > /dev/null || {
echo "Python not installed. Please install Python before running the installation script."
exit 1
}

if ! [ -x "$(command -v gcc)" ]; then
echo "Installing gcc."
sudo apt install gcc
fi

if ! [ -x "$(command -v git)" ]; then
echo "Installing git."
sudo apt install git
fi

if [ $(dpkg-query -W -f='${Status}' libncurses5-dev 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "Installing ncurses."
sudo apt install libncurses5-dev
fi

$RTT_PYTHON -m pip list > /dev/null || {
echo "Installing pip."
sudo apt install python3-pip
}

if ! [ -x "$(command -v scons)" ]; then
echo "Installing scons."
sudo apt install scons
fi

./touch_env.sh
41 changes: 41 additions & 0 deletions install_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

RTT_PYTHON=python

for p_cmd in python3 python; do
$p_cmd --version >/dev/null 2>&1 || continue
RTT_PYTHON=$p_cmd
break
done

$RTT_PYTHON --version 2 > /dev/null || {
echo "Python not installed. Please install Python before running the installation script."
exit 1
}

if ! [ -x "$(command -v brew)" ]; then
echo "Installing Homebrew."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

if ! [ -x "$(command -v git)" ]; then
echo "Installing git."
brew install git
fi

brew list ncurses > /dev/null || {
echo "Installing ncurses."
brew install ncurses
}

$RTT_PYTHON -m pip list > /dev/null || {
echo "Installing pip."
$RTT_PYTHON -m ensurepip --upgrade
}

if ! [ -x "$(command -v scons)" ]; then
echo "Installing scons."
$RTT_PYTHON -m pip install scons
fi

./touch_env.sh
19 changes: 19 additions & 0 deletions touch_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

DEFAULT_RTT_PACKAGE_URL=https://github.com/RT-Thread/packages.git
# you can change the package url by defining RTT_PACKAGE_URL, ex:
# export RTT_PACKAGE_URL=https://github.com/Varanda-Labs/packages.git

env_dir=$HOME/.env
if ! [ -d $env_dir ]; then
echo 1
package_url=${RTT_PACKAGE_URL:-$DEFAULT_RTT_PACKAGE_URL}
mkdir $env_dir
mkdir $env_dir/local_pkgs
mkdir $env_dir/packages
mkdir $env_dir/tools
git clone $package_url $env_dir/packages/packages
echo 'source "$PKGS_DIR/packages/Kconfig"' > $env_dir/packages/Kconfig
git clone https://github.com/RT-Thread/env.git $env_dir/tools/scripts
echo 'export PATH=$HOME/.env/tools/scripts:$PATH' > $env_dir/env.sh
fi

0 comments on commit c060a8e

Please sign in to comment.