-
Notifications
You must be signed in to change notification settings - Fork 7
/
find-obsolete-debug-packages
executable file
·102 lines (69 loc) · 2.68 KB
/
find-obsolete-debug-packages
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#
# A script to find debug packages of obsoleted packages. Give distro version
# as parameter to the script for other distro releases.
#
#
import sys
import urllib
import lzma
import bz2
import piksemel
repoOf = {'2009' : 'http://packages.pardus.org.tr/pardus-2009-debug/pisi-index.xml.bz2',
'2011' : 'http://packages.pardus.org.tr/pardus/2011/devel/x86_64-debug/pisi-index.xml.xz',
'2011-i686' : 'http://packages.pardus.org.tr/pardus/2011/devel/i686-debug/pisi-index.xml.xz',
'Corporate2' : 'http://packages.pardus.org.tr/pardus/corporate2/devel/x86_64-debug/pisi-index.xml.xz',
'Corporate2-i686' : 'http://packages.pardus.org.tr/pardus/corporate2/devel/i686-debug/pisi-index.xml.xz'
}
def fail(message):
print message
sys.exit(1)
def downloadFile(_url):
global data
try:
response = urllib.urlopen(_url)
except IOError:
fail("Could not connect to %s" % _url)
data = response.read()
response.close()
def getDocument():
global document
if url.endswith("xz"):
cmp_data = lzma.decompress( data )
elif url.endswith("bz2"):
cmp_data = bz2.decompress( data )
else:
fail("not support filetype %s for decompress" % url.rsplit(".", 1)[1])
document = piksemel.parseString(cmp_data)
def getObsoletePackageList():
global document
obsolete_package_list = []
package_elements = document.getTag("Distribution").getTag("Obsoletes").tags("Package")
for package in package_elements:
package_name = package.firstChild().data()
obsolete_package_list.append( package_name )
return obsolete_package_list
if __name__ == "__main__":
data = None
document = None
if len(sys.argv) != 2 :
print "Usage: %s PardusRelease\n\nFinds obsolete debug packages in PardusRelease (which is one of %s)" % (sys.argv[0], ', '.join(sorted(repoOf.keys())))
sys.exit()
else:
which_release = sys.argv[1]
if which_release in repoOf.keys():
url = repoOf.get(which_release)
else:
fail("Could not find release %s\nknown releases are %s\n" % (which_release, ", ".join(repoOf.keys())))
downloadFile(url)
getDocument()
obsolete_package_list = getObsoletePackageList()
package_elements = document.tags( "Package" )
for package in package_elements:
package_src_name = package.getTag( "Source" ).getTagData( "Name" ) #kdeutils
package_name = package.getTagData("Name") # kdeutils-kwallet-dbginfo
if package_name.replace("-dbginfo", "") in obsolete_package_list:
packageURI = package.getTagData( "PackageURI" )
print packageURI