Pamhyr2/packages/setup.sh

55 lines
1.4 KiB
Bash
Executable File

#! /usr/bin/env bash
# setup.sh -- Pamhyr
# Copyright (C) 2024 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
function perr() {
>&2 echo $1
}
function try() {
echo "$1"
res=$($1)
if [ $? -ne 0 ];
then
perr " !!! Command failed with exit value $?: '$1'"
perr " - $res"
exit 2
fi
}
if [ $# -ne 0 ];
then
perr "usage: $0"
exit 1
fi
OLD_PWD=$PWD
try "python3 -m venv .pamhyr-env"
try "source .pamhyr-env/bin/activate"
try "python3 -m pip install -r ./pamhyr/requirements.txt"
echo '#! /usr/bin/env bash' > run-pamhyr
echo 'source .pamhyr-env/bin/activate' >> run-pamhyr
echo 'if [ $XDG_SESSION_TYPE == wayland ]; then' >> run-pamhyr
echo ' export QT_QPA_PLATFORM=wayland' >> run-pamhyr
echo 'fi' >> run-pamhyr
echo 'python3 ./pamhyr/src/pamhyr.py $@' >> run-pamhyr
try "chmod +x run-pamhyr"
cd $OLD_PWD