[Yum] Re: Recreating headers yields different files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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;
done)

					-Michael

-- 
  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner@xxxxxxxxxxxx
  Box 90305, Durham N.C. 27708-0305

--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gzip_notimestamp.py"

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
        self.fileobj.write(chr(flags))
        #write32u(self.fileobj, long(time.time()))
        write32u(self.fileobj, long(0))
        self.fileobj.write('\002')
        self.fileobj.write('\377')
        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')
        fo.write(data)
        fo.close()
        shutil.copyfile(tf, fn)

--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="null_gzip_ts.py"

#!/usr/bin/python

# 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
    fo.seek(0)
    magic = fo.read(2)
    if not magic == '\037\213':
        print 'skipping non-gzip file: %s' % filename
        continue
    
    # now null the timestamp
    fo.seek(4)
    fo.write('\000' * 4)
    fo.close()

--mP3DRpeJDSE+ciuQ--


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux