From 619b1eb81eae74a45958337f59054b5c1eaba615 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de>
Date: Fri, 20 Dec 2024 16:27:45 +0100
Subject: [PATCH] feat: replace dzil-based installation of ta-tools by package
 based installation

---
 tasks/install_ta_tools.yml | 132 +++++++++++++++++++++----------------
 1 file changed, 75 insertions(+), 57 deletions(-)

diff --git a/tasks/install_ta_tools.yml b/tasks/install_ta_tools.yml
index 2dbdc38..1784726 100644
--- a/tasks/install_ta_tools.yml
+++ b/tasks/install_ta_tools.yml
@@ -1,60 +1,78 @@
 ---
-- name: install Git (prerequisite for ansible.builtin.git)
-  ansible.builtin.apt:
-    name: [
-#      "gcc",    # needed only for Archivematica version
-      "git",
-      "libdist-zilla-perl",
-    ]
+- name: Install TA-Tools
+  ansible.builtin.package:
+    name: "tools-for-technical-analysts"
     state: latest
 
-- name: checkout ta-tools repo
-  ansible.builtin.git:
-    repo: "https://git.slub-dresden.de/digital-preservation/tools-for-technical-analysts.git"
-    dest: "/tmp/tools-for-technical-analysts/"
-    version: "version1.0-rosetta"
-  register: ta_tools_git
-
-# Run `dzil listdeps` to get an updated list of dependencies.
-# Commented dependencies are not available as Debian packages and will be
-# installed when running `dzil install` in the next task.
-- name: install dependencies for ta-tools
-  ansible.builtin.apt:
-    name: [
-      # App::Cmd::Setup
-#      "libcurl4-gnutls-dev",    # needed only for Archivematica version
-      "libdata-printer-perl",
-      "libdatetime-perl",
-      "libdatetime-format-dateparse-perl",
-      # ExtUtils::MakeMaker
-      # IO::Zlib
-      # LWP::UserAgent
-      "libextutils-pkgconfig-perl",
-      "libpath-tiny-perl",
-      "libregexp-optimizer-perl",
-      "libsoap-lite-perl",
-#      "libtest-cmd-perl",    # needed only for Archivematica version
-      "libtext-csv-perl",
-      "libyaml-perl",
-    ]
-
-# This is THE main purpose of this task file, so we won't run this as a handler
-# but set "noqa: no-handler" instead.
-# Also, OF COURSE we want to run it every time. We just pulled a fresh copy
-# from Git and it's onyl run when that action changed.
-- name: install ta-tools
-  ansible.builtin.command:    # noqa: no-changed-when
-    cmd: "dzil install"
-    chdir: "/tmp/tools-for-technical-analysts/"
-  when: ta_tools_git.changed    # noqa: no-handler
-
-- name: create directories needed by ta-tool
-  ansible.builtin.file:
-    path: "/home/{{ vault_subapp_user }}/{{ item }}/"
-    state: directory
-    mode: "0755"
-    owner: "{{ vault_subapp_user }}"
-    group: "{{ vault_subapp_group }}"
-  loop:
-    - ".cache"
-    - ".config"
+- name: |
+    Remove build dependencies used for the old installation method that didn't
+    rely on a prebuilt Debian package.
+  block:
+    - name: install Git (prerequisite for ansible.builtin.git)
+      ansible.builtin.apt:
+        name: [
+          "gcc",    # needed only for Archivematica version
+          "git",
+          "libdist-zilla-perl",
+        ]
+        state: absent
+    
+#    - name: checkout ta-tools repo
+#      ansible.builtin.git:
+#        repo: "https://git.slub-dresden.de/digital-preservation/tools-for-technical-analysts.git"
+#        dest: "/tmp/tools-for-technical-analysts/"
+#        version: "version1.0-rosetta"
+#      register: ta_tools_git
+    - name: REMOVE ta-tools repo
+      ansible.builtin.file:
+        path: "/tmp/tools-for-technical-analysts/"
+        state: absent
+    
+    # Run `dzil listdeps` to get an updated list of dependencies.
+    # Commented dependencies are not available as Debian packages and will be
+    # installed when running `dzil install` in the next task.
+    - name: |
+        REMOVE dependencies for ta-tools. Keep only what is also listed as a
+        dependency in the tools-for-technical-analysts Debian package to avoid
+        removing and immediately reinstalling them.
+      ansible.builtin.apt:
+        name: [
+          # App::Cmd::Setup
+          # "libcurl4-gnutls-dev",    # needed only for Archivematica version
+          # "libdata-printer-perl",   # Package dependency
+          "libdatetime-perl",
+          "libdatetime-format-dateparse-perl",
+          # ExtUtils::MakeMaker
+          # IO::Zlib
+          # LWP::UserAgent
+          "libextutils-pkgconfig-perl",
+          "libpath-tiny-perl",
+          # "libregexp-optimizer-perl",   # Package dependency
+          # "libsoap-lite-perl",    # Package dependency
+          # "libtest-cmd-perl",    # needed only for Archivematica version
+          "libtext-csv-perl",
+          "libyaml-perl",
+        ]
+      state: absent
+    
+#     # This is THE main purpose of this task file, so we won't run this as a
+#     # handler, but set "noqa: no-handler" instead.
+#     # Also, OF COURSE we want to run it every time. We just pulled a fresh copy
+#     # from Git and it's onyl run when that action changed.
+#     - name: install ta-tools
+#       ansible.builtin.command:    # noqa: no-changed-when
+#         cmd: "dzil install"
+#         chdir: "/tmp/tools-for-technical-analysts/"
+#       when: ta_tools_git.changed    # noqa: no-handler
+#       async: 100000
+    
+    - name: create directories needed by ta-tool
+      ansible.builtin.file:
+        path: "/home/{{ vault_subapp_user }}/{{ item }}/"
+        state: directory
+        mode: "0755"
+        owner: "{{ vault_subapp_user }}"
+        group: "{{ vault_subapp_group }}"
+      loop:
+        - ".cache"
+        - ".config"
-- 
GitLab