diff --git a/docs/source/content_generator_metadata.rst b/docs/source/content_generator_metadata.rst index 3fd56999..190209c3 100644 --- a/docs/source/content_generator_metadata.rst +++ b/docs/source/content_generator_metadata.rst @@ -138,6 +138,9 @@ Each map in the output list contains the following entries: - buildroot\_id: The id of the buildroot used to create this file. Must match an entry in the buildroots list. - filename: The name of the file. +- relpath: relative path for the uploaded file. I.e. the file was uploaded to + $upload_dir/$relpath/$filename +- subdir: subdir for final location. Only valid for logs and non-legacy btypes - filesize: The size of the file. - arch: The architecture of the file (if applicable). - checksum: The checksum of the file. diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py index 7d8ddd1f..015cddee 100644 --- a/kojihub/kojihub.py +++ b/kojihub/kojihub.py @@ -6977,6 +6977,9 @@ class CG_Importer(object): def assert_policy(self): policy_data = { 'package': self.buildinfo['name'], + 'version': self.buildinfo['version'], + 'release': self.buildinfo['release'], + 'btypes': list(self.typeinfo), 'source': self.buildinfo.get('source'), 'metadata_only': self.metadata_only, 'cg_list': [self.cg], @@ -7397,6 +7400,8 @@ class CG_Importer(object): if fileinfo['type'] not in ['rpm', 'log']: self.prep_archive(fileinfo) if fileinfo['type'] == 'rpm': + if fileinfo.get('subdir'): + raise koji.GenericError("subdir field not allowed for rpm outputs") koji.check_NVRA(fileinfo['filename'], strict=True) outputs.append(fileinfo) self.prepped_outputs = outputs @@ -7430,6 +7435,8 @@ class CG_Importer(object): "%(filename)s" % fileinfo) btype = key type_info = extra[key] + if fileinfo.get('subdir'): + raise koji.GenericError("subdir field not allowed for legacy btypes") for key in extra.get('typeinfo', {}): if btype == key: raise koji.GenericError("Duplicate typeinfo for: %r" % btype) @@ -7473,9 +7480,9 @@ class CG_Importer(object): if fileinfo.get('metadata_only', False): # logs are not currently tracked, so this is a no op return - # TODO: determine subdir + subdir = fileinfo.get('subdir') fn = fileinfo['hub.path'] - import_build_log(fn, buildinfo, subdir=None) + import_build_log(fn, buildinfo, subdir=subdir) def import_archive(self, buildinfo, brinfo, fileinfo): fn = fileinfo['hub.path'] @@ -7585,9 +7592,9 @@ def import_build_log(fn, buildinfo, subdir=None): """Move a logfile related to a build to the right place""" logdir = koji.pathinfo.build_logs(buildinfo) if subdir: - logdir = "%s/%s" % (logdir, subdir) + logdir = joinpath(logdir, subdir) koji.ensuredir(logdir) - final_path = "%s/%s" % (logdir, os.path.basename(fn)) + final_path = joinpath(logdir, os.path.basename(fn)) if os.path.exists(final_path): raise koji.GenericError("Error importing build log. %s already exists." % final_path) if os.path.islink(fn) or not os.path.isfile(fn): @@ -8088,6 +8095,9 @@ def import_archive_internal(filepath, buildinfo, type, typeInfo, buildroot_id=No # new style type, no supplementary table if not metadata_only: destdir = koji.pathinfo.typedir(buildinfo, btype['name']) + subdir = fileinfo.get('subdir') + if subdir: + destdir = joinpath(destdir, subdir) _import_archive_file(filepath, destdir) archiveinfo = get_archive(archive_id, strict=True)