Merge lp:~aptdaemon-developers/aptdaemon/cached-changelogs into lp:aptdaemon

Proposed by Sebastian Heinlein
Status: Merged
Merged at revision: 730
Proposed branch: lp:~aptdaemon-developers/aptdaemon/cached-changelogs
Merge into: lp:aptdaemon
Diff against target: 65 lines (+41/-7)
1 file modified
aptdaemon/pkcompat.py (+41/-7)
To merge this branch: bzr merge lp:~aptdaemon-developers/aptdaemon/cached-changelogs
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Review via email: mp+83377@code.launchpad.net

Description of the change

The changelogs are cached in "Dir::Cache::Changelog" which defaults to /var/cache/apt/Changelog

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

That looks great.

What I also don't get is where the changelogs are cached in the first place, but maybe that is already part of the code?

This code :
if pkg.name.startswith("linux-image-") or \
 pkg.name in ["libc6", "dbus"]:
        restart == RESTART_SYSTEM

could probably use the nwe (and yet unused) XB-Restart-Required bit in the packages file.

review: Approve
Revision history for this message
Sebastian Heinlein (glatzor) wrote :

The changelog gets written after being downloaded - line 57 ff

Revision history for this message
Sebastian Heinlein (glatzor) wrote :

The XB-Restart-Required bit is Ubuntu only?

Revision history for this message
Michael Vogt (mvo) wrote :

Its currently ubuntu only not not really used, but I think its really useful, so we could suggest it to debian as well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'aptdaemon/pkcompat.py'
--- aptdaemon/pkcompat.py 2011-11-25 00:23:33 +0000
+++ aptdaemon/pkcompat.py 2011-11-25 09:18:23 +0000
@@ -18,6 +18,8 @@
18__author__ = "Sebastian Heinlein <devel@glatzor.de>"18__author__ = "Sebastian Heinlein <devel@glatzor.de>"
1919
20import datetime20import datetime
21import glob
22import gzip
21import locale23import locale
22import logging24import logging
23import os25import os
@@ -2196,13 +2198,45 @@
2196 # a reboot on Ubuntu but not on Debian2198 # a reboot on Ubuntu but not on Debian
2197 if pkg.name.startswith("linux-image-") or \2199 if pkg.name.startswith("linux-image-") or \
2198 pkg.name in ["libc6", "dbus"]:2200 pkg.name in ["libc6", "dbus"]:
2199 restart == RESTART_SYSTEM2201 restart == pk_enums.RESTART_SYSTEM
2200 changelog_raw = pkg.getChangelog()2202 changelog_dir = apt_pkg.config.find_dir("Dir::Cache::Changelog")
2201 # The internal download error string of python-apt ist not2203 if changelog_dir == "/":
2202 # provided as unicode object2204 changelog_dir = os.path.join(apt_pkg.config.find_dir("Dir::"
2203 if not isinstance(changelog_raw, unicode):2205 "Cache"),
2204 changelog_raw = changelog_raw.decode(DEFAULT_ENCODING)2206 "Changelog")
2205 # Convert the changelog to markdown syntax2207 filename = os.path.join(changelog_dir,
2208 "%s_%s.gz" % (pkg.name,
2209 pkg.candidate.version))
2210 changelog_raw = ""
2211 if os.path.exists(filename):
2212 pklog.debug("Reading changelog from cache")
2213 changelog_file = gzip.open(filename, "rb")
2214 try:
2215 changelog_raw = changelog_file.read().decode("UTF-8")
2216 except:
2217 pass
2218 finally:
2219 changelog_file.close()
2220 if not changelog_raw:
2221 pklog.debug("Downloading changelog")
2222 changelog_raw = pkg.get_changelog()
2223 # The internal download error string of python-apt ist not
2224 # provided as unicode object
2225 if not isinstance(changelog_raw, unicode):
2226 changelog_raw = changelog_raw.decode("UTF-8")
2227 # Cache the fetched changelog
2228 if not os.path.exists(changelog_dir):
2229 os.makedirs(changelog_dir)
2230 # Remove old cached changelogs
2231 pattern = os.path.join(changelog_dir, "%s_*" % pkg.name)
2232 for old_changelog in glob.glob(pattern):
2233 os.rm(os.path.join(changelog_dir, old_changelog))
2234 changelog_file = gzip.open(filename, mode="wb")
2235 try:
2236 changelog_file.write(changelog_raw.encode("UTF-8"))
2237 finally:
2238 changelog_file.close()
2239 # Convert the changelog to markdown syntax
2206 changelog = u""2240 changelog = u""
2207 for line in changelog_raw.split("\n"):2241 for line in changelog_raw.split("\n"):
2208 if line == "":2242 if line == "":

Subscribers

People subscribed via source and target branches

to status/vote changes: