devuan-releasebot

devuan's releasebot reimplemented (scorsh version)
git clone git://parazyd.org/devuan-releasebot.git
Log | Files | Refs | LICENSE

funcs.py (1671B)


      1 # See LICENSE file for copyright and license details.
      2 
      3 """
      4 Common releasebot functions
      5 """
      6 
      7 from os.path import isfile, join
      8 
      9 from config import templatedir, vcs_credentials
     10 
     11 
     12 def read_template(jobtype, distro):
     13     """
     14     Reads a template file into memory
     15     """
     16     fpath = join(templatedir, distro, jobtype+'-config.xml')
     17     if isfile(fpath):
     18         return open(fpath).read()
     19 
     20     return None
     21 
     22 
     23 def fill_template(pkgname, jobtype, distro, arches=None, desc=None,
     24                   git_uri=None, buildvar='', sequential=None, jlabels=None):
     25     """
     26     Fills up blanks in the template
     27     """
     28     tmpl = read_template(jobtype, distro)
     29 
     30     if tmpl:
     31         if not git_uri:
     32             git_uri = 'https://git.devuan.org/devuan-packages/%s.git' % pkgname
     33         if not desc:
     34             desc = 'Releasebot created Jenkins job for %s %s packaging' % \
     35                                                              (pkgname, jobtype)
     36         archlist = ''
     37         for arch in arches:
     38             archlist += '        <string>%s</string>\n' % arch
     39 
     40         jlablist = ''
     41         for lab in jlabels:
     42             jlablist += '        <string>%s</string>\n' % lab
     43 
     44         tmpl = tmpl.replace('{{{PKGNAME}}}', pkgname)
     45         tmpl = tmpl.replace('{{{GIT_URI}}}', git_uri)
     46         tmpl = tmpl.replace('{{{GIT_CREDENTIALS}}}', vcs_credentials)
     47         tmpl = tmpl.replace('{{{DESCRIPTION}}}', desc)
     48         tmpl = tmpl.replace('{{{ARCHITECTURES}}}', archlist)
     49         tmpl = tmpl.replace('{{{LABELS}}}', jlablist)
     50         tmpl = tmpl.replace('{{{BUILD_ADDVAR}}}', buildvar)
     51         tmpl = tmpl.replace('{{{RUNSEQUENTIAL}}}', sequential)
     52         return tmpl
     53 
     54     return None