From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2E40C1385B2 for ; Mon, 17 Aug 2015 03:39:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 89D1DE06FE; Mon, 17 Aug 2015 03:39:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2E31F14278 for ; Mon, 17 Aug 2015 03:39:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CD1FE340905 for ; Mon, 17 Aug 2015 03:39:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2EACF14E for ; Mon, 17 Aug 2015 03:39:39 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1439782508.6dacd0ed9f6dc206f4932d42bbb36300f56e71f7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/manifest.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 6dacd0ed9f6dc206f4932d42bbb36300f56e71f7 X-VCS-Branch: master Date: Mon, 17 Aug 2015 03:39:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 124cf61b-720a-4f8b-a110-6c2f5bb177fd X-Archives-Hash: b48323c3d350055af008bd0467bff82c commit: 6dacd0ed9f6dc206f4932d42bbb36300f56e71f7 Author: Zac Medico gentoo org> AuthorDate: Mon Aug 17 02:56:43 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Aug 17 03:35:08 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6dacd0ed Manifest.write: stable/predictable Manifest mtime for rsync (bug 557962) Use the max mtime of the existing Manifest and the files that the updated Manifest contains. X-Gentoo-Bug: 557962 X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=557962 Acked-by: Brian Dolbec gentoo.org> pym/portage/manifest.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 3936b9a..f5cf0f5 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import errno import io import re +import stat import sys import warnings @@ -281,6 +282,7 @@ class Manifest(object): try: myentries = list(self._createManifestEntries()) update_manifest = True + existing_st = None if myentries and not force: try: f = io.open(_unicode_encode(self.getFullname(), @@ -288,6 +290,7 @@ class Manifest(object): mode='r', encoding=_encodings['repo.content'], errors='replace') oldentries = list(self._parseManifestLines(f)) + existing_st = os.fstat(f.fileno()) f.close() if len(oldentries) == len(myentries): update_manifest = False @@ -309,6 +312,7 @@ class Manifest(object): # non-empty for all currently known use cases. write_atomic(self.getFullname(), "".join("%s\n" % _unicode(myentry) for myentry in myentries)) + self._apply_max_mtime(existing_st, myentries) rval = True else: # With thin manifest, there's no need to have @@ -328,6 +332,37 @@ class Manifest(object): raise return rval + def _apply_max_mtime(self, existing_st, entries): + """ + Set the Manifest mtime to the max mtime of all relevant files + (the existing Manifest mtime is included in order to account for + eclass modifications that change DIST entries). This results in a + stable/predictable mtime, which is useful when converting thin + manifests to thick manifests for distribution via rsync. For + portability, the mtime is set with 1 second resolution. + + @param existing_st: stat result for existing Manifest + @type existing_st: posix.stat_result + @param entries: list of current Manifest2Entry instances + @type entries: list + """ + # Use stat_result[stat.ST_MTIME] for 1 second resolution, since + # it always rounds down. Note that stat_result.st_mtime will round + # up from 0.999999999 to 1.0 when precision is lost during conversion + # from nanosecond resolution to float. + max_mtime = None if existing_st is None else existing_st[stat.ST_MTIME] + for entry in entries: + if entry.type == 'DIST': + continue + abs_path = (os.path.join(self.pkgdir, 'files', entry.name) if + entry.type == 'AUX' else os.path.join(self.pkgdir, entry.name)) + mtime = os.stat(abs_path)[stat.ST_MTIME] + if max_mtime is None or mtime > max_mtime: + max_mtime = mtime + + if max_mtime is not None: + os.utime(self.getFullname(), (max_mtime, max_mtime)) + def sign(self): """ Sign the Manifest """ raise NotImplementedError()