[python] deb maker code fix cleanup help with?
well, i've been using python to develop app that will pack deb files, but, issue is that i want to do it on my way:
create digisigsums and md5sums in control/ then pack control/ and data/ into control.tar.gz & data.tar.gz and then assemble all into .ar
but seems like making tgz's is not as it should be...:S
so, i would really need someone's help here :)
here's raw code:
Code:
import os, time
import tarfile as tf
print "tar.gz-ing :D"
tmp = "temp/"
if os.path.exists(tmp):
pass
else:
os.mkdir(tmp)
datafle = "data.tar.gz"
controlfle = "control.tar.gz"
blacklist = ["Thumbs.db", "desktop.ini"]
blacklistlnk = ".lnk"
def getfiles(a, dirx, files):
for inn in files:
if len(dirx) >= 1: # this part is created because we need to chdir into data and into control to collect files into archive
pth=dirx+"/"
else:
pth = dirx +"/"
if os.path.isfile(pth+inn):
if inn in blacklist:
print "skipping " + pth+inn
else:
if inn.endswith(blacklistlnk):
print "skipping " + pth+inn
else:
print pth+inn
tar.add(pth+inn)
# create data.tar.bz
os.chdir("temp")
tar = tf.open(datafle, "w:gz")
os.chdir("../data/")
# tar.add("") #should do job?, but there's .db and .ini files that's hidden, under win32 so we'll do my way :D
os.path.walk("", getfiles, None)
tar.close()
os.chdir("..")
# create control.tar.bz
os.chdir("temp")
tar = tf.open(controlfle, "w:gz")
os.chdir("../control/")
os.path.walk("", getfiles, None)
tar.close()
os.chdir("..")
|