Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] Manifest._apply_max_mtime: handle EPERM from utime (bug 582388)
Date: Sun, 08 May 2016 23:15:55
Message-Id: 20160508161501.23145ecb.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] Manifest._apply_max_mtime: handle EPERM from utime (bug 582388) by Zac Medico
1 On Sun, 8 May 2016 14:57:36 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Only warn if utime fails due to the Manifest parent directory
5 > being owned by a different user, since it's not a problem
6 > unless the repo is being prepared for distribution via rsync.
7 >
8 > X-Gentoo-bug: 582388
9 > X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=582388
10 > ---
11 > pym/portage/manifest.py | 17 ++++++++++++++---
12 > 1 file changed, 14 insertions(+), 3 deletions(-)
13 >
14 > diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
15 > index f696f84..fe4166c 100644
16 > --- a/pym/portage/manifest.py
17 > +++ b/pym/portage/manifest.py
18 > @@ -1,10 +1,11 @@
19 > -# Copyright 1999-2014 Gentoo Foundation
20 > +# Copyright 1999-2016 Gentoo Foundation
21 > # Distributed under the terms of the GNU General Public License v2
22 >
23 > from __future__ import unicode_literals
24 >
25 > import errno
26 > import io
27 > +import logging
28 > import re
29 > import stat
30 > import sys
31 > @@ -15,7 +16,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
32 > 'portage.checksum:hashfunc_map,perform_multiple_checksums,'
33 > + \ 'verify_all,_apply_hash_filter,_filter_unaccelarated_hashes',
34 > 'portage.repository.config:_find_invalid_path_char',
35 > - 'portage.util:write_atomic',
36 > + 'portage.util:write_atomic,writemsg_level',
37 > )
38 >
39 > from portage import os
40 > @@ -387,7 +388,17 @@ class Manifest(object):
41 >
42 > if max_mtime is not None:
43 > for path in preserved_stats:
44 > - os.utime(path, (max_mtime,
45 > max_mtime))
46 > + try:
47 > + os.utime(path, (max_mtime,
48 > max_mtime))
49 > + except OSError as e:
50 > + # Even though we have write
51 > permission, utime fails
52 > + # with EPERM if path is
53 > owned by a different user.
54 > + # Only warn in this case,
55 > since it's not a problem
56 > + # unless this repo is being
57 > prepared for distribution
58 > + # via rsync.
59 > + writemsg_level('!!!
60 > utime(\'%s\', (%s, %s)): %s\n' %
61 > + (path, max_mtime,
62 > max_mtime, e),
63 > +
64 > level=logging.WARNING, noiselevel=-1)
65 > def sign(self):
66 > """ Sign the Manifest """
67
68
69 Looks fine :)
70
71 --
72 Brian Dolbec <dolsen>