From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from <gentoo-commits+bounces-355307-garchives=archives.gentoo.org@lists.gentoo.org>) id 1QY3kK-00074Z-W3 for garchives@archives.gentoo.org; Sat, 18 Jun 2011 22:12:05 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 99D191C04D; Sat, 18 Jun 2011 22:11:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 50D1A1C04D for <gentoo-commits@lists.gentoo.org>; Sat, 18 Jun 2011 22:11:54 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B2E5A1B4007 for <gentoo-commits@lists.gentoo.org>; Sat, 18 Jun 2011 22:11:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6EDA68003C for <gentoo-commits@lists.gentoo.org>; Sat, 18 Jun 2011 22:11:52 +0000 (UTC) From: "Zac Medico" <zmedico@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org> Message-ID: <574fe329895fdc923d7554ea87e1cdc4c9f4d950.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emaint X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 574fe329895fdc923d7554ea87e1cdc4c9f4d950 Date: Sat, 18 Jun 2011 22:11:52 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 0dd12a64e1c9fac2923f1ffd4aec3afd commit: 574fe329895fdc923d7554ea87e1cdc4c9f4d950 Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Sat Jun 18 22:09:07 2011 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Sat Jun 18 22:09:07 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D574fe329 emaint binhost: add method for SIZE/MTIME checks --- bin/emaint | 57 ++++++++++++++++++++++++++++++++++++++----------------= --- 1 files changed, 38 insertions(+), 19 deletions(-) diff --git a/bin/emaint b/bin/emaint index 7294d79..fdd01ed 100755 --- a/bin/emaint +++ b/bin/emaint @@ -3,6 +3,7 @@ =20 from __future__ import print_function =20 +import errno import re import signal import stat @@ -19,6 +20,7 @@ except ImportError: import portage =20 from portage import os +from portage.util import writemsg =20 if sys.hexversion >=3D 0x3000000: long =3D int @@ -124,6 +126,39 @@ class BinhostHandler(object): self._pkgindex_file =3D self._bintree._pkgindex_file self._pkgindex =3D self._bintree._load_pkgindex() =20 + def _need_update(self, cpv, data): + + if "MD5" not in data: + return True + + size =3D data.get("SIZE") + if size is None: + return True + + mtime =3D data.get("MTIME") + if mtime is None: + return True + + pkg_path =3D self._bintree.getname(cpv) + try: + s =3D os.lstat(pkg_path) + except OSError as e: + if e.errno not in (errno.ENOENT, errno.ESTALE): + raise + # We can't update the index for this one because + # it disappeared. + return False + + try: + if long(mtime) !=3D s[stat.ST_MTIME]: + return True + if long(size) !=3D long(s.st_size): + return True + except ValueError: + return True + + return False + def check(self, onProgress=3DNone): missing =3D [] cpv_all =3D self._bintree.dbapi.cpv_all() @@ -138,7 +173,7 @@ class BinhostHandler(object): metadata[d["CPV"]] =3D d for i, cpv in enumerate(cpv_all): d =3D metadata.get(cpv) - if not d or "MD5" not in d: + if not d or self._need_update(cpv, d): missing.append(cpv) if onProgress: onProgress(maxval, i+1) @@ -164,7 +199,7 @@ class BinhostHandler(object): =20 for i, cpv in enumerate(cpv_all): d =3D metadata.get(cpv) - if not d or "MD5" not in d: + if not d or self._need_update(cpv, d): missing.append(cpv) =20 stale =3D set(metadata).difference(cpv_all) @@ -189,23 +224,7 @@ class BinhostHandler(object): del missing[:] for i, cpv in enumerate(cpv_all): d =3D metadata.get(cpv) - if not d or \ - "MD5" not in d or \ - "SIZE" not in d or \ - "MTIME" not in d: - missing.append(cpv) - continue - - pkg_path =3D bintree.getname(cpv) - s =3D os.lstat(pkg_path) - try: - if long(d["MTIME"]) !=3D s[stat.ST_MTIME]: - missing.append(cpv) - continue - if long(d["SIZE"]) !=3D long(s.st_size): - missing.append(cpv) - continue - except ValueError: + if not d or self._need_update(cpv, d): missing.append(cpv) =20 maxval =3D len(missing)