2012-01-11 18:03:27 +00:00
|
|
|
import codecs
|
2018-10-01 20:45:35 +00:00
|
|
|
import re
|
2012-01-11 17:16:00 +00:00
|
|
|
from collections import OrderedDict
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-10-01 20:45:35 +00:00
|
|
|
from .debian import Changelog, PackageArchitecture, PackageDescription, \
|
|
|
|
PackageRelation, Version
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2012-01-11 17:16:00 +00:00
|
|
|
|
|
|
|
class PackagesList(OrderedDict):
|
2008-05-01 07:54:28 +00:00
|
|
|
def append(self, package):
|
|
|
|
self[package['Package']] = package
|
|
|
|
|
|
|
|
def extend(self, packages):
|
|
|
|
for package in packages:
|
|
|
|
self[package['Package']] = package
|
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
class Makefile(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.rules = {}
|
|
|
|
self.add('.NOTPARALLEL')
|
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
def add(self, name, deps=None, cmds=None):
|
2008-05-01 07:54:28 +00:00
|
|
|
if name in self.rules:
|
|
|
|
self.rules[name].add(deps, cmds)
|
|
|
|
else:
|
|
|
|
self.rules[name] = self.Rule(name, deps, cmds)
|
|
|
|
if deps is not None:
|
|
|
|
for i in deps:
|
|
|
|
if i not in self.rules:
|
|
|
|
self.rules[i] = self.Rule(i)
|
|
|
|
|
|
|
|
def write(self, out):
|
2014-01-02 22:18:35 +00:00
|
|
|
for i in sorted(self.rules.keys()):
|
2008-05-01 07:54:28 +00:00
|
|
|
self.rules[i].write(out)
|
|
|
|
|
|
|
|
class Rule(object):
|
2012-01-11 16:52:29 +00:00
|
|
|
def __init__(self, name, deps=None, cmds=None):
|
2008-05-01 07:54:28 +00:00
|
|
|
self.name = name
|
|
|
|
self.deps, self.cmds = set(), []
|
|
|
|
self.add(deps, cmds)
|
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
def add(self, deps=None, cmds=None):
|
2008-05-01 07:54:28 +00:00
|
|
|
if deps is not None:
|
|
|
|
self.deps.update(deps)
|
|
|
|
if cmds is not None:
|
|
|
|
self.cmds.append(cmds)
|
|
|
|
|
|
|
|
def write(self, out):
|
|
|
|
deps_string = ''
|
|
|
|
if self.deps:
|
|
|
|
deps = list(self.deps)
|
|
|
|
deps.sort()
|
|
|
|
deps_string = ' ' + ' '.join(deps)
|
|
|
|
|
|
|
|
if self.cmds:
|
|
|
|
if deps_string:
|
|
|
|
out.write('%s::%s\n' % (self.name, deps_string))
|
|
|
|
for c in self.cmds:
|
|
|
|
out.write('%s::\n' % self.name)
|
|
|
|
for i in c:
|
|
|
|
out.write('\t%s\n' % i)
|
|
|
|
else:
|
|
|
|
out.write('%s:%s\n' % (self.name, deps_string))
|
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
class MakeFlags(dict):
|
|
|
|
def __str__(self):
|
2014-01-02 22:18:35 +00:00
|
|
|
return ' '.join("%s='%s'" % i for i in sorted(self.items()))
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def copy(self):
|
|
|
|
return self.__class__(super(MakeFlags, self).copy())
|
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2019-03-04 03:25:34 +00:00
|
|
|
def iter_featuresets(config):
|
|
|
|
for featureset in config['base', ]['featuresets']:
|
|
|
|
if config.merge('base', None, featureset).get('enabled', True):
|
|
|
|
yield featureset
|
|
|
|
|
|
|
|
|
|
|
|
def iter_arches(config):
|
|
|
|
return iter(config['base', ]['arches'])
|
|
|
|
|
|
|
|
|
|
|
|
def iter_arch_featuresets(config, arch):
|
|
|
|
for featureset in config['base', arch].get('featuresets', []):
|
|
|
|
if config.merge('base', arch, featureset).get('enabled', True):
|
|
|
|
yield featureset
|
|
|
|
|
|
|
|
|
|
|
|
def iter_flavours(config, arch, featureset):
|
|
|
|
return iter(config['base', arch, featureset]['flavours'])
|
|
|
|
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
class Gencontrol(object):
|
2012-06-14 14:39:30 +00:00
|
|
|
makefile_targets = ('binary-arch', 'build-arch', 'setup')
|
2016-11-04 18:37:00 +00:00
|
|
|
makefile_targets_indep = ('binary-indep', 'build-indep', 'setup')
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2012-01-11 16:52:29 +00:00
|
|
|
def __init__(self, config, templates, version=Version):
|
2008-05-01 07:54:28 +00:00
|
|
|
self.config, self.templates = config, templates
|
2012-01-11 16:52:29 +00:00
|
|
|
self.changelog = Changelog(version=version)
|
2016-04-03 16:29:17 +00:00
|
|
|
self.vars = {}
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def __call__(self):
|
|
|
|
packages = PackagesList()
|
|
|
|
makefile = Makefile()
|
|
|
|
|
|
|
|
self.do_source(packages)
|
|
|
|
self.do_main(packages, makefile)
|
|
|
|
self.do_extra(packages, makefile)
|
|
|
|
|
2018-09-10 23:59:07 +00:00
|
|
|
self.merge_build_depends(packages)
|
2008-05-01 07:54:28 +00:00
|
|
|
self.write(packages, makefile)
|
|
|
|
|
|
|
|
def do_source(self, packages):
|
|
|
|
source = self.templates["control.source"][0]
|
2018-04-07 08:32:02 +00:00
|
|
|
if not source.get('Source'):
|
|
|
|
source['Source'] = self.changelog[0].source
|
2016-04-03 16:29:17 +00:00
|
|
|
packages['source'] = self.process_package(source, self.vars)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def do_main(self, packages, makefile):
|
|
|
|
vars = self.vars.copy()
|
|
|
|
|
|
|
|
makeflags = MakeFlags()
|
|
|
|
extra = {}
|
|
|
|
|
|
|
|
self.do_main_setup(vars, makeflags, extra)
|
|
|
|
self.do_main_makefile(makefile, makeflags, extra)
|
2008-05-11 18:17:54 +00:00
|
|
|
self.do_main_packages(packages, vars, makeflags, extra)
|
|
|
|
self.do_main_recurse(packages, makefile, vars, makeflags, extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def do_main_setup(self, vars, makeflags, extra):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def do_main_makefile(self, makefile, makeflags, extra):
|
2018-10-01 15:22:49 +00:00
|
|
|
makefile.add('build-indep',
|
|
|
|
cmds=["$(MAKE) -f debian/rules.real build-indep %s" %
|
|
|
|
makeflags])
|
|
|
|
makefile.add('binary-indep',
|
|
|
|
cmds=["$(MAKE) -f debian/rules.real binary-indep %s" %
|
|
|
|
makeflags])
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-05-11 18:17:54 +00:00
|
|
|
def do_main_packages(self, packages, vars, makeflags, extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
pass
|
|
|
|
|
2008-05-11 18:17:54 +00:00
|
|
|
def do_main_recurse(self, packages, makefile, vars, makeflags, extra):
|
2019-03-04 03:25:34 +00:00
|
|
|
for featureset in iter_featuresets(self.config):
|
|
|
|
self.do_indep_featureset(packages, makefile, featureset,
|
|
|
|
vars.copy(), makeflags.copy(), extra)
|
|
|
|
for arch in iter_arches(self.config):
|
2018-10-01 15:22:49 +00:00
|
|
|
self.do_arch(packages, makefile, arch, vars.copy(),
|
|
|
|
makeflags.copy(), extra)
|
2008-05-11 18:17:54 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_extra(self, packages, makefile):
|
|
|
|
templates_extra = self.templates.get("control.extra", None)
|
|
|
|
if templates_extra is None:
|
|
|
|
return
|
|
|
|
|
2013-11-21 01:15:15 +00:00
|
|
|
packages_extra = self.process_packages(templates_extra, self.vars)
|
|
|
|
packages.extend(packages_extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
extra_arches = {}
|
2013-11-21 01:15:15 +00:00
|
|
|
for package in packages_extra:
|
2008-05-01 07:54:28 +00:00
|
|
|
arches = package['Architecture']
|
|
|
|
for arch in arches:
|
|
|
|
i = extra_arches.get(arch, [])
|
|
|
|
i.append(package)
|
|
|
|
extra_arches[arch] = i
|
2014-01-02 22:18:35 +00:00
|
|
|
for arch in sorted(extra_arches.keys()):
|
2008-05-01 07:54:28 +00:00
|
|
|
cmds = []
|
|
|
|
for i in extra_arches[arch]:
|
2018-10-01 15:22:49 +00:00
|
|
|
cmds.append("$(MAKE) -f debian/rules.real install-dummy "
|
|
|
|
"ARCH='%s' DH_OPTIONS='-p%s'" %
|
|
|
|
(arch, i['Package']))
|
|
|
|
makefile.add('binary-arch_%s' % arch,
|
|
|
|
['binary-arch_%s_extra' % arch])
|
|
|
|
makefile.add("binary-arch_%s_extra" % arch, cmds=cmds)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2016-11-04 18:37:00 +00:00
|
|
|
def do_indep_featureset(self, packages, makefile, featureset, vars,
|
2018-10-01 15:22:49 +00:00
|
|
|
makeflags, extra):
|
2016-11-04 18:37:00 +00:00
|
|
|
vars['localversion'] = ''
|
|
|
|
if featureset != 'none':
|
|
|
|
vars['localversion'] = '-' + featureset
|
|
|
|
|
|
|
|
self.do_indep_featureset_setup(vars, makeflags, featureset, extra)
|
|
|
|
self.do_indep_featureset_makefile(makefile, featureset, makeflags,
|
|
|
|
extra)
|
|
|
|
self.do_indep_featureset_packages(packages, makefile, featureset,
|
|
|
|
vars, makeflags, extra)
|
|
|
|
|
|
|
|
def do_indep_featureset_setup(self, vars, makeflags, featureset, extra):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def do_indep_featureset_makefile(self, makefile, featureset, makeflags,
|
|
|
|
extra):
|
|
|
|
makeflags['FEATURESET'] = featureset
|
|
|
|
|
|
|
|
for i in self.makefile_targets_indep:
|
|
|
|
target1 = i
|
|
|
|
target2 = '_'.join((target1, featureset))
|
|
|
|
target3 = '_'.join((target2, 'real'))
|
|
|
|
makefile.add(target1, [target2])
|
|
|
|
makefile.add(target2, [target3])
|
|
|
|
|
|
|
|
def do_indep_featureset_packages(self, packages, makefile, featureset,
|
|
|
|
vars, makeflags, extra):
|
|
|
|
pass
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
|
|
|
|
vars['arch'] = arch
|
|
|
|
|
|
|
|
self.do_arch_setup(vars, makeflags, arch, extra)
|
|
|
|
self.do_arch_makefile(makefile, arch, makeflags, extra)
|
|
|
|
self.do_arch_packages(packages, makefile, arch, vars, makeflags, extra)
|
|
|
|
self.do_arch_recurse(packages, makefile, arch, vars, makeflags, extra)
|
|
|
|
|
|
|
|
def do_arch_setup(self, vars, makeflags, arch, extra):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def do_arch_makefile(self, makefile, arch, makeflags, extra):
|
2008-05-11 18:37:03 +00:00
|
|
|
makeflags['ARCH'] = arch
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
for i in self.makefile_targets:
|
|
|
|
target1 = i
|
|
|
|
target2 = '_'.join((target1, arch))
|
|
|
|
target3 = '_'.join((target2, 'real'))
|
|
|
|
makefile.add(target1, [target2])
|
|
|
|
makefile.add(target2, [target3])
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_arch_packages(self, packages, makefile, arch, vars, makeflags,
|
|
|
|
extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
pass
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_arch_recurse(self, packages, makefile, arch, vars, makeflags,
|
|
|
|
extra):
|
2019-03-04 03:25:34 +00:00
|
|
|
for featureset in iter_arch_featuresets(self.config, arch):
|
2018-10-01 15:22:49 +00:00
|
|
|
self.do_featureset(packages, makefile, arch, featureset,
|
|
|
|
vars.copy(), makeflags.copy(), extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_featureset(self, packages, makefile, arch, featureset, vars,
|
|
|
|
makeflags, extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
vars['localversion'] = ''
|
|
|
|
if featureset != 'none':
|
|
|
|
vars['localversion'] = '-' + featureset
|
|
|
|
|
|
|
|
self.do_featureset_setup(vars, makeflags, arch, featureset, extra)
|
2018-10-01 15:22:49 +00:00
|
|
|
self.do_featureset_makefile(makefile, arch, featureset, makeflags,
|
|
|
|
extra)
|
|
|
|
self.do_featureset_packages(packages, makefile, arch, featureset, vars,
|
|
|
|
makeflags, extra)
|
|
|
|
self.do_featureset_recurse(packages, makefile, arch, featureset, vars,
|
|
|
|
makeflags, extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def do_featureset_setup(self, vars, makeflags, arch, featureset, extra):
|
|
|
|
pass
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_featureset_makefile(self, makefile, arch, featureset, makeflags,
|
|
|
|
extra):
|
2008-05-11 18:37:03 +00:00
|
|
|
makeflags['FEATURESET'] = featureset
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
for i in self.makefile_targets:
|
|
|
|
target1 = '_'.join((i, arch))
|
|
|
|
target2 = '_'.join((target1, featureset))
|
|
|
|
target3 = '_'.join((target2, 'real'))
|
|
|
|
makefile.add(target1, [target2])
|
|
|
|
makefile.add(target2, [target3])
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_featureset_packages(self, packages, makefile, arch, featureset,
|
|
|
|
vars, makeflags, extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
pass
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_featureset_recurse(self, packages, makefile, arch, featureset, vars,
|
|
|
|
makeflags, extra):
|
2019-03-04 03:25:34 +00:00
|
|
|
for flavour in iter_flavours(self.config, arch, featureset):
|
2018-10-01 15:22:49 +00:00
|
|
|
self.do_flavour(packages, makefile, arch, featureset, flavour,
|
|
|
|
vars.copy(), makeflags.copy(), extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_flavour(self, packages, makefile, arch, featureset, flavour, vars,
|
|
|
|
makeflags, extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
vars['localversion'] += '-' + flavour
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
self.do_flavour_setup(vars, makeflags, arch, featureset, flavour,
|
|
|
|
extra)
|
|
|
|
self.do_flavour_makefile(makefile, arch, featureset, flavour,
|
|
|
|
makeflags, extra)
|
|
|
|
self.do_flavour_packages(packages, makefile, arch, featureset, flavour,
|
|
|
|
vars, makeflags, extra)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_flavour_setup(self, vars, makeflags, arch, featureset, flavour,
|
|
|
|
extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
for i in (
|
|
|
|
('kernel-arch', 'KERNEL_ARCH'),
|
|
|
|
('localversion', 'LOCALVERSION'),
|
2018-10-01 15:22:49 +00:00
|
|
|
):
|
2012-01-11 16:52:29 +00:00
|
|
|
if i[0] in vars:
|
2008-05-01 07:54:28 +00:00
|
|
|
makeflags[i[1]] = vars[i[0]]
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_flavour_makefile(self, makefile, arch, featureset, flavour,
|
|
|
|
makeflags, extra):
|
2008-05-11 18:37:03 +00:00
|
|
|
makeflags['FLAVOUR'] = flavour
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
for i in self.makefile_targets:
|
|
|
|
target1 = '_'.join((i, arch, featureset))
|
|
|
|
target2 = '_'.join((target1, flavour))
|
|
|
|
target3 = '_'.join((target2, 'real'))
|
|
|
|
makefile.add(target1, [target2])
|
|
|
|
makefile.add(target2, [target3])
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
def do_flavour_packages(self, packages, makefile, arch, featureset,
|
|
|
|
flavour, vars, makeflags, extra):
|
2008-05-01 07:54:28 +00:00
|
|
|
pass
|
|
|
|
|
2008-05-11 18:53:46 +00:00
|
|
|
def process_relation(self, dep, vars):
|
2008-05-01 07:54:28 +00:00
|
|
|
import copy
|
2008-05-11 18:53:46 +00:00
|
|
|
dep = copy.deepcopy(dep)
|
2008-05-01 07:54:28 +00:00
|
|
|
for groups in dep:
|
|
|
|
for item in groups:
|
|
|
|
item.name = self.substitute(item.name, vars)
|
2009-08-03 08:43:32 +00:00
|
|
|
if item.version:
|
|
|
|
item.version = self.substitute(item.version, vars)
|
2008-05-11 18:53:46 +00:00
|
|
|
return dep
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-05-11 18:53:46 +00:00
|
|
|
def process_description(self, in_desc, vars):
|
2008-05-01 07:54:28 +00:00
|
|
|
desc = in_desc.__class__()
|
|
|
|
desc.short = self.substitute(in_desc.short, vars)
|
|
|
|
for i in in_desc.long:
|
|
|
|
desc.append(self.substitute(i, vars))
|
2008-05-11 18:53:46 +00:00
|
|
|
return desc
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2010-04-20 19:27:18 +00:00
|
|
|
def process_package(self, in_entry, vars={}):
|
2008-05-11 18:53:46 +00:00
|
|
|
entry = in_entry.__class__()
|
2015-10-29 12:06:25 +00:00
|
|
|
for key, value in in_entry.items():
|
2008-05-01 07:54:28 +00:00
|
|
|
if isinstance(value, PackageRelation):
|
2008-05-11 18:53:46 +00:00
|
|
|
value = self.process_relation(value, vars)
|
|
|
|
elif isinstance(value, PackageDescription):
|
|
|
|
value = self.process_description(value, vars)
|
2008-05-01 07:54:28 +00:00
|
|
|
else:
|
2008-05-11 18:53:46 +00:00
|
|
|
value = self.substitute(value, vars)
|
|
|
|
entry[key] = value
|
|
|
|
return entry
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2008-05-11 18:45:11 +00:00
|
|
|
def process_packages(self, entries, vars):
|
|
|
|
return [self.process_package(i, vars) for i in entries]
|
2008-05-01 07:54:28 +00:00
|
|
|
|
|
|
|
def substitute(self, s, vars):
|
|
|
|
if isinstance(s, (list, tuple)):
|
2008-05-11 18:53:46 +00:00
|
|
|
return [self.substitute(i, vars) for i in s]
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def subst(match):
|
|
|
|
return vars[match.group(1)]
|
2012-01-11 16:52:29 +00:00
|
|
|
|
2015-08-29 20:48:39 +00:00
|
|
|
return re.sub(r'@([-_a-z0-9]+)@', subst, str(s))
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-09-10 23:59:07 +00:00
|
|
|
def merge_build_depends(self, packages):
|
|
|
|
# Merge Build-Depends pseudo-fields from binary packages into the
|
|
|
|
# source package
|
|
|
|
source = packages["source"]
|
|
|
|
arch_all = PackageArchitecture("all")
|
|
|
|
for name, package in packages.items():
|
|
|
|
if name == "source":
|
|
|
|
continue
|
|
|
|
dep = package.get("Build-Depends")
|
|
|
|
if not dep:
|
|
|
|
continue
|
|
|
|
del package["Build-Depends"]
|
|
|
|
for group in dep:
|
|
|
|
for item in group:
|
|
|
|
if package["Architecture"] != arch_all and not item.arches:
|
|
|
|
item.arches = sorted(package["Architecture"])
|
|
|
|
if package.get("Build-Profiles") and not item.restrictions:
|
|
|
|
profiles = package["Build-Profiles"]
|
|
|
|
assert profiles[0] == "<" and profiles[-1] == ">"
|
|
|
|
item.restrictions = re.split(r"\s+", profiles[1:-1])
|
|
|
|
if package["Architecture"] == arch_all:
|
|
|
|
dep_type = "Build-Depends-Indep"
|
|
|
|
else:
|
|
|
|
dep_type = "Build-Depends-Arch"
|
|
|
|
if dep_type not in source:
|
|
|
|
source[dep_type] = PackageRelation()
|
|
|
|
source[dep_type].extend(dep)
|
|
|
|
|
2008-05-01 07:54:28 +00:00
|
|
|
def write(self, packages, makefile):
|
2014-01-02 22:18:35 +00:00
|
|
|
self.write_control(packages.values())
|
2008-05-01 07:54:28 +00:00
|
|
|
self.write_makefile(makefile)
|
|
|
|
|
2018-04-06 08:14:34 +00:00
|
|
|
def write_control(self, list, name='debian/control'):
|
|
|
|
self.write_rfc822(codecs.open(name, 'w', 'utf-8'), list)
|
2008-05-01 07:54:28 +00:00
|
|
|
|
2018-04-06 08:14:34 +00:00
|
|
|
def write_makefile(self, makefile, name='debian/rules.gen'):
|
|
|
|
f = open(name, 'w')
|
2008-05-01 07:54:28 +00:00
|
|
|
makefile.write(f)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def write_rfc822(self, f, list):
|
|
|
|
for entry in list:
|
2015-10-29 12:06:25 +00:00
|
|
|
for key, value in entry.items():
|
2012-01-11 18:03:27 +00:00
|
|
|
f.write(u"%s: %s\n" % (key, value))
|
2015-08-29 20:48:39 +00:00
|
|
|
f.write('\n')
|
2016-05-29 13:27:04 +00:00
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
|
2016-05-29 13:27:04 +00:00
|
|
|
def merge_packages(packages, new, arch):
|
|
|
|
for new_package in new:
|
|
|
|
name = new_package['Package']
|
|
|
|
if name in packages:
|
|
|
|
package = packages.get(name)
|
|
|
|
package['Architecture'].add(arch)
|
|
|
|
|
2018-10-01 15:22:49 +00:00
|
|
|
for field in ('Depends', 'Provides', 'Suggests', 'Recommends',
|
|
|
|
'Conflicts'):
|
2016-05-29 13:27:04 +00:00
|
|
|
if field in new_package:
|
|
|
|
if field in package:
|
|
|
|
v = package[field]
|
|
|
|
v.extend(new_package[field])
|
|
|
|
else:
|
|
|
|
package[field] = new_package[field]
|
|
|
|
|
|
|
|
else:
|
|
|
|
new_package['Architecture'] = arch
|
|
|
|
packages.append(new_package)
|