From: Fabian Groffen Date: Sat, 14 Oct 2006 15:37:51 +0000 (-0000) Subject: manually sync with trunk, somehow this was not kept up-to-date X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=8cdda3051cff58bf116af46f3315038c05294bbe;p=portage.git manually sync with trunk, somehow this was not kept up-to-date svn path=/main/branches/prefix/; revision=4693 --- diff --git a/pym/portage.py b/pym/portage.py index 8c964e7c8..d6e874d27 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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"]))) diff --git a/pym/portage_checksum.py b/pym/portage_checksum.py index e7f0ec8c2..699652514 100644 --- a/pym/portage_checksum.py +++ b/pym/portage_checksum.py @@ -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 diff --git a/pym/portage_const.py b/pym/portage_const.py index 11079b4bc..3212a3874 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -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" diff --git a/pym/portage_data.py b/pym/portage_data.py index 2330646ff..20b6767e7 100644 --- a/pym/portage_data.py +++ b/pym/portage_data.py @@ -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 diff --git a/pym/portage_dep.py b/pym/portage_dep.py index fc248b63e..6b36ab952 100644 --- a/pym/portage_dep.py +++ b/pym/portage_dep.py @@ -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: diff --git a/pym/portage_exception.py b/pym/portage_exception.py index 0d0206df1..99dd473b0 100644 --- a/pym/portage_exception.py +++ b/pym/portage_exception.py @@ -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""" diff --git a/pym/portage_exec.py b/pym/portage_exec.py index 31b379396..a53d3afdc 100644 --- a/pym/portage_exec.py +++ b/pym/portage_exec.py @@ -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) diff --git a/pym/portage_gpg.py b/pym/portage_gpg.py index 2465b18a7..915a193d3 100644 --- a/pym/portage_gpg.py +++ b/pym/portage_gpg.py @@ -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 diff --git a/pym/portage_localization.py b/pym/portage_localization.py index ba47b06b0..3fe1ffcce 100644 --- a/pym/portage_localization.py +++ b/pym/portage_localization.py @@ -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. diff --git a/pym/portage_locks.py b/pym/portage_locks.py index c33d761b7..a27c6974c 100644 --- a/pym/portage_locks.py +++ b/pym/portage_locks.py @@ -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 index 000000000..99ed77fda --- /dev/null +++ b/pym/portage_mail.py @@ -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 index 000000000..e4d80fa1e --- /dev/null +++ b/pym/portage_selinux.py @@ -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 diff --git a/pym/portage_update.py b/pym/portage_update.py index cd233c8a8..57aa8b43b 100644 --- a/pym/portage_update.py +++ b/pym/portage_update.py @@ -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 diff --git a/pym/portage_util.py b/pym/portage_util.py index d5772a9a0..182010436 100644 --- a/pym/portage_util.py +++ b/pym/portage_util.py @@ -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: diff --git a/pym/portage_versions.py b/pym/portage_versions.py index c38bb19b1..7492d606e 100644 --- a/pym/portage_versions.py +++ b/pym/portage_versions.py @@ -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):