-
Notifications
You must be signed in to change notification settings - Fork 7
/
mass-build-dependency-change
executable file
·66 lines (47 loc) · 1.26 KB
/
mass-build-dependency-change
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 -*-
#
# a small script to change build dependencies of files
# just give pspec.xml files as parameters
import os
import sys
changeFrom = "qt"
changeTo = "qt-devel"
def loadFile(_file):
try:
f = file(_file)
d = f.readlines()
f.close()
return d
except:
return []
def writeFile(fname, data):
print fname
psfile = open(fname, "w")
psfile.write(data)
psfile.close()
def updatePspec(_file):
nf = ""
change = False
for i in loadFile(_file):
if i.strip().startswith("<BuildDependencies>"):
change = True
elif i.strip().startswith("</BuildDependencies>"):
change = False
if change and "<Dependency" in i and ">%s</Dependency>" % changeFrom in i:
i = i.replace(">%s<" % changeFrom, ">%s<" % changeTo)
change = False
nf += "%s" % i
writeFile(_file, nf)
def usage():
print "usage :"
print " %s <pspec.xml files to change ....>" % sys.argv[0]
print
if __name__ == "__main__":
""" tikkat main var basmain """
if len(sys.argv) < 2:
usage()
sys.exit(1)
packages = sys.argv[1:]
for i in packages:
updatePspec(i.rstrip("\n"))