summaryrefslogtreecommitdiff
path: root/lib/ansible/galaxy/collection/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/galaxy/collection/__init__.py')
-rw-r--r--lib/ansible/galaxy/collection/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/ansible/galaxy/collection/__init__.py b/lib/ansible/galaxy/collection/__init__.py
index 1a0720c0b9..ffeba77dea 100644
--- a/lib/ansible/galaxy/collection/__init__.py
+++ b/lib/ansible/galaxy/collection/__init__.py
@@ -479,6 +479,7 @@ def build_collection(u_collection_path, u_output_path, force):
collection_meta['name'], # type: ignore[arg-type]
collection_meta['build_ignore'], # type: ignore[arg-type]
collection_meta['manifest'], # type: ignore[arg-type]
+ collection_meta['license_file'], # type: ignore[arg-type]
)
artifact_tarball_file_name = '{ns!s}-{name!s}-{ver!s}.tar.gz'.format(
@@ -1062,8 +1063,9 @@ def _make_entry(name, ftype, chksum_type='sha256', chksum=None):
}
-def _build_files_manifest(b_collection_path, namespace, name, ignore_patterns, manifest_control):
- # type: (bytes, str, str, list[str], dict[str, t.Any]) -> FilesManifestType
+def _build_files_manifest(b_collection_path, namespace, name, ignore_patterns,
+ manifest_control, license_file):
+ # type: (bytes, str, str, list[str], dict[str, t.Any], t.Optional[str]) -> FilesManifestType
if ignore_patterns and manifest_control is not Sentinel:
raise AnsibleError('"build_ignore" and "manifest" are mutually exclusive')
@@ -1073,14 +1075,15 @@ def _build_files_manifest(b_collection_path, namespace, name, ignore_patterns, m
namespace,
name,
manifest_control,
+ license_file,
)
return _build_files_manifest_walk(b_collection_path, namespace, name, ignore_patterns)
-def _build_files_manifest_distlib(b_collection_path, namespace, name, manifest_control):
- # type: (bytes, str, str, dict[str, t.Any]) -> FilesManifestType
-
+def _build_files_manifest_distlib(b_collection_path, namespace, name, manifest_control,
+ license_file):
+ # type: (bytes, str, str, dict[str, t.Any], t.Optional[str]) -> FilesManifestType
if not HAS_DISTLIB:
raise AnsibleError('Use of "manifest" requires the python "distlib" library')
@@ -1124,6 +1127,9 @@ def _build_files_manifest_distlib(b_collection_path, namespace, name, manifest_c
'recursive-include plugins */**.py */**.license',
])
+ if license_file:
+ directives.append(f'include {license_file}')
+
plugins = set(l.package.split('.')[-1] for d, l in get_all_plugin_loaders())
for plugin in sorted(plugins):
if plugin in ('modules', 'module_utils'):
@@ -1585,6 +1591,7 @@ def install_src(collection, b_collection_path, b_collection_output_path, artifac
collection_meta['namespace'], collection_meta['name'],
collection_meta['build_ignore'],
collection_meta['manifest'],
+ collection_meta['license_file'],
)
collection_output_path = _build_collection_dir(