From 3f537c85782850306be6efa12c9ed92e521f9bcb Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 19 Jan 2007 18:58:31 +0000 Subject: [PATCH] Merged from trunk 5649:5657 exithandler is not a portageq func, so ignore it (WarnerBro) For bug #162275, make doebuild validate *DEPEND and bail out if necessary. Clean up variables when finished. Make invalid deps non-fatal for some phases. elevate the importance of 64bit clean code on 64bit hosts (SpankMan) Clean up imports in portage_locks.py svn path=/main/branches/prefix/; revision=5724 --- bin/misc-functions.sh | 6 +++++- bin/portageq | 2 +- pym/portage.py | 24 +++++++++++++++++++++++ pym/portage_locks.py | 44 ++++++++++++++++++++----------------------- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh index 3a4931787..231e5c514 100644 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@ -345,7 +345,11 @@ install_qa_check() { eqawarn " but will almost certainly crash on 64bit architectures." eqawarn "${f}" vecho -ne '\a\n' - abort="yes" + # just warn on 32bit hosts but bail on 64bit hosts + case ${CHOST} in + alpha*|ia64*|powerpc64*|mips64*|sparc64*|x86_64*) die "this code is not 64bit clean";; + *) abort="yes";; + esac fi [[ ${abort} == "yes" ]] && hasq stricter ${FEATURES} && die "poor code kills airplanes" fi diff --git a/bin/portageq b/bin/portageq index 55723e10a..3c863aa37 100755 --- a/bin/portageq +++ b/bin/portageq @@ -280,7 +280,7 @@ def usage(argv): # for name in globals().keys(): # Drop python stuff, modules, and our own support functions. - if (name in ("usage", "__doc__", "__name__", "main", "os", "portage", "sys", "__builtins__", "types", "string")): + if (name in ("usage", "__doc__", "__name__", "main", "os", "portage", "sys", "__builtins__", "types", "string","exithandler")): continue # Drop non-functions diff --git a/pym/portage.py b/pym/portage.py index 5841fa8f5..9ea00896e 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3359,6 +3359,30 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, return spawn(EBUILD_SH_BINARY + " depend", mysettings) + # Validate dependency metadata here to ensure that ebuilds with invalid + # data are never installed (even via the ebuild command). + invalid_dep_exempt_phases = \ + set(["clean", "cleanrm", "help", "prerm", "postrm"]) + mycpv = mysettings["CATEGORY"] + "/" + mysettings["PF"] + dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"] + metadata = dict(izip(dep_keys, mydbapi.aux_get(mycpv, dep_keys))) + class FakeTree(object): + def __init__(self, mydb): + self.dbapi = mydb + dep_check_trees = {myroot:{}} + dep_check_trees[myroot]["porttree"] = \ + FakeTree(fakedbapi(settings=mysettings)) + for dep_type in dep_keys: + mycheck = dep_check(metadata[dep_type], None, mysettings, + myuse="all", myroot=myroot, trees=dep_check_trees) + if not mycheck[0]: + writemsg("%s: %s\n%s\n" % ( + dep_type, metadata[dep_type], mycheck[1]), noiselevel=-1) + if mydo not in invalid_dep_exempt_phases: + return 1 + del dep_type, mycheck + del mycpv, dep_keys, metadata, FakeTree, dep_check_trees + if "PORTAGE_TMPDIR" not in mysettings or \ not os.path.isdir(mysettings["PORTAGE_TMPDIR"]): writemsg("The directory specified in your " + \ diff --git a/pym/portage_locks.py b/pym/portage_locks.py index 621401182..5be8599a5 100644 --- a/pym/portage_locks.py +++ b/pym/portage_locks.py @@ -4,14 +4,10 @@ # $Id: portage_locks.py 4449 2006-09-14 07:52:39Z zmedico $ -import errno -import os -import stat -import time -import types -import portage_exception -import portage_util -import portage_data +import errno, os, stat, time, types +from portage_exception import InvalidData, DirectoryNotFound, FileNotFound +from portage_data import portage_gid +from portage_util import writemsg from portage_localization import _ import portage_const @@ -28,7 +24,7 @@ def lockfile(mypath,wantnewlockfile=0,unlinkfile=0): import fcntl if not mypath: - raise portage_exception.InvalidData, "Empty path given" + raise InvalidData, "Empty path given" if type(mypath) == types.StringType and mypath[-1] == '/': mypath = mypath[:-1] @@ -49,18 +45,18 @@ def lockfile(mypath,wantnewlockfile=0,unlinkfile=0): if type(mypath) == types.StringType: if not os.path.exists(os.path.dirname(mypath)): - raise portage_exception.DirectoryNotFound, os.path.dirname(mypath) + raise DirectoryNotFound, os.path.dirname(mypath) if not os.path.exists(lockfilename): old_mask=os.umask(000) myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660) try: - if os.stat(lockfilename).st_gid != portage_data.portage_gid: - os.chown(lockfilename,os.getuid(),portage_data.portage_gid) + if os.stat(lockfilename).st_gid != portage_gid: + os.chown(lockfilename,os.getuid(),portage_gid) except OSError, e: if e[0] == 2: # No such file or directory return lockfile(mypath,wantnewlockfile,unlinkfile) else: - portage_util.writemsg("Cannot chown a lockfile. This could cause inconvenience later.\n"); + writemsg("Cannot chown a lockfile. This could cause inconvenience later.\n"); os.umask(old_mask) else: myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR,0660) @@ -111,10 +107,10 @@ def lockfile(mypath,wantnewlockfile=0,unlinkfile=0): myfd != HARDLINK_FD and os.fstat(myfd).st_nlink == 0: # The file was deleted on us... Keep trying to make one... os.close(myfd) - portage_util.writemsg("lockfile recurse\n",1) + writemsg("lockfile recurse\n",1) lockfilename,myfd,unlinkfile,locking_method = lockfile(mypath,wantnewlockfile,unlinkfile) - portage_util.writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1) + writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1) return (lockfilename,myfd,unlinkfile,locking_method) def unlockfile(mytuple): @@ -127,7 +123,7 @@ def unlockfile(mytuple): elif len(mytuple) == 4: lockfilename,myfd,unlinkfile,locking_method = mytuple else: - raise + raise InvalidData if(myfd == HARDLINK_FD): unhardlink_lockfile(lockfilename) @@ -135,7 +131,7 @@ def unlockfile(mytuple): # myfd may be None here due to myfd = mypath in lockfile() if type(lockfilename) == types.StringType and not os.path.exists(lockfilename): - portage_util.writemsg("lockfile does not exist '%s'\n" % lockfilename,1) + writemsg("lockfile does not exist '%s'\n" % lockfilename,1) if myfd is not None: os.close(myfd) return False @@ -161,18 +157,18 @@ def unlockfile(mytuple): locking_method(myfd,fcntl.LOCK_EX|fcntl.LOCK_NB) # We won the lock, so there isn't competition for it. # We can safely delete the file. - portage_util.writemsg("Got the lockfile...\n",1) + writemsg("Got the lockfile...\n",1) if os.fstat(myfd).st_nlink == 1: os.unlink(lockfilename) - portage_util.writemsg("Unlinked lockfile...\n",1) + writemsg("Unlinked lockfile...\n",1) locking_method(myfd,fcntl.LOCK_UN) else: - portage_util.writemsg("lockfile does not exist '%s'\n" % lockfilename,1) + writemsg("lockfile does not exist '%s'\n" % lockfilename,1) os.close(myfd) return False except Exception, e: - portage_util.writemsg("Failed to get lock... someone took it.\n",1) - portage_util.writemsg(str(e)+"\n",1) + writemsg("Failed to get lock... someone took it.\n",1) + writemsg(str(e)+"\n",1) # why test lockfilename? because we may have been handed an # fd originally, and the caller might not like having their @@ -213,7 +209,7 @@ def hardlink_lockfile(lockfilename, max_wait=14400): os.close(myfd) if not os.path.exists(myhardlock): - raise portage_exception.FileNotFound, _("Created lockfile is missing: %(filename)s") % {"filename":myhardlock} + raise FileNotFound, _("Created lockfile is missing: %(filename)s") % {"filename":myhardlock} try: res = os.link(myhardlock, lockfilename) @@ -227,7 +223,7 @@ def hardlink_lockfile(lockfilename, max_wait=14400): return True if reported_waiting: - portage_util.writemsg(".") + writemsg(".") else: reported_waiting = True print -- 2.26.2