Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] env installation script for linux/macos #187

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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