82
81
assert self._depcache.BrokenCount == 0 and self._depcache.DelCount == 0
83
82
self._depcache.Upgrade()
85
def _has_ver_with_not_automatic_origin(self, pkg):
87
internal helper that checks if one pkg version has the
90
for ver in pkg._pkg.VersionList:
91
for (verFileIter, index) in ver.FileList:
92
if verFileIter.NotAutomatic:
95
def notAutomaticUpgradable(self, pkg):
97
check if 'pkg' is upgradable but has the 'NotAutomatic' flag
99
if ( pkg.isInstalled and
100
not pkg.isUpgradable and
101
pkg.candidateOrigin and
102
self._has_ver_with_not_automatic_origin(pkg)
104
# now check if there is a higher NotAutomatic version
105
candVer = pkg._depcache.GetCandidateVer(pkg._pkg)
106
for ver in pkg._pkg.VersionList:
107
if apt_pkg.VersionCompare(ver.VerStr, candVer.VerStr) > 0:
110
def markUpgradeInstall(self, pkg):
112
mark package for upgrade/install. we have a special version
113
here because update-manager deals with NotAutomatic by
114
explictely selecting it if there is no candidate already
116
# handle NotAutomatic: yes packages special
117
if self.notAutomaticUpgradable(pkg):
118
for ver in pkg._pkg.VersionList:
119
print "looking at: ", ver
120
for (verFileIter, index) in ver.FileList:
121
if verFileIter.NotAutomatic:
122
print "setting candidate ver: ", ver
123
pkg._depcache.SetCandidateVer(pkg._pkg, ver)
124
print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
125
pkg._depcache.MarkInstall(pkg._pkg)
126
print "new cand: ", pkg._depcache.GetCandidateVer(pkg._pkg)
129
print pkg.markedInstall
130
print pkg.markedUpgrade
132
84
def matchPackageOrigin(self, pkg, matcher):
133
85
""" match 'pkg' origin against 'matcher', take versions between
134
86
installedVersion and candidateVersion into account too
191
134
if srcpkg.startswith("lib"):
192
135
prefix = "lib" + srcpkg[3]
194
uri = CHANGELOGS_URI % (src_section,prefix,srcpkg,srcpkg, srcver, fname)
195
# print "Trying: %s " % uri
196
changelog = urllib2.urlopen(uri)
197
#print changelog.read()
198
# do only get the lines that are new
200
regexp = "^%s \((.*)\)(.*)$" % (re.escape(srcpkg))
204
line = changelog.readline()
207
match = re.match(regexp,line)
209
# strip epoch from installed version
210
# and from changelog too
211
installed = pkg.installedVersion
212
if installed and ":" in installed:
213
installed = installed.split(":",1)[1]
214
changelogver = match.group(1)
215
if changelogver and ":" in changelogver:
216
changelogver = changelogver.split(":",1)[1]
217
# we test for "==" here for changelogs
218
# to ensure that the version
219
# is actually really in the changelog - if not
220
# just display it all, this catches cases like:
221
# gcc-defaults with "binver=4.3.1" and srcver=1.76
223
# for NEWS.Debian we do require the changelogver > installed
224
if strict_versioning:
226
apt_pkg.VersionCompare(changelogver,installed)<0):
137
# stip epoch, but save epoch for later when displaying the
138
# launchpad changelog
139
srcver_epoch = srcver
140
l = string.split(srcver,":")
142
srcver = "".join(l[1:])
145
uri = CHANGELOGS_URI % (src_section,prefix,srcpkg,srcpkg, srcver)
146
# print "Trying: %s " % uri
147
changelog = urllib2.urlopen(uri)
148
#print changelog.read()
149
# do only get the lines that are new
151
regexp = "^%s \((.*)\)(.*)$" % (re.escape(srcpkg))
155
line = changelog.readline()
158
match = re.match(regexp,line)
160
# strip epoch from installed version
161
# and from changelog too
162
installed = pkg.installedVersion
163
if installed and ":" in installed:
164
installed = installed.split(":",1)[1]
165
changelogver = match.group(1)
166
if changelogver and ":" in changelogver:
167
changelogver = changelogver.split(":",1)[1]
168
# we test for "==" here to ensure that the version
169
# is actually really in the changelog - if not
170
# just display it all, this catches cases like:
171
# gcc-defaults with "binver=4.3.1" and srcver=1.76
229
172
if (installed and
230
173
apt_pkg.VersionCompare(changelogver,installed)==0):
232
alllines = alllines + line
235
def get_news_and_changelog(self, name, lock):
237
self.get_changelog(name)
240
def get_news(self, name):
241
" get the NEWS.Debian file from the changelogs location "
243
news = self._get_changelog_or_news(name, "NEWS.Debian", True)
247
self.all_news[name] = news
249
def get_changelog(self, name):
250
" get the changelog file from the changelog location "
251
srcpkg = self[name].sourcePackageName
252
srcver_epoch = self[name].candidateVersion
254
changelog = self._get_changelog_or_news(name, "changelog")
255
if len(changelog) == 0:
256
changelog = _("The changelog does not contain any relevant changes.\n\n"
257
"Please use http://launchpad.net/ubuntu/+source/%s/%s/+changelog\n"
258
"until the changes become available or try again "
259
"later.") % (srcpkg, srcver_epoch)
175
alllines = alllines + line
177
# Print an error if we failed to extract a changelog
178
if len(alllines) == 0:
179
alllines = _("The changelog does not contain any relevant changes.\n\n"
180
"Please use http://launchpad.net/ubuntu/+source/%s/%s/+changelog\n"
181
"until the changes become available or try again "
182
"later.") % (srcpkg, srcver_epoch),
183
# only write if we where not canceld
185
self.all_changes[name] = [alllines, srcpkg]
260
186
except urllib2.HTTPError, e:
261
changelog = _("The list of changes is not available yet.\n\n"
262
"Please use http://launchpad.net/ubuntu/+source/%s/%s/+changelog\n"
263
"until the changes become available or try again "
264
"later.") % (srcpkg, srcver_epoch)
188
self.all_changes[name] = [
189
_("The list of changes is not available yet.\n\n"
190
"Please use http://launchpad.net/ubuntu/+source/%s/%s/+changelog\n"
191
"until the changes become available or try again "
192
"later.") % (srcpkg, srcver_epoch),
265
194
except (IOError, httplib.BadStatusLine, socket.error), e:
266
195
print "caught exception: ", e
267
196
if lock.locked():
268
self.all_changes[name] = _("Failed to download the list "
269
"of changes. \nPlease "
270
"check your Internet "
272
self.all_changes[name] = changelog
197
self.all_changes[name] = [_("Failed to download the list "
198
"of changes. \nPlease "
199
"check your Internet "
200
"connection."), srcpkg]