From b581e4a6f9dbc1f5d9b2f34c7639c5d4c08b65e1 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 22 Dec 2015 17:37:06 +0000 Subject: [PATCH] Use the gitolite Alias feature in staging. --- roles/distgit/files/RepoAliases.header | 8 ++++++++ roles/distgit/tasks/main.yml | 3 +++ roles/distgit/templates/genacls.sh | 16 ++++++++++++++++ roles/distgit/templates/gitolite.rc | 16 +++++++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 roles/distgit/files/RepoAliases.header diff --git a/roles/distgit/files/RepoAliases.header b/roles/distgit/files/RepoAliases.header new file mode 100644 index 0000000000..3ecea867ff --- /dev/null +++ b/roles/distgit/files/RepoAliases.header @@ -0,0 +1,8 @@ +package RepoAliases; +use Exporter; +our @ISA= qw( Exporter ); +our @EXPORT_OK = qw( repo_aliases ); +sub repo_aliases { + return { +# Content auto-generated by genacls.sh... + diff --git a/roles/distgit/tasks/main.yml b/roles/distgit/tasks/main.yml index 7f919ac7c3..cc8c8106c9 100644 --- a/roles/distgit/tasks/main.yml +++ b/roles/distgit/tasks/main.yml @@ -149,6 +149,9 @@ - config - distgit +- name: Copy in RepoAliases.header + copy: src=RepoAliases.header dest=/etc/gitolite/RepoAliases.header owner=root group=root mode=0755 + - name: Create the update-block-push-origin symlink command: ln -s /usr/share/git-core/update-block-push-origin /etc/gitolite/local/VREF/update-block-push-origin creates=/etc/gitolite/local/VREF/update-block-push-origin diff --git a/roles/distgit/templates/genacls.sh b/roles/distgit/templates/genacls.sh index 079f98eb3e..a9042eb141 100644 --- a/roles/distgit/templates/genacls.sh +++ b/roles/distgit/templates/genacls.sh @@ -10,8 +10,24 @@ cd $TEMPDIR # Then create the repos and branches on disk (if we need any new ones) python /usr/local/bin/pkgdb_sync_git_branches.py +{% if env == 'staging' %} +# Leverage gitolite's Alias.pm feature to build backwards compat links +cat /etc/gitolite/RepoAliases.header > RepoAliases.pm +# Get all repos. Strip off 'rpms/'. Convert to perl mapping. Tack it on. +grep rpms/ /etc/gitolite/conf/gitolite.conf | \ + sed 's/repo rpms\///g' | \ + sed "s/.*/'&' => 'rpms\/&',/g" \ + >> RepoAliases.pm +echo "};}1;" >> RepoAliases.pm +{% endif %} + +# With that done, move the files into place and run compile mv gitolite.conf /etc/gitolite/conf/ chown gen-acls:gen-acls -R /etc/gitolite/conf/ +{% if env == 'staging' %} +mv RepoAliases.pm /etc/gitolite/RepoAliases.pm +chown gen-acls:gen-acls -R /etc/gitolite/RepoAliases.pm +{% endif %} HOME=/srv/git /usr/bin/gitolite compile {% if env != 'staging' %} diff --git a/roles/distgit/templates/gitolite.rc b/roles/distgit/templates/gitolite.rc index b8530e438c..c5e1bbea55 100644 --- a/roles/distgit/templates/gitolite.rc +++ b/roles/distgit/templates/gitolite.rc @@ -12,6 +12,14 @@ # "list of non-core programs shipped with gitolite" in the master index) or # directly in the corresponding source file. + +{% if env == 'staging' %} +# Hack! +# Pull in our repo aliases generated by genacls.sh +use lib ('/etc/gitolite/'); +use RepoAliases qw( repo_aliases ); +{% endif %} + %RC = ( # ------------------------------------------------------------------ @@ -40,6 +48,10 @@ WRITERS => 1, }, + {% if env == 'staging' %} + REPO_ALIASES => repo_aliases(), + {% endif %} + # enable caching (currently only Redis). PLEASE RTFM BEFORE USING!!! # CACHE => 'Redis', @@ -121,8 +133,10 @@ # no auto-create at all (don't forget to enable the 'create' command!) 'no-auto-create', + {% if env == 'staging' %} # access a repo by another (possibly legacy) name - # 'Alias', + 'Alias', + {% endif %} # give some users direct shell access. See documentation in # sts.html for details on the following two choices.