~ubuntu-branches/ubuntu/jaunty/yum/jaunty

« back to all changes in this revision

Viewing changes to repomd/test.py

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2008-07-28 23:20:59 UTC
  • mfrom: (2.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080728232059-24lo1r17smhr71l8
Tags: 3.2.12-1.2
* Non-maintainer upload
* Updated for compatibility with current python-pyme (Closes: #490368)
  based on patch by Martin Meredith <mez@ubuntu.com>
  - Changed import in yum/misc.py
  - Set versioned dependency on python-pyme

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python -tt
2
 
# This program is free software; you can redistribute it and/or modify
3
 
# it under the terms of the GNU General Public License as published by
4
 
# the Free Software Foundation; either version 2 of the License, or
5
 
# (at your option) any later version.
6
 
#
7
 
# This program is distributed in the hope that it will be useful,
8
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
# GNU Library General Public License for more details.
11
 
#
12
 
# You should have received a copy of the GNU General Public License
13
 
# along with this program; if not, write to the Free Software
14
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
 
# Copyright 2003 Duke University
16
 
 
17
 
# classes for parsing the metadata files for the new metadata format
18
 
 
19
 
 
20
 
# used with python -i :)
21
 
import sys
22
 
import os
23
 
import time
24
 
import rpm
25
 
import packageSack
26
 
import packageObject
27
 
import repoMDObject
28
 
import mdUtils
29
 
import mdErrors
30
 
 
31
 
 
32
 
def process(current, total):
33
 
    sys.stdout.write('\r' + ' ' * 80)
34
 
    sys.stdout.write('\rNode %d of %d' % (current, total))
35
 
    sys.stdout.flush()
36
 
 
37
 
if len(sys.argv) < 4:
38
 
    print 'test.py: /path/to/repo /other/repo somepackagename'
39
 
    sys.exit(1)
40
 
   
41
 
print time.time()
42
 
repos = sys.argv[1:3]
43
 
pkgSack = packageSack.XMLPackageSack(packageObject.RpmXMLPackageObject)
44
 
numid = 0
45
 
for repo in repos:
46
 
    numid+=1
47
 
    basepath = repo
48
 
    repomdxmlfile = os.path.join(basepath, 'repodata/repomd.xml')
49
 
    repoid = repo
50
 
 
51
 
    try:
52
 
        repodata = repoMDObject.RepoMD(repoid, repomdxmlfile)
53
 
    except mdErrors.RepoMDError, e:
54
 
        print >> sys.stderr, e
55
 
        sys.exit(1)
56
 
    
57
 
    (pbase, phref) = repodata.primaryLocation()
58
 
    (fbase, fhref) = repodata.filelistsLocation()
59
 
    (obase, ohref) = repodata.otherLocation()
60
 
    
61
 
    
62
 
    processlist = [phref]
63
 
    for file in processlist:
64
 
        print time.time()
65
 
        print 'importing %s from %s' % (file, repoid)
66
 
        complete = basepath + '/' + file
67
 
        try:
68
 
            pkgSack.addFile(repoid, complete, process)
69
 
        except mdErrors.PackageSackError, e:
70
 
            print >> sys.stderr, e
71
 
            sys.exit(1)
72
 
            
73
 
    print ' '
74
 
    print time.time()
75
 
 
76
 
for pkg in pkgSack.searchNevra(sys.argv[3]):
77
 
    print pkg
78
 
    for reqtup in pkg.returnPrco('requires'):
79
 
        (reqn, reqf, (reqe,reqv,reqr)) = reqtup
80
 
        # rpmlib deps should be handled on their own
81
 
        if reqn[:6] == 'rpmlib':
82
 
            continue
83
 
        # kill self providers, too
84
 
        if pkg.checkPrco('provides', reqtup):
85
 
            continue
86
 
            
87
 
        # get a list of all pkgs that match the reqn
88
 
        providers = pkgSack.searchProvides(reqn)
89
 
        if len(providers) == 0:
90
 
            print 'unresolved: %s  %s %s:%s-%s' % (reqn, reqf, reqe, reqv, reqr)
91
 
            continue
92
 
 
93
 
        if len(providers) == 1:
94
 
            if reqf is None:
95
 
                print '%s: %s from %s' % (reqn, providers[0], providers[0].returnSimple('relativepath'))
96
 
                continue
97
 
 
98
 
            # only one entry but we need to match out it out
99
 
            if providers[0].checkPrco('provides', reqtup):
100
 
                print '%s: %s from %s' % (reqn, providers[0], providers[0].returnSimple('relativepath'))
101
 
                continue
102
 
 
103
 
        
104
 
        output = '%s:' % reqn
105
 
        for prov in providers:
106
 
            if reqf is not None:
107
 
                if prov.checkPrco('provides', reqtup):
108
 
                    output = output + '||' + prov.__str__()
109
 
                else:
110
 
                    print '%s does not provide %s %s %s %s %s' % (prov, reqn, reqf, reqe, reqv, reqr)                
111
 
            else:
112
 
                output = output + '||' + prov.__str__()
113
 
                
114
 
        print output
115
 
print time.time()
116