4 import sys, os.path, gzip, subprocess
5 #from debian_bundle import deb822
9 def check_source(ok, srcs, fw):
13 f = subprocess.Popen("zcat %s" % (f), shell=True, stdout=subprocess.PIPE).stdout
14 pkg = apt_pkg.ParseTagFile(f)
16 if not pkg.Section.get('Package'): continue
17 if pkg.Section.get('Section','').startswith('non-free'):
18 if pkg.Section.get('Autobuild') != 'yes': continue
19 if pkg.Section['Package'] not in ok: continue
20 ret += [pkg.Section['Package']]
21 fw.write(str(pkg.Section))
27 def check_binary(ok, bins, fw):
29 f = subprocess.Popen("zcat %s" % (f), shell=True, stdout=subprocess.PIPE).stdout
30 pkg = apt_pkg.ParseTagFile(f)
32 if pkg.Section.get('Source', pkg.Section.get('Package')).split(" ")[0] not in ok: continue
33 fw.write(str(pkg.Section))
38 def outfile(name, file):
39 #return open(dir + "/" + os.path.basename(file), "w")
40 #return open(file + name, "w")
41 if file.endswith(name): return open(file[:-len(name)], "w")
43 def replarch(arch, pkgs):
44 return [ x.replace('%ARCH%', arch) for x in pkgs ]
48 # /org/wanna-build/etc/non-free-include-list "arch1 arch2" write-sources write-packages Sources* . Packages*
49 if len(sys.argv) <= 4:
50 print "Error - too few args"
53 oklist = [ x[:-1].split(' ')[0] for x in open(sys.argv[1]) ]
54 #outsrcs = open(sys.argv[3], "w")
58 print "need both Sources and Packages"
60 src = rem[:rem.index('.')]
61 bin = rem[rem.index('.')+1:]
62 if not src or not bin:
63 print "need non-empty Sources and Packages"
65 okpkgs = check_source(oklist, src, open(sys.argv[3], "w"))
67 for arch in sys.argv[2].split(" "):
68 check_binary(okpkgs, replarch(arch, bin), open(replarch(arch, [sys.argv[4]])[0], "w"))
70 if __name__ == '__main__':