Skip to content

Instantly share code, notes, and snippets.

@jmcerrejon
Last active November 5, 2020 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmcerrejon/fce902236891e2b029789602abddee9b to your computer and use it in GitHub Desktop.
Save jmcerrejon/fce902236891e2b029789602abddee9b to your computer and use it in GitHub Desktop.
Install Box86
#!/bin/bash
#
# Description : Box86
# Author : Jose Cerrejon Gonzalez (ulysess@gmail_dot._com)
# Version : 1.0.0 (05/Nov/20)
# Repository : https://github.com/ptitSeb/box86
#
clear
readonly INSTALL_DIR="$HOME/box86"
readonly SOURCE_PATH="https://github.com/ptitSeb/box86"
check_if_latest_version_is_installed() {
local BOX86_PATH
local BOX86_VERSION
local GIT_VERSION
# If Box86 is not installed, skip the process
command -v box86 >/dev/null 2>&1 || return 0
BOX86_PATH=$(whereis box86 | awk '{print $2}')
BOX86_VERSION=$("$BOX86_PATH" -v | awk '{print $5}')
GIT_VERSION=$(git rev-parse HEAD | cut -c 1-8)
if [[ $BOX86_VERSION = "$GIT_VERSION" ]]; then
echo -e "\nYour box86 is already updated!.\n"
exit 0
fi
}
install_dependencies() {
echo -e "\nInstalling dependencies for Box86 if proceed..."
command -v cmake >/dev/null 2>&1 || sudo apt-get install -y cmake
echo "Done."
}
get_updated_repo() {
echo
if [[ ! -d "$INSTALL_DIR" ]]; then
git clone "$SOURCE_PATH" "$INSTALL_DIR" && cd "$_"
else
echo "Updating the repo if proceed..."
cd "$INSTALL_DIR" && git pull
[[ -d "$INSTALL_DIR"/build ]] && rm -rf "$INSTALL_DIR"/build
fi
echo "Done."
}
compile() {
local PI_VERSION_NUMBER
PI_VERSION_NUMBER=$(< /proc/device-tree/model awk '{print $3}')
cd "$INSTALL_DIR"
mkdir -p build && cd "$_"
echo -e "\nCompiling, please wait...\n"
cmake .. -DRPI"${PI_VERSION_NUMBER}"=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
time make -j"$(nproc)"
echo -e "\nCompilation done. Installing...\n"
sudo make install
echo -e "\nBox successfully installed.\n"
}
install_dependencies
get_updated_repo
check_if_latest_version_is_installed
compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment