From 8d76e10f771b6009d93ee2b60f16e628fbe3c08e Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 10 Nov 2020 13:32:21 +0100
Subject: [PATCH] when pip install fails show message how to proceed

---
 debian-template/postinst | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/debian-template/postinst b/debian-template/postinst
index 94a06ff8..c2e4acd4 100644
--- a/debian-template/postinst
+++ b/debian-template/postinst
@@ -10,7 +10,7 @@ if [ "$1" = "configure" ] && [ -z "$2" ]; then
         addgroup --quiet --system smasch
     fi
 
-    ln -s /etc/smasch/smasch.py /usr/lib/smasch/smash/local_settings.py
+    ln -sf /etc/smasch/smasch.py /usr/lib/smasch/smash/local_settings.py
 
     virtualenv --python=python3 /usr/lib/smasch/env
 
@@ -24,9 +24,17 @@ if [ "$1" = "configure" ] && [ -z "$2" ]; then
 
 fi
 
-echo "Instal python dependencies"
-source /usr/lib/smasch/env/bin/activate && pip install -r /usr/lib/smasch/requirements.txt --log $LOG_FILE
-source /usr/lib/smasch/env/bin/activate && pip install -r /usr/lib/smasch/requirements-dev.txt  --log $LOG_FILE
+echo "Installing python dependencies"
+{
+  source /usr/lib/smasch/env/bin/activate && pip install -r /usr/lib/smasch/requirements.txt --log $LOG_FILE
+  source /usr/lib/smasch/env/bin/activate && pip install -r /usr/lib/smasch/requirements-dev.txt  --log $LOG_FILE
+} || {
+  echo "There was an issue when installing python dependencies." >> $LOG_FILE
+  echo "There was an issue when installing python dependencies. Reinstall of smasch could help (in case you are upgrading smasch the data should not be lost in the process): "
+  echo "apt-get remove smasch"
+  echo "apt-get install smasch"
+  exit 1
+}
 
 echo "Collecting static files"
 source /usr/lib/smasch/env/bin/activate && /usr/lib/smasch/manage.py collectstatic --no-input >> $LOG_FILE 2>&1
-- 
GitLab