From a75da5cd084f71862073ad5707767b6acaba1846 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 19 May 2021 10:15:25 +0200 Subject: [dummy-package] equivs based roled to install dummy packages --- dummy-package/scripts/dummy-package.sh | 28 +++++++++++++++++++++++ dummy-package/tasks/main.yml | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 dummy-package/scripts/dummy-package.sh create mode 100644 dummy-package/tasks/main.yml (limited to 'dummy-package') diff --git a/dummy-package/scripts/dummy-package.sh b/dummy-package/scripts/dummy-package.sh new file mode 100644 index 0000000..7990de9 --- /dev/null +++ b/dummy-package/scripts/dummy-package.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +[ "$#" -eq 2 ] || exit 1 +[ -d "$1" ] || exit 2 +[ -f "$2" ] && rm -f "$2" + +cd "$1" + +equivs-control "$2" + +sed -r -i \ + -e "s/^(#\s)?(Maintainer).*/\\2: bwlehrpool@hs-offenburg.de/" \ + -e "s/^(#\s)?(Package).*/\\2: ${2}/" \ + -e "s/^(#\s)?(Provides).*/\\2: ${2}/" \ + -e "s/^(#\s)?(Version).*/\\2: 99.9.9/" \ + -e "s/^(#\s)?(Description).*/\\2: Dummy package to provide $2/" \ + -e "/^Description.*/q" \ + "$2" + +cat <> "$2" + Long description + with + some + more + lines... +EOF + +equivs-build "$2" diff --git a/dummy-package/tasks/main.yml b/dummy-package/tasks/main.yml new file mode 100644 index 0000000..921e4c6 --- /dev/null +++ b/dummy-package/tasks/main.yml @@ -0,0 +1,41 @@ +--- +- name: Create and install dummy package + block: + - name: Install equivs + apt: + name: equivs + state: present + update_cache: yes + + - name: Create temporary directory for packages + tempfile: + state: directory + register: tempdir + + - name: Create dummy packages + script: scripts/dummy-package.sh "{{ tempdir.path }}" "{{ item }}" + args: + executable: bash + loop: "{{ dummy_packages }}" + + - name: Register newly created packages + find: + path: "{{ tempdir.path }}" + pattern: '*.deb' + register: deb_files + + - name: Install dummy packages + apt: + deb: "{{ item.path }}" + loop: "{{ deb_files.files }}" + + - name: Hold on to dummy packages + command: "apt-mark hold {{ item }}" + loop: "{{ dummy_packages }}" + + - name: Remove temporary directory + file: + path: "${{ tempdir.path }}" + state: absent + when: + - dummy_packages is defined -- cgit v1.2.3-55-g7522