manually sync with trunk, somehow this was not kept up-to-date
authorFabian Groffen <grobian@gentoo.org>
Sat, 14 Oct 2006 15:37:51 +0000 (15:37 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 14 Oct 2006 15:37:51 +0000 (15:37 -0000)
svn path=/main/branches/prefix/; revision=4693

15 files changed:
pym/portage.py
pym/portage_checksum.py
pym/portage_const.py
pym/portage_data.py
pym/portage_dep.py
pym/portage_exception.py
pym/portage_exec.py
pym/portage_gpg.py
pym/portage_localization.py
pym/portage_locks.py
pym/portage_mail.py [new file with mode: 0644]
pym/portage_selinux.py [new file with mode: 0644]
pym/portage_update.py
pym/portage_util.py
pym/portage_versions.py

index 8c964e7c80dc44b0352b684c6defa575c9942b81..d6e874d271b255610190dda30ab882aa016f15f0 100644 (file)
@@ -1,7 +1,7 @@
 # portage.py -- core Portage functionality
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
+# $Id: portage.py 4664 2006-10-12 10:49:27Z zmedico $
 
 
 VERSION="$Rev$"[6:-2] + "-svn"
@@ -2963,6 +2963,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                mysettings, debug=debug, free=1, logfile=logfile)
 
                mycpv = "/".join((mysettings["CATEGORY"], mysettings["PF"]))
+
                # Make sure we get the correct tree in case there are overlays.
                mytree = os.path.realpath(
                        os.path.dirname(os.path.dirname(mysettings["O"])))
index e7f0ec8c2bbb6cf0438f903cf9562ce22fa1026c..6996525147e8ba68e4977e2b27a531b3ada698ac 100644 (file)
@@ -1,7 +1,7 @@
 # portage_checksum.py -- core Portage functionality
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_checksum.py,v 1.10.2.2 2005/08/10 05:42:03 ferringb Exp $
+# $Id: portage_checksum.py 3835 2006-07-11 00:59:10Z zmedico $
 
 
 from portage_const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
@@ -94,7 +94,9 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
                if mydict["size"] != mysize:
                        return False,("Filesize does not match recorded size", mysize, mydict["size"])
        except OSError, e:
-               return False, str(e)
+               if e.errno == errno.ENOENT:
+                       raise portage_exception.FileNotFound(filename)
+               return False, (str(e), None, None)
        for x in mydict.keys():
                if   x == "size":
                        continue
index 11079b4bcfae83b277098d3d83dcea1641f71722..3212a387464a8b82d10b202852df38987a472fce 100644 (file)
@@ -1,7 +1,7 @@
 # portage: Constants
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_const.py,v 1.3.2.3 2005/04/29 04:56:35 jstubbs Exp $
+# $Id: portage_const.py 3483 2006-06-10 21:40:40Z genone $
 import os
 
 # ===========================================================================
@@ -45,10 +45,11 @@ EBUILD_SH_ENV_FILE      = USER_CONFIG_PATH+"/bashrc"
 INVALID_ENV_FILE        = "/etc/spork/is/not/valid/profile.env"
 CUSTOM_MIRRORS_FILE     = USER_CONFIG_PATH+"/mirrors"
 CONFIG_MEMORY_FILE      = PRIVATE_PATH + "/config"
+COLOR_MAP_FILE          = USER_CONFIG_PATH + "/color.map"
 
 INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"]
-STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"]
-EBUILD_PHASES                  = ["setup","unpack","compile","test","install","preinst","postinst","prerm","postrm"]
+EBUILD_PHASES           = ["setup", "unpack", "compile", "test", "install",
+                          "preinst", "postinst", "prerm", "postrm", "other"]
 
 EAPI = "prefix"
 
index 2330646ff60477018c0a90d33d9d6af818e87840..20b6767e71d58ccd68357e6262c2f93541451196 100644 (file)
@@ -1,7 +1,7 @@
 # portage_data.py -- Calculated/Discovered Data Values
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
+# $Id: portage_data.py 4530 2006-09-25 21:16:32Z zmedico $
 
 
 import os,pwd,grp
index fc248b63ebf4a7c09f9ce14737281c92e5d63d75..6b36ab952cbb990b2c43961c9fcfe7af301590d6 100644 (file)
@@ -1,7 +1,7 @@
 # deps.py -- Portage dependency resolution functions
 # Copyright 2003-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_dep.py,v 1.15.2.3 2005/04/02 14:07:59 jstubbs Exp $
+# $Id: portage_dep.py 4598 2006-10-05 11:52:50Z zmedico $
 
 
 # DEPEND SYNTAX:
index 0d0206df1cbd832846273185e56b998ca5c40c98..99dd473b0dfe61bd3238f3791db09f7635a31e41 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_exception.py,v 1.8.2.1 2005/01/16 02:35:33 carpaski Exp $
+# $Id: portage_exception.py 3483 2006-06-10 21:40:40Z genone $
 
 
 class PortageException(Exception):
@@ -49,6 +49,12 @@ class DirectoryNotFound(InvalidLocation):
 class OperationNotPermitted(PortageException):
        """An operation was not permitted operating system"""
 
+class PermissionDenied(PortageException):
+       """Permission denied"""
+
+class ReadOnlyFileSystem(PortageException):
+       """Read-only file system"""
+
 class CommandNotFound(PortageException):
        """A required binary was not available or executable"""
 
index 31b3793968d5f856c343b528afdafcc2f4d4a4ba..a53d3afdca9647abaf4bf5ca08756ca93d4854e1 100644 (file)
@@ -1,7 +1,7 @@
 # portage.py -- core Portage functionality
 # Copyright 1998-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_exec.py,v 1.13.2.4 2005/04/17 09:01:56 jstubbs Exp $
+# $Id: portage_exec.py 3483 2006-06-10 21:40:40Z genone $
 
 
 import os, atexit, signal, sys
@@ -17,6 +17,13 @@ try:
 except ImportError:
        max_fd_limit = 256
 
+if os.path.isdir("/proc/%i/fd" % os.getpid()):
+       def get_open_fds():
+               return map(int, [fd for fd in os.listdir("/proc/%i/fd" % os.getpid()) if fd.isdigit()])
+else:
+       def get_open_fds():
+               return xrange(max_fd_limit)
+
 sandbox_capable = (os.path.isfile(SANDBOX_BINARY) and
                    os.access(SANDBOX_BINARY, os.X_OK))
 
@@ -222,7 +229,7 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask):
                os.dup2(my_fds[fd], fd)
        # Then close _all_ fds that haven't been explictly
        # requested to be kept open.
-       for fd in range(max_fd_limit):
+       for fd in get_open_fds():
                if fd not in my_fds:
                        try:
                                os.close(fd)
index 2465b18a7f2abbb73559c939238a334183e13201..915a193d34e7bcc62daa4a28123d1b488ec34a74 100644 (file)
@@ -1,7 +1,7 @@
 # portage_gpg.py -- core Portage functionality
 # Copyright 2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_gpg.py,v 1.6.2.1 2005/01/16 02:35:33 carpaski Exp $
+# $Id: portage_gpg.py 3483 2006-06-10 21:40:40Z genone $
 
 
 import os
index ba47b06b0fa600a84d2e1a149e75daf25ae17bd3..3fe1ffcceff76183a483b8710d5ec11a29dbe824 100644 (file)
@@ -1,7 +1,7 @@
 # portage_localization.py -- Code to manage/help portage localization.
 # Copyright 2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_localization.py,v 1.2.2.1 2005/01/16 02:35:33 carpaski Exp $
+# $Id: portage_localization.py 3483 2006-06-10 21:40:40Z genone $
 
 
 # We define this to make the transition easier for us.
index c33d761b74b910757c9172bd16b799b61dcbaf5d..a27c6974cf37ab268a0ce067a3bfbecd5f1831e0 100644 (file)
@@ -1,7 +1,7 @@
 # portage: Lock management code
 # Copyright 2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
+# $Id: portage_locks.py 4449 2006-09-14 07:52:39Z zmedico $
 
 
 import errno
diff --git a/pym/portage_mail.py b/pym/portage_mail.py
new file mode 100644 (file)
index 0000000..99ed77f
--- /dev/null
@@ -0,0 +1,89 @@
+# portage.py -- core Portage functionality
+# Copyright 1998-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id: portage.py 3483 2006-06-10 21:40:40Z genone $
+
+import portage_exception, socket, smtplib, os, sys, time
+from email.MIMEText import MIMEText as TextMessage
+from email.MIMEMultipart import MIMEMultipart as MultipartMessage
+from email.MIMEBase import MIMEBase as BaseMessage
+
+def create_message(sender, recipient, subject, body, attachments=None):
+       if attachments == None:
+               mymessage = TextMessage(body)
+       else:
+               mymessage = MultipartMessage()
+               mymessage.attach(TextMessage(body))
+               for x in attachments:
+                       if isinstance(x, BaseMessage):
+                               mymessage.attach(x)
+                       elif isinstance(x, str):
+                               mymessage.attach(TextMessage(x))
+                       else:
+                               raise portage_exception.PortageException("Can't handle type of attachment: %s" % type(x))
+
+       mymessage.set_unixfrom(sender)
+       mymessage["To"] = recipient
+       mymessage["From"] = sender
+       mymessage["Subject"] = subject
+       mymessage["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S %z")
+       
+       return mymessage
+
+def send_mail(mysettings, message):
+       mymailhost = "localhost"
+       mymailport = 25
+       mymailuser = ""
+       mymailpasswd = ""
+       myrecipient = "root@localhost"
+       
+       # Syntax for PORTAGE_ELOG_MAILURI (if defined):
+       # adress [[user:passwd@]mailserver[:port]]
+       # where adress:     recipient adress
+       #       user:       username for smtp auth (defaults to none)
+       #       passwd:     password for smtp auth (defaults to none)
+       #       mailserver: smtp server that should be used to deliver the mail (defaults to localhost)
+       #                                       alternatively this can also be the absolute path to a sendmail binary if you don't want to use smtp
+       #       port:       port to use on the given smtp server (defaults to 25, values > 100000 indicate that starttls should be used on (port-100000))
+       if " " in mysettings["PORTAGE_ELOG_MAILURI"]:
+               myrecipient, mymailuri = mysettings["PORTAGE_ELOG_MAILURI"].split()
+               if "@" in mymailuri:
+                       myauthdata, myconndata = mymailuri.rsplit("@", 1)
+                       try:
+                               mymailuser,mymailpasswd = myauthdata.split(":")
+                       except ValueError:
+                               print "!!! invalid SMTP AUTH configuration, trying unauthenticated ..."
+               else:
+                       myconndata = mymailuri
+               if ":" in myconndata:
+                       mymailhost,mymailport = myconndata.split(":")
+               else:
+                       mymailhost = myconndata
+       else:
+               myrecipient = mysettings["PORTAGE_ELOG_MAILURI"]
+       
+       myfrom = message.get("From")
+               
+       # user wants to use a sendmail binary instead of smtp
+       if mymailhost[0] == os.sep and os.path.exists(mymailhost):
+               fd = os.popen(mymailhost+" -f "+myfrom+" "+myrecipient, "w")
+               fd.write(message.as_string())
+               if fd.close() != None:
+                       sys.stderr.write("!!! %s returned with a non-zero exit code. This generally indicates an error.\n" % mymailhost)
+       else:
+               try:
+                       if int(mymailport) > 100000:
+                               myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
+                               myconn.starttls()
+                       else:
+                               myconn = smtplib.SMTP(mymailhost, mymailport)
+                       if mymailuser != "" and mymailpasswd != "":
+                               myconn.login(mymailuser, mymailpasswd)
+                       myconn.sendmail(myfrom, myrecipient, message.as_string())
+                       myconn.quit()
+               except smtplib.SMTPException, e:
+                       raise portage_exception.PortageException("!!! An error occured while trying to send logmail:\n"+str(e))
+               except socket.error, e:
+                       raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
+       return
+       
diff --git a/pym/portage_selinux.py b/pym/portage_selinux.py
new file mode 100644 (file)
index 0000000..e4d80fa
--- /dev/null
@@ -0,0 +1,8 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+import selinux
+from selinux import is_selinux_enabled
+from selinux_aux import setexec, secure_symlink, secure_rename, \
+       secure_copy, secure_mkdir, getcontext, get_sid, get_lsid
index cd233c8a873b8d1dab7379ccf58269c2d9b2c849..57aa8b43bc943b121b734a246ccd346dae04c9ac 100644 (file)
@@ -1,3 +1,6 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
 
 import errno, os, re, sys
 
index d5772a9a0edfefd4d2a120fa389eb4a84c7d717e..182010436b2a1d0a293ae3443195748618bb9c44 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id$
+# $Id: portage_util.py 4603 2006-10-06 03:28:25Z zmedico $
 
 from portage_exception import PortageException, FileNotFound, \
        OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem
@@ -261,7 +261,7 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
                                #invalid token
                                #lex.error_leader(self.filename,lex.lineno)
                                if not tolerant:
-                                       writemsg("!!! invalid token (not \"=\") "+str(equ)+"\n",
+                                       writemsg("!!! Invalid token (not \"=\") "+str(equ)+"\n",
                                                noiselevel=-1)
                                        raise Exception("ParseError: Invalid token (not '='): "+str(mycfg)+": line "+str(lex.lineno))
                                else:
index c38bb19b144a6f20f26fafa4215a0e0e7d6d5318..7492d606e3ed0e5b578ee1ac104896aa796aad99 100644 (file)
@@ -3,6 +3,8 @@ import re,string
 ver_regexp = re.compile("^(cvs\\.)?(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+))?$")
 suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
 suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
+endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
+
 
 def ververify(myver, silent=1):
        if ver_regexp.match(myver):