From 8349b28317031a4ff45755079a0e4d47ade1768c Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 4 Dec 2009 21:01:04 +0100 Subject: Add support for repositories.xml database format --- AUTHORS | 1 + CHANGES | 6 ++++++ doc/layman.8.xml | 46 ++++++++++++++++++++--------------------- etc/layman.cfg | 4 ++-- layman/config.py | 9 ++++---- layman/overlay.py | 17 +++++++++++----- layman/overlays/overlay.py | 51 +++++++++++++++++++++++++++++++--------------- 7 files changed, 84 insertions(+), 50 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8bdad29..c832d31 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,3 +18,4 @@ A. F. T. Arahesis (arfrever.fta@gmail.com) - Quieten the VC systems - Better locale support. Donnie Berkholz (dberkholz@gentoo.org) - git support fixes Martin von Gagern (Martin.vGagern@gmx.net) - Better list format. +Sebastian Pipping (sebastian@pipping.org) - repositories.xml support diff --git a/CHANGES b/CHANGES index 4e11896..77ee5f0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ CHANGES ------- +TODO +=================================== + + - Add support for repositories.xml database format + + Version 1.2.3 - Released 2009/01/01 =================================== diff --git a/doc/layman.8.xml b/doc/layman.8.xml index 95fee44..a7df688 100644 --- a/doc/layman.8.xml +++ b/doc/layman.8.xml @@ -22,7 +22,7 @@ - 2005-2008 + 2005-2009 Gunnar Wrobel @@ -618,7 +618,7 @@ Specifies the URL for the remote list of all available overlays. The default is - http://www.gentoo.org/proj/en/overlays/layman-global.txt. You + http://www.gentoo.org/proj/en/overlays/repositories.xml. You can specify several URLs here (one per line). The contents will get merged to a single list of overlays. This allows to add a personal collection of @@ -664,7 +664,7 @@ files. In order for this to be possible the script needs an external list of possible overlay sources. There is a centralized list available at + url="http://www.gentoo.org/proj/en/overlays/repositories.xml"/> but nothing will prevent you from using or publishing your own list of overlays. The location of the remote lists can also be modified using the @@ -857,26 +857,26 @@ Layman uses a central list of overlays in XML format. The file looks like this: - An example overlay.xml file + An example overlays.xml file - <?xml version="1.0" ?> - <layman> - <overlays> - <overlay - type = "svn" - src = "https://mydomain.net/svn/myoverlay/" - contact = "me@mydomain.net" - name = "myoverlay"> - - <link> - http://mydomain.net/myoverlay - </link> - - <description> - Contains some of my ebuilds. - </description> - </overlay> - </overlays> + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE repositories SYSTEM "/dtd/repositories.dtd"> + <repositories xmlns="" version="1.0"> + <repo quality="experimental" status="official"> + <name>gnome</name> + <description>experimental gnome ebuilds</description> + <homepage>http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=summary</homepage> + <owner type="project"> + <email>gnome@gentoo.org</email> + <name>GNOME herd</name> + </owner> + <source type="git">git://git.overlays.gentoo.org/proj/gnome.git</source> + <source type="git">http://git.overlays.gentoo.org/gitroot/proj/gnome.git</source> + <source type="git">git+ssh://git@git.overlays.gentoo.org/proj/gnome.git</source> + <feed>http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=atom</feed> + <feed>http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=rss</feed> + </repo> + </repositories> @@ -904,7 +904,7 @@ The global list of overlays used by layman lies at - http://www.gentoo.org/proj/en/overlays/layman-global.txt. + http://www.gentoo.org/proj/en/overlays/repositories.xml. diff --git a/etc/layman.cfg b/etc/layman.cfg index 2759f84..a52984e 100644 --- a/etc/layman.cfg +++ b/etc/layman.cfg @@ -26,12 +26,12 @@ make_conf : %(storage)s/make.conf # URLs of the remote lists of overlays (one per line) or # local overlay definitions # -#overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt +#overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml # http://dev.gentoo.org/~wrobel/layman/global-overlays.xml # http://mydomain.org/my-layman-list.xml # file:///usr/local/portage/layman/my-list.xml -overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt +overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml #----------------------------------------------------------- # Proxy support diff --git a/layman/config.py b/layman/config.py index 63b1c15..d41491e 100644 --- a/layman/config.py +++ b/layman/config.py @@ -8,11 +8,13 @@ # Handles layman configuration # # Copyright: -# (c) 2005 - 2008 Gunnar Wrobel +# (c) 2005 - 2009 Gunnar Wrobel +# (c) 2009 Sebastian Pipping # Distributed under the terms of the GNU General Public License v2 # # Author(s): # Gunnar Wrobel +# Sebastian Pipping # '''Defines the configuration options and provides parsing functionality.''' @@ -50,7 +52,7 @@ class Config(object): >>> sys.argv.append(here + '/../etc/layman.cfg') >>> a = Config() >>> a['overlays'] - '\\nhttp://www.gentoo.org/proj/en/overlays/layman-global.txt' + '\\nhttp://www.gentoo.org/proj/en/overlays/repositories.xml' >>> sorted(a.keys()) ['cache', 'config', 'local_list', 'make_conf', 'nocheck', 'overlays', 'proxy', 'quietness', 'storage', 'umask', 'width'] ''' @@ -64,8 +66,7 @@ class Config(object): 'proxy' : '', 'umask' : '0022', 'overlays' : - 'http://www.gentoo.org/proj/en/overlays/layman-global.' - 'txt',} + 'http://www.gentoo.org/proj/en/overlays/repositories.xml',} self.parser = OptionParser( diff --git a/layman/overlay.py b/layman/overlay.py index a9a1980..5b8c73f 100644 --- a/layman/overlay.py +++ b/layman/overlay.py @@ -8,11 +8,13 @@ # Access to an xml list of overlays # # Copyright: -# (c) 2005 - 2008 Gunnar Wrobel +# (c) 2005 - 2009 Gunnar Wrobel +# (c) 2009 Sebastian Pipping # Distributed under the terms of the GNU General Public License v2 # # Author(s): # Gunnar Wrobel +# Sebastian Pipping # '''Main handler for overlays.''' @@ -110,14 +112,19 @@ class Overlays: raise Exception('Failed to parse the overlay list!\nError was:\n' + str(error)) - overlays = document.getElementsByTagName('overlay') + overlays = document.getElementsByTagName('overlay') + \ + document.getElementsByTagName('repo') for overlay in overlays: OUT.debug('Parsing overlay entry', 8) + try: + element_to_scan = overlay.getElementsByTagName('source')[0] + except IndexError: + element_to_scan = overlay - for index in range(0, overlay.attributes.length): - attr = overlay.attributes.item(index) + for index in range(0, element_to_scan.attributes.length): + attr = element_to_scan.attributes.item(index) if attr.name == 'type': if attr.nodeValue in OVERLAY_TYPES.keys(): try: @@ -151,7 +158,7 @@ class Overlays: imp = xml.dom.minidom.getDOMImplementation() - doc = imp.createDocument('layman', 'overlays', None) + doc = imp.createDocument('layman', 'repositories', None) root = doc.childNodes[0] diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index b9568b1..bee7529 100644 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -8,11 +8,13 @@ # Base class for the different overlay types. # # Copyright: -# (c) 2005 - 2008 Gunnar Wrobel +# (c) 2005 - 2009 Gunnar Wrobel +# (c) 2009 Sebastian Pipping # Distributed under the terms of the GNU General Public License v2 # # Author(s): # Gunnar Wrobel +# Sebastian Pipping # ''' Basic overlay class.''' @@ -55,7 +57,7 @@ class Overlay: True >>> a.src u'https://overlays.gentoo.org/svn/dev/wrobel' - >>> a.contact + >>> a.owner_email u'nobody@gentoo.org' >>> a.description u'Test' @@ -69,27 +71,40 @@ class Overlay: self.data = node_to_dict(xml) - if '&name' in self.data.keys(): + if '1' in self.data.keys(): + self.name = self.data['1']['@'].strip() + elif '&name' in self.data.keys(): self.name = self.data['&name'] else: - raise Exception('Overlay is missing a "name" attribute!') + raise Exception('Overlay is missing a "name" entry!') - if '&src' in self.data.keys(): + if '1' in self.data.keys(): + self.src = self.data['1']['@'].strip() + elif '&src' in self.data.keys(): self.src = self.data['&src'] else: - raise Exception('Overlay "' + self.name + '" is missing a "src" ' - 'attribute!') - - if '&contact' in self.data.keys(): - self.contact = self.data['&contact'] + raise Exception('Overlay "' + self.name + '" is missing a "source" ' + 'entry!') + + if '1' in self.data.keys() and \ + '1' in self.data['1']: + self.owner_email = self.data['1']['1']['@'].strip() + if '1' in self.data['1']: + self.owner_name = self.data['1']['1']['@'].strip() + else: + self.owner_name = None + elif '&contact' in self.data.keys(): + self.owner_email = self.data['&contact'] + self.owner_name = None else: - self.contact = '' + self.owner_email = '' + self.owner_name = None if not ignore: raise Exception('Overlay "' + self.name + '" is missing a ' - '"contact" attribute!') + '"owner.email" entry!') elif ignore == 1: OUT.warn('Overlay "' + self.name + '" is missing a ' - '"contact" attribute!', 4) + '"owner.email" entry!', 4) if '1' in self.data.keys(): self.description = self.data['1']['@'].strip() @@ -193,7 +208,10 @@ class Overlay: result += self.name + u'\n' + (len(self.name) * u'~') result += u'\nSource : ' + self.src - result += u'\nContact : ' + self.contact + if self.owner_name != None: + result += u'\nContact : %s <%s>' % (self.owner_name, self.owner_email) + else: + result += u'\nContact : ' + self.owner_email result += u'\nType : ' + self.type result += u'; Priority: ' + str(self.priority) + u'\n' @@ -204,13 +222,14 @@ class Overlay: result += u'\n '.join((u'\n' + description).split(u'\n')) result += u'\n' - if '1' in self.data.keys(): - link = self.data['1']['@'].strip() + for key in (e for e in ('1', '1') if e in self.data.keys()): + link = self.data[key]['@'].strip() link = re.compile(u' +').sub(u' ', link) link = re.compile(u'\n ').sub(u'\n', link) result += u'\nLink:\n' result += u'\n '.join((u'\n' + link).split(u'\n')) result += u'\n' + break return result -- cgit v1.2.3-1-g7c22