Introduce option to use clang++, and option to skip apt packages (#971)

- Make clang++-11 the default for compiling rascsi
- Add --with_gcc option to use g++ instead
- Add option to skip apt-get package installation (this saves a significant amount of time running the script on a Zero when you already have the required packages installed)
- Add a line to the script menu showing current options
- Surrounding cleanup
This commit is contained in:
Daniel Markstedt 2022-11-07 18:59:19 -08:00 committed by GitHub
parent 1cae530d42
commit e8b72c48de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,9 @@ logo="""
echo -e $logo
}
COMPILER="clang++-11"
CONNECT_TYPE="FULLSPEC"
CORES=1
USER=$(whoami)
BASE=$(dirname "$(readlink -f "${0}")")
CPP_PATH="$BASE/cpp"
@ -88,6 +91,10 @@ function sudoCheck() {
# install all dependency packages for RaSCSI Service
function installPackages() {
if [[ $SKIP_PACKAGES ]]; then
echo "Skipping package installation"
return 0
fi
sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \
build-essential \
git \
@ -113,20 +120,25 @@ function installPackages() {
man2html \
hfsutils \
dosfstools \
kpartx
kpartx \
clang-11
}
# install Debian packges for RaSCSI standalone
function installPackagesStandalone() {
if [[ $SKIP_PACKAGES ]]; then
echo "Skipping package installation"
return 0
fi
sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \
build-essential \
git \
libspdlog-dev \
libpcap-dev \
libprotobuf-dev \
protobuf-compiler \
disktype \
libgmock-dev \
man2html
clang-11
}
# cache the pip packages
@ -140,10 +152,10 @@ function cachePipPackages(){
function compileRaScsi() {
cd "$CPP_PATH" || exit 1
echo "Compiling with ${CORES:-1} simultaneous cores..."
echo "Compiling $CONNECT_TYPE with $COMPILER on $CORES simultaneous cores..."
make clean </dev/null
make -j "${CORES:-1}" all CONNECT_TYPE="${CONNECT_TYPE:-FULLSPEC}" </dev/null
make CXX="$COMPILER" CONNECT_TYPE="$CONNECT_TYPE" -j "$CORES" all </dev/null
}
function cleanupOutdatedManPage() {
@ -163,7 +175,7 @@ function installRaScsi() {
cleanupOutdatedManPage "sasidump.1"
# install
sudo make install CONNECT_TYPE="${CONNECT_TYPE:-FULLSPEC}" </dev/null
sudo make install CONNECT_TYPE="$CONNECT_TYPE" </dev/null
# update launch parameters
if [[ -f $SECRET_FILE ]]; then
@ -806,7 +818,7 @@ function installNetatalk() {
rm "netatalk-$NETATALK_VERSION.tar.gz"
cd "$HOME/Netatalk-2.x-netatalk-$NETATALK_VERSION/contrib/shell_utils" || exit 1
./debian_install.sh -j="${CORES:-1}" -n="$FILE_SHARE_NAME" -p="$FILE_SHARE_PATH" || exit 1
./debian_install.sh -j="$CORES" -n="$FILE_SHARE_NAME" -p="$FILE_SHARE_PATH" || exit 1
}
# Appends the images dir as a shared Netatalk volume
@ -1171,7 +1183,7 @@ function enableWebInterfaceAuth {
function runChoice() {
case $1 in
1)
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE:-FULLSPEC}) + Web Interface"
echo "Installing / Updating RaSCSI Service ($CONNECT_TYPE) + Web Interface"
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
@ -1212,10 +1224,10 @@ function runChoice() {
showRaScsiStatus
showRaScsiWebStatus
notifyBackup
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE:-FULLSPEC}) + Web Interface - Complete!"
echo "Installing / Updating RaSCSI Service ($CONNECT_TYPE) + Web Interface - Complete!"
;;
2)
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE:-FULLSPEC})"
echo "Installing / Updating RaSCSI Service ($CONNECT_TYPE)"
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
@ -1228,7 +1240,7 @@ function runChoice() {
createImagesDir
createCfgDir
updateRaScsiGit
installPackages
installPackagesStandalone
stopRaScsiScreen
stopRaScsi
compileRaScsi
@ -1247,7 +1259,7 @@ function runChoice() {
showRaScsiCtrlBoardStatus
showRaScsiStatus
notifyBackup
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE:-FULLSPEC}) - Complete!"
echo "Installing / Updating RaSCSI Service ($CONNECT_TYPE) - Complete!"
;;
3)
echo "Installing / Updating RaSCSI OLED Screen"
@ -1322,7 +1334,7 @@ function runChoice() {
echo "Installing Web Proxy Server - Complete!"
;;
10)
echo "Configuring RaSCSI stand-alone (${CONNECT_TYPE:-FULLSPEC})"
echo "Configuring RaSCSI stand-alone ($CONNECT_TYPE)"
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Create directories and change permissions"
@ -1335,7 +1347,7 @@ function runChoice() {
stopRaScsi
compileRaScsi
installRaScsi
echo "Configuring RaSCSI stand-alone (${CONNECT_TYPE:-FULLSPEC}) - Complete!"
echo "Configuring RaSCSI stand-alone ($CONNECT_TYPE) - Complete!"
echo "Use 'rascsi' to launch RaSCSI, and 'rasctl' to control the running process."
;;
11)
@ -1403,9 +1415,10 @@ function readChoice() {
# Shows the interactive main menu of the script
function showMenu() {
echo "Board Type: $CONNECT_TYPE | Compiler: $COMPILER | Compiler Cores: $CORES"
echo ""
echo "Choose among the following options:"
echo "INSTALL/UPDATE RASCSI (${CONNECT_TYPE-FULLSPEC} version)"
echo "INSTALL/UPDATE RASCSI"
echo " 1) Install or update RaSCSI Service + Web Interface"
echo " 2) Install or update RaSCSI Service"
echo " 3) Install or update RaSCSI OLED Screen (requires hardware)"
@ -1462,6 +1475,12 @@ while [ "$1" != "" ]; do
-h | --headless)
HEADLESS=1
;;
-g | --with_gcc)
COMPILER="g++"
;;
-s | --skip_packages)
SKIP_PACKAGES=1
;;
*)
echo "ERROR: Unknown parameter \"$PARAM\""
exit 1