101 lines
2.9 KiB
Python
Executable File
101 lines
2.9 KiB
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
import ConfigParser
|
|
import fnmatch
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
from eobuilder import settings, init as eobuilder_init
|
|
|
|
|
|
def init():
|
|
eobuilder_init()
|
|
gitolite_admin_path = os.path.join(settings.GIT_PATH, 'gitolite-admin')
|
|
if not os.path.exists(gitolite_admin_path):
|
|
p = subprocess.Popen(
|
|
['git', 'clone', 'git@repos.entrouvert.org:gitolite-admin.git'],
|
|
close_fds=True,
|
|
stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE,
|
|
cwd=settings.GIT_PATH,
|
|
)
|
|
else:
|
|
p = subprocess.Popen(
|
|
['git', 'pull'],
|
|
close_fds=True,
|
|
stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE,
|
|
cwd=gitolite_admin_path,
|
|
)
|
|
stdout, stderr = p.communicate()
|
|
if p.returncode != 0:
|
|
# abort if there's an error in this git call, we could try going on
|
|
# with a prvious clone of gitolite-admin but we would certainly face
|
|
# git errors for other modules too.
|
|
sys.exit(1)
|
|
|
|
|
|
def get_modules():
|
|
modules = []
|
|
gitolite_admin_path = os.path.join(settings.GIT_PATH, 'gitolite-admin')
|
|
for line in open(os.path.join(gitolite_admin_path, 'conf/gitolite.conf')):
|
|
if line.startswith('repo'):
|
|
modules.append(line.split()[-1])
|
|
return modules
|
|
|
|
|
|
def build_module(config, module):
|
|
try:
|
|
dists = config.get('dists', module)
|
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
|
dists = 'bullseye'
|
|
rc = os.system('/usr/local/bin/eobuilder -d %(dists)s %(module)s' % {'dists': dists, 'module': module})
|
|
if rc == 0:
|
|
return 'ok'
|
|
elif rc % 256 != 0:
|
|
return 'fail' # killed by a signal
|
|
else:
|
|
exit_code = rc / 256
|
|
if exit_code == 2:
|
|
return 'skip'
|
|
else:
|
|
return 'fail'
|
|
|
|
|
|
if __name__ == '__main__':
|
|
init()
|
|
cfg_file = os.path.expanduser('~/.config/eobuilder')
|
|
blacklist = []
|
|
config = ConfigParser.RawConfigParser()
|
|
if os.path.exists(cfg_file):
|
|
config.read(cfg_file)
|
|
try:
|
|
blacklist = config.get('eobuildall', 'blacklist').split()
|
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
|
pass
|
|
|
|
results = {}
|
|
for module in sorted(get_modules()):
|
|
blacklisted = False
|
|
for pattern in blacklist:
|
|
if fnmatch.fnmatch(module, pattern):
|
|
blacklisted = True
|
|
break
|
|
if blacklisted:
|
|
continue
|
|
t0 = time.time()
|
|
print('=' * 60)
|
|
print(module)
|
|
print('=' * 60)
|
|
sys.stdout.flush()
|
|
results[module] = build_module(config, module)
|
|
print('\n')
|
|
print('(%1.2f seconds)' % (time.time() - t0))
|
|
print('\n')
|
|
|
|
sys.stdout.flush()
|
|
for module in sorted(results.keys()):
|
|
print('%-40s %s' % (module, results[module]))
|