summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-sysadm/2011-January/001693.html
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-04-14 13:46:12 +0000
committerNicolas Vigier <boklm@mageia.org>2013-04-14 13:46:12 +0000
commit1be510f9529cb082f802408b472a77d074b394c0 (patch)
treeb175f9d5fcb107576dabc768e7bd04d4a3e491a0 /zarb-ml/mageia-sysadm/2011-January/001693.html
parentfa5098cf210b23ab4f419913e28af7b1b07dafb2 (diff)
downloadarchives-master.tar
archives-master.tar.gz
archives-master.tar.bz2
archives-master.tar.xz
archives-master.zip
Add zarb MLs html archivesHEADmaster
Diffstat (limited to 'zarb-ml/mageia-sysadm/2011-January/001693.html')
-rw-r--r--zarb-ml/mageia-sysadm/2011-January/001693.html527
1 files changed, 527 insertions, 0 deletions
diff --git a/zarb-ml/mageia-sysadm/2011-January/001693.html b/zarb-ml/mageia-sysadm/2011-January/001693.html
new file mode 100644
index 000000000..02037a7e2
--- /dev/null
+++ b/zarb-ml/mageia-sysadm/2011-January/001693.html
@@ -0,0 +1,527 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [Mageia-sysadm] [704] add cia bot svn hook
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B704%5D%20add%20cia%20bot%20svn%20hook&In-Reply-To=%3C20110107174334.48F0B41BAA%40valstar.mageia.org%3E">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="001699.html">
+ <LINK REL="Next" HREF="001694.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[Mageia-sysadm] [704] add cia bot svn hook</H1>
+ <B>root at mageia.org</B>
+ <A HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B704%5D%20add%20cia%20bot%20svn%20hook&In-Reply-To=%3C20110107174334.48F0B41BAA%40valstar.mageia.org%3E"
+ TITLE="[Mageia-sysadm] [704] add cia bot svn hook">root at mageia.org
+ </A><BR>
+ <I>Fri Jan 7 18:43:34 CET 2011</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="001699.html">[Mageia-sysadm] Rebuild failed on i586 for @264:psutils-p17-16mga1.src.rpm
+</A></li>
+ <LI>Next message: <A HREF="001694.html">[Mageia-sysadm] [706] use sh version of cia script
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#1693">[ date ]</a>
+ <a href="thread.html#1693">[ thread ]</a>
+ <a href="subject.html#1693">[ subject ]</a>
+ <a href="author.html#1693">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>Revision: 704
+Author: boklm
+Date: 2011-01-07 18:43:33 +0100 (Fri, 07 Jan 2011)
+Log Message:
+-----------
+add cia bot svn hook
+
+Modified Paths:
+--------------
+ puppet/modules/subversion/manifests/init.pp
+
+Added Paths:
+-----------
+ puppet/modules/subversion/templates/ciabot_svn.py
+
+Modified: puppet/modules/subversion/manifests/init.pp
+===================================================================
+--- puppet/modules/subversion/manifests/init.pp 2011-01-07 15:10:20 UTC (rev 703)
++++ puppet/modules/subversion/manifests/init.pp 2011-01-07 17:43:33 UTC (rev 704)
+@@ -123,6 +123,7 @@
+ define repository ($group = &quot;svn&quot;,
+ $public = true,
+ $commit_mail = '',
++ $cia_post = true,
+ $syntax_check = '',
+ $extract_dir = '') {
+ # check permissions
+@@ -177,6 +178,17 @@
+ }
+ }
+
++ if $cia_post {
++ file { &quot;$name/hooks/post-commit.d/cia.vc&quot;:
++ ensure =&gt; present,
++ owner =&gt; root,
++ group =&gt; root,
++ mode =&gt; 755,
++ content =&gt; template(&quot;subversion/ciabot_svn.py&quot;),
++ }
++
++ }
++
+ if $extract_dir {
+ file { &quot;$name/hooks/post-commit.d/extract_dir&quot;:
+ ensure =&gt; present,
+
+Added: puppet/modules/subversion/templates/ciabot_svn.py
+===================================================================
+--- puppet/modules/subversion/templates/ciabot_svn.py (rev 0)
++++ puppet/modules/subversion/templates/ciabot_svn.py 2011-01-07 17:43:33 UTC (rev 704)
+@@ -0,0 +1,398 @@
++#!/usr/bin/env python
++#
++# This is a CIA client script for Subversion repositories, written in python.
++# It generates commit messages using CIA's XML format, and can deliver them
++# using either XML-RPC or email. See below for usage and cuztomization
++# information.
++#
++# --------------------------------------------------------------------------
++#
++# Copyright (c) 2004-2007, Micah Dowty
++# All rights reserved.
++#
++# Redistribution and use in source and binary forms, with or without
++# modification, are permitted provided that the following conditions are met:
++#
++# * Redistributions of source code must retain the above copyright notice,
++# this list of conditions and the following disclaimer.
++# * Redistributions in binary form must reproduce the above copyright
++# notice, this list of conditions and the following disclaimer in the
++# documentation and/or other materials provided with the distribution.
++# * The name of the author may not be used to endorse or promote products
++# derived from this software without specific prior written permission.
++#
++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
++# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
++# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
++# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
++# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
++# POSSIBILITY OF SUCH DAMAGE.
++#
++# --------------------------------------------------------------------------
++#
++# This script is cleaner and much more featureful than the shell
++# script version, but won't work on systems without Python.
++#
++# To use the CIA bot in your Subversion repository...
++#
++# 1. Customize the parameters below
++#
++# 2. This script should be called from your repository's post-commit
++# hook with the repository and revision as arguments. For example,
++# you could copy this script into your repository's &quot;hooks&quot; directory
++# and add something like the following to the &quot;post-commit&quot; script,
++# also in the repository's &quot;hooks&quot; directory:
++#
++# REPOS=&quot;$1&quot;
++# REV=&quot;$2&quot;
++# $REPOS/hooks/ciabot_svn.py &quot;$REPOS&quot; &quot;$REV&quot; &amp;
++#
++# Or, if you have multiple project hosted, you can add each
++# project's name to the commandline in that project's post-commit
++# hook:
++#
++# $REPOS/hooks/ciabot_svn.py &quot;$REPOS&quot; &quot;$REV&quot; &quot;ProjectName&quot; &amp;
++#
++############# There are some parameters for this script that you can customize:
++
++class config:
++ # Replace this with your project's name, or always provide a project
++ # name on the commandline.
++ #
++ # NOTE: This shouldn't be a long description of your project. Ideally
++ # it is a short identifier with no spaces, punctuation, or
++ # unnecessary capitalization. This will be used in URLs related
++ # to your project, as an internal identifier, and in IRC messages.
++ # If you want a longer name shown for your project on the web
++ # interface, please use the &quot;title&quot; metadata key rather than
++ # putting that here.
++ #
++ project = &quot;Mageia&quot;
++
++ # Subversion's normal directory hierarchy is powerful enough that
++ # it doesn't have special methods of specifying modules, tags, or
++ # branches like CVS does. Most projects do use a naming
++ # convention though that works similarly to CVS's modules, tags,
++ # and branches.
++ #
++ # This is a list of regular expressions that are tested against
++ # paths in the order specified. If a regex matches, the 'branch'
++ # and 'module' groups are stored and the matching section of the
++ # path is removed.
++ #
++ # Several common directory structure styles are below as defaults.
++ # Uncomment the ones you're using, or add your own regexes.
++ # Whitespace in the each regex are ignored.
++
++ pathRegexes = [
++ # r&quot;^ trunk/ (?P&lt;module&gt;[^/]+)/ &quot;,
++ # r&quot;^ (branches|tags)/ (?P&lt;branch&gt;[^/]+)/ &quot;,
++ # r&quot;^ (branches|tags)/ (?P&lt;module&gt;[^/]+)/ (?P&lt;branch&gt;[^/]+)/ &quot;,
++ ]
++
++ # If your repository is accessible over the web, put its base URL here
++ # and 'uri' attributes will be given to all &lt;file&gt; elements. This means
++ # that in CIA's online message viewer, each file in the tree will link
++ # directly to the file in your repository.
++ repositoryURI = None
++
++ # If your repository is accessible over the web via a tool like ViewVC
++ # that allows viewing information about a full revision, put a format string
++ # for its URL here. You can specify various substitution keys in the Python
++ # syntax: &quot;%(project)s&quot; is replaced by the project name, and likewise
++ # &quot;%(revision)s&quot; and &quot;%(author)s&quot; are replaced by the revision / author.
++ # The resulting URI is added to the data sent to CIA. After this, in CIA's
++ # online message viewer, the commit will link directly to the corresponding
++ # revision page.
++ revisionURI = None
++ # Example (works for ViewVC as used by SourceForge.net):
++ #revisionURI = &quot;<A HREF="https://svn.sourceforge.net/viewcvs.cgi/%(project">https://svn.sourceforge.net/viewcvs.cgi/%(project</A>)s?view=rev&amp;rev=%(revision)s&quot;
++
++ # This can be the <A HREF="http://">http://</A> URI of the CIA server to deliver commits over
++ # XML-RPC, or it can be an email address to deliver using SMTP. The
++ # default here should work for most people. If you need to use e-mail
++ # instead, you can replace this with &quot;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-sysadm">cia at cia.navi.cx</A>&quot;
++ server = &quot;<A HREF="http://cia.navi.cx">http://cia.navi.cx</A>&quot;
++
++ # The SMTP server to use, only used if the CIA server above is an
++ # email address.
++ smtpServer = &quot;localhost&quot;
++
++ # The 'from' address to use. If you're delivering commits via email, set
++ # this to the address you would normally send email from on this host.
++ fromAddress = &quot;<A HREF="https://www.mageia.org/mailman/listinfo/mageia-sysadm">cia-user at localhost</A>&quot;
++
++ # When nonzero, print the message to stdout instead of delivering it to CIA.
++ debug = 0
++
++
++############# Normally the rest of this won't need modification
++
++import sys, os, re, urllib, getopt
++
++class File:
++ &quot;&quot;&quot;A file in a Subversion repository. According to our current
++ configuration, this may have a module, branch, and URI in addition
++ to a path.&quot;&quot;&quot;
++
++ # Map svn's status letters to our action names
++ actionMap = {
++ 'U': 'modify',
++ 'A': 'add',
++ 'D': 'remove',
++ }
++
++ def __init__(self, fullPath, status=None):
++ self.fullPath = fullPath
++ self.path = fullPath
++ self.action = self.actionMap.get(status)
++
++ def getURI(self, repo):
++ &quot;&quot;&quot;Get the URI of this file, given the repository's URI. This
++ encodes the full path and joins it to the given URI.&quot;&quot;&quot;
++ quotedPath = urllib.quote(self.fullPath)
++ if quotedPath[0] == '/':
++ quotedPath = quotedPath[1:]
++ if repo[-1] != '/':
++ repo = repo + '/'
++ return repo + quotedPath
++
++ def makeTag(self, config):
++ &quot;&quot;&quot;Return an XML tag for this file, using the given config&quot;&quot;&quot;
++ attrs = {}
++
++ if config.repositoryURI is not None:
++ attrs['uri'] = self.getURI(config.repositoryURI)
++
++ if self.action:
++ attrs['action'] = self.action
++
++ attrString = ''.join([' %s=&quot;%s&quot;' % (key, escapeToXml(value,1))
++ for key, value in attrs.items()])
++ return &quot;&lt;file%s&gt;%s&lt;/file&gt;&quot; % (attrString, escapeToXml(self.path))
++
++
++class SvnClient:
++ &quot;&quot;&quot;A CIA client for Subversion repositories. Uses svnlook to
++ gather information&quot;&quot;&quot;
++ name = 'Python Subversion client for CIA'
++ version = '1.20'
++
++ def __init__(self, repository, revision, config):
++ self.repository = repository
++ self.revision = revision
++ self.config = config
++
++ def deliver(self, message):
++ if config.debug:
++ print message
++ else:
++ server = self.config.server
++ if server.startswith('http:') or server.startswith('https:'):
++ # Deliver over XML-RPC
++ import xmlrpclib
++ xmlrpclib.ServerProxy(server).hub.deliver(message)
++ else:
++ # Deliver over email
++ import smtplib
++ smtp = smtplib.SMTP(self.config.smtpServer)
++ smtp.sendmail(self.config.fromAddress, server,
++ &quot;From: %s\r\nTo: %s\r\n&quot;
++ &quot;Subject: DeliverXML\r\n\r\n%s&quot; %
++ (self.config.fromAddress, server, message))
++
++ def main(self):
++ self.collectData()
++ self.deliver(&quot;&lt;message&gt;&quot; +
++ self.makeGeneratorTag() +
++ self.makeSourceTag() +
++ self.makeBodyTag() +
++ &quot;&lt;/message&gt;&quot;)
++
++ def makeAttrTags(self, *names):
++ &quot;&quot;&quot;Given zero or more attribute names, generate XML elements for
++ those attributes only if they exist and are non-None.
++ &quot;&quot;&quot;
++ s = ''
++ for name in names:
++ if hasattr(self, name):
++ v = getattr(self, name)
++ if v is not None:
++ # Recent Pythons don't need this, but Python 2.1
++ # at least can't convert other types directly
++ # to Unicode. We have to take an intermediate step.
++ if type(v) not in (type(''), type(u'')):
++ v = str(v)
++
++ s += &quot;&lt;%s&gt;%s&lt;/%s&gt;&quot; % (name, escapeToXml(v), name)
++ return s
++
++ def makeGeneratorTag(self):
++ return &quot;&lt;generator&gt;%s&lt;/generator&gt;&quot; % self.makeAttrTags(
++ 'name',
++ 'version',
++ )
++
++ def makeSourceTag(self):
++ return &quot;&lt;source&gt;%s&lt;/source&gt;&quot; % self.makeAttrTags(
++ 'project',
++ 'module',
++ 'branch',
++ )
++
++ def makeBodyTag(self):
++ return &quot;&lt;body&gt;&lt;commit&gt;%s%s&lt;/commit&gt;&lt;/body&gt;&quot; % (
++ self.makeAttrTags(
++ 'revision',
++ 'author',
++ 'log',
++ 'diffLines',
++ 'url',
++ ),
++ self.makeFileTags(),
++ )
++
++ def makeFileTags(self):
++ &quot;&quot;&quot;Return XML tags for our file list&quot;&quot;&quot;
++ return &quot;&lt;files&gt;%s&lt;/files&gt;&quot; % ''.join([file.makeTag(self.config)
++ for file in self.files])
++
++ def svnlook(self, command):
++ &quot;&quot;&quot;Run the given svnlook command on our current repository and
++ revision, returning all output&quot;&quot;&quot;
++ # We have to set LC_ALL to force svnlook to give us UTF-8 output,
++ # then we explicitly slurp that into a unicode object.
++ return unicode(os.popen(
++ 'LC_ALL=&quot;en_US.UTF-8&quot; svnlook %s -r &quot;%s&quot; &quot;%s&quot;' %
++ (command, self.revision, self.repository)).read(),
++ 'utf-8', 'replace')
++
++ def collectData(self):
++ self.author = self.svnlook('author').strip()
++ self.project = self.config.project
++ self.log = self.svnlook('log')
++ self.diffLines = len(self.svnlook('diff').split('\n'))
++ self.files = self.collectFiles()
++ if self.config.revisionURI is not None:
++ self.url = self.config.revisionURI % self.__dict__
++ else:
++ self.url = None
++
++ def collectFiles(self):
++ # Extract all the files from the output of 'svnlook changed'
++ files = []
++ for line in self.svnlook('changed').split('\n'):
++ path = line[2:].strip()
++ if path:
++ status = line[0]
++ files.append(File(path, status))
++
++ # Try each of our several regexes. To be applied, the same
++ # regex must mach every file under consideration and they must
++ # all return the same results. If we find one matching regex,
++ # or we try all regexes without a match, we're done.
++ matchDict = None
++ for regex in self.config.pathRegexes:
++ matchDict = matchAgainstFiles(regex, files)
++ if matchDict is not None:
++ self.__dict__.update(matchDict)
++ break
++
++ return files
++
++
++def matchAgainstFiles(regex, files):
++ &quot;&quot;&quot;Try matching a regex against all File objects in the provided list.
++ If the regex returns the same matches for every file, the matches
++ are returned in a dict and the matched portions are filtered out.
++ If not, returns None.
++ &quot;&quot;&quot;
++ prevMatchDict = None
++ compiled = re.compile(regex, re.VERBOSE)
++ for f in files:
++
++ match = compiled.match(f.fullPath)
++ if not match:
++ # Give up, it must match every file
++ return None
++
++ matchDict = match.groupdict()
++ if prevMatchDict is not None and prevMatchDict != matchDict:
++ # Give up, we got conflicting matches
++ return None
++
++ prevMatchDict = matchDict
++
++ # If we got this far, the regex matched every file with
++ # the same results. Now filter the matched portion out of
++ # each file and store the matches we found.
++ for f in files:
++ f.path = compiled.sub('', f.fullPath)
++ return prevMatchDict
++
++
++def escapeToXml(text, isAttrib=0):
++ text = unicode(text)
++ text = text.replace(&quot;&amp;&quot;, &quot;&amp;amp;&quot;)
++ text = text.replace(&quot;&lt;&quot;, &quot;&amp;lt;&quot;)
++ text = text.replace(&quot;&gt;&quot;, &quot;&amp;gt;&quot;)
++ if isAttrib == 1:
++ text = text.replace(&quot;'&quot;, &quot;&amp;apos;&quot;)
++ text = text.replace(&quot;\&quot;&quot;, &quot;&amp;quot;&quot;)
++ return text
++
++
++def usage():
++ &quot;&quot;&quot;Print a short usage description of this script and exit&quot;&quot;&quot;
++ sys.stderr.write(&quot;Usage: %s [OPTIONS] REPOS-PATH REVISION [PROJECTNAME]\n&quot; %
++ sys.argv[0])
++
++
++def version():
++ &quot;&quot;&quot;Print out the version of this script&quot;&quot;&quot;
++ sys.stderr.write(&quot;%s %s\n&quot; % (sys.argv[0], SvnClient.version))
++
++
++def main():
++ try:
++ options = [ &quot;version&quot; ]
++ for key in config.__dict__:
++ if not key.startswith(&quot;_&quot;):
++ options.append(key + &quot;=&quot;);
++ opts, args = getopt.getopt(sys.argv[1:], &quot;&quot;, options)
++ except getopt.GetoptError:
++ usage()
++ sys.exit(2)
++
++ for o, a in opts:
++ if o == &quot;--version&quot;:
++ version()
++ sys.exit()
++ else:
++ # Everything else maps straight to a config key. Just have
++ # to remove the &quot;--&quot; prefix from the option name.
++ config.__dict__[o[2:]] = a
++
++ # Print a usage message when not enough parameters are provided.
++ if not len(args) in (2,3):
++ sys.stderr.write(&quot;%s: incorrect number of arguments\n&quot; % sys.argv[0])
++ usage();
++ sys.exit(2);
++
++ # If a project name was provided, override the default project name.
++ if len(args) == 3:
++ config.project = args[2]
++
++ # Go do the real work.
++ SvnClient(args[0], args[1], config).main()
++
++
++if __name__ == &quot;__main__&quot;:
++ main()
++
++### The End ###
+-------------- next part --------------
+An HTML attachment was scrubbed...
+URL: &lt;/pipermail/mageia-sysadm/attachments/20110107/ed31022c/attachment-0001.html&gt;
+</PRE>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="001699.html">[Mageia-sysadm] Rebuild failed on i586 for @264:psutils-p17-16mga1.src.rpm
+</A></li>
+ <LI>Next message: <A HREF="001694.html">[Mageia-sysadm] [706] use sh version of cia script
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#1693">[ date ]</a>
+ <a href="thread.html#1693">[ thread ]</a>
+ <a href="subject.html#1693">[ subject ]</a>
+ <a href="author.html#1693">[ author ]</a>
+ </LI>
+ </UL>
+
+<hr>
+<a href="https://www.mageia.org/mailman/listinfo/mageia-sysadm">More information about the Mageia-sysadm
+mailing list</a><br>
+</body></html>