Merge lp://staging/~afb/smart/rpmutil into lp://staging/smart

Proposed by Anders F Björklund
Status: Merged
Merge reported by: Anders F Björklund
Merged at revision: not available
Proposed branch: lp://staging/~afb/smart/rpmutil
Merge into: lp://staging/smart
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~afb/smart/rpmutil
Reviewer Review Type Date Requested Status
Smart Package Manager Team Pending
Review via email: mp+4057@code.staging.launchpad.net
To post a comment you must log in.
lp://staging/~afb/smart/rpmutil updated
850. By Anders F Björklund

add missing DIRINDEXES <duh>

851. By Anders F Björklund

make sure it's a list

852. By Anders F Björklund

add test case for filepaths

853. By Anders F Björklund

merge changes from trunk

854. By Anders F Björklund

merge changes from trunk

855. By Anders F Björklund

fix test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'smart/backends/rpm/base.py'
2--- smart/backends/rpm/base.py 2007-11-25 22:07:53 +0000
3+++ smart/backends/rpm/base.py 2009-03-02 07:43:53 +0000
4@@ -25,6 +25,7 @@
5 import zlib
6
7 from rpmver import checkdep, vercmp, splitarch, splitrelease
8+from util import archscore
9 from smart.util.strtools import isGlob
10 from smart.cache import *
11 from smart import *
12@@ -41,8 +42,6 @@
13 traceback.print_exc()
14 raise Error, _("'rpm' python module is not available")
15
16-archscore = rpm.archscore
17-
18 __all__ = ["RPMPackage", "RPMProvides", "RPMNameProvides", "RPMPreRequires",
19 "RPMRequires", "RPMUpgrades", "RPMConflicts", "RPMObsoletes",
20 "rpm", "getTS", "system_provides"]
21
22=== modified file 'smart/backends/rpm/header.py'
23--- smart/backends/rpm/header.py 2008-07-22 10:37:20 +0000
24+++ smart/backends/rpm/header.py 2009-03-02 07:43:53 +0000
25@@ -21,6 +21,7 @@
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #
28 from smart.backends.rpm.rpmver import splitarch
29+from smart.backends.rpm.util import filepaths, archscore
30 from smart.util.strtools import globdistance
31 from smart.cache import Loader, PackageInfo
32 from smart.channel import FileChannel
33@@ -120,9 +121,7 @@
34
35 def getPathList(self):
36 if self._path is None:
37- paths = self._h[rpm.RPMTAG_OLDFILENAMES]
38- if type(paths) != list:
39- paths = [paths]
40+ paths = filepaths(self._h)
41 modes = self._h[rpm.RPMTAG_FILEMODES]
42 if modes:
43 if type(modes) != list:
44@@ -196,7 +195,7 @@
45 if h[1106]: # RPMTAG_SOURCEPACKAGE
46 continue
47 arch = h[1022] # RPMTAG_ARCH
48- if rpm.archscore(arch) == 0:
49+ if archscore(arch) == 0:
50 continue
51
52 name = h[1000] # RPMTAG_NAME
53@@ -323,10 +322,8 @@
54 searcher.addResult(pkg, ratio)
55 continue
56 if searcher.path:
57- paths = h[rpm.RPMTAG_OLDFILENAMES]
58+ paths = filepaths(h)
59 if paths:
60- if type(paths) != list:
61- paths = [paths]
62 for spath, cutoff in searcher.path:
63 for path in paths:
64 _, newratio = globdistance(spath, path, cutoff, ic)
65@@ -474,9 +471,7 @@
66 h, offset = rpm.readHeaderFromFD(file.fileno())
67 bfp = self.buildFileProvides
68 while h:
69- fnlst = h[1027] # RPMTAG_OLDFILENAMES
70- if type(fnlst) != list:
71- fnlst = [fnlst]
72+ fnlst = filepaths(h)
73 for fn in fnlst:
74 fn = fndict.get(fn)
75 if fn and offset in self._offsets:
76@@ -487,9 +482,7 @@
77 def loadFileProvidesHDL(self, fndict):
78 bfp = self.buildFileProvides
79 for offset, h in enumerate(self._hdl):
80- fnlst = h[1027] # RPMTAG_OLDFILENAMES
81- if type(fnlst) != list:
82- fnlst = [fnlst]
83+ fnlst = filepaths(h)
84 for fn in fnlst:
85 fn = fndict.get(fn)
86 if fn and offset in self._offsets:
87@@ -677,9 +670,7 @@
88 iface.error("%s: %s" % (os.path.basename(filepath), e))
89 else:
90 file.close()
91- fnlst = h[1027] # RPMTAG_OLDFILENAMES
92- if type(fnlst) != list:
93- fnlst = [fnlst]
94+ fnlst = filepaths(h)
95 for fn in fnlst:
96 fn = fndict.get(fn)
97 if fn:
98
99=== modified file 'smart/backends/rpm/metadata.py'
100--- smart/backends/rpm/metadata.py 2008-08-02 15:07:10 +0000
101+++ smart/backends/rpm/metadata.py 2009-03-02 07:43:53 +0000
102@@ -22,6 +22,7 @@
103 #
104 from smart.cache import PackageInfo, Loader
105 from smart.backends.rpm.base import *
106+from smart.backends.rpm.util import *
107
108 try:
109 from xml.etree import cElementTree
110@@ -172,7 +173,7 @@
111 skip = None
112
113 elif tag == ARCH:
114- if rpm.archscore(elem.text) == 0:
115+ if archscore(elem.text) == 0:
116 skip = PACKAGE
117 else:
118 arch = elem.text
119
120=== modified file 'smart/backends/rpm/redcarpet.py'
121--- smart/backends/rpm/redcarpet.py 2006-11-07 22:22:46 +0000
122+++ smart/backends/rpm/redcarpet.py 2009-03-02 07:43:53 +0000
123@@ -21,6 +21,7 @@
124 #
125 from smart.cache import PackageInfo, Loader
126 from smart.backends.rpm.base import *
127+from smart.backends.rpm.util import *
128 from smart import *
129 import posixpath
130 import locale
131@@ -191,7 +192,7 @@
132 self._release = data
133
134 def handleArchEnd(self, name, attrs, data):
135- if rpm.archscore(data) == 0:
136+ if archscore(data) == 0:
137 self._skip = self.PACKAGE
138 else:
139 self._arch = data
140
141=== modified file 'smart/backends/rpm/synthesis.py'
142--- smart/backends/rpm/synthesis.py 2006-11-07 22:22:46 +0000
143+++ smart/backends/rpm/synthesis.py 2009-03-02 07:43:53 +0000
144@@ -23,6 +23,7 @@
145 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
146 #
147 from smart.backends.rpm.rpmver import splitarch
148+from smart.backends.rpm.util import archscore
149 from smart.cache import PackageInfo, Loader
150 from smart.backends.rpm.base import *
151 from smart import *
152@@ -165,7 +166,7 @@
153 version, arch = version[:dot], version[dot+1:]
154 versionarch = "@".join((version, arch))
155
156- if rpm.archscore(arch) == 0:
157+ if archscore(arch) == 0:
158 continue
159
160 name = "-".join(rpmnameparts[0:-2])
161
162=== added file 'smart/backends/rpm/util.py'
163--- smart/backends/rpm/util.py 1970-01-01 00:00:00 +0000
164+++ smart/backends/rpm/util.py 2009-03-02 07:43:53 +0000
165@@ -0,0 +1,49 @@
166+#
167+# Copyright (c) 2005 Canonical
168+#
169+# Written by Anders F Bjorklund <afb@users.sourceforge.net>
170+#
171+# This file is part of Smart Package Manager.
172+#
173+# Smart Package Manager is free software; you can redistribute it and/or
174+# modify it under the terms of the GNU General Public License as published
175+# by the Free Software Foundation; either version 2 of the License, or (at
176+# your option) any later version.
177+#
178+# Smart Package Manager is distributed in the hope that it will be useful,
179+# but WITHOUT ANY WARRANTY; without even the implied warranty of
180+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
181+# General Public License for more details.
182+#
183+# You should have received a copy of the GNU General Public License
184+# along with Smart Package Manager; if not, write to the Free Software
185+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
186+#
187+import rpm
188+
189+archscores = {}
190+
191+def archscore(arch):
192+ if not arch in archscores:
193+ try:
194+ archscores[arch] = rpm.archscore(arch)
195+ except AttributeError:
196+ # rpm.archscore missing from RPM 4.4.7 and 5.0.0
197+ # (but available from 4.4.9 and 5.0.3, and later,
198+ # using PlatformScore rather than MachineScore)
199+ archscores[arch] = 1
200+ return archscores[arch]
201+
202+def filepaths(h):
203+ paths = h[rpm.RPMTAG_OLDFILENAMES]
204+ if not paths:
205+ dirs = h[rpm.RPMTAG_DIRNAMES]
206+ base = h[rpm.RPMTAG_BASENAMES]
207+ paths = []
208+ for i in range(0,len(dirs)):
209+ paths.append(dirs[i] + base[i])
210+ elif type(paths) != list:
211+ paths = [paths]
212+ return paths
213+
214+# vim:ts=4:sw=4:et
215
216=== modified file 'smart/backends/rpm/yast2.py'
217--- smart/backends/rpm/yast2.py 2007-10-08 01:42:30 +0000
218+++ smart/backends/rpm/yast2.py 2009-03-02 07:43:53 +0000
219@@ -22,6 +22,7 @@
220 from smart.backends.rpm.rpmver import splitarch
221 from smart.cache import PackageInfo, Loader
222 from smart.backends.rpm.base import *
223+from smart.backends.rpm.util import *
224 from smart import *
225 import posixpath
226 import locale
227@@ -188,7 +189,7 @@
228 raise Error("Error loading YaST2 channel info. Possibly " \
229 "corrupted file.\n%s" % self._pkginfofile)
230
231- if rpm.archscore(arch) <= 0:
232+ if archscore(arch) <= 0:
233 return
234 name = nameparts[0]
235 self.curpkgname = name

Subscribers

People subscribed via source and target branches