#16 Use rpmlintrc file if it exists in distgit
Merged 6 years ago by kparal. Opened 6 years ago by lbrabec.

@@ -0,0 +1,36 @@ 

+ #!/usr/bin/env python2

+ '''Script for downloading <srcpkgname>.rpmlintrc file from distgit'''

+ 

+ import sys

+ import os

+ 

+ from libtaskotron.directives import distgit_directive

+ from libtaskotron.ext.fedora import rpm_utils

+ from libtaskotron.exceptions import TaskotronRemoteError

+ 

+ def download_rpmlintconf(koji_build, workdir='.'):

+     '''If it exists, download <srcpkgname>.rpmlint file from distgit. If it

+     doesn't, do nothing.

+ 

+     :param str koji_build: NVR used to determine distgit repo and <srcpkgname>

+     :param str workdir: directory into which to download the file

+     '''

+     distgit = distgit_directive.DistGitDirective()

+ 

+     pkgname = rpm_utils.rpmformat(koji_build, fmt='n')

+ 

+     params = {"nvr": koji_build,

+               "path": ["%s.rpmlintrc" % pkgname],

+               "target_dir": workdir}

+ 

+     try:

+         print "Trying to download %s.rpmlintrc ..." % pkgname

+         distgit.process(params, {"workdir": workdir})

+         print "%s.rpmlintrc downloaded successfully into %s" % (pkgname,

+             os.path.abspath(workdir))

+     except TaskotronRemoteError as e:

+         print "Failed to download %s.rpmlintrc: %s" % (pkgname, e)

+ 

+ 

+ if __name__ == "__main__":

+     download_rpmlintconf(koji_build=sys.argv[1], workdir=sys.argv[2])

file modified
+14 -4
@@ -15,6 +15,7 @@ 

  

  from libtaskotron import check

  from libtaskotron import os_utils

+ from libtaskotron.ext.fedora import rpm_utils

  

  log = logging.getLogger('rpmlint')

  log.setLevel(logging.DEBUG)
@@ -44,11 +45,20 @@ 

              rpms.append(filepath)

          else:

              log.debug('Ignoring non-rpm file: %s', filepath)

+     pkgname = rpm_utils.rpmformat(koji_build, fmt='n')

+     rpmlintconf = os.path.join(workdir, "%s.rpmlintrc" % pkgname)

+     if os.path.isfile(rpmlintconf):

+         log.debug('Found rpmlint config file: %s', rpmlintconf)

+     else:

+         rpmlintconf = None

+ 

+     command = ['rpmlint']

+     if rpmlintconf:

+         command.extend(['--file', rpmlintconf])

  

      # run rpmlint on SRPMs

      if srpms:

-         command = ['rpmlint'] + srpms

-         srpm_result = run_rpmlint(command)

+         srpm_result = run_rpmlint(command + srpms)

      else:

          log.critical('No .src.rpm files found in: %s', workdir)

          log.debug('Files available in the workdir:\n%s', '\n'.join(files))
@@ -60,8 +70,8 @@ 

      # network checks were already) performed on the SRPM.

      # See https://phab.qa.fedoraproject.org/T760

      if rpms:

-         command = ['rpmlint', '-o', 'NetworkEnabled False'] + rpms

-         rpm_result = run_rpmlint(command)

+         command.extend(['--option', 'NetworkEnabled False'])

+         rpm_result = run_rpmlint(command + rpms)

      else:

          log.warn('No binary rpm files found in: %s', workdir)

          rpm_result = Result('PASSED', "", 0, 0)

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

          - rpmlint

          - koji

          - libtaskotron-core

+         - libtaskotron-fedora

  

      - name: Make sure taskotron results dir exists

        # this is for placing results.yml file
@@ -56,6 +57,11 @@ 

            args:

              chdir: "{{ workdir.path }}"

  

+         - name: Download rpmlint conf from distgit

+           shell: >

+             ./download_rpmlintconf.py {{ taskotron_item }} {{ workdir.path }}

+             &>> {{ artifacts }}/test.log

+ 

          - name: Run rpmlint

            shell: >

              ./run_rpmlint.py {{ taskotron_item }} {{ workdir.path }}

Please add a module docstring documenting the purpose of this script, thanks.

I pushed a change to distgit directive, this should be no longer needed.

You're using the config file only when running against binary rpms, but not when running against srpm. Please use it in both cases.

Please redirect the stream output to test.log, the same way the other tasks are redirected.

This at least deserves a line logged. Actually, since we don't get much info when running the ansible tasks, it's very useful to print some info when starting the script and another one when exiting the script. So, either use logging or just a print (completely sufficient) and print something like "Trying to download <name>.rpmlintrc ..." when starting this, and then either "<name>.rpmlintrc downloaded successfully into <path>" or "Failed to download <name>.rpmlintrc: <error>". Note the <errror> part, that's the important part.

Also, you need to add dependency on libtaskotron-fedora.

1 new commit added

  • docs, fixes, debug prints
6 years ago

1 new commit added

  • added dependency on libtaskotron-fedora
6 years ago

rebased onto 5d92d08

6 years ago

1 new commit added

  • a few polish touches
6 years ago

rebased onto 44b6a05

6 years ago

Pull-Request has been merged by kparal

6 years ago