Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/private/deb/deb.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def _pkg_deb_impl(ctx):
for d in ctx.attr.provides:
args.add("--provides", substitute_package_variables(ctx, d))

if ctx.attr.extra_control_file:
args.add("--extra_control_file", ctx.file.extra_control_file.path)
files.append(ctx.file.extra_control_file)

args.set_param_file_format("flag_per_line")
args.use_param_file("@%s", use_always = True)
ctx.actions.run(
Expand Down Expand Up @@ -400,6 +404,10 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
),
"extra_control_file": attr.label(
doc = """File with extra control fields appended verbatim to the control file.""",
allow_single_file = True,
),

# Common attributes
"out": attr.output(
Expand Down
16 changes: 14 additions & 2 deletions pkg/private/deb/make_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def MakeDebianControlField(name: str, value: str, multiline:Multiline=Multiline.
return result


def CreateDebControl(extrafiles=None, **kwargs):
def CreateDebControl(extrafiles=None, extra_control_content=None, **kwargs):
"""Create the control.tar.gz file."""
# create the control file
controlfile = u''
Expand All @@ -168,6 +168,8 @@ def CreateDebControl(extrafiles=None, **kwargs):
key = fieldname[0].lower() + fieldname[1:].replace('-', '')
if mandatory or (key in kwargs and kwargs[key]):
controlfile += MakeDebianControlField(fieldname, kwargs[key], multiline)
if extra_control_content:
controlfile += extra_control_content
# Create the control.tar file
tar = io.BytesIO()
with gzip.GzipFile('control.tar.gz', mode='w', fileobj=tar, mtime=0) as gz:
Expand Down Expand Up @@ -204,6 +206,7 @@ def CreateDeb(output,
md5sums=None,
conffiles=None,
changelog=None,
extra_control_content=None,
**kwargs):
"""Create a full debian package."""
extrafiles = OrderedDict()
Expand All @@ -227,7 +230,7 @@ def CreateDeb(output,
extrafiles['conffiles'] = ('\n'.join(conffiles) + '\n', 0o644)
if changelog:
extrafiles['changelog'] = (changelog, 0o644)
control = CreateDebControl(extrafiles=extrafiles, **kwargs)
control = CreateDebControl(extrafiles=extrafiles, extra_control_content=extra_control_content, **kwargs)

# Write the final AR archive (the deb package)
with open(output, 'wb') as f:
Expand Down Expand Up @@ -384,9 +387,17 @@ def main():
parser.add_argument(
'--changelog',
help='The changelog file (prefix item with @ to provide a path).')
parser.add_argument(
'--extra_control_file',
help='File with extra control fields to append verbatim to the control file.')
AddControlFlags(parser)
options = parser.parse_args()

extra_control_content = None
if options.extra_control_file:
with open(options.extra_control_file, 'r') as f:
extra_control_content = f.read()

CreateDeb(
options.output,
options.data,
Expand All @@ -400,6 +411,7 @@ def main():
md5sums=helpers.GetFlagValue(options.md5sums, False),
conffiles=GetFlagValues(options.conffile),
changelog=helpers.GetFlagValue(options.changelog, False),
extra_control_content=extra_control_content,
package=options.package,
version=helpers.GetFlagValue(options.version),
description=helpers.GetFlagValue(options.description),
Expand Down