#4113 cg import updates
Merged 6 months ago by tkopecek. Opened 7 months ago by mikem.
mikem/koji cg-import-tweaks  into  master

@@ -138,6 +138,9 @@ 

  -  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.

file modified
+14 -4
@@ -6717,6 +6717,9 @@ 

      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],
@@ -7137,6 +7140,8 @@ 

              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
@@ -7170,6 +7175,8 @@ 

                                          "%(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)
@@ -7213,9 +7220,9 @@ 

          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']
@@ -7325,9 +7332,9 @@ 

      """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):
@@ -7828,6 +7835,9 @@ 

          # 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)

Two not-quite-related updates to cg_import

  • support subdir field for some outputs
  • provide additional data for cg policy

Previously, all cg logs went directly into the logs dir for the build with no way to indicate a different subdir. This prevented including multiple logs with the same filename (e.g. build.log per arch as native koji builds do). The field is also supported for non-legacy btypes. Legacy btypes have prescribed locations and do not allow subdir.

The additional policy data enables using the buildtype, version, and release tests in cg import policy

Fixes https://pagure.io/koji/issue/4119
Fixes https://pagure.io/koji/issue/1402

Metadata Update from @mikem:
- Pull-request tagged with: discussion

7 months ago

Metadata Update from @tkopecek:
- Pull-request untagged with: discussion
- Pull-request tagged with: testing-ready

7 months ago

Metadata Update from @relias-redhat:
- Pull-request tagged with: testing-done

6 months ago

Commit 4abd336 fixes this pull-request

Pull-Request has been merged by tkopecek

6 months ago