gencontrol.py: Change substitute_file() from local function to method
We will need to use it in multiple methods of Gencontrol.
This commit is contained in:
parent
9bbc2cf793
commit
eaff86e9e2
|
@ -16,7 +16,6 @@ from debian_linux.debian import *
|
||||||
from debian_linux.gencontrol import Gencontrol as Base
|
from debian_linux.gencontrol import Gencontrol as Base
|
||||||
from debian_linux.utils import Templates, read_control
|
from debian_linux.utils import Templates, read_control
|
||||||
|
|
||||||
|
|
||||||
class Gencontrol(Base):
|
class Gencontrol(Base):
|
||||||
config_schema = {
|
config_schema = {
|
||||||
'abi': {
|
'abi': {
|
||||||
|
@ -64,6 +63,10 @@ class Gencontrol(Base):
|
||||||
if src in data or not optional:
|
if src in data or not optional:
|
||||||
makeflags[dst] = data[src]
|
makeflags[dst] = data[src]
|
||||||
|
|
||||||
|
def _substitute_file(self, template, vars, target, append=False):
|
||||||
|
with codecs.open(target, 'a' if append else 'w', 'utf-8') as f:
|
||||||
|
f.write(self.substitute(self.templates[template], vars))
|
||||||
|
|
||||||
def do_main_setup(self, vars, makeflags, extra):
|
def do_main_setup(self, vars, makeflags, extra):
|
||||||
super(Gencontrol, self).do_main_setup(vars, makeflags, extra)
|
super(Gencontrol, self).do_main_setup(vars, makeflags, extra)
|
||||||
makeflags.update({
|
makeflags.update({
|
||||||
|
@ -453,25 +456,21 @@ class Gencontrol(Base):
|
||||||
|
|
||||||
# Substitute kernel version etc. into maintainer scripts,
|
# Substitute kernel version etc. into maintainer scripts,
|
||||||
# translations and lintian overrides
|
# translations and lintian overrides
|
||||||
def substitute_file(template, target, append=False):
|
self._substitute_file('headers.postinst', vars,
|
||||||
with codecs.open(target, 'a' if append else 'w',
|
'debian/linux-headers-%s%s.postinst' %
|
||||||
'utf-8') as f:
|
(vars['abiname'], vars['localversion']))
|
||||||
f.write(self.substitute(self.templates[template], vars))
|
|
||||||
substitute_file('headers.postinst',
|
|
||||||
'debian/linux-headers-%s%s.postinst' %
|
|
||||||
(vars['abiname'], vars['localversion']))
|
|
||||||
for name in ['postinst', 'postrm', 'preinst', 'prerm', 'templates']:
|
for name in ['postinst', 'postrm', 'preinst', 'prerm', 'templates']:
|
||||||
substitute_file('image.%s' % name,
|
self._substitute_file('image.%s' % name, vars,
|
||||||
'debian/linux-image-%s%s.%s' %
|
'debian/linux-image-%s%s.%s' %
|
||||||
(vars['abiname'], vars['localversion'], name))
|
(vars['abiname'], vars['localversion'], name))
|
||||||
for path in glob.glob('debian/templates/po/*.po'):
|
for path in glob.glob('debian/templates/po/*.po'):
|
||||||
substitute_file('po/' + os.path.basename(path),
|
self._substitute_file('po/' + os.path.basename(path), vars,
|
||||||
'debian/po/' + os.path.basename(path),
|
'debian/po/' + os.path.basename(path),
|
||||||
append=True)
|
append=True)
|
||||||
if build_debug:
|
if build_debug:
|
||||||
substitute_file('image-dbg.lintian-override',
|
self._substitute_file('image-dbg.lintian-override', vars,
|
||||||
'debian/linux-image-%s%s-dbg.lintian-overrides' %
|
'debian/linux-image-%s%s-dbg.lintian-overrides' %
|
||||||
(vars['abiname'], vars['localversion']))
|
(vars['abiname'], vars['localversion']))
|
||||||
|
|
||||||
def merge_packages(self, packages, new, arch):
|
def merge_packages(self, packages, new, arch):
|
||||||
for new_package in new:
|
for new_package in new:
|
||||||
|
|
Loading…
Reference in New Issue