Installer: improvements (#335)

* Fix vext.gi error
The problem occurs because vext and vext.gi are installed at the same time
we need to install the requirements in order

* Simplify path (the env was activated)

* Colorize output

* Abort if pip exit is not clean
This commit is contained in:
Alfredo Monclus
2021-11-21 17:42:11 -03:00
committed by GitHub
parent 4f61cedd6c
commit 0a6ac42069

View File

@@ -8,12 +8,24 @@ PKGLIST="xserver-xorg-video-fbturbo xdotool xinit xinput x11-xserver-utils libop
PKGLIST="${PKGLIST} python3-gi-cairo python3-virtualenv gir1.2-gtk-3.0 virtualenv matchbox-keyboard wireless-tools"
PKGLIST="${PKGLIST} libatlas-base-dev fonts-freefont-ttf"
DGRAY='\033[1;30m'
NC='\033[0m'
Red='\033[0;31m'
Green='\033[0;32m'
Cyan='\033[0;36m'
Normal='\033[0m'
echo_text ()
{
printf "${NC}$1${DGRAY}\n"
printf "${Normal}$1${Cyan}\n"
}
echo_error ()
{
printf "${Red}$1${Normal}\n"
}
echo_ok ()
{
printf "${Green}$1${Normal}\n"
}
install_packages()
@@ -28,11 +40,11 @@ install_packages()
sudo apt-get -f install
output=$(dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' | grep -E ^.[^nci])
if [ $? -eq 0 ]; then
echo_text "Unable to fix dependencies. These must be fixed before KlipperScreen can be installed"
echo_error "Unable to fix broken packages. These must be fixed before KlipperScreen can be installed"
exit 1
fi
else
echo_text "No broken packages"
echo_ok "No broken packages"
fi
echo_text "Installing KlipperScreen dependencies"
@@ -44,8 +56,20 @@ create_virtualenv()
echo_text "Creating virtual environment"
[ ! -d ${KSENV} ] && virtualenv -p /usr/bin/python3 ${KSENV}
${KSENV}/bin/pip install -r ${KSPATH}/scripts/KlipperScreen-requirements.txt
${KSENV}/bin/vext -e
source ${KSENV}/bin/activate
pip install -U pip
while read requirements; do
pip install $requirements
if [ $? -gt 0 ]; then
echo "Error: pip install exited with status code $?"
echo "Unable to install dependencies, aborting install."
deactivate
exit
fi
done < ${KSPATH}/scripts/KlipperScreen-requirements.txt
vext -e
deactivate
echo_ok "Virtual enviroment created"
}
install_systemd_service()
@@ -86,7 +110,9 @@ update_x11()
fi
}
start_KlipperScreen() {
start_KlipperScreen()
{
echo_text "Starting service..."
sudo systemctl start KlipperScreen
}
@@ -95,5 +121,5 @@ create_virtualenv
modify_user
install_systemd_service
update_x11
echo_ok "KlipperScreen was installed"
start_KlipperScreen
echo "${NC}"