import sys, os, tempfile
import apt_pkg
-import bz2, gzip, time
from daklib import utils
################################################################################
if os.path.isfile(file):
f = open(file, "r")
elif os.path.isfile("%s.gz" % file):
- f = decompressors[ 'zcat' ]( file )
+ f = create_temp_file(os.popen("zcat %s.gz" % file, "r"))
elif os.path.isfile("%s.bz2" % file):
- f = decompressors[ 'bzcat' ]( file )
+ f = create_temp_file(os.popen("bzcat %s.bz2" % file, "r"))
else:
f = None
return f
for h in l:
out.write(" %s %7d %s\n" % (hs[h][1][0], hs[h][1][1], h))
-decompressors = { 'zcat' : gzip.GzipFile,
- 'bzip2' : bz2.BZ2File }
+def create_temp_file(r):
+ f = tempfile.TemporaryFile()
+ while 1:
+ x = r.readline()
+ if not x: break
+ f.write(x)
+ r.close()
+ del x,r
+ f.flush()
+ f.seek(0)
+ return f
def sizesha1(f):
size = os.fstat(f.fileno())[6]
if not Options.has_key("PatchName"):
format = "%Y-%m-%d-%H%M.%S"
- Options["PatchName"] = time.strftime( format )
+ i,o = os.popen2("date +%s" % (format))
+ i.close()
+ Options["PatchName"] = o.readline()[:-1]
+ o.close()
AptCnf = apt_pkg.newConfiguration()
apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file())