Merge lp:~nacc/extract-changelogs/changelog-components into lp:extract-changelogs

Proposed by Nish Aravamudan
Status: Rejected
Rejected by: Nish Aravamudan
Proposed branch: lp:~nacc/extract-changelogs/changelog-components
Merge into: lp:extract-changelogs
Diff against target: 113 lines (+48/-20)
1 file modified
lp-extract-changelogs.py (+48/-20)
To merge this branch: bzr merge lp:~nacc/extract-changelogs/changelog-components
Reviewer Review Type Date Requested Status
Brian Murray Needs Fixing
Review via email: mp+319761@code.launchpad.net

Description of the change

Reorganize c.u.c for sources in main and binaries in universe

Currently, for packages such as qemu, `apt-get changelog qemu` fails because the source is in main but the binary is in universe. `apt` uses the binary package to create the URI, but c.u.c uses the source for extracting the changelog files.

This may not be accetable for merging yet, but I'd like a review.

LP: #1672555

To post a comment you must log in.
Revision history for this message
Nish Aravamudan (nacc) wrote :

Note that also I do recognize there is already the binary/ namespace that solves this problem too. `apt` does not use it, though, and I think the concern is while it could be changed to do so (I have tested this locally while investigating the code), it would not work with another mirror of c.u.c that did not have binary/.

Revision history for this message
Brian Murray (brian-murray) wrote :

What concerns do you have that leads you to say "this may not be acceptable for merging yet"?

The log messages for "removing broken symlink" are not distinct between binary or component symlinks, while the creation messages are. That seems worth fixing to me.

Thanks for working on this!

review: Needs Fixing
Revision history for this message
Nish Aravamudan (nacc) wrote :

Hi Brian,

My primary concern is making sure I got the B-C right.

My thinking is:

A) old apt + new layout = will still use pool/component/

B) new apt + new layout = will use pool/

C) old apt + old layout = will still work as it is unchanged

But I think we do have to worry about:

D) new apt + old layout = will look in pool/ and not find it and thus break.

at least initially until we do a pass through all the changelogs and update them with links?

I don't know enough about the various use-cases for apt -- but as I write this, I'm realizing it shouldn't matter yet as there is only the "old apt" case, which should be fine with browsing to a real file or to a symlink in pool/component.

I'm just being overly cautious with new code that is very visible :)

I will fixup the log messages for sure, thanks for catching that!

Unmerged revisions

53. By Nish Aravamudan

_create_{binary,component}_symlinks: specify type of broken symlink to remove

52. By Nish Aravamudan

Move pool/ changelogs into the root directory, symlink in component subdirs

If a srcpkg is in main but some binaries are in universe, `apt changelog
$binpkg` will fail because `apt` has the component in the URL and the
component comes from the binary package, but the changelog is stored
according to the source package. There isn't really any reason for the
component to be in the URI, but we need to maintain
backwards-compatibility.

For new changelogs, elide the component from the URI for the actual
file. Make symlinks in the old component/ path for compatibility.

LP: #1672555

51. By Nish Aravamudan

_create_binary_symlinks: create symlinks regardless of existing changelog

r45 change the behavior in attempting to fix the code, by creating the
binary/ symlinks even if the target changelog already exists. However,
it removed the invocation of (what is now) _create_binary_symlinks that
occurs when the target changelog is initially created.

50. By Nish Aravamudan

create_binary_symlinks: log symlinks correctly

Right now, the symlink deletion and creation logs appear to be reversed
(referring to the target not to the link).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lp-extract-changelogs.py'
2--- lp-extract-changelogs.py 2016-04-13 23:40:29 +0000
3+++ lp-extract-changelogs.py 2017-03-14 19:07:44 +0000
4@@ -131,7 +131,8 @@
5 # statistics
6 self.skipped = 0
7 self.extracted = 0
8- self.symlinked = 0
9+ self.binary_symlinked = 0
10+ self.component_symlinked = 0
11 # date
12 self._time_of_last_check = 0
13 if os.path.exists(self.LAST_CHECK_FILE):
14@@ -234,8 +235,7 @@
15 if os.path.exists(os.path.join(dest, "changelog")):
16 logging.debug("skipping already existing '%s'" % dest)
17 self.skipped += 1
18- if self._create_binary_symlinks(s, dest):
19- self.symlinked += 1
20+ self._create_symlinks(s, dest)
21 return False
22
23 # fetch/unpack
24@@ -272,6 +272,7 @@
25 (s.srcname, s.srcversion))
26 return False
27
28+ self._create_symlinks(s, dest)
29 # remove unpack dir
30 shutil.rmtree(tmpdir)
31 return True
32@@ -291,12 +292,11 @@
33 continue
34
35 # main extraction
36- dest = "%s/pool/%s/%s/%s/%s_%s" % (self.targetdir,
37- s.srccomponent,
38- poolhash(s.srcname),
39- s.srcname,
40- s.srcname,
41- s.srcversion)
42+ dest = "%s/pool/%s/%s/%s_%s" % (self.targetdir,
43+ poolhash(s.srcname),
44+ s.srcname,
45+ s.srcname,
46+ s.srcversion)
47
48 if not self._unpack_changelogs_to_target(s, dest):
49 continue
50@@ -318,15 +318,43 @@
51 if not os.path.exists(lnk):
52 # broken symlink, get rid of them
53 if os.path.islink(lnk):
54- logging.debug("removing broken symlink '%s'" % dest)
55- os.remove(lnk)
56- logging.debug("create compat symlink '%s' -> '%s'" %
57- (dest, lnk))
58- if not os.path.exists(lnkdir):
59- os.makedirs(lnkdir)
60- os.symlink(os.path.abspath(dest), lnk)
61- linked = True
62- return linked
63+ logging.debug("removing broken binary symlink '%s'" % lnk)
64+ os.remove(lnk)
65+ logging.debug("create compat binary symlink '%s' -> '%s'" %
66+ (lnk, dest))
67+ if not os.path.exists(lnkdir):
68+ os.makedirs(lnkdir)
69+ os.symlink(os.path.abspath(dest), lnk)
70+ linked = True
71+ return linked
72+
73+ def _create_component_symlinks(self, s, dest):
74+ linked = False
75+ for comp in set(b[2] for b in
76+ s.binary_packages_versions_components):
77+ lnkdir = "%s/pool/%s/%s/%s" % (self.targetdir,
78+ comp,
79+ poolhash(s.srcname),
80+ s.srcname)
81+ lnk = "%s/%s_%s" % (lnkdir, s.srcname, s.srcversion)
82+ if not os.path.exists(lnk):
83+ # broken symlink, get rid of them
84+ if os.path.islink(lnk):
85+ logging.debug("removing broken component symlink '%s'" % lnk)
86+ os.remove(lnk)
87+ logging.debug("create compat component symlink '%s' -> '%s'" %
88+ (lnk, dest))
89+ if not os.path.exists(lnkdir):
90+ os.makedirs(lnkdir)
91+ os.symlink(os.path.abspath(dest), lnk)
92+ linked = True
93+ return linked
94+
95+ def _create_symlinks(self, s, dest):
96+ if self._create_binary_symlinks(s, dest):
97+ self.binary_symlinked += 1
98+ if self._create_component_symlinks(s, dest):
99+ self.component_symlinked += 1
100
101 def write_last_check_date(self):
102 with open(self.LAST_CHECK_FILE, "w+") as fd:
103@@ -352,8 +380,8 @@
104 if c.get_changelogs():
105 c.write_last_check_date()
106 os.close(lock)
107- logging.info("skipped: %i, extracted: %i, symlinked: %i" % \
108- (c.skipped, c.extracted, c.symlinked))
109+ logging.info("skipped: %i, extracted: %i, binary symlinked: %i, compoment_symlinked: %i" % \
110+ (c.skipped, c.extracted, c.binary_symlinked, c.component_symlinked))
111
112 # test code
113 #ubuntu = c._launchpad.distributions[DISTRIBUTION]

Subscribers

People subscribed via source and target branches