1 |
Preserve mtime when the md5sum is identical. |
2 |
|
3 |
X-Gentoo-Bug: 557192 |
4 |
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=557192 |
5 |
--- |
6 |
bin/egencache | 14 ++++++++++++++ |
7 |
1 file changed, 14 insertions(+) |
8 |
|
9 |
diff --git a/bin/egencache b/bin/egencache |
10 |
index 5c00248..7ac1fba 100755 |
11 |
--- a/bin/egencache |
12 |
+++ b/bin/egencache |
13 |
@@ -7,6 +7,7 @@ from __future__ import print_function, unicode_literals |
14 |
|
15 |
import platform |
16 |
import signal |
17 |
+import stat |
18 |
import sys |
19 |
# This block ensures that ^C interrupts are handled quietly. |
20 |
try: |
21 |
@@ -487,6 +488,8 @@ class GenUseLocalDesc(object): |
22 |
def run(self): |
23 |
repo_path = self._portdb.porttrees[0] |
24 |
ops = {'<':0, '<=':1, '=':2, '>=':3, '>':4} |
25 |
+ prev_mtime = None |
26 |
+ prev_md5 = None |
27 |
|
28 |
if self._output is None or self._output != '-': |
29 |
if self._output is None: |
30 |
@@ -500,6 +503,12 @@ class GenUseLocalDesc(object): |
31 |
desc_path = self._output |
32 |
|
33 |
try: |
34 |
+ prev_md5 = portage.checksum.perform_md5(desc_path) |
35 |
+ prev_mtime = os.stat(desc_path)[stat.ST_MTIME] |
36 |
+ except (portage.exception.FileNotFound, OSError): |
37 |
+ pass |
38 |
+ |
39 |
+ try: |
40 |
if self._preserve_comments: |
41 |
# Probe in binary mode, in order to avoid |
42 |
# potential character encoding issues. |
43 |
@@ -651,6 +660,11 @@ class GenUseLocalDesc(object): |
44 |
output.write('%s:%s - %s\n' % (cp, flag, resdesc)) |
45 |
|
46 |
output.close() |
47 |
+ if (prev_mtime is not None and |
48 |
+ prev_md5 == portage.checksum.perform_md5(desc_path)): |
49 |
+ # preserve mtime for rsync |
50 |
+ os.utime(desc_path, (prev_mtime, prev_mtime)) |
51 |
+ |
52 |
|
53 |
if sys.hexversion < 0x3000000: |
54 |
_filename_base = unicode |
55 |
-- |
56 |
2.4.6 |