Merged from trunk 7976:7984
authorFabian Groffen <grobian@gentoo.org>
Mon, 8 Oct 2007 17:17:39 +0000 (17:17 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 8 Oct 2007 17:17:39 +0000 (17:17 -0000)
   | 7977   | default set configuration, should probably go into            |
   | genone | /usr/share/portage                                            |

   | 7978   | Add some documentation about set configuration                |
   | genone |                                                               |

   | 7979   | Also look for sets.conf in overlays                           |
   | genone |                                                               |

   | 7980   | Also clean portage.txt                                        |
   | genone |                                                               |

   | 7981   | clean up module namespace                                     |
   | genone |                                                               |

   | 7982   | Add @localhost to default PORTAGE_ELOG_MAILFROM to account    |
   | genone | for mail servers that don't accept mails without a domainname |

   | 7983   | let dohtml handle weird filenames, patch by TGL (bug #171272) |
   | genone |                                                               |

   | 7984   | Handle Exceptions in mod_mail_summary.finalize() and check if |
   | genone | the server actually supports TLS, bug #183808                 |

svn path=/main/branches/prefix/; revision=8003

16 files changed:
bin/dohtml
cnf/make.globals
cnf/sets.conf [new file with mode: 0644]
doc/Makefile
doc/config.docbook [new file with mode: 0644]
doc/config/sets.docbook [new file with mode: 0644]
doc/portage.docbook
pym/emerge/__init__.py
pym/portage/elog/mod_mail_summary.py
pym/portage/mail.py
pym/portage/sets/__init__.py
pym/portage/sets/dbapi.py
pym/portage/sets/files.py
pym/portage/sets/profiles.py
pym/portage/sets/security.py
pym/portage/sets/shell.py

index b0fce399adf9cf80d1991a46555309f1d6f3f5d6..aaebb716930aeb50ac26394f5f2411440b9a69cf 100755 (executable)
@@ -34,17 +34,17 @@ import sys
 import types
 
 def dodir(path):
-       os.system("install -d '%s'" % path)
+       os.spawnlp(os.P_WAIT, "install", "install", "-d", path)
 
 def dofile(src,dst):
-
-       os.system("install -m 0644 '%s' '%s'" % (src, dst))
+       os.spawnlp(os.P_WAIT, "install", "install", "-m0644", src, dst)
 
 def install(basename, dirname, options, prefix=""):
-
        fullpath = basename
-       if prefix: fullpath = prefix + "/" + fullpath
-       if dirname: fullpath = dirname + "/" + fullpath
+       if prefix:
+               fullpath = prefix + "/" + fullpath
+       if dirname:
+               fullpath = dirname + "/" + fullpath
 
        if options.DOCDESTTREE:
                destdir = options.ED + "/usr/share/doc/" + options.PF + "/" + options.DOCDESTTREE + "/" + options.doc_prefix + "/" + prefix
index 94b7aa54813ad8b06e2faa4ed146c014b940eae6..aa5e025f988a5feb7f3b9911f3696cfd5cfcdbb6 100644 (file)
@@ -82,7 +82,7 @@ PORTAGE_ELOG_SYSTEM="save_summary echo"
 
 PORTAGE_ELOG_MAILURI="@rootuser@"
 PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for \${PACKAGE} on \${HOST}"
-PORTAGE_ELOG_MAILFROM="@portageuser@"
+PORTAGE_ELOG_MAILFROM="@portageuser@@localhost"
 
 #            *****************************
 #            **  DO NOT EDIT THIS FILE  **
diff --git a/cnf/sets.conf b/cnf/sets.conf
new file mode 100644 (file)
index 0000000..8f7852b
--- /dev/null
@@ -0,0 +1,34 @@
+# WARNING: default set configuration, DO NOT CHANGE.
+# If you want to change anything redefine the relevant section in 
+# /etc/portage/sets.conf. Any changes to this file will be lost on the next 
+# portage update, and configuration errors here might upset portage in 
+# unexpected ways.
+
+# Not much that could be changed for world, so better leave it alone
+[world]
+class = portage.sets.files.WorldSet
+
+# Same as for world, though later portage versions might use a different class
+[system]
+class = portage.sets.profiles.PackagesSystemSet
+
+# For security there are multiple classes available, but differences are 
+# rather small (normally there should be no visible difference):
+# - AffectedSet: include all GLSAs that cover a vulnerable package
+# - NewAffectedSet: include all GLSAs that cover a vulnerable package and 
+#   haven't been applied previously
+# - NewGlsaSet: include all GLSAs that haven't been applied
+# - SecuritySet: include all GLSAs
+[security]
+class = portage.sets.security.NewAffectedSet
+
+# Again, not much to change here, though people might prefer a different name
+[everything]
+class = portage.sets.dbapi.EverythingSet
+
+# The following treats all files in /etc/portage/sets as a package set called
+# 'sets/$filename'.
+[usersets]
+class = portage.sets.files.StaticFileSet
+multiset = true
+directory = /etc/portage/sets
index c829639ca9c82444f479a8de102d4ca89c7b1a99..5c2ab0ba9d674437e90497ac638fd1f3ce4d709a 100644 (file)
@@ -5,7 +5,7 @@ man pdf txt xhtml xhtml-nochunks:
        xmlto $@ $(XMLTO_FLAGS_$@) portage.docbook
 
 clean distclean:
-       rm -f *.1 *.html
+       rm -f *.1 *.html portage.txt
 
 .PHONY: all clean distclean \
         man pdf txt xhtml xhtml-nochunks
diff --git a/doc/config.docbook b/doc/config.docbook
new file mode 100644 (file)
index 0000000..39c5600
--- /dev/null
@@ -0,0 +1,4 @@
+<part id='config'>
+<title>Configuration</title>
+&config_set;
+</part>
diff --git a/doc/config/sets.docbook b/doc/config/sets.docbook
new file mode 100644 (file)
index 0000000..5657b2c
--- /dev/null
@@ -0,0 +1,114 @@
+<chapter id='config-set'>
+       <title>Package Set Configuration</title>
+       <sect1 id='config-set-locations'>
+               <title>sets.conf locations</title>
+               <para>
+               There are multiple locations where portage looks for set configuration 
+               files, which are usually named <filename>sets.conf</filename>. Not all 
+               of these locations have to contain a sets.conf, missing files are simply 
+               ignored.
+               </para>
+               <para>
+               At first it looks for the default configuration in 
+               <filename>/usr/share/portage/config</filename>.
+               The default config includes sets that are expected on all systems and 
+               often critical for normal operation, like <varname>world</varname>, 
+               <varname>system</varname> or <varname>security</varname>.
+               <!-- TODO: Add reference to currently non-existing documentation about
+               set usage and default sets -->
+               After that it will read repository specific configurations from 
+               <envar>PORTDIR</envar> and <envar>PORTDIR_OVERLAY</envar>that might
+               include definitions of sets included in the repository.
+               Finally a system-specific set configuration may reside in 
+               <filename>/etc/portage</filename> to either define additional sets or
+               alter the default and repository sets.
+               </para>
+       </sect1>
+       <sect1 id='config-set-syntax'>
+               <title>sets.conf Syntax</title>
+               <para>
+               Unlike other Portage configuration files <filename>sets.conf</filename> 
+               uses Pythons <classname>ConfigParser</classname> module, which implements
+               the syntax usually found in .ini files. At it's core it allows various
+               named sections that each can contain any number of key-value pairs, see
+               the <ulink url="http://doc.python.org/lib/module-ConfigParser.html" type="text/html">Python documentation</ulink>
+               for the full details.
+               </para>
+               <para>
+               In a <filename>sets.conf</filename> file, a section can define either a 
+               single package set, or a complete class of sets. These cases are handled 
+               in different ways, and will be explained in detail in the following sections.
+               </para>
+               <sect2 id='config-set-syntax-single'>
+                       <title>Single Set Configuration</title>
+                       <para>
+                       The configuration of a single set can be very simple as in most cases
+                       it only requires a single option <varname>class</varname> to be 
+                       complete. That option defines which handler class should be used to 
+                       create the set. Another universal option available for single sets is
+                       <varname>name</varname>, however it's usually not needed as the name
+                       of the set is generated from the section name if <varname>name</varname>
+                       is missing. Some handler classes might require additional
+                       options for their configuration, these will be covered later in 
+                       this chapter.
+                       </para>
+                       <para>
+                       Here are a few examples for single sets taken from the default 
+                       configuration file:
+                       <programlisting>
+                       # The classic world set
+                       [world]
+                       class = portage.sets.files.WorldSet
+                       
+                       # The classic system set
+                       [system]
+                       class = portage.sets.profiles.PackagesSystemSet
+                       </programlisting>
+                       <!-- TODO: reference list of available set handler classes here -->
+                       </para>
+               </sect2>
+               <sect2 id='config-set-syntax-multi'>
+                       <title>Multi Set Configuration</title>
+                       <para>
+                       As configuring each single set manually could be quite annoying if 
+                       you want many sets with the same options Portage also allows to
+                       define whole classes of sets in a single section. Like with single
+                       sets each section still requires the <varname>class</varname> option,
+                       but to indicate that the section should generate multiple sets it's
+                       also necessary to set the <varname>multiset</varname> option to 
+                       <parameter>true</parameter>.
+                       </para>
+                       <para>
+                       As it doesn't make much sense to specify a single name for multiple sets
+                       the <varname>name</varname> option isn't available for multiset sections.
+                       Most handler classes will have a reasonable default for generating names,
+                       and usually you can (but don't have to) set the 
+                       <varname>name_pattern</varname> option to change the naming rules. That 
+                       option generally has to include a (handler-specific) placeholder that 
+                       will be replaced with a unique identifier (e.g. for category sets the 
+                       category name). As with single sets handler classes might require and/or 
+                       support additional options, these will be discussed later.
+                       </para>
+                       <para>
+                       Some examples for multiset configurations:
+                       <programlisting>
+                       # generate a set for each file in /etc/portage/sets
+                       # this section is also in the default configuration
+                       [user sets]
+                       class = portage.sets.files.StaticFileSet
+                       multiset = true
+                       directory = /etc/portage/sets
+                       
+                       # Generate a set for each category that includes all installed packages
+                       # from that category. The sets will be named &lt;category&gt;/*
+                       [installed category packages]
+                       class = portage.sets.dbapi.CategorySet
+                       multiset = true
+                       repository = vartree
+                       name_pattern = $category/*
+                       </programlisting>
+                       </para>
+                       <!-- TODO: reference list of available set handler classes here -->
+               </sect2>
+       </sect1>
+</chapter>
index 1ca868722e6aabb479f10b35815219b6885284c1..ac1061310131bc0947a49347a2b6b9a27f51f9aa 100644 (file)
@@ -8,6 +8,8 @@
        <!ENTITY project "portage">
 
        <!ENTITY qa SYSTEM "qa.docbook">
+       <!ENTITY config SYSTEM "config.docbook">
+       <!ENTITY config_set SYSTEM "config/sets.docbook">
 ]>
 
 <book id="portage" lang="en">
@@ -27,6 +29,7 @@
  &date;
 </bookinfo>
 
+&config;
 &qa;
 
 </book>
index bea5cd26e90fd6ea4843df1f5202b20d8ba9e836..d7aca4850d71267bfe16b8f077089d62daac52be 100644 (file)
@@ -6464,8 +6464,10 @@ def emerge_main():
                        print colorize("BAD", "\n*** emerging by path is broken and may not always work!!!\n")
                        break
 
-       setconfigpaths = ["/usr/share/portage/config/sets.conf", os.path.join(settings["PORTDIR"], "sets.conf"), \
-               os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf")]
+       setconfigpaths = ["/usr/share/portage/config/sets.conf"]
+       setconfigpaths.append(os.path.join(settings["PORTDIR"], "sets.conf"))
+       setconfigpaths += [os.path.join(x, "sets.conf") for x in settings["PORDIR_OVERLAY"].split()]
+       setconfigpaths.append(os.path.join(os.sep, settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "sets.conf"))
        #setconfig = SetConfig(setconfigpaths, settings, trees[settings["ROOT"]])
        setconfig = make_default_config(settings, trees[settings["ROOT"]])
        del setconfigpaths
index 7410f05af326e63e4e2fb458336e2c6240b300cd..d0b2577ae056afa0462485d975e7ce8e64ebb26d 100644 (file)
@@ -4,6 +4,7 @@
 # $Id$
 
 import portage.mail, socket, os, time
+from portage.exception import PortageException
 from email.MIMEText import MIMEText as TextMessage
 
 _items = {}
@@ -48,6 +49,9 @@ def _finalize(mysettings, items):
 
        mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject,
                mybody, attachments=items.values())
-       portage.mail.send_mail(mysettings, mymessage)
+       try:
+               portage.mail.send_mail(mysettings, mymessage)
+       except PortageException, e:
+               print str(e)
 
        return
index 0c39b4cc9b3f3978e3ce9ae3dc64778c11c80d8e..cf6ebd134e116a6ae3b3353d3c6fef85aa6ae0d9 100644 (file)
@@ -74,7 +74,11 @@ def send_mail(mysettings, message):
                try:
                        if int(mymailport) > 100000:
                                myconn = smtplib.SMTP(mymailhost, int(mymailport) - 100000)
+                               myconn.ehlo()
+                               if not myconn.has_extn("STARTTLS"):
+                                       raise portage.exception.PortageException("!!! TLS support requested for logmail but not suported by server")
                                myconn.starttls()
+                               myconn.ehlo()
                        else:
                                myconn = smtplib.SMTP(mymailhost, mymailport)
                        if mymailuser != "" and mymailpasswd != "":
index de588fb4f2f31900a1a159c31452488e26aab2b4..9cf90600a500802df87161279a323d8843fc02bf 100644 (file)
@@ -14,6 +14,9 @@ DEFAULT_SETS = ["world", "system", "everything", "security"] \
        +["package_"+x for x in ["mask", "unmask", "use", "keywords"]]
 del x
 
+__all__ = ["PackageSet", "EditablePackageSet", "InternalPackageSet", \
+                       "SetConfigError", "SetConfig", "make_default_config"]
+
 class PackageSet(object):
        # Set this to operations that are supported by your subclass. While 
        # technically there is no difference between "merge" and "unmerge" regarding
@@ -270,7 +273,6 @@ if __name__ == "__main__":
        import portage
        sc = make_default_config(portage.settings, portage.db["/"])
        l, e = sc.getSets()
-       print l, e
        for x in l:
                print x+":"
                print "DESCRIPTION = %s" % l[x].getMetadata("Description")
index 1a7a669070263092d3c1b46eae8c5ca12614f4a7..164027943700d9dc9840c0c114b7caef679a2ec5 100644 (file)
@@ -5,6 +5,8 @@
 from portage.versions import catsplit
 from portage.sets import PackageSet, SetConfigError
 
+__all__ = ["CategorySet", "EverythingSet"]
+
 class EverythingSet(PackageSet):
        _operations = ["merge", "unmerge"]
        description = "Package set containing all installed packages"
index ab04dc846f0f6f0f1fcbb62a325d4c16e651a5c3..889e7f973519a4d906e3bd39d86df899648af0d8 100644 (file)
@@ -12,6 +12,8 @@ from portage.sets import PackageSet, EditablePackageSet, SetConfigError
 from portage.env.loaders import ItemFileLoader, KeyListFileLoader
 from portage.env.validators import ValidAtomValidator
 
+__all__ = ["StaticFileSet", "ConfigFileSet", "WorldSet"]
+
 class StaticFileSet(EditablePackageSet):
        _operations = ["merge", "unmerge"]
        
index 6d629fc67f01d705241fe41e3faad0742b73ba98..fcefaff887ddbff0020676dc5bd410f106a6ad35 100644 (file)
@@ -6,6 +6,8 @@ import os
 from portage.util import grabfile_package, stack_lists
 from portage.sets import PackageSet
 
+__all__ = ["PackagesSystemSet"]
+
 class PackagesSystemSet(PackageSet):
        _operations = ["merge"]
 
index 576009364a3cf78288c759670a5c716e41cf97d4..f58e725f9d4799101832102aa007d2b29a9651aa 100644 (file)
@@ -8,6 +8,8 @@ from portage.util import grabfile, write_atomic
 from portage.const import CACHE_PATH
 from portage.sets import PackageSet
 
+__all__ = ["SecuritySet", "NewGlsaSet", "NewAffectedSet", "AffectedSet"]
+
 class SecuritySet(PackageSet):
        _operations = ["merge"]
        _skip_applied = False
index d61c116ceca3e592e8ecf38b3003471bffbb81a9..56b8ef5efd1ea2ba2434c29d125ec9b9f5e9b9b8 100644 (file)
@@ -7,6 +7,8 @@ import os
 
 from portage.sets import PackageSet, SetConfigError
 
+__all__ = ["CommandOutputSet"]
+
 class CommandOutputSet(PackageSet):
        """This class creates a PackageSet from the output of a shell command.
           The shell command should produce one atom per line, that is: