@@ -157,7 +157,7 @@ def MakeDebianControlField(name: str, value: str, multiline:Multiline=Multiline.
157157 return result
158158
159159
160- def CreateDebControl (extrafiles = None , ** kwargs ):
160+ def CreateDebControl (extrafiles = None , extra_control_content = None , ** kwargs ):
161161 """Create the control.tar.gz file."""
162162 # create the control file
163163 controlfile = u''
@@ -168,6 +168,8 @@ def CreateDebControl(extrafiles=None, **kwargs):
168168 key = fieldname [0 ].lower () + fieldname [1 :].replace ('-' , '' )
169169 if mandatory or (key in kwargs and kwargs [key ]):
170170 controlfile += MakeDebianControlField (fieldname , kwargs [key ], multiline )
171+ if extra_control_content :
172+ controlfile += extra_control_content
171173 # Create the control.tar file
172174 tar = io .BytesIO ()
173175 with gzip .GzipFile ('control.tar.gz' , mode = 'w' , fileobj = tar , mtime = 0 ) as gz :
@@ -201,6 +203,7 @@ def CreateDeb(output,
201203 md5sums = None ,
202204 conffiles = None ,
203205 changelog = None ,
206+ extra_control_content = None ,
204207 ** kwargs ):
205208 """Create a full debian package."""
206209 extrafiles = OrderedDict ()
@@ -224,7 +227,7 @@ def CreateDeb(output,
224227 extrafiles ['conffiles' ] = ('\n ' .join (conffiles ) + '\n ' , 0o644 )
225228 if changelog :
226229 extrafiles ['changelog' ] = (changelog , 0o644 )
227- control = CreateDebControl (extrafiles = extrafiles , ** kwargs )
230+ control = CreateDebControl (extrafiles = extrafiles , extra_control_content = extra_control_content , ** kwargs )
228231
229232 # Write the final AR archive (the deb package)
230233 with open (output , 'wb' ) as f :
@@ -381,9 +384,17 @@ def main():
381384 parser .add_argument (
382385 '--changelog' ,
383386 help = 'The changelog file (prefix item with @ to provide a path).' )
387+ parser .add_argument (
388+ '--extra_control_file' ,
389+ help = 'File with extra control fields to append verbatim to the control file.' )
384390 AddControlFlags (parser )
385391 options = parser .parse_args ()
386392
393+ extra_control_content = None
394+ if options .extra_control_file :
395+ with open (options .extra_control_file , 'r' ) as f :
396+ extra_control_content = f .read ()
397+
387398 CreateDeb (
388399 options .output ,
389400 options .data ,
@@ -397,6 +408,7 @@ def main():
397408 md5sums = helpers .GetFlagValue (options .md5sums , False ),
398409 conffiles = GetFlagValues (options .conffile ),
399410 changelog = helpers .GetFlagValue (options .changelog , False ),
411+ extra_control_content = extra_control_content ,
400412 package = options .package ,
401413 version = helpers .GetFlagValue (options .version ),
402414 description = helpers .GetFlagValue (options .description ),
0 commit comments