[Yum] Re: Recreating headers yields different files

Michael Stenner mstenner at phy.duke.edu
Tue Apr 29 15:50:25 UTC 2003

Regarding gzip and timestamps:

On Mon, Apr 28, 2003 at 10:54:05PM -0400, seth vidal wrote:
> it can be and if it can be done nicely in the code I will, but I don't
> think it can be done that cleanly at the moment.

I talked with seth about this a little.  It is possible to do this in
the yum code, but not cleanly.  The added complexity is probably not
worth the modest benefit.  In case it's useful to anyone, I'm
including a file that subclasses the gzip stuff and writes files with
a null timestamp.

I'm also including a short script which nulls the timestamps in
existing gzip files.   You should be able to do a 
  null_gzip_ts.py *.hdr

In your headers dir after each rebuild.  (there may be buffer length
issues requiring you do  for file in *.hdr; do null_gzip_ts.py $file;


  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner at phy.duke.edu
  Box 90305, Durham N.C. 27708-0305
-------------- next part --------------
import gzip
from gzip import write32u, FNAME

__all__ = ["GzipFile","open"]

class GzipFile(gzip.GzipFile):
    def _write_gzip_header(self):
        self.fileobj.write('\037\213')             # magic header
        self.fileobj.write('\010')                 # compression method
        fname = self.filename[:-3]
        flags = 0
        if fname:
            flags = FNAME
        #write32u(self.fileobj, long(time.time()))
        write32u(self.fileobj, long(0))
        if fname:
            self.fileobj.write(fname + '\000')

def open(filename, mode="rb", compresslevel=9):
    return GzipFile(filename, mode, compresslevel)

if __name__ == '__main__':
    import shutil
    tf = 'tmpfile'
    data = '01234567890abcdefghijklmnopqrstuvwxyz\n'
    #data = ''
    for i in range(10):
        fn = 'gzip_test_%i' % i
        fo = open(tf, 'wb')
        shutil.copyfile(tf, fn)
-------------- next part --------------

# take a list of gzipped files and null their timestamps:
#    null_gzip_tz.py file1.gz file2.gz

import sys
for filename in sys.argv[1:]:
    fo = open(filename, 'r+')
    # first check to see if it's a gzipped file
    magic = fo.read(2)
    if not magic == '\037\213':
        print 'skipping non-gzip file: %s' % filename
    # now null the timestamp
    fo.write('\000' * 4)

More information about the Yum mailing list