--- /dev/null
+#!/bin/sh
+
+set -e
+set -u
+
+escape() {
+ echo "$1" | sed -e 's/@/@@/g'
+}
+
+category=$(escape "$1")
+name=$(escape "$2")
+principal=$(escape "$3")
+
+base=build.hooks.post_add_repo.zephyr
+class=$(invirt-getconf "$base.class" 2>/dev/null || :)
+instance=$(invirt-getconf "$base.instance" 2>/dev/null || :)
+zsig=$(invirt-getconf "$base.zsig" 2>/dev/null || :)
+
+if [ -z "$class" ]; then
+ echo "I don't know where to send a commit zephyr!" >&2
+ echo "Please provide a value for $base.class in" >&2
+ echo "your invirt config file." >&2
+ exit 1
+fi
+
+(echo "$principal just created a new repository, $category/$name.git") | zwrite -c "$class" -i "${instance:-add-repo}" -s "${zsig:-Make a new repo}" -d
--- /dev/null
+#!/usr/bin/env python
+
+import optparse
+import os
+import shutil
+import sys
+
+from invirt import builder, common
+from invirt.config import structs as config
+
+REPO_BASE = '/srv/git/invirt'
+HOOK_BASE = '/usr/share/invirt-dev/git-hooks'
+
+def main():
+ parser = optparse.OptionParser('%prog repo <category> <name>')
+ opts, args = parser.parse_args()
+
+ if len(args) != 3:
+ parser.print_help()
+ return 1
+
+ category = args[1]
+ name = args[2]
+ principal = os.environ['REMOTE_USER']
+ repo_path = os.path.join(REPO_BASE, category, '%s.git' % name)
+
+ if os.path.exists(repo_path):
+ print >>sys.stderr, '%s already exists!' % repo_path
+ return 1
+
+ print 'Creating new repo at %s' % repo_path
+ os.makedirs(repo_path)
+ common.captureOutput(['git', 'init', '--bare'], cwd=repo_path)
+ print 'Replacing hooks directory with a symlink'
+ hooks_dir = os.path.join(repo_path, 'hooks')
+ shutil.rmtree(hooks_dir)
+ common.captureOutput(['chown', '-R', 'git:', repo_path])
+ if category == 'packages':
+ os.symlink(os.path.join(HOOK_BASE, 'sub'), hooks_dir)
+ else:
+ os.symlink(os.path.join(HOOK_BASE, 'other'), hooks_dir)
+
+ builder.runHook('post-add-repo', [category, name, principal])
+
+if __name__ == '__main__':
+ sys.exit(main())
for pocket in config.build.pockets:
print >>f, 'build %s %s %s' % (pocket, build_handler, acl_path(pocket))
- os.rename(conf_name, '/etc/remctl/conf.d/build')
+ with atomic_write('/etc/remctl/acl/repo_admin') as f:
+ acl = authz.expandAdmin(config.build.repo_admin, None)
+ print >>f, '\n'.join(userToPrinc(a) for a in acl)
- k5login_fd, k5login_name = tempfile.mkstemp()
- k5login = os.fdopen(k5login_fd, 'r+')
- print >>k5login, '\n'.join(all_devs)
+ with atomic_write('/etc/remctl/conf.d/repo_admin') as f:
+ print >>f, 'create repo /usr/bin/invirt-add-repo /etc/remctl/acl/repo_admin'
with atomic_write(os.path.join(builder._REPO_DIR, '.k5login')) as f:
print >>f, '\n'.join(all_devs)
py_modules = ['invirt.builder'],
package_dir = {'': 'python'},
- scripts = ['invirtibuilder', 'invirt-build-conf', 'invirt-submit-build']
+ scripts = ['invirtibuilder', 'invirt-build-conf', 'invirt-submit-build', 'invirt-add-repo']
)