fix: check via md5sum of requirements text file if an update of the python env is necessary. if yes, do that update automatically. no user interaction anymore.

This commit is contained in:
th33xitus
2021-01-08 14:57:51 +01:00
parent 88afa55268
commit 33a9fef676

View File

@@ -67,22 +67,31 @@ update_klipper(){
save_klipper_state
status_msg "Updating $GET_BRANCH"
cd $KLIPPER_DIR
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
if [ "$DETACHED_HEAD" == "true" ]; then
git checkout $GET_BRANCH
unset DETACHED_HEAD
fi
### pull latest files from github
git pull && ok_msg "Update successfull!"
#check for possible new dependencies and install them
status_msg "Checking for possible new dependencies ..."
PKGLIST=$(grep "PKGLIST=" ~/klipper/scripts/install-octopi.sh | cut -d'"' -f2- | cut -d'"' -f1 | cut -d"}" -f2)
### check for possible new dependencies and install them
if [[ $(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1) != $KLIPPER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/klippy-env"
sudo apt-get update && sudo apt-get install --yes $PKGLIST
$PYTHONDIR/bin/pip install -r ~/klipper/scripts/klippy-requirements.txt
ok_msg "Dependencies already met or have been installed!"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p python2 ${PYTHONDIR}
$PYTHONDIR/bin/pip install -r $KLIPPER_DIR/scripts/klippy-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
fi
klipper_service "start"
klipper_service "restart"
}
update_dwc2fk(){
@@ -116,51 +125,27 @@ update_fluidd(){
update_moonraker(){
bb4u "moonraker"
status_msg "Updating Moonraker ..."
while true; do
echo
top_border
echo -e "| You can now choose how you want to update Moonraker. |"
blank_line
echo -e "| Changes made to the Moonraker code and/or its depen- |"
echo -e "| dencies might require a rebuild of the python virtual |"
echo -e "| environment or downloading of additional packages. |"
blank_line
echo -e "| ${red}Check the docs in the Moonraker repository to see if${default} |"
echo -e "| ${red}rebuilding is necessary (user_changes.md)!${default} |"
blank_line
echo -e "| 1) Update Moonraker (default) |"
echo -e "| 2) Update Moonraker + rebuild virtualenv/dependencies |"
quit_footer
read -p "${cyan}###### Please choose:${default} " action
case "$action" in
1|"")
echo -e "###### > Update Moonraker"
update_mr="true" && rebuild_env="false"
break;;
2)
echo -e "###### > Update Moonraker + rebuild virtualenv/dependencies"
update_mr="true" && rebuild_env="true"
break;;
Q|q)
clear; update_menu; break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
stop_moonraker; echo
if [[ $update_mr = "true" ]] && [[ $rebuild_env = "false" ]]; then
unset update_mr && unset rebuild_env
cd $MOONRAKER_DIR && git pull
moonraker_service "stop"; echo
cd $MOONRAKER_DIR
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### pull latest files from github
git pull && ok_msg "Update successfull!"
### check for possible new dependencies and install them
if [[ $(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1) != $MOONRAKER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/moonraker-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p /usr/bin/python3 ${PYTHONDIR}
ln -s /usr/lib/python3/dist-packages/gpiod* ${PYTHONDIR}/lib/python*/site-packages
${PYTHONDIR}/bin/pip install -r $MOONRAKER_DIR/scripts/moonraker-requirements.txt
ok_msg "Dependencies have been installed!"
fi
if [[ $update_mr = "true" ]] && [[ $rebuild_env = "true" ]]; then
unset update_mr && unset rebuild_env
cd $MOONRAKER_DIR && git pull && ./scripts/install-moonraker.sh -r
fi
#read printer.cfg location and patch /etc/default/klipper if entries don't match
locate_printer_cfg && patch_klipper_sysfile
ok_msg "Update complete!"
restart_moonraker
moonraker_service "restart"
}
update_klipperscreen(){