Merge pull request #12 from praiskup/config-only

config: use ini file
This commit is contained in:
Michal Novotný 2017-02-23 15:14:12 -05:00 committed by GitHub
commit 91ab0a3be9
7 changed files with 24 additions and 26 deletions

View file

@ -1,2 +1,4 @@
GITROOT_DIR=/var/lib/dist-git/git
CACHE_DIR=/var/lib/dist-git/cache
[dist-git]
git_author = Fedora Release Engineering <rel-eng@lists.fedoraproject.org>
cache_dir = /var/lib/dist-git/cache
gitroot_dir = /var/lib/dist-git/git

View file

@ -29,6 +29,7 @@ Requires: git-daemon
Requires: python-requests
Requires: mod_ssl
Requires: fedmsg
Requires: crudini
Requires(pre): shadow-utils
%description

View file

@ -6,9 +6,8 @@
# Looking for git repos.
#
source <(grep = /etc/dist-git/dist-git.conf)
destination=$GITROOT_DIR/pkgs-git-repos-list
eval "$(crudini --format=sh --get /etc/dist-git/dist-git.conf)"
destination=$gitroot_dir/pkgs-git-repos-list
if [ -n "$1" ]
then
@ -17,7 +16,7 @@ fi
newfile=`mktemp`
cd $GITROOT_DIR/repositories
cd $gitroot_dir/repositories
ls > $newfile
cp -fZ $newfile $destination
rm $newfile

View file

@ -9,10 +9,10 @@
# Figure out the environment we're running in
RUNDIR=$(cd $(dirname $0) && pwd)
RUNDIR=$(cd "$(dirname "$0")" && pwd)
source <(grep = /etc/dist-git/dist-git.conf)
REPODIR=$GITROOT_DIR/repositories
eval "$(crudini --format=sh --get /etc/dist-git/dist-git.conf)"
REPODIR=$gitroot_dir/repositories
# check if a moron is driving me
if [ ! -d $REPODIR ] ; then
@ -32,7 +32,6 @@ IGNORE=
BRANCH=""
PACKAGES=""
SRC_BRANCH="master"
AUTHOR="Fedora Release Engineering <rel-eng@lists.fedoraproject.org>"
Usage() {
cat <<EOF

View file

@ -9,10 +9,10 @@
# Figure out the environment we're running in
RUNDIR=$(cd $(dirname $0) && pwd)
RUNDIR=$(cd "$(dirname "$0")" && pwd)
source <(grep = /etc/dist-git/dist-git.conf)
REPODIR=$GITROOT_DIR/repositories
eval "$(crudini --format=sh --get /etc/dist-git/dist-git.conf)"
REPODIR=$gitroot_dir/repositories
# check if a moron is driving me
if [ ! -d $REPODIR ] ; then
@ -32,7 +32,6 @@ IGNORE=
BRANCH=""
PACKAGES=""
SRC_BRANCH="master"
AUTHOR="Fedora Release Engineering <rel-eng@lists.fedoraproject.org>"
Usage() {
cat <<EOF

View file

@ -9,8 +9,9 @@
# Figure out the environment we're running in
source <(grep = /etc/dist-git/dist-git.conf)
REPODIR=$GITROOT_DIR/repositories
eval "$(crudini --format=sh --get /etc/dist-git/dist-git.conf)"
REPODIR=$gitroot_dir/repositories
: ${git_author="Undefined <undefined@example.com>"}
# check if a moron is driving me
if [ ! -d $REPODIR ] ; then
@ -24,7 +25,6 @@ fi
VERBOSE=0
TEST=
IGNORE=
AUTHOR="Fedora Release Engineering <rel-eng@lists.fedoraproject.org>"
GIT_SSH_URL="ssh://localhost"
Usage() {
@ -92,7 +92,7 @@ git init -q $TMPDIR/$PACKAGE
pushd $TMPDIR/$PACKAGE >/dev/null
touch .gitignore sources
git add .
git commit -q -m 'Initial setup of the repo' --author "$AUTHOR"
git commit -q -m 'Initial setup of the repo' --author "$git_author"
git remote add origin $REPODIR/$PACKAGE.git
git push -q origin master
popd >/dev/null

View file

@ -17,16 +17,11 @@ import tempfile
import fedmsg
import fedmsg.config
from configparser import ConfigParser
# Reading buffer size
BUFFER_SIZE = 4096
# We check modules exist from this dircetory
GITREPO = '/var/lib/dist-git/git/repositories'
# Lookaside cache directory
CACHE_DIR = '/var/lib/dist-git/cache/lookaside/pkgs'
# Fedora Packager Group
PACKAGER_GROUP = 'packager'
@ -97,6 +92,9 @@ def makedirs(dir_, username, mode=02755):
def main():
config = ConfigParser()
config.read('/etc/dist-git/dist-git.conf')
os.umask(002)
username = os.environ.get('SSL_CLIENT_S_DN_CN', None)
@ -162,12 +160,12 @@ def main():
username, name, filename, hash_type.upper(),
checksum))
module_dir = os.path.join(CACHE_DIR, name)
module_dir = os.path.join(config['dist-git']['cache_dir'], "lookaside/pkgs", name)
hash_dir = os.path.join(module_dir, filename, hash_type, checksum)
msgpath = os.path.join(name, filename, hash_type, checksum, filename)
# first test if the module really exists
git_dir = os.path.join(GITREPO, '%s.git' % name)
git_dir = os.path.join(config['dist-git']['gitroot_dir'], 'repositories', '%s.git' % name)
if not os.path.isdir(git_dir):
sys.stderr.write('[username=%s] Unknown module: %s' % (username, name))
send_error('Module "%s" does not exist!' % name,