1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pkgng: clean up test package creation

Make pkg json manifest more readable. Create package using
FreeBSD's `pkg create` instead of manually using tar. This
change also simplifies the manifest to a single file for
the integration test role.
This commit is contained in:
Ross Williams 2021-10-13 17:51:12 +00:00
parent ad42951b66
commit 75212ad73d
5 changed files with 46 additions and 32 deletions

View file

@ -1,34 +1,35 @@
--- ---
- name: Check if out-of-date test package has already been created - name: Create temporary directory for package creation
stat: tempfile:
path: '{{ pkgng_test_outofdate_pkg_path }}' state: directory
register: pkgng_test_outofdate_pkg_stat register: pkgng_test_outofdate_pkg_tempdir
- name: Create out-of-date test package - name: Copy intentionally out-of-date package manifest to testhost
when: not pkgng_test_outofdate_pkg_stat.stat.exists template:
block: src: MANIFEST.json.j2
- set_fact: # Plus-sign must be added at the destination
pkgng_test_outofdate_pkg_tempdir: '{{ pkgng_test_outofdate_pkg_path }}__tempdir' # CI doesn't like files with '+' in them in the repository
dest: '{{ pkgng_test_outofdate_pkg_tempdir.path }}/MANIFEST'
- name: Create temporary directory to assemble test package - name: Create out-of-date test package file
file: command:
state: directory argv:
path: '{{ pkgng_test_outofdate_pkg_tempdir }}' - pkg
- create
- '--verbose'
- '--out-dir'
- '{{ pkgng_test_outofdate_pkg_tempdir.path }}'
- '--manifest'
- '{{ pkgng_test_outofdate_pkg_tempdir.path }}/MANIFEST'
warn: no
- name: Copy intentionally out-of-date package manifests to testhost - name: Copy the created package file to the expected location
template: copy:
src: test_package_manifests/{{ item }}.json.j2 remote_src: yes
# Plus-sign must be added at the destination src: '{{ pkgng_test_outofdate_pkg_tempdir.path }}/{{ pkgng_test_pkg_name }}-0.pkg'
# CI doesn't like files with '+' in them in the repository dest: '{{ pkgng_test_outofdate_pkg_path }}'
dest: '{{ pkgng_test_outofdate_pkg_tempdir }}/+{{ item }}'
loop:
- COMPACT_MANIFEST
- MANIFEST
- name: Create out-of-date test package file - name: Remove temporary directory
command: 'tar -C {{ pkgng_test_outofdate_pkg_tempdir }} -cJf {{ pkgng_test_outofdate_pkg_path }} +COMPACT_MANIFEST +MANIFEST' file:
state: absent
- name: Remove temporary directory path: '{{ pkgng_test_outofdate_pkg_tempdir.path }}'
file:
state: absent
path: '{{ pkgng_test_outofdate_pkg_tempdir }}'

View file

@ -0,0 +1,16 @@
{
"name": "{{ pkgng_test_pkg_name }}",
"origin": "{{ pkgng_test_pkg_category }}/{{ pkgng_test_pkg_name }}",
"version": "{{ pkgng_test_pkg_version | default('0') }}",
"comment": "{{ pkgng_test_pkg_name }} (Ansible Integration Test Package)",
"maintainer": "ansible-devel@googlegroups.com",
"www": "https://github.com/ansible-collections/community.general",
"abi": "FreeBSD:*:*",
"arch": "freebsd:*:*",
"prefix": "/usr/local",
"flatsize":0,
"licenselogic": "single",
"licenses":["GPLv3"],
"desc": "This package is only installed temporarily for integration testing of the community.general.pkgng Ansible module.\nIts version number is 0 so that ANY version of the real package, with the same name, will be considered an upgrade.\nIts architecture and abi are FreeBSD:*:* so that it will install on any version or architecture of FreeBSD,\nthus future-proof as long as the package MANIFEST format does not change\nand a wildcard in the version portion of the abi or arch field is not prohibited.",
"categories":["{{ pkgng_test_pkg_category }}"]
}

View file

@ -1 +0,0 @@
{{ '{' }}{% include "test_package_metadata.j2" -%}{{ '}' }}

View file

@ -1 +0,0 @@
{{ '{' }}{% include "test_package_metadata.j2" -%},"files":{}{{ '}' }}

View file

@ -1 +0,0 @@
"name":"{{ pkgng_test_pkg_name }}","origin":"{{ pkgng_test_pkg_category }}/{{ pkgng_test_pkg_name }}","version":"0","comment":"{{ pkgng_test_pkg_name }} (Ansible Integration Test Package)","maintainer":"ansible-devel@googlegroups.com","www":"https://github.com/ansible-collections/community.general","abi":"FreeBSD:*:*","arch":"freebsd:*:*","prefix":"/usr/local","flatsize":0,"licenselogic":"single","licenses":["GPLv3"],"desc":"This package is only installed temporarily for integration testing of the community.general.pkgng Ansible module.\nIts version number is 0 so that ANY version of the real package, with the same name, will be considered an upgrade.\nIts architecture and abi are FreeBSD:*:* so that it will install on any version or architecture of FreeBSD,\nthus future-proof as long as the package MANIFEST format does not change\nand a wildcard in the version portion of the abi or arch field is not prohibited.","categories":["{{ pkgng_test_pkg_category }}"]