#4184 kiwi: Add support for overriding version and releasever
Merged 8 months ago by tkopecek. Opened 8 months ago by ngompa.

file modified
+11 -4
@@ -103,6 +103,8 @@ 

              name = "%s-%s" % (name, opts.get('profile', default_profile))

  

          bld_info = {}

+         if opts.get('version'):

+             version = opts['version']

          if opts.get('release'):

              release = opts['release']

          else:
@@ -188,7 +190,7 @@ 

      Methods = ['createKiwiImage']

      _taskWeight = 2.0

  

-     def prepareDescription(self, desc_path, name, version, repos, arch):

+     def prepareDescription(self, desc_path, name, version, repos, repo_releasever, arch):

          # XML errors should have already been caught by parent task

          newxml = xml.dom.minidom.parse(desc_path)  # nosec

          image = newxml.getElementsByTagName('image')[0]
@@ -229,11 +231,15 @@ 

  

          image.setAttribute('name', name)

          preferences = image.getElementsByTagName('preferences')[0]

+ 

+         # Handle version and release-version

+         preferences.getElementsByTagName('version')[0].childNodes[0].data = version

          try:

-             preferences.getElementsByTagName('release-version')[0].childNodes[0].data = version

+             preferences.getElementsByTagName('release-version')[0].childNodes[0].data \

+                 = repo_releasever

          except IndexError:

              releasever_node = newxml.createElement('release-version')

-             text = newxml.createTextNode(version)

+             text = newxml.createTextNode(repo_releasever)

              releasever_node.appendChild(text)

              preferences.appendChild(releasever_node)

  
@@ -357,6 +363,7 @@ 

              baseurl = '%s/%s' % (repopath, arch)

              self.logger.debug('BASEURL: %s' % baseurl)

              repos.append(baseurl)

+         repo_releasever = self.opts.get('repo_releasever', version)

  

          base_path = os.path.dirname(desc_path)

          if opts.get('make_prep'):
@@ -368,7 +375,7 @@ 

                  raise koji.GenericError("Preparation step failed")

  

          path = os.path.join(scmsrcdir, desc_path)

-         desc, types = self.prepareDescription(path, name, version, repos, arch)

+         desc, types = self.prepareDescription(path, name, version, repos, repo_releasever, arch)

          self.uploadFile(desc)

  

          target_dir = '/builddir/result/image'

file modified
+6
@@ -19,11 +19,13 @@ 

      parser = OptionParser(usage=usage)

      parser.add_option("--scratch", action="store_true", default=False,

                        help="Perform a scratch build")

+     parser.add_option("--version", help="Override default version of the output image")

      parser.add_option("--release", help="Release of the output image")

      parser.add_option("--repo", action="append",

                        help="Specify a repo that will override the repo used to install "

                             "RPMs in the image. May be used multiple times. The "

                             "build tag repo associated with the target is the default.")

+     parser.add_option("--repo-releasever", help="Override default releasever of the output image")

      parser.add_option("--noprogress", action="store_true",

                        help="Do not display progress of the upload")

      parser.add_option("--kiwi-profile", action="store", default=None,
@@ -71,6 +73,8 @@ 

              if arch]

      if options.kiwi_profile:

          kwargs['profile'] = options.kiwi_profile

+     if options.version:

+         kwargs['version'] = options.version

      if options.release:

          kwargs['release'] = options.release

      if options.make_prep:
@@ -85,6 +89,8 @@ 

          kwargs['arches'] = [canonArch(arch) for arch in options.arches]

      if options.repo:

          kwargs['repos'] = options.repo

+     if options.repo_releasever:

+         kwargs['repo_releasever'] = options.repo_releasever

  

      if session.hub_version < (1, 35, 0):

          warn("hub version is < 1.35, buildroot repo is always used in addition to specified repos")

file modified
+7 -2
@@ -17,9 +17,10 @@ 

  @export

  def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile=None,

                scratch=False, priority=None, make_prep=False, repos=None, release=None,

-               type=None, type_attr=None, result_bundle_name_format=None, use_buildroot_repo=True):

+               type=None, type_attr=None, result_bundle_name_format=None, use_buildroot_repo=True,

+               version=None, repo_releasever=None):

      context.session.assertPerm('image')

-     for i in [desc_url, desc_path, profile, release]:

+     for i in [desc_url, desc_path, profile, version, release, repo_releasever]:

          if i is not None:

              kojihub.convert_value(i, cast=str, check_only=True)

      if repos:
@@ -52,12 +53,16 @@ 

          opts['scratch'] = True

      if profile:

          opts['profile'] = profile

+     if version:

+         opts['version'] = version

      if release:

          opts['release'] = release

      if optional_arches:

          opts['optional_arches'] = optional_arches

      if repos:

          opts['repos'] = repos

+     if repo_releasever:

+         opts['repo_releasever'] = repo_releasever

      if make_prep:

          opts['make_prep'] = True

      if type:

This allows for kiwi descriptions that are compatible across
multiple targets to be easily used without needless modifications.

Additionally, it allows for custom values when preparing milestone
releases without needlessly modifying the descriptions.

Fixes: #4183

I stacked this on top of @adamwill's #4181 since otherwise it can't build...

2 new commits added

  • kiwi: Add support for overriding version and releasever
  • Fix a typo in the kiwi image type attribute override patch
8 months ago

FYI @lsedlar, this needs to be plumbed into pungi too. :sweat_smile:

2 new commits added

  • kiwi: Add support for overriding version and releasever
  • Fix a typo in the kiwi image type attribute override patch
8 months ago

rebased onto faf3d93

8 months ago

flake8 is failing:

./plugins/builder/kiwi.py:238:100: E501 line too long (103 > 99 characters)

rebased onto faf3d93

8 months ago

I believe I've fixed it now.

oof, now there are conflicts...

yep, too many changes to kiwi plugin. But everything else is merged now, so it should be final rebase.

rebased onto e18e400

8 months ago

Commit 7ce96c9 fixes this pull-request

Pull-Request has been merged by tkopecek

8 months ago