Mal richtig schnell ein kleines Python-Script geschrieben, welches die Paket-Datenban...
[people/pmueller/ipfire-2.x.git] / tools / make_pkg_list.py
CommitLineData
76c87b23
MT
1#!/usr/bin/python
2
3import sys
4import os
5
6def usage():
7 print '''Usage:
8 $0 <dir>
9 Where <dir> is the path to the metas.'''
10
11if len(sys.argv) < 2:
12 usage()
13 sys.exit()
14
15dir = sys.argv[1]
16
17if not os.path.exists(dir):
18 print dir, "doesn't exist."
19 usage()
20 sys.exit()
21
22dst = file(dir+"/packages_list.db", "w")
23
24for i in os.listdir(dir):
25 if not os.path.isfile(dir+"/"+i):
26 print "Is a directory", i
27 continue
28
29 if not i.startswith('meta-'):
30 print "Is no meta file", i
31 continue
32
33 src = file(dir+"/"+i)
34 for i in src.readlines():
35 i = i.rstrip("\n")
36 if i.startswith("Name:"):
37 trash,name = i.split(": ")
38 elif i.startswith("Version:"):
39 trash,ver = i.split(": ")
40 elif i.startswith("Release:"):
41 trash,rel = i.split(": ")
42 elif i.startswith("Size:"):
43 trash,size = i.split(": ")
44
45 src.close()
46
47 dst.write(name+";"+ ver +";"+ rel +";"+ size +";\n")
48
49dst.close()