Skip to content

Instantly share code, notes, and snippets.

@ekam230
Created October 17, 2022 17:26
Show Gist options
  • Save ekam230/baf3991744e7ca042f811578e34d6649 to your computer and use it in GitHub Desktop.
Save ekam230/baf3991744e7ca042f811578e34d6649 to your computer and use it in GitHub Desktop.
#!/bin/bash
# install base packages for displaying qtvcp screens and sounds
echo -e '\ninstalling common base packages'
sudo apt-get install -y gstreamer1.0-tools espeak espeak-ng sound-theme-freedesktop
echo -e '\ninstalling base packages for python2'
sudo apt-get install -y python-opengl python-pyqt5 python-pyqt5.qsci python-pyqt5.qtsvg python-pyqt5.qtopengl python-opencv python-dbus python-dbus.mainloop.pyqt5 python-espeak python-pyqt5.qtwebkit python-xlib python-cairo
# prompt to install designer
while true; do
# clear
echo -e '\nDo you wish to install Qt Designer for creating or modifying GUI files'
echo ' 1 = No, exit'
echo ' 2 = Yes, for a Run In Place installation'
echo ' 3 = Yes, for a package installation'
read -p $'\nSelection? ' response
case $response in
[1]* ) echo -e '\nInstallation complete, QtVCP screens are now available.\n'
exit;;
[2]* ) break;;
[3]* ) break;;
* ) echo -e '\nInstallation complete, QtVCP screens are now available.\n'
exit;;
esac
done
# install tools
#clear
echo -e '\ninstalling common tools'
sudo apt-get install -y qttools5-dev qttools5-dev-tools
echo -e '\ninstalling python2 tools'
sudo apt-get install -y libpython-dev pyqt5-dev-tools
# get qttools version
qttools=$(dpkg-query -W -f='${Version}\n' qttools5-dev)
case $qttools in
*5.5* ) qtver=5.5; qtfile=libpyqt5_py2.tar.gz;;
*5.7* ) qtver=5.7; qtfile=libpyqt5_py2.tar.gz;;
*5.9* ) qtver=5.9; qtfile=libpyqt5_py2.so.tar.gz;;
*5.11* ) qtver=5.11; qtfile=libpyqt5_py2.so.tar.gz;;
* ) clear
echo -e '\nUnknown qttools version '$qttools
echo -e '\ncannot continue designer installation\n'
exit
esac
# get the correct .so file to copy
# for run in place LinuxCNC installation
if [ $response -eq 2 ]; then
if [ -f ~/linuxcnc-dev/lib/python/qtvcp/designer/x86_64/qt$qtver/$qtfile ]; then
sofile=~/linuxcnc-dev/lib/python/qtvcp/designer/x86_64/qt$qtver/$qtfile
pifile=~/linuxcnc-dev/lib/python/qtvcp/plugins/qtvcp_plugin.py
ripdir='~/linuxcnc-dev'
else
while true; do
# clear
echo -e '\nrun in place installation not found'
echo 'Enter base directory name e.g. linuxcnc-2.9'
echo 'X to exit'
read -p $'\nDirectory? ' basedir
case $basedir in
[Xx]* ) clear
exit;;
* ) if [ -f ~/$basedir/lib/python/qtvcp/designer/x86_64/qt$qtver/$qtfile ]; then
sofile=~/$basedir/lib/python/qtvcp/designer/x86_64/qt$qtver/$qtfile
pifile=~/$basedir/lib/python/qtvcp/plugins/qtvcp_plugin.py
ripdir='~/'$basedir
break
fi
;;
esac
done
fi
# for full LinuxCNC installation
elif [ $response -eq 3 ]; then
# check for valid $qtfile
if [ -f /usr/lib/python2.7/dist-packages/qtvcp/designer/x86_64/qt$qtver/$qtfile ]; then
sofile=/usr/lib/python2.7/dist-packages/qtvcp/designer/x86_64/qt$qtver/$qtfile
pifile=/usr/lib/python2.7/dist-packages/qtvcp/plugins/qtvcp_plugin.py
else
# clear
echo -e '\n'$qtfile 'not found in /usr/lib/python2.7/dist-packages/qtvcp/designer/x86_64/qt'$qtver'/'
echo -e '\ncannot continue designer installation\n'
exit
fi
fi
# install python2 module loading library
# if library exists
if [ -f /usr/lib/x86_64-linux-gnu/qt5/plugins/designer/libpyqt5.so ]; then
# rename it
sudo mv /usr/lib/x86_64-linux-gnu/qt5/plugins/designer/libpyqt5.so /usr/lib/x86_64-linux-gnu/qt5/plugins/designer/libpyqt5.so.old
fi
# copy the new .so file
sudo tar -xzvf $sofile -C /usr/lib/x86_64-linux-gnu/qt5/plugins/designer
# create users plugin directory
mkdir -p ~/.designer/plugins/python
# link to plugins
if [ -f ~/.designer/plugins/python/qtvcp_plugin.py ]; then
sudo rm ~/.designer/plugins/python/qtvcp_plugin.py
fi
echo -e '\ncreate plugin link at:\n~/.designer/plugins/python/\n'
ln -s $pifile ~/.designer/plugins/python/
#clear
echo -e '\nInstallation complete, designer can be started with:'
echo -e '\ndesigner -qt=5\n'
if [ $response -eq 2 ]; then
echo -e 'After setting the rip-environment with:\n'
echo -e 'source '$ripdir'/scripts/rip-environment\n'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment