def CreateDebControl()

in pkg/private/deb/make_deb.py [0:0]


def CreateDebControl(extrafiles=None, **kwargs):
  """Create the control.tar.gz file."""
  # create the control file
  controlfile = u''
  for values in DEBIAN_FIELDS:
    fieldname = values[0]
    key = fieldname[0].lower() + fieldname[1:].replace('-', '')
    if values[1] or (key in kwargs and kwargs[key]):
      controlfile += MakeDebianControlField(fieldname, kwargs[key], values[2])
  # Create the control.tar file
  tar = io.BytesIO()
  with gzip.GzipFile('control.tar.gz', mode='w', fileobj=tar, mtime=0) as gz:
    with tarfile.open('control.tar.gz', mode='w', fileobj=gz,
                      format=tarfile.GNU_FORMAT) as f:
      tarinfo = tarfile.TarInfo('./control')
      control_file_data = controlfile.encode('utf-8')
      tarinfo.size = len(control_file_data)
      f.addfile(tarinfo, fileobj=io.BytesIO(control_file_data))
      if extrafiles:
        for name, (data, mode) in extrafiles.items():
          tarinfo = tarfile.TarInfo('./' + name)
          data_encoded = data.encode('utf-8')
          tarinfo.size = len(data_encoded)
          tarinfo.mode = mode
          f.addfile(tarinfo, fileobj=io.BytesIO(data_encoded))
  control = tar.getvalue()
  tar.close()
  return control