From f4aae5f66f2bf204cdb700d1ed70a9cf573f2269 Mon Sep 17 00:00:00 2001 From: Ben Plotnick Date: Tue, 17 Mar 2026 22:00:19 -0400 Subject: [PATCH 1/2] Add extra_control_file attr to pkg_deb --- pkg/private/deb/deb.bzl | 8 ++++++++ pkg/private/deb/make_deb.py | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pkg/private/deb/deb.bzl b/pkg/private/deb/deb.bzl index 169b007a..82471aea 100644 --- a/pkg/private/deb/deb.bzl +++ b/pkg/private/deb/deb.bzl @@ -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( @@ -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( diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py index 967b75b5..dac5c62e 100644 --- a/pkg/private/deb/make_deb.py +++ b/pkg/private/deb/make_deb.py @@ -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'' @@ -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: @@ -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() @@ -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: @@ -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, @@ -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), From 7e4c33214c6ead3790b68b47a30b7b90065ae296 Mon Sep 17 00:00:00 2001 From: Ben Plotnick Date: Wed, 30 Sep 2026 09:07:33 -0400 Subject: [PATCH 2/2] Clarify extra control file syntax responsibility --- pkg/private/deb/deb.bzl | 3 ++- pkg/private/deb/make_deb.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/private/deb/deb.bzl b/pkg/private/deb/deb.bzl index 82471aea..caa8b6d9 100644 --- a/pkg/private/deb/deb.bzl +++ b/pkg/private/deb/deb.bzl @@ -405,7 +405,8 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""", default = [], ), "extra_control_file": attr.label( - doc = """File with extra control fields appended verbatim to the control file.""", + doc = """File with extra control fields appended verbatim to the control file. + This text is unparsed, so responsibility for correct syntax is up to the user.""", allow_single_file = True, ), diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py index dac5c62e..8fae6b7b 100644 --- a/pkg/private/deb/make_deb.py +++ b/pkg/private/deb/make_deb.py @@ -389,7 +389,9 @@ def main(): 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.') + help=('File with extra control fields to append verbatim to the control ' + 'file. This text is unparsed, so responsibility for correct syntax ' + 'is up to the user.')) AddControlFlags(parser) options = parser.parse_args()