#4063 kiwi: Only add buildroot repo if user repositories are not defined
Merged 5 months ago by tkopecek. Opened 10 months ago by tkopecek.
tkopecek/koji pr4061a  into  master

file modified
+6 -6
@@ -351,12 +351,12 @@ 

  

          # user repos

          repos = self.opts.get('repos', [])

-         # buildroot repo

-         path_info = koji.PathInfo(topdir=self.options.topurl)

-         repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])

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

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

-         repos.append(baseurl)

+         if self.opts.get('use_buildroot_repo', False):

+             path_info = koji.PathInfo(topdir=self.options.topurl)

+             repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])

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

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

+             repos.append(baseurl)

  

          base_path = os.path.dirname(desc_path)

          if opts.get('make_prep'):

file modified
+13
@@ -7,6 +7,7 @@ 

      _running_in_bg,

      activate_session,

      watch_tasks,

+     warn,

  )

  

  
@@ -34,6 +35,10 @@ 

      parser.add_option("--result-bundle-name-format", help="Override default bundle name format")

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

                        help="Run 'make prep' in checkout before starting the build")

+     parser.add_option("--buildroot-repo", action="store_true",

+                       dest="use_buildroot_repo", default=False,

+                       help="Add buildroot repo to installation sources. This is off by default, "

+                            "but if there is no --repo used, it will be turned on automatically.")

      parser.add_option("--can-fail", action="store", dest="optional_arches",

                        metavar="ARCH1,ARCH2,...", default="",

                        help="List of archs which are not blocking for build "
@@ -81,6 +86,14 @@ 

      if options.repo:

          kwargs['repos'] = options.repo

  

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

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

+     elif options.use_buildroot_repo:

+         kwargs['use_buildroot_repo'] = True

+     elif not options.repo:

+         warn("no repos given, using buildroot repo")

+         kwargs['use_buildroot_repo'] = True

+ 

      task_id = session.kiwiBuild(**kwargs)

  

      if not goptions.quiet:

file modified
+3 -1
@@ -17,7 +17,7 @@ 

  @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):

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

      context.session.assertPerm('image')

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

          if i is not None:
@@ -62,6 +62,8 @@ 

          opts['make_prep'] = True

      if type:

          opts['type'] = type

+     if use_buildroot_repo:

+         opts['use_buildroot_repo'] = True

      if type_attr:

          opts['type_attr'] = type_attr

      if result_bundle_name_format:

Is all the logic right here?

I applied this in our koji and you can see in
https://koji.fedoraproject.org/koji/taskinfo?taskID=116499372

we are passing
repos': ['https://kojipkgs.fedoraproject.org/compose/branched/Fedora-40-20240417.n.0/compose/Everything/$arch/os'],

but the container is building using the buildroot. ;(

I expected it to default to NOT using the buildroot if there is a repo passed...

The flag --no-buildroot-repo needs to be flipped to --use-buildroot-repo instead and default to off when repos is populated.

The change itself looks fine, but does not match the description -- "Only add buildroot repo if user repositories are not defined". We either need to update the description or the code.

Implicitly changing the behavior when repos != [] is a backwards-incompatible change. That said, this is a plugin with specialized uses, so perhaps we can make a such a change. Open to discussion here.

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

8 months ago

If you are passing repos, I would expect it to use just those... if you needed those repos + buildroot, you could just pass that as an additional repo right?
The only time you should enable buildroot repos is no repos at all are passed it, and I'd be fine if that case was just an error personally.

rebased onto 02d814f

8 months ago

Ok, I've changed it to:
1) use buildroot repo by default if no --repo is used
2) If --repo is used, still allow --buildroot-repo to add the current buildroot repo. (You can still refer to some other/older existing buildroot repo via --repo)

3 new commits added

  • Don't use buildroot repo by default
  • kiwi: option for not using buildroot repo
  • kiwi: Only add buildroot repo if user repositories are not defined
8 months ago

Seems reasonable. Just to be super clear:

3) If --repo is used and --buildroot-repo is not passed, only repo is used (buildroot is not).

Right?

    parser.add_option("--buildroot-repo", action="store_false",
                      dest="use_buildroot_repo", default=False,
                      help="Add buildroot repo to installation sources. This is off by default, "
                           "but uf there is no --repo used, it will be turned on automatically.")
  • should be store_true
  • s/uf/if/
    if options.use_buildroot_repo or not options.repo:
        kwargs['use_buildroot_repo'] = True

Maybe worth printing a message/warning in not options.repo case? E.g. "no repos given, using buildroot repo"

It's worth noting that this will error on an old hub if no repos are given. Probably worth checking the hub version to avoid confusion.

If --repo is used and --buildroot-repo is not passed, only repo is used (buildroot is not).

That is what the current logic says. The option must be explicitly passed and we only pass it if options.use_buildroot_repo or not options.repo

1 new commit added

  • version check + typo fixes
8 months ago

Redundant warning for old hub

$ lkoji --plugin-paths plugins/cli kiwi-build f24 foo bar 
no repos given, using buildroot repo
hub version is < 1.35, buildroot repo is always used in addition to specified repos

Perhaps this?

    if session.hub_version < (1, 35, 0):
        warn("hub version is < 1.35, buildroot repo is always used in addition to specified repos")
    elif options.use_buildroot_repo:
        kwargs['use_buildroot_repo'] = True
    elif not options.repo:
        warn("no repos given, using buildroot repo")
        kwargs['use_buildroot_repo'] = True

1 new commit added

  • improve warnings for older hub
8 months ago

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

8 months ago

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

5 months ago

rebased onto faf3d93

5 months ago

Commit e18e400 fixes this pull-request

Pull-Request has been merged by tkopecek

5 months ago