1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import getopt
import gzip
import errno
import simplejson
import patchtracker.Conf as Conf
from patchtracker.SourceArchive import Archive, SourcePackage
from patchtracker.DB import PatchTrackerDB
from patchtracker.PtsIndex import PtsIndexFile
if __name__ == '__main__':
db = PatchTrackerDB()
os.system("cheetah compile templates/skeleton")
opts,args = getopt.getopt(sys.argv[1:], "ais:p:")
suites = None
packages = None
update_archive = False
gen_pts_index = False
for o,v in opts:
if o == "-s":
suites = v.split(',')
elif o == "-p":
packages = v.split(',')
elif o == "-a":
update_archive = True
elif o == "-i":
gen_pts_index = True
if update_archive:
os.system("env PYTHONPATH=%s reprepro -b %s --confdir ./reprepro/conf update"%
(os.path.dirname(os.path.realpath(sys.argv[0])),
Conf.archive_root,))
a = Archive(Conf.archive_root, suitefilter=suites, pkgfilter=packages)
pts_idx = PtsIndexFile()
print a
for s in a.suites(filter=suites):
print "suite: ",s
db.saveSuite(s)
for c in a.components(s):
print "\tcomponent:",c
db.saveComponent(c)
for p in a.sourcepackages(s, c, filter=packages):
print "\t\tpackage:",p
db.saveSourcePackage(p)
db.relateSourcePackage(name=p.name, version=p.version, suite=s,
component=c)
if gen_pts_index:
pts_idx.add(p)
if gen_pts_index:
pts_fh = gzip.GzipFile(Conf.pts_index_file, mode="wb")
simplejson.dump(pts_idx, pts_fh)
pts_fh.close()
db.prune()
db.unmark()
db.finalize()
|