diff --git a/files/pkgdb_sync_git_branches.py b/files/pkgdb_sync_git_branches.py index dcfee5e..884d55e 100644 --- a/files/pkgdb_sync_git_branches.py +++ b/files/pkgdb_sync_git_branches.py @@ -50,6 +50,10 @@ def _get_conf(cp, section, option, default): config = ConfigParser() config.read("/etc/dist-git/dist-git.conf") PKGDB_URL = _get_conf(config, "acls", "pkgdb_acls_url", "") +EMAIL_DOMAIN = _get_conf(config, "notifications", "email_domain", "fedoraproject.org") +PKG_OWNER_EMAILS = _get_conf(config, "notifications", "pkg_owner_emails", + "$PACKAGE-owner@fedoraproject.org,scm-commits@lists.fedoraproject.org") + GIT_FOLDER = '/srv/git/rpms/' MKBRANCH = '/usr/local/bin/mkbranch' @@ -179,7 +183,8 @@ def branch_package(pkgname, requested_branches, existing_branches): # Create the devel branch if necessary exists = os.path.exists(os.path.join(GIT_FOLDER, '%s.git' % pkgname)) if not exists or 'master' not in existing_branches: - _invoke(SETUP_PACKAGE, [pkgname]) + emails = PKG_OWNER_EMAILS.replace("$PACKAGE", pkgname) + _invoke(SETUP_PACKAGE, ["--pkg-owner-emails", emails, "--email-domain", EMAIL_DOMAIN, pkgname]) if 'master' in requested_branches: requested_branches.remove('master') # SETUP_PACKAGE creates master diff --git a/files/setup_git_package b/files/setup_git_package index 67103ec..dd8ab81 100644 --- a/files/setup_git_package +++ b/files/setup_git_package @@ -8,6 +8,7 @@ # All local changes will be lost. + # Figure out the environment we're running in GITROOT=/srv/git/rpms @@ -29,43 +30,57 @@ GIT_SSH_URL="ssh://localhost" Usage() { cat < + $0 [OPTIONS] Creates a new repo for Options: -h,--help This help message + --email-domain DOMAIN Email domain for git hooks.maildomain + --pkg-owner-emails EMAILS Comma separated list of emails for + git hooks.mailinglist EOF } -if [ $# -gt 2 ]; then +# fail with no arguments +if [ $# -eq 0 ]; then Usage exit -1 fi -# parse the arguments -while [ -n "$1" ] ; do - case "$1" in - -h | --help ) - Usage - exit 0 - ;; +OPTS=$(getopt -o h -l help -l email-domain: -l pkg-owner-emails: -- "$@") +if [ $? != 0 ] +then + exit 1 +fi - * ) - PACKAGE="$1" - ;; +eval set -- "$OPTS" + +while true ; do + case "$1" in + -h | --help) Usage; exit 0;; + --email-domain) EMAIL_DOMAIN=$2; shift 2;; + --pkg-owner-emails) PKG_OWNER_EMAILS=$2; shift 2;; + --) shift; break;; esac - shift done -# I hate shell scripting. I'm sure the above is totally wrong - -# check the arguments -if [ -z "$PACKAGE" ] ; then +# fail when more or none packages are specified +if ! [ $# -eq 1 ]; then Usage exit -1 fi +PACKAGE=$1 + +if [ -z $EMAIL_DOMAIN ]; then + EMAIL_DOMAIN=fedoraproject.org +fi + +if [ -z $PKG_OWNER_EMAILS ]; then + PKG_OWNER_EMAILS=$PACKAGE-owner@fedoraproject.org,scm-commits@lists.fedoraproject.org +fi + # Sanity checks before we start doing damage [ $VERBOSE -gt 1 ] && echo "Checking package $PACKAGE..." if [ -f $GITROOT/$PACKAGE.git/refs/heads/master ] ; then @@ -95,8 +110,8 @@ mkdir -p $GITROOT/$PACKAGE.git pushd $GITROOT/$PACKAGE.git >/dev/null git init -q --shared --bare echo "$PACKAGE" > description # This is used to figure out who to send mail to. -git config --add hooks.mailinglist "$PACKAGE-owner@fedoraproject.org,scm-commits@lists.fedoraproject.org" -git config --add hooks.maildomain fedoraproject.org +git config --add hooks.mailinglist $PKG_OWNER_EMAILS +git config --add hooks.maildomain $EMAIL_DOMAIN popd >/dev/null # Now clone that repo and create the .gitignore and sources file