Merge lp:~mvo/pkgme-devportal/i386-only-for-now into lp:pkgme-devportal

Proposed by Michael Vogt
Status: Merged
Approved by: James Westby
Approved revision: 62
Merged at revision: 62
Proposed branch: lp:~mvo/pkgme-devportal/i386-only-for-now
Merge into: lp:pkgme-devportal
Diff against target: 125 lines (+31/-16)
4 files modified
devportalbinary/binary.py (+5/-2)
devportalbinary/configuration.py (+15/-0)
devportalbinary/database.py (+4/-14)
devportalbinary/tests/test_binary.py (+7/-0)
To merge this branch: bzr merge lp:~mvo/pkgme-devportal/i386-only-for-now
Reviewer Review Type Date Requested Status
James Westby Needs Information
Review via email: mp+115684@code.launchpad.net

Commit message

Makes supported architectures configurable, and default to i386 for now.

Description of the change

This is a branch that make the architectures configurable and defaults to "i386" for now. It does affect the database as the previous default for the architectures included "all". AFAICT this should cause any regressions as in the database it was overriden.

Reference is bug #832128.

This will eventually lead to lp:~mvo/pkgme-devportal/more-architecture-when-scanning-binaries where the architecture configuration will actually mean that the database is filled with the additional architectures.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Hi Michael,

I'm not really sure what "supported" architectures mean here, could you help me
out?

37 + # XXX: mvo: it seems we don't need "all" here as we are interessted
38 + # in binary symbols only?

I'm not sure what that means, but it sounds like something we should have an
answer for before we land this?

53 +ARCHITECTURES = load_configuration().options.architectures_supported

Setting a module-level variable based on reading a config file is bad form,
because it will read the config file at import, which means it's hard
to write tests for example. Querying the config at use would be better.

Thanks,

James

review: Needs Information
61. By Michael Vogt

do not load ARCHITECTURES configuration on a module level but instead in each function that needs it, thanks to james_w for this suggestion

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

On Thu, Jul 19, 2012 at 05:15:33PM -0000, James Westby wrote:
> Review: Needs Information
>
> Hi Michael,
Hi James,

> I'm not really sure what "supported" architectures mean here, could you help me
> out?

Just to clarify, do you mean that the string for the configuration
option in the configglue part is not clear? Or that its overall not
clear?

What I mean with "supported" for the architectures is that those are
the architectures we have symbols for in the database and expect to
generate packages for. Do you think a different name would make it
clearer? Maybe "known" or something like this?

> 37 + # XXX: mvo: it seems we don't need "all" here as we are interessted
> 38 + # in binary symbols only?
>
> I'm not sure what that means, but it sounds like something we should have an
> answer for before we land this?

Indeed, its based on the previous code that remove "all" from the list
of ARCHITECTURES for the launchpad querry. And it made me wonder if we
need "all" at all. I think not, but maybe I'm overlooking something.

> 53 +ARCHITECTURES = load_configuration().options.architectures_supported
>
> Setting a module-level variable based on reading a config file is bad form,
> because it will read the config file at import, which means it's hard
> to write tests for example. Querying the config at use would be better.

This is fixed now in my branch.

Thinking a bit more about the branch it may actually not be that
useful, I mainly did it in preparation for the
lp:~mvo/pkgme-devportal/raise-on-unsupported-architectures

But given that the database currently does not have a architecture
field afaik it may well be a bit pointless to make it configurable
before it is actually configurable. So I'm fine putting that branch on
hold for now until the rest of the code is updated to work with
multiple architectures too.

Cheers,
 Michael

Revision history for this message
James Westby (james-w) wrote :

On Fri, 20 Jul 2012 06:47:26 -0000, Michael Vogt <email address hidden> wrote:
> On Thu, Jul 19, 2012 at 05:15:33PM -0000, James Westby wrote:
> > Review: Needs Information
> >
> > Hi Michael,
> Hi James,
>
> > I'm not really sure what "supported" architectures mean here, could you help me
> > out?
>
> Just to clarify, do you mean that the string for the configuration
> option in the configglue part is not clear? Or that its overall not
> clear?

I'm not sure what it means for an architecture to be "supported".

> What I mean with "supported" for the architectures is that those are
> the architectures we have symbols for in the database and expect to
> generate packages for. Do you think a different name would make it
> clearer? Maybe "known" or something like this?

Maybe. If the info is in the database, then could it be inferred from
that?

> > 37 + # XXX: mvo: it seems we don't need "all" here as we are interessted
> > 38 + # in binary symbols only?
> >
> > I'm not sure what that means, but it sounds like something we should have an
> > answer for before we land this?
>
> Indeed, its based on the previous code that remove "all" from the list
> of ARCHITECTURES for the launchpad querry. And it made me wonder if we
> need "all" at all. I think not, but maybe I'm overlooking something.

Right, if this is the architectures we are looking in packages for
symbols for then all probably isn't needed.

> > 53 +ARCHITECTURES = load_configuration().options.architectures_supported
> >
> > Setting a module-level variable based on reading a config file is bad form,
> > because it will read the config file at import, which means it's hard
> > to write tests for example. Querying the config at use would be better.
>
> This is fixed now in my branch.

Great, thanks.

> Thinking a bit more about the branch it may actually not be that
> useful, I mainly did it in preparation for the
> lp:~mvo/pkgme-devportal/raise-on-unsupported-architectures
>
> But given that the database currently does not have a architecture
> field afaik it may well be a bit pointless to make it configurable
> before it is actually configurable. So I'm fine putting that branch on
> hold for now until the rest of the code is updated to work with
> multiple architectures too.

Ok.

If this is just about giving better error messages until we have
architectures figured then I'm fine with it, but we might as well skip
the configuration overhead and just hardcode the list in that case.

Thanks,

James

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

Thanks James, I agree that in itself this is probably not useful to have this as a config option. Maybe it makes more sense in the context that this will eventually lead up to lp:~mvo/pkgme-devportal/more-architectures which should make it easy to add additional architecture via this config option.

62. By Michael Vogt

merged trunk and resolved conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'devportalbinary/binary.py'
2--- devportalbinary/binary.py 2012-07-24 14:16:18 +0000
3+++ devportalbinary/binary.py 2012-07-24 14:43:20 +0000
4@@ -283,8 +283,11 @@
5 DEPENDS = '${shlibs:Depends}, ${misc:Depends}'
6
7 def get_architecture(self, metadata):
8- # XXX: No idea about architecture
9- return None
10+ # XXX: once we scan more than one architecture we need to actually
11+ # pick the ones that we build for (e.g. set to "i386 amd64")
12+ # But currently our database only does i386 so its ok for now
13+ conf = load_configuration()
14+ return "".join(conf.options.architectures_supported)
15
16 def get_build_depends(self, metadata):
17 return ', '.join(guess_dependencies(self.path))
18
19=== modified file 'devportalbinary/configuration.py'
20--- devportalbinary/configuration.py 2012-07-17 13:26:31 +0000
21+++ devportalbinary/configuration.py 2012-07-24 14:43:20 +0000
22@@ -11,6 +11,7 @@
23 Section,
24 DictOption,
25 StringOption,
26+ TupleOption,
27 )
28
29
30@@ -57,6 +58,20 @@
31 help='mapping of library name to pkgname to force picking selected '
32 'dependencies')
33
34+ # The architectures that we fetch binary packages for.
35+ #
36+ # XXX: Really, we should be fetching the binary packages for _all_
37+ # architectures and storing their symbols in the database keyed by
38+ # architecture, and then using the architecture of the incoming binary to
39+ # figure out which libraries we need (XXX - not sure how multiarch affects
40+ # this. Instead, for the moment we are assuming that all binaries are
41+ # i386.
42+ architectures = Section()
43+ architectures.supported = TupleOption(
44+ # XXX: mvo: it seems we don't need "all" here as we are interessted
45+ # in binary symbols only?
46+ default=("i386",),
47+ help='The supported architectures')
48
49 def get_config_file_path():
50 """Return the path to the configuration file."""
51
52=== modified file 'devportalbinary/database.py'
53--- devportalbinary/database.py 2012-07-17 13:51:11 +0000
54+++ devportalbinary/database.py 2012-07-24 14:43:20 +0000
55@@ -34,16 +34,6 @@
56 SERVICE_ROOT = uris.LPNET_SERVICE_ROOT
57
58
59-# The architectures that we fetch binary packages for.
60-#
61-# XXX: Really, we should be fetching the binary packages for _all_
62-# architectures and storing their symbols in the database keyed by
63-# architecture, and then using the architecture of the incoming binary to
64-# figure out which libraries we need (XXX - not sure how multiarch affects
65-# this. Instead, for the moment we are assuming that all binaries are i386.
66-ARCHITECTURES = ('i386', 'all')
67-
68-
69 class LaunchpadFixture(Fixture):
70
71 def __init__(self, application_name, service_root):
72@@ -78,16 +68,15 @@
73
74
75 def iter_published_binaries(lp, since=None, name=None, exact_match=False):
76+ architectures = load_configuration().options.architectures_supported
77 ubuntu = lp.distributions['ubuntu']
78 archive = ubuntu.main_archive
79 # XXX: oneiric is a puppy that is just for christmas. Specifically, it's a
80 # bug that this is looking in oneiric, should instead be looking in
81 # ... well, we don't know.
82 oneiric = ubuntu.getSeries(name_or_version='oneiric')
83- # XXX: 'all' doesn't work?
84- ARCHITECTURES = ['i386']
85 our_series = (
86- oneiric.getDistroArchSeries(archtag=tag) for tag in ARCHITECTURES)
87+ oneiric.getDistroArchSeries(archtag=tag) for tag in architectures)
88 filters = dict(status='Published')
89 if since:
90 filters['created_since_date'] = since
91@@ -174,6 +163,7 @@
92 """
93 directory = tempfile.mkdtemp()
94 binary_file_urls = self.spph.binaryFileUrls()
95+ architectures = load_configuration().options.architectures_supported
96 for url in binary_file_urls:
97 # XXX: This is a bit of a hack to work around the fact that Launchpad
98 # has no way of filtering binary packages for a source package by
99@@ -185,7 +175,7 @@
100 # binary packages that export symbols and *don't* start with lib.
101 continue
102 architecture = filename.split('_')[-1]
103- if architecture not in ARCHITECTURES:
104+ if architecture not in architectures:
105 continue
106 path = download_file(url, directory)
107 symbols_contents = extract_symbols_file(path)
108
109=== modified file 'devportalbinary/tests/test_binary.py'
110--- devportalbinary/tests/test_binary.py 2012-07-24 14:16:18 +0000
111+++ devportalbinary/tests/test_binary.py 2012-07-24 14:43:20 +0000
112@@ -344,6 +344,13 @@
113 get_packages_for_libraries(["libasound.so.2"], "i386"),
114 set(["libasound2"]))
115
116+ def test_architecture(self):
117+ backend = self.make_backend()
118+ conf = load_configuration()
119+ self.assertEqual(
120+ backend.get_architecture(metadata={}),
121+ "".join(conf.options.architectures_supported))
122+
123 def test_get_extra_targets_no_bundled_libs(self):
124 package_name = self.getUniqueString()
125 path = self.getUniqueString()

Subscribers

People subscribed via source and target branches