mirror of
https://github.com/archlinux-jerry/buildbot
synced 2024-12-05 03:10:41 +08:00
add nspawn detection and print_log
This commit is contained in:
parent
b1b6c3f0b0
commit
71a1a470cc
2 changed files with 43 additions and 2 deletions
11
buildbot.py
11
buildbot.py
|
@ -39,6 +39,11 @@ os.chdir(abspath)
|
||||||
logger = logging.getLogger('buildbot')
|
logger = logging.getLogger('buildbot')
|
||||||
configure_logger(logger, logfile='buildbot.log', rotate_size=1024*1024*10)
|
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)
|
REPO_ROOT = Path(PKGBUILD_DIR)
|
||||||
|
|
||||||
class Job:
|
class Job:
|
||||||
|
@ -84,13 +89,15 @@ class jobsManager:
|
||||||
return ret
|
return ret
|
||||||
def reset_dir(self, pkgdirname=None, all=False):
|
def reset_dir(self, pkgdirname=None, all=False):
|
||||||
if all:
|
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:
|
else:
|
||||||
if not pkgdirname:
|
if not pkgdirname:
|
||||||
return False
|
return False
|
||||||
cwd = REPO_ROOT / pkgdirname
|
cwd = REPO_ROOT / pkgdirname
|
||||||
if cwd.exists():
|
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()]:
|
for fpath in [f for f in cwd.iterdir()]:
|
||||||
if fpath.is_dir() and \
|
if fpath.is_dir() and \
|
||||||
fpath.name in ('pkg', 'src'):
|
fpath.name in ('pkg', 'src'):
|
||||||
|
|
34
client.py
34
client.py
|
@ -39,6 +39,36 @@ if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
from utils import configure_logger
|
from utils import configure_logger
|
||||||
configure_logger(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:
|
try:
|
||||||
parser = argparse.ArgumentParser(description='Client for buildbot')
|
parser = argparse.ArgumentParser(description='Client for buildbot')
|
||||||
parser.add_argument('--info', action='store_true', help='show buildbot info')
|
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('--cleanall', action='store_true', help='checkout pkgbuilds')
|
||||||
parser.add_argument('--clean', nargs='?', default=None, help='checkout pkgbuilds in one package')
|
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('--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()
|
args = parser.parse_args()
|
||||||
if args.info:
|
if args.info:
|
||||||
server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD)
|
server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD)
|
||||||
|
@ -62,6 +93,9 @@ if __name__ == '__main__':
|
||||||
elif args.rebuild:
|
elif args.rebuild:
|
||||||
server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD)
|
server=(MASTER_BIND_ADDRESS, MASTER_BIND_PASSWD)
|
||||||
logger.info(run('rebuild_package', args=(args.rebuild,), kwargs={'clean': True}, server=server))
|
logger.info(run('rebuild_package', args=(args.rebuild,), kwargs={'clean': True}, server=server))
|
||||||
|
elif args.log:
|
||||||
|
logger.info('printing logs')
|
||||||
|
print_log()
|
||||||
else:
|
else:
|
||||||
parser.error("Please choose an action")
|
parser.error("Please choose an action")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in a new issue