Make control.tar.gz in pkg_deb repeatable
This patch sets the mtime attribute of gzip explicitly to zero.
Python2 doesn't expose this via the tarfile module so we have to
create an explicit gzip instance.
Fixes
# limitations under the License.
"""A simple cross-platform helper to create a debian package."""
+import gzip
import hashlib
import os.path
from StringIO import StringIO
@@ -130,7 +131,8 @@ def CreateDebControl(extrafiles=None, **kwargs):
controlfile += MakeDebianControlField(fieldname, kwargs[key], values[2])
# Create the control.tar file
tar = StringIO()
- with tarfile.open('control.tar.gz', mode='w:gz', fileobj=tar) as f:
+ with gzip.GzipFile('control.tar.gz', mode='w', fileobj=tar, mtime=0) as gz:
+ with tarfile.open('control.tar.gz', mode='w', fileobj=gz) as f:
tarinfo = tarfile.TarInfo('control')
tarinfo.size = len(controlfile)
f.addfile(tarinfo, fileobj=StringIO(controlfile))
