small improvements

This commit is contained in:
JerryXiao 2019-04-11 17:06:25 +08:00
parent 551ea4c1be
commit 53165071c7
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

View file

@ -252,6 +252,7 @@ class jobsManager:
self._new_buildjob(newjob) self._new_buildjob(newjob)
else: else:
# This part does the job # This part does the job
self.idle = False
job = self.__get_job() job = self.__get_job()
if not job: if not job:
logging.error('No job got') logging.error('No job got')
@ -316,44 +317,47 @@ class updateManager:
def check_update(self, rebuild_package=None): def check_update(self, rebuild_package=None):
updates = list() updates = list()
for pkg in jobsmgr.pkgconfigs: for pkg in jobsmgr.pkgconfigs:
if rebuild_package and \ try:
rebuild_package != pkg.dirname: if rebuild_package and \
continue rebuild_package != pkg.dirname:
pkgdir = REPO_ROOT / pkg.dirname continue
logger.info(f'checking update: {pkg.dirname}') pkgdir = REPO_ROOT / pkg.dirname
pkgbuild = pkgdir / 'PKGBUILD' logger.info(f'checking update: {pkg.dirname}')
archs = get_arch_from_pkgbuild(pkgbuild) pkgbuild = pkgdir / 'PKGBUILD'
buildarchs = [BUILD_ARCH_MAPPING.get(arch, None) for arch in archs] archs = get_arch_from_pkgbuild(pkgbuild)
buildarchs = [arch for arch in buildarchs if arch is not None] buildarchs = [BUILD_ARCH_MAPPING.get(arch, None) for arch in archs]
if not buildarchs: buildarchs = [arch for arch in buildarchs if arch is not None]
logger.warning(f'No build arch for {pkg.dirname}, refuse to build.') if not buildarchs:
continue logger.warning(f'No build arch for {pkg.dirname}, refuse to build.')
# hopefully we only need to check one arch for update continue
arch = 'x86_64' if 'x86_64' in buildarchs else buildarchs[0] # prefer x86 # hopefully we only need to check one arch for update
mon_nspawn_shell(arch, MAKEPKG_UPD_CMD, cwd=pkgdir, seconds=60*60, arch = 'x86_64' if 'x86_64' in buildarchs else buildarchs[0] # prefer x86
logfile = pkgdir / 'buildbot.log.update', mon_nspawn_shell(arch, MAKEPKG_UPD_CMD, cwd=pkgdir, seconds=60*60,
short_return = True) logfile = pkgdir / 'buildbot.log.update',
if pkg.type in ('git', 'manual'): short_return = True)
ver = self.__get_new_ver(pkg.dirname, arch) if pkg.type in ('git', 'manual'):
oldver = self.__pkgvers.get(pkg.dirname, None) ver = self.__get_new_ver(pkg.dirname, arch)
has_update = False oldver = self.__pkgvers.get(pkg.dirname, None)
if rebuild_package: has_update = False
has_update = True if rebuild_package:
if oldver:
res = vercmp(ver, oldver)
if res == 1:
has_update = True has_update = True
elif res == -1: if oldver:
logger.warning(f'package: {pkg.dirname} downgrade attempted') res = vercmp(ver, oldver)
elif res == 0: if res == 1:
logger.info(f'package: {pkg.dirname} is up to date') has_update = True
elif res == -1:
logger.warning(f'package: {pkg.dirname} downgrade attempted')
elif res == 0:
logger.info(f'package: {pkg.dirname} is up to date')
else:
has_update = True
if has_update:
self.__pkgvers[pkg.dirname] = ver
updates.append((pkg, ver, buildarchs))
else: else:
has_update = True logger.warning(f'unknown package type: {pkg.type}')
if has_update: except Exception:
self.__pkgvers[pkg.dirname] = ver print_exc_plus()
updates.append((pkg, ver, buildarchs))
else:
logger.warning(f'unknown package type: {pkg.type}')
self._save() self._save()
return updates return updates