-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuilddepfaker
executable file
·71 lines (61 loc) · 1.91 KB
/
builddepfaker
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
66
67
68
69
70
71
#!/usr/bin/python3
import deb822
import sys
#f = open("/home/repo/private/private/conf/fakebuilddeps")
f = open(sys.argv[1])
fakelines = f.readlines()
f.close()
fakedepdict = {}
for fakeline in fakelines:
if ':' in fakeline:
(package, fakedeps) = fakeline.split(':',1)
fakedeps = fakedeps.split(',')
positive = set()
negative = set()
if (package in fakedepdict):
(negative,positive) = fakedepdict[package]
for fakedep in fakedeps:
fakedep = fakedep.strip()
if (fakedep[0] == '!'):
negative.add(fakedep[1:])
else:
positive.add(fakedep)
fakedepdict[package] = (negative,positive)
#print(repr(fakedepdict))
#exit()
#f = open("/home/repo/private/private/dists/buster-staging/main/source/Sources")
f = open(sys.argv[2])
#fakelist = ()
for entry in deb822.Sources.iter_paragraphs(f):
package = entry['Package'];
if (package in fakedepdict):
(negative,positive) = fakedepdict[package]
#if package == 'gcc-6':
# sys.stderr.write(repr((negative,positive)))
builddeps = []
if 'Build-Depends' in entry:
builddeps = entry['Build-Depends'].split(',')
processedbuilddeps = []
for depstr in builddeps:
depname = depstr.lstrip().split(' ')[0].split(':')[0]
#if package == 'gcc-6':
# sys.stderr.write(depname+'\n')
if not (depname in negative):
processedbuilddeps.append(depstr)
#if package == 'gcc-6':
# sys.stderr.write(depname+' output\n')
positive.discard(depname)
for depstr in positive:
processedbuilddeps.append(' '+depstr+' (!= 0.fake.0)')
entry['Build-Depends'] = ','.join(processedbuilddeps)
if 'Build-Depends-Indep' in entry:
builddeps = entry['Build-Depends-Indep'].split(',')
processedbuilddeps = []
for depstr in builddeps:
depname = depstr.lstrip().split(' ')[0]
#print(depname)
if not (depname in negative):
processedbuilddeps.append(depstr)
entry['Build-Depends-Indep'] = ','.join(processedbuilddeps)
print(entry)
f.close()