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

Satisfied shellcheck, early check for dependencies to simplify. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
101 changes: 40 additions & 61 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,78 +1,87 @@
#!/bin/bash

set -e

# Ensuring we have all the tools we require

missing=""
for tool in git curl apt wget make
do
if command -v "$tool" > /dev/null ; then
missing="$missing $tool"
fi
done
if [ -n "$missing" ]; then
echo "E: This script lacks the following tool(s) to be executed successfully: $missing"
echo "I: To update your current installation and install all build deps run"
echo " sudo apt update
echo " sudo apt upgrade -y
echo " sudo apt install -y git curl wget make"
exit 1
fi

# Loading helping routines

source lib/source

# Main

RED="\e[0;31m"
GRN="\e[0;32m"
PNK="\e[0;35m"
TXT="\033[0m"
YLW="\e[0;33m"
FIN="\e[0m"
GIT_BRANCH=`git branch`

echo ""
GIT_BRANCH=$(git branch)

echo
echo -en "${TXT}Raspberry Pi Image Builder:${FIN}"
echo -e " ${PNK}[${FIN}${GRN}${GIT_BRANCH}${FIN}${PNK}]${FIN}"

if [[ `command -v curl` ]]; then
:;
else
echo ""
echo -e "Missing dependency: curl"
sudo apt install -y curl wget
fi
echo -en "${TXT}Checking Internet Connection:${FIN} "
if [[ `curl -I https://github.com 2>&1 | grep 'HTTP/2 200'` ]]; then
if curl -I https://github.com 2>&1 | grep -q 'HTTP/2 200' ; then
echo -en "${PNK}[${FIN}${GRN}OK${FIN}${PNK}]${FIN}"
echo ""
echo
else
echo -en "${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}"
echo ""
echo
echo -e "${TXT}Please check your internet connection and try again${FIN}."
exit 0
exit 1
fi
echo -en "${TXT}Checking Host Machine:${FIN} "
sleep .50
if [[ "$HOST_CODENAME" == "jammy" ]]; then
echo -en "${PNK}[${FIN}${GRN}Ubuntu Jammy Jellyfish${FIN}${PNK}]${FIN}"
echo ""
echo
else
if [[ "$HOST_CODENAME" == "bullseye" ]]; then
echo -en "${PNK}[${FIN}${GRN}Debian Bullseye${FIN}${PNK}]${FIN}"
echo ""
echo
else
if [[ "$HOST_CODENAME" == "bookworm" ]]; then
echo -en "${PNK}[${FIN}${GRN}Debian Bookworm${FIN}${PNK}]${FIN}"
echo ""
echo
else
echo -ne "${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}"
echo ""
echo
echo -e "${TXT}The OS you are running is not supported${FIN}."
exit 0
exit 1
fi
fi
fi
echo ""
echo
if [[ "$HOST_ARCH" == "x86_64" || "$HOST_ARCH" == "aarch64" ]]; then
:;
else
echo -e "ARCH: $HOST_ARCH is not supported by this script."
exit 0
exit 1
fi

if [[ "$HOST_ARCH" == "x86_64" ]]; then
echo -e "${TXT}Starting install ...${FIN}"
sleep .50
if [[ `command -v make` ]]; then
sudo apt update
sudo apt upgrade -y
make ccompile
else
sleep 1s
sudo apt update
sudo apt upgrade -y
sudo apt install -y make
make ccompile
fi
make ccompile
fi

if [[ "$HOST_ARCH" == "aarch64" ]]; then
Expand All @@ -83,41 +92,11 @@ if [[ "$HOST_ARCH" == "aarch64" ]]; then
do
case $opt in
"Cross Compiling")
if [[ `command -v make` ]]; then
echo ""
echo -e "${TXT}Starting install ...${FIN}"
sleep 1s
sudo apt update
sudo apt upgrade -y
make ccompile64
else
echo ""
echo -e "${TXT}Starting install ...${FIN}"
sleep 1s
sudo apt update
sudo apt upgrade -y
sudo apt install -y make
make ccompile64
fi
break
;;
"Native Compiling")
if [[ `command -v make` ]]; then
echo ""
echo -e "${TXT}Starting install ...${FIN}"
sleep 1s
sudo apt update
sudo apt upgrade -y
make ncompile
else
echo ""
echo -e "${TXT}Starting install ...${FIN}"
sleep 1s
sudo apt update
sudo apt upgrade -y
sudo apt install -y make
make ncompile
fi
break
;;
"Quit")
Expand Down