From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 079BC1382C5 for ; Sun, 31 May 2020 06:39:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0D977E0866; Sun, 31 May 2020 06:39:10 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EC951E0866 for ; Sun, 31 May 2020 06:39:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A313834F011 for ; Sun, 31 May 2020 06:39:08 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D735131 for ; Sun, 31 May 2020 06:39:05 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1590907138.dacd3b42154210e1d50fbe947a9bf9a7136d3081.robbat2@gentoo> Subject: [gentoo-commits] proj/qa-scripts:master commit in: / X-VCS-Repository: proj/qa-scripts X-VCS-Files: genrdeps-index.py X-VCS-Directories: / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: dacd3b42154210e1d50fbe947a9bf9a7136d3081 X-VCS-Branch: master Date: Sun, 31 May 2020 06:39:05 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6db7f0dc-135f-4e43-94d6-aaa1bf9b6c01 X-Archives-Hash: 27e348131ca472fe4d88a29a1957f8a7 commit: dacd3b42154210e1d50fbe947a9bf9a7136d3081 Author: Robin H. Johnson gentoo org> AuthorDate: Sun May 31 06:38:58 2020 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sun May 31 06:38:58 2020 +0000 URL: https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=dacd3b42 genrdeps-index: safely create/overwrite rdeps tarball Signed-off-by: Robin H. Johnson gentoo.org> genrdeps-index.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/genrdeps-index.py b/genrdeps-index.py index 1f0b24c..feea62c 100755 --- a/genrdeps-index.py +++ b/genrdeps-index.py @@ -11,6 +11,7 @@ import os.path import shutil import subprocess import sys +import tempfile import pkgcore.config from pkgcore.ebuild.atom import atom @@ -102,12 +103,24 @@ def main(): os.rename(newdir, outdir) shutil.rmtree(olddir, onerror=rmtree_ignore_enoent) - subprocess.check_call( - ['tar', '-cf', 'rdeps.tar'] + [gi for g, gi in GROUPS], - cwd=args.outputdir) - subprocess.check_call( - ['xz', '-9', 'rdeps.tar'], - cwd=args.outputdir) + with tempfile.NamedTemporaryFile(prefix='.tmp.rdeps-', suffix='.tar', dir=args.outputdir, delete=False) as tmpf: + try: + subprocess.check_call( + ['tar', '-cf', tmpf.name] + [gi for g, gi in GROUPS], + cwd=args.outputdir) + subprocess.check_call( + ['xz', '-9', tmpf.name], + cwd=args.outputdir) + os.rename(tmpf.name + '.xz', os.path.join(args.outputdir, 'rdeps.tar.xz')) + except Exception as e: + raise e + finally: + # Cleanup: + for f in [tmpf.name, (tmpf.name + '.xz')]: + try: + os.unlink(f) + except FileNotFoundError as e: + pass return 0