Gentoo Archives: gentoo-portage-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Chris Reffett <creffett@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH v3] Test for read-only filesystems, bail out during preinst if there are any which will be written to and display a useful error message. Fixes bug 378869.
Date: Sun, 19 Jan 2014 09:17:45
Message-Id: 201401190417.41690.vapier@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v3] Test for read-only filesystems, bail out during preinst if there are any which will be written to and display a useful error message. Fixes bug 378869. by Chris Reffett
1 On Saturday 18 January 2014 21:00:48 Chris Reffett wrote:
2 > --- /dev/null
3 > +++ b/pym/portage/util/rochecker.py
4 > @@ -0,0 +1,81 @@
5 > +#-*- coding:utf-8 -*-
6 > +# Copyright 2014 Gentoo Foundation
7 > +# Distributed under the terms of the GNU General Public License v2
8 > +"""
9 > +Methods to check whether Portage is going to write to read-only
10 > filesystems. +Since the methods are not portable across different OSes,
11 > each OS needs its +own method. To expand RO checking for different OSes,
12 > add a method which +accepts a list of directories and returns a list of
13 > mounts which need to be +remounted RW, then add "elif ostype == (the
14 > ostype value for your OS)" to
15
16 prefer OSes -> OS's
17
18 > +get_ro_checker()
19 > +"""
20
21 period at the end
22
23 > +def get_ro_checker():
24 > + """
25 > + Uses the system type to find an appropriate method for testing whether
26 > Portage
27 > + is going to write to any read-only filesystems
28 > +
29 > + @return:
30 > + 1. A method for testing for RO filesystems appropriate to the current
31 > system
32 > + """
33
34 not a new issue, but we really need to get away from this style and use
35 PEP257. someone feel like fixing that in the code base ? :)
36
37 > + if ostype == "Linux":
38 > + return linux_ro_checker
39 > + else:
40 > + return empty_ro_checker
41
42 isn't this a glorified dict ?
43
44 _CHECKERS = {
45 'Linux': linux_ro_checker,
46 }
47
48 def get_ro_checker()
49 return _CHECKERS.get(ostype, empty_ro_checker)
50 -mike

Attachments

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

Replies