From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111828 invoked by alias); 11 May 2017 17:33:02 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 111707 invoked by uid 9795); 11 May 2017 17:33:01 -0000 Date: Thu, 11 May 2017 17:33:00 -0000 Message-ID: <20170511173301.111679.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-79-gff4c1b9 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 1df741ca99b61726efabde01557f5a55be1da8e3 X-Git-Newrev: ff4c1b9d1bb650d6b2120fe30fcdb216c9c233bf X-SW-Source: 2017-q2/txt/msg00023.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=ff4c1b9d1bb650d6b2120fe30fcdb216c9c233bf commit ff4c1b9d1bb650d6b2120fe30fcdb216c9c233bf Author: Jon Turney Date: Wed Apr 12 13:05:17 2017 +0100 Add experimental tool to help write gitolite configuration Diff: --- calm/mkgitoliteconf.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 105 insertions(+), 0 deletions(-) diff --git a/calm/mkgitoliteconf.py b/calm/mkgitoliteconf.py new file mode 100755 index 0000000..e32c69b --- /dev/null +++ b/calm/mkgitoliteconf.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2017 Jon Turney +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +# +# mkgitoliteconf - creates a gitolite conf file fragment from cygwin-pkg-maint +# + +from collections import defaultdict +import argparse +import logging +import os +import sys + +from . import common_constants +from . import maintainers + + +# +# transform username to charset acceptable to gitolite +# + + +def transform_username(name): + name = name.replace('.', '') + name = name.replace(' ', '_') + name = name.encode('ascii', 'replace').decode() + return name + + +# +# +# + +def do_main(args): + # read maintainer list + mlist = {} + mlist = maintainers.Maintainer.add_packages(mlist, args.pkglist, getattr(args, 'orphanmaint', None)) + + # make the list of all packages + all_packages = maintainers.Maintainer.all_packages(mlist) + + # invert to a per-package list of maintainers + pkgs = defaultdict(list) + # for each maintainer + for m in mlist.values(): + # for each package + for p in m.pkgs: + # add the maintainer name + pkgs[p].append(m.name) + + # header + print("# automatically generated by mkgitoliteconf") + + # for each package + for p in sorted(pkgs): + users = ' '.join(map(transform_username, pkgs[p])) + if p.startswith('_'): + p = p[1:] + + print("repo cygwin-packages/%s" % (p)) + print("C = %s" % (users)) + print("RW = %s" % (users)) + print("") + +# +# +# + + +def main(): + pkglist_default = common_constants.PKGMAINT + + parser = argparse.ArgumentParser(description='gitolite rules config generator') + parser.add_argument('--pkglist', action='store', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", default=pkglist_default) + (args) = parser.parse_args() + + do_main(args) + +# +# +# + +if __name__ == "__main__": + sys.exit(main()) diff --git a/setup.py b/setup.py index 6472e62..b7b6262 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ setup( 'console_scripts': [ 'calm = calm.calm:main', 'mksetupini = calm.mksetupini:main', + 'calm-mkgitoliteconf = calm.mkgitoliteconf:main', ], }, url='https://cygwin.com/git/?p=cygwin-apps/calm.git',