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 ) id 1RQmou-0001N1-Cx for garchives@archives.gentoo.org; Wed, 16 Nov 2011 21:15:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 45E6221C054; Wed, 16 Nov 2011 21:14:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0230B21C054 for ; Wed, 16 Nov 2011 21:14:52 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 717D01B402B for ; Wed, 16 Nov 2011 21:14:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id C089F80042 for ; Wed, 16 Nov 2011 21:14:51 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <001970d23ff76b451a60ecdc9075344ee8e3c7d5.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/emerge/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/Scheduler.py pym/portage/tests/emerge/test_simple.py X-VCS-Directories: pym/portage/tests/emerge/ pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 001970d23ff76b451a60ecdc9075344ee8e3c7d5 Date: Wed, 16 Nov 2011 21:14:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: cb75ae77-bf43-40c7-a774-2a273cfdb45c X-Archives-Hash: 978645776b301bfbea0804561c107aa6 commit: 001970d23ff76b451a60ecdc9075344ee8e3c7d5 Author: Zac Medico gentoo org> AuthorDate: Wed Nov 16 21:14:42 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Nov 16 21:14:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D001970d2 pkg_pretend: clean first for bug #390711 --- pym/_emerge/Scheduler.py | 46 ++++++++++++++++++++++---= ------ pym/portage/tests/emerge/test_simple.py | 4 +++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 729b2d7..d5e801b 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -7,10 +7,8 @@ from collections import deque import gc import gzip import logging -import shutil import signal import sys -import tempfile import textwrap import time import warnings @@ -28,9 +26,10 @@ from portage.output import colorize, create_color_func= , red bad =3D create_color_func("BAD") from portage._sets import SETPREFIX from portage._sets.base import InternalPackageSet -from portage.util import ensure_dirs, writemsg, writemsg_level +from portage.util import writemsg, writemsg_level from portage.package.ebuild.digestcheck import digestcheck from portage.package.ebuild.digestgen import digestgen +from portage.package.ebuild.doebuild import _check_temp_dir from portage.package.ebuild.prepare_build_dirs import prepare_build_dirs =20 import _emerge @@ -44,6 +43,7 @@ from _emerge.create_depgraph_params import create_depgr= aph_params from _emerge.create_world_atom import create_world_atom from _emerge.DepPriority import DepPriority from _emerge.depgraph import depgraph, resume_depgraph +from _emerge.EbuildBuildDir import EbuildBuildDir from _emerge.EbuildFetcher import EbuildFetcher from _emerge.EbuildPhase import EbuildPhase from _emerge.emergelog import emergelog @@ -52,11 +52,9 @@ from _emerge._find_deep_system_runtime_deps import _fi= nd_deep_system_runtime_dep from _emerge._flush_elog_mod_echo import _flush_elog_mod_echo from _emerge.JobStatusDisplay import JobStatusDisplay from _emerge.MergeListItem import MergeListItem -from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from _emerge.Package import Package from _emerge.PackageMerge import PackageMerge from _emerge.PollScheduler import PollScheduler -from _emerge.RootConfig import RootConfig from _emerge.SlotObject import SlotObject from _emerge.SequentialTaskQueue import SequentialTaskQueue =20 @@ -915,11 +913,14 @@ class Scheduler(PollScheduler): root_config =3D x.root_config settings =3D self.pkgsettings[root_config.root] settings.setcpv(x) - tmpdir_orig =3D settings["PORTAGE_TMPDIR"] - build_prefix_orig =3D os.path.join(tmpdir_orig, 'portage') - ensure_dirs(build_prefix_orig) - tmpdir =3D tempfile.mkdtemp(dir=3Dbuild_prefix_orig) - settings["PORTAGE_TMPDIR"] =3D tmpdir + + # setcpv/package.env allows for per-package PORTAGE_TMPDIR so we + # have to validate it for each package + rval =3D _check_temp_dir(settings) + if rval !=3D os.EX_OK: + return rval + + build_dir =3D None =20 try: if x.built: @@ -948,7 +949,8 @@ class Scheduler(PollScheduler): if fetched: bintree.inject(x.cpv, filename=3Dfetched) tbz2_file =3D bintree.getname(x.cpv) - infloc =3D os.path.join(tmpdir, x.category, x.pf, "build-info") + infloc =3D os.path.join(settings["PORTAGE_TMPDIR"], + x.category, x.pf, "build-info") os.makedirs(infloc) portage.xpak.tbz2(tbz2_file).unpackinfo(infloc) ebuild_path =3D os.path.join(infloc, x.pf + ".ebuild") @@ -970,6 +972,20 @@ class Scheduler(PollScheduler): portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, "pretend", settings=3Dsettings, db=3Dself.trees[settings['EROOT']][tree].dbapi) + + existing_buildir =3D os.path.isdir(settings["PORTAGE_BUILDDIR"]) + build_dir =3D EbuildBuildDir(scheduler=3Dsched_iface, + settings=3Dsettings) + build_dir.lock() + + # Clean up the existing build dir, in case pkg_pretend + # checks for available space (bug #390711). + if existing_buildir: + clean_phase =3D EbuildPhase(background=3DFalse, + phase=3D'clean', scheduler=3Dsched_iface, settings=3Dsettings) + clean_phase.start() + clean_phase.wait() + prepare_build_dirs(root_config.root, settings, cleanup=3D0) =20 vardb =3D root_config.trees['vartree'].dbapi @@ -987,8 +1003,12 @@ class Scheduler(PollScheduler): failures +=3D 1 portage.elog.elog_process(x.cpv, settings) finally: - shutil.rmtree(tmpdir) - settings["PORTAGE_TMPDIR"] =3D tmpdir_orig + if build_dir is not None: + clean_phase =3D EbuildPhase(background=3DFalse, + phase=3D'clean', scheduler=3Dsched_iface, settings=3Dsettings) + clean_phase.start() + clean_phase.wait() + build_dir.unlock() =20 if failures: return 1 diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/= emerge/test_simple.py index db3f496..5f285c2 100644 --- a/pym/portage/tests/emerge/test_simple.py +++ b/pym/portage/tests/emerge/test_simple.py @@ -228,7 +228,11 @@ pkg_preinst() { emerge_cmd + ("-p", "dev-libs/B"), emerge_cmd + ("-B", "dev-libs/B",), emerge_cmd + ("--oneshot", "--usepkg", "dev-libs/B",), + + # trigger clean prior to pkg_pretend as in bug #390711 + ebuild_cmd + (test_ebuild, "unpack"),=20 emerge_cmd + ("--oneshot", "dev-libs/A",), + emerge_cmd + ("--noreplace", "dev-libs/A",), emerge_cmd + ("--config", "dev-libs/A",), emerge_cmd + ("--info", "dev-libs/A", "dev-libs/B"),