From 82e47cbcd1fd0c1951b27298a96bf608c5556abd Mon Sep 17 00:00:00 2001
From: Alessio Igor Bogani <alessio.bogani@elettra.eu>
Date: Thu, 4 May 2023 12:07:25 +0200
Subject: [PATCH] Re-enable support for Voltumna systems

---
 inau-dispatcher.py | 12 ++++++++----
 inau.py            |  1 +
 lib/db.py          |  1 +
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/inau-dispatcher.py b/inau-dispatcher.py
index a1240a9..62d2733 100755
--- a/inau-dispatcher.py
+++ b/inau-dispatcher.py
@@ -84,10 +84,14 @@ class Store(Build):
         self.emails = emails
 
 class Builder:
-    def __init__(self, name, platform_id):
+    def __init__(self, name, platform_id, environment):
         self.name = name
         self.platform_id = platform_id
         self.platdir = args.repo + '/' + str(platform_id)
+        if environment is None:
+            self.environment = ""
+        else:
+            self.environment = "source " + environment + "; "
         self.queue = Queue()
         self.process = Process(target=self.handler)
         self.process.start()
@@ -122,7 +126,7 @@ class Builder:
             sshClient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
             sshClient.connect(hostname=self.name, port=22, username="inau",
                     key_filename="/home/inau/.ssh/id_rsa.pub")
-            _, raw, _ = sshClient.exec_command("(source /etc/profile; cd " + builddir 
+            _, raw, _ = sshClient.exec_command("(" + self.environment + "source /etc/profile; cd " + builddir
                                 + " && (test -f *.pro && qmake && cuuimake --plain-text-output);"
                                 + " make -j`getconf _NPROCESSORS_ONLN`) 2>&1")
             job.status = raw.channel.recv_exit_status()
@@ -220,9 +224,9 @@ def reconcile():
         oldbuilders = allbuilders
         for b in session.query(db.Builders).all():
             try:
-                newbuilders[b.platform_id].append(Builder(b.name, b.platform_id))
+                newbuilders[b.platform_id].append(Builder(b.name, b.platform_id, b.environment))
             except KeyError:
-                newbuilders[b.platform_id] = [Builder(b.name, b.platform_id)]
+                newbuilders[b.platform_id] = [Builder(b.name, b.platform_id, b.environment)]
         allbuilders = newbuilders
 
         for oldbuilder in oldbuilders.values():
diff --git a/inau.py b/inau.py
index a5667b3..93c7d93 100644
--- a/inau.py
+++ b/inau.py
@@ -98,6 +98,7 @@ class Builders(db.Model):
     platform_id = db.Column(db.Integer, db.ForeignKey('platforms.id'), nullable=False)
     name = db.Column(db.String(255), unique=False, nullable=False)
     platform = db.relationship('Platforms', lazy=True, backref=db.backref('builders', lazy=True))
+    environment = db.Column(db.String(255), unique=False, nullable=True)
 
 class Artifacts(db.Model):
     id = db.Column(db.Integer, primary_key=True)
diff --git a/lib/db.py b/lib/db.py
index 00a7c2a..d04279e 100644
--- a/lib/db.py
+++ b/lib/db.py
@@ -67,6 +67,7 @@ class Builders(Base):
     id = Column(Integer, primary_key=True)
     platform_id = Column(Integer, ForeignKey('platforms.id'), nullable=False)
     name = Column(String(255), unique=False, nullable=False)
+    environment = Column(String(255), unique=False, nullable=True)
 
 class Providers(Base):
     __tablename__ = 'providers'
-- 
GitLab