From 751924a149f5602355411d86b45be62b43afae24 Mon Sep 17 00:00:00 2001
From: Daniel Mueller <daniel.q.mueller@stud.h-da.de>
Date: Fri, 25 Dec 2020 20:34:42 +0100
Subject: [PATCH] Support mpstools on 64-bit systems

Added 32-bit compatibility packages for the mpstools toolchain when on 64-bit system.
---
 roles/mpstools/tasks/main.yml       |  5 ++++-
 roles/mpstools/tasks/x64-compat.yml | 34 +++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 roles/mpstools/tasks/x64-compat.yml

diff --git a/roles/mpstools/tasks/main.yml b/roles/mpstools/tasks/main.yml
index 159c816..6995d43 100644
--- a/roles/mpstools/tasks/main.yml
+++ b/roles/mpstools/tasks/main.yml
@@ -17,6 +17,10 @@
     install_recommends: false
     force_apt_get: true
 
+- name: Install 32-bit compatibility packages when on 64-bit system
+  import_tasks: x64-compat.yml
+  when: ansible_architecture != "i386"
+
 - name: Install toolchain
   become: true
   unarchive:
@@ -49,4 +53,3 @@
     src: .sn
     dest: "/home/{{ vm_user }}"
     force: "{{ overwrite_config | default(false) }}"
-
diff --git a/roles/mpstools/tasks/x64-compat.yml b/roles/mpstools/tasks/x64-compat.yml
new file mode 100644
index 0000000..89c3fcd
--- /dev/null
+++ b/roles/mpstools/tasks/x64-compat.yml
@@ -0,0 +1,34 @@
+---
+# roles/mpstools/x64-compat
+
+- name: Check if i386 packages are enabled
+  become: true
+  lineinfile:
+    dest: /var/lib/dpkg/arch
+    line: i386
+    state: present
+    create: true
+  check_mode: yes
+  register: chk_i386
+
+- name: Add i386 arch
+  become: true
+  command: dpkg --add-architecture i386
+  when: chk_i386.changed
+  
+- name: Update apt cache
+  become: true
+  apt:
+    update_cache: true
+  when: chk_i386.changed
+
+- name: Install required packages
+  become: true
+  apt:
+    name:
+      - libc6:i386
+      - libstdc++6:i386
+      - libx11-6:i386
+      - libncurses5:i386
+    install_recommends: false
+    state: present
\ No newline at end of file
-- 
GitLab