Reimplement %ansible_collection_url to accept the collection namespace
and name as arguments instead of requiring oblique control macros. This
also adds some basic tests to ensure that the macro behaves properly.
This commit adds sys.stdout.flush() before subprocess.run() in
ansible_collection.py. Without this, the print statements are shown
after the command output when building in mock.
%ansible_collection_files cannot be adapted to dynamically determine the
collection namespace. We need to use a file list for that.
%ansible_collection_install writes out a file list to
%ansible_collection_filelist. Packagers would pass
`%{ansible_collection_filelist}` to `%files -f`.
Eventually, I'd like to deprecate %ansible_collection_files. That won't
happen until the new approach has gotten more testing and adoption.
We want %ansible_test_unit to retrieve the collection name{,space} from
galaxy.yml. This removes the need for the %collection_name{,space}
macros and utilizes ansible_collection.py's more robust approach to
running the tests.
This change removes %ansible_collection_install's dependence on the
%collection_namespace and %collection_name macros. Now, the macro uses
the new helper script which extracts this information from galaxy.yml.
Parsing the galaxy.yml instead of using %{version} to determine the
collection version also lends another benefit: it allows us to package
pre-releases. Previously, discrepancies between %{version} and the
upstream version (eg. "3.0.0~rc1" vs "3.0.0-rc1") broke the macro.
The %collection_namespace and %collection_name macros are clunky. This
script preforms two tasks:
- install: extract the namespace, name, and version from galaxy.yml,
run `ansible-galaxy install`, and write a filelist for use with
%files -f.
- test: create a temporary build directory with the required
directory structure for ansible-test to work and run `ansible-test
units`.
We expect collections to use %ansible_collection_install and
%ansible_collection_file{s,list}. I'm mainly defining
%ansible_collection_dir for use in our macros.
There are a couple packaged roles in Fedora that can use
%ansible_roles_dir. This can also be used if we decide to implement
macros for packaging roles.