diff --git a/buildbot.py b/buildbot.py index f29ecb6..5f04a21 100755 --- a/buildbot.py +++ b/buildbot.py @@ -39,6 +39,11 @@ os.chdir(abspath) logger = logging.getLogger('buildbot') configure_logger(logger, logfile='buildbot.log', rotate_size=1024*1024*10) +# refuse to run in systemd-nspawn +if 'systemd-nspawn' in bash('systemd-detect-virt || true'): + logger.error('Refused to run in systemd-nspawn.') + raise AssertionError('Refused to run in systemd-nspawn.') + REPO_ROOT = Path(PKGBUILD_DIR) class Job: @@ -84,13 +89,15 @@ class jobsManager: return ret def reset_dir(self, pkgdirname=None, all=False): if all: - logger.info('git checkout all: %s', bash(GIT_RESET_SUBDIR, cwd=REPO_ROOT)) + logger.info('resetting %s', str(REPO_ROOT)) + bash(GIT_RESET_SUBDIR, cwd=REPO_ROOT) else: if not pkgdirname: return False cwd = REPO_ROOT / pkgdirname if cwd.exists(): - logger.info('git checkout: %s', bash(GIT_RESET_SUBDIR, cwd=cwd)) + logger.info('resetting %s', str(cwd)) + bash(GIT_RESET_SUBDIR, cwd=cwd) for fpath in [f for f in cwd.iterdir()]: if fpath.is_dir() and \ fpath.name in ('pkg', 'src'): diff --git a/client.py b/client.py index 13c1564..b1e9161 100755 --- a/client.py +++ b/client.py @@ -39,6 +39,36 @@ if __name__ == '__main__': import argparse from utils import configure_logger configure_logger(logger) + def print_log(): + import os, re + abspath=os.path.abspath(__file__) + abspath=os.path.dirname(abspath) + os.chdir(abspath) + def is_debug_msg(msg, DEBUG): + if '- DEBUG -' in msg: + return True + elif re.match(r'[0-9]{4}-[0-9]{2}-[0-9]{2}.*', msg): + return False + else: + return DEBUG + with open('buildbot.log', 'r') as f: + DEBUG = False + lines = list() + lines += f.read().split('\n') + while len(lines) >= 100: + lines.pop(0) + while True: + nlines = f.read().split('\n') + if len(nlines) == 1 and nlines[0] == '': + continue + else: + lines += nlines + for line in lines: + DEBUG = is_debug_msg(line, DEBUG) + if not DEBUG: + print(line) + lines = list() + sleep(1) try: parser = argparse.ArgumentParser(description='Client for buildbot') parser.add_argument('--info', action='store_true', help='show buildbot info') @@ -46,6 +76,7 @@ if __name__ == '__main__': parser.add_argument('--cleanall', action='store_true', help='checkout pkgbuilds') parser.add_argument('--clean', nargs='?', default=None, help='checkout pkgbuilds in one package') parser.add_argument('--rebuild', nargs='?', default=None, help='rebuild a package with its dirname') + parser.add_argument('--log', action='store_true' , help='print log') args = parser.parse_args() if args.info: server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD) @@ -62,6 +93,9 @@ if __name__ == '__main__': elif args.rebuild: server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD) logger.info(run('rebuild_package', args=(args.rebuild,), kwargs={'clean': True}, server=server)) + elif args.log: + logger.info('printing logs') + print_log() else: parser.error("Please choose an action") except Exception: