Merged from trunk 5649:5657
authorFabian Groffen <grobian@gentoo.org>
Fri, 19 Jan 2007 18:58:31 +0000 (18:58 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 19 Jan 2007 18:58:31 +0000 (18:58 -0000)
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
bin/portageq
pym/portage.py
pym/portage_locks.py

index 3a4931787e209b9a3e67d6d134e2d4b21fc7d057..231e5c5148c7269ab52a73effb37ba668e4ce04b 100644 (file)
@@ -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
index 55723e10a7ccc8a7fb63a93b707655b91a1f3cd3..3c863aa37f29e05c52fc8d55b931a4721a2561d9 100755 (executable)
@@ -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
index 5841fa8f59b2cbc3fec7a3aa73426dc4094f3962..9ea00896ec989422a6fd32e8d58765adda52fe51 100644 (file)
@@ -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 " + \
index 6214011823a4ad11c122e0bcb6262ed30f290f35..5be8599a5fbc465b2919e079e1d5b6533f23a7c1 100644 (file)
@@ -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