Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH 1/2] modules/generic_stage_target.py, Create SOURCE_MOUNTS_DEFAULTS
Date: Fri, 03 Jan 2014 06:52:08
Message-Id: 1388731920.3753.14.camel@big_daddy.dol-sen.ca
In Reply to: Re: [gentoo-catalyst] [PATCH 1/2] modules/generic_stage_target.py, Create SOURCE_MOUNTS_DEFAULTS by "W. Trevor King"
1 On Thu, 2014-01-02 at 22:20 -0800, W. Trevor King wrote:
2 > I shift quoted lines around for easier comparison.
3 >
4 > On Thu, Jan 02, 2014 at 10:00:43PM -0800, Brian Dolbec wrote:
5 > > +SOURCE_MOUNTS_DEFAULTS = {
6 > > …
7 > > + "distdir": "/usr/portage/distfiles",
8 > > + "portdir": "/usr/portage",
9 > > …
10 > > - "distdir": self.settings["distdir"],
11 > > - "portdir": normpath("/".join([
12 > > - self.settings["snapshot_cache_path"],
13 > > - self.settings["repo_name"],
14 > > - ])),
15 > > …
16 > > + # initialize our source mounts
17 > > + self.mountmap = SOURCE_MOUNTS_DEFAULTS.copy()
18 > > + # update them from settings
19 > > + self.mountmap["distdir"] = self.settings["distdir"]
20 > > + self.mountmap["portdir"] = normpath("/".join([
21 > > + self.settings["snapshot_cache_path"],
22 > > + self.settings["repo_name"],
23 > > + ]))
24 >
25 > Why create dummy initial values and then blow them away? Wouldn't:
26 >
27 > SOURCE_MOUNTS_DEFAULTS = {
28 > …
29 > 'distdir': None, # initialized from settings
30 > 'portdir': None, # initialized from settings
31 > }
32 >
33 > make more sense? We'll blow away this default dict once we're loading
34 > it via ConfigParser, so this doesn't have to be super elegant, but
35 > adding values just to clobber them seems misleading.
36 >
37
38 We probably could, they are defaulted in config_defaults. But at the
39 time I was just thinking that catalyst.conf or a spec file may not have
40 the value declared, so was better to give it a default here, just in
41 case.
42
43
44 > > - if "SNAPCACHE" in self.settings:
45 > > - self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
46 > > …
47 > > - else:
48 > > - self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
49 > > …
50 > > + self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
51 > > …
52 > > + if "SNAPCACHE" not in self.settings:
53 > > + self.mounts.remove("portdir")
54 >
55 > I'd prefer:
56 >
57 > self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
58 > if "SNAPCACHE" in self.settings:
59 > self.mounts.append("portdir")
60 >
61 > Cheers,
62 > Trevor
63 >
64
65 I didn't do that because I didn't know if the mount order was important,
66 so erred on the side of the current order.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies