#1548 rpmbuild: set Vendor metadata for builds
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.
Unknown source vendor  into  master

@@ -32,6 +32,12 @@

          self.copr_username = task.get("project_owner")

          self.copr_projectname = task.get("project_name")

          self.modules = task.get("modules")

+         rpm_vendor_copr_name = self.config.get("main", "rpm_vendor_copr_name")

+         self.vendor = "{0} - {1} {2}".format(

+             rpm_vendor_copr_name,

+             "group" if self.copr_username.startswith("@") else "user",

+             self.copr_username,

+         )

  

      def run(self):

          open(self.logfile, 'w').close() # truncate logfile
@@ -72,7 +78,8 @@

                                 repos=self.repos,

                                 copr_username=self.copr_username, copr_projectname=self.copr_projectname,

                                 modules=self.enable_modules,

-                                copr_build_id=self.build_id)

+                                copr_build_id=self.build_id,

+                                vendor=self.vendor)

  

      def produce_srpm(self, spec, sources, resultdir):

          cmd = MOCK_CALL + [

@@ -153,6 +153,7 @@

          "logfile": "/var/lib/copr-rpmbuild/main.log",

          "pidfile": "/var/lib/copr-rpmbuild/pid",

          "enabled_source_protocols": "https ftps",

+         "rpm_vendor_copr_name": "Unknown Copr",

      })

      config_paths = [os.path.join(path, "main.ini") for path in CONF_DIRS]

      config.read(config_path or reversed(config_paths))

file modified
+2
@@ -4,6 +4,8 @@

  enabled_source_protocols = https ftps

  distgit_lookaside_url = {scheme}://{netloc}/repo/pkgs/%(ns1)s/%(name)s/%(filename)s/%(hashtype)s/%(hash)s/%(filename)s

  distgit_clone_url = {scheme}://{netloc}/%(module)s

+ # The final %vendor would be e.g. "Fedora Copr - group @copr"

+ #rpm_vendor_copr_name="Fedora Copr"

  

  [distgit0]

  distgit_hostname_pattern = src.fedoraproject.org

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

  {% if buildroot_pkgs %}

  config_opts['chroot_additional_packages'] = '{{ buildroot_pkgs| join(" ") }}'

  {% endif %}

- 

+ config_opts['macros']['%vendor'] = '{{ vendor }}'

  {% if enable_net %}

  config_opts['rpmbuild_networking'] = True

  config_opts['use_host_resolv'] = True

file modified
+2 -1
@@ -92,6 +92,7 @@

          self.config = configparser.RawConfigParser()

          self.config.add_section('main')

          self.config.set('main', 'logfile', '/dev/null')

+         self.config.set('main', 'rpm_vendor_copr_name', 'Copr Testsuite')

  

      def teardown_method(self, method):

          shutil.rmtree(self.resultdir)
@@ -144,7 +145,7 @@

  

  config_opts['chroot_additional_packages'] = 'pkg1 pkg2 pkg3'

  

- 

+ config_opts['macros']['%vendor'] = 'Copr Testsuite - group @copr'

  

  config_opts['rpmbuild_networking'] = True

  config_opts['use_host_resolv'] = True

This is configurable per Copr instance in main.ini (the
main.rpm_vendor_prefix option).

The final Vendor format is e.g. "Fedora Copr : @copr". This should be
useful in the future "sticky vendors" DNF's feature.

Fixes: #1543

LGTM

The copr:// variant would be pretty nonstandard on Fedora:

I agree with this, it looks like vendor names are usually just simple unstructured values, so I would go with that is proposed in this PR. Alternatively with separating the owner with - or ().

@ngompa do you see this as reasonable thing? Any feedback?

We should change this from : {{ copr_username }} to owned by {{ copr_username }} or something more obvious of the relationship

@praiskup Suggestion: Copr on {{ rpm_vendor_prefix }} owned by {{ copr_username }}

Thank you for the feedback! Ok, one more iteration, what about:
{{ rpm_vendor_copr_name }} {{ "group" if copr_username.startswith("@") else "user" }}{{copr_username}}
I.e.

$ rpm -qi <p1> <p2> | grep Vendor
Vendor      : Fedora Copr user praiskup
Vendor      : Fedora Copr group @copr

... it clearly answers the question "Who?", and it is really short.

Alternatively as you suggested:
Project on {{ rpm_vendor_copr_name }} owned by {{ copr_username }}
... because there's tendency to not call the projects "coprs" as before.

Both of your suggested options make sense to me. I'm happy with either. :thumbsup:

Your first option makes more sense to me in terms of conciseness.

rebased onto e2e738359b0d3ab3affc285e6b143b482eceb22c

3 years ago

Per @frostyx suggestion, I put there the - separator:

Vendor      : Fedora Copr - user praiskup
Vendor      : Fedora Copr - group @copr

Here is still the old format

Can we please construct the string somewhere in the python code, so we can wrap the lines and have it a bit more readable?

Just some last bits ^^ but overall I like the change.

rebased onto c97c0d85e6fd76bc108fd713508631b8eebd29db

3 years ago

Thanks for the review, PTAL

rebased onto 1f41fbf36a174dd6753471c4202f2f5b85e2337c

3 years ago

rebased onto 42482ca

3 years ago

Commit 42482ca fixes this pull-request

Pull-Request has been merged by praiskup

3 years ago

Pull-Request has been merged by praiskup

3 years ago