def build_update(): packages = Package.objects.all() sync.system_upgrade() # dict of server tag to list of Build need_check: Dict[str, List[Build]] = {} for package in packages: if package.ignore: continue try: latest = Build.objects.filter(package_id=package.id).order_by('-id')[0] except IndexError: BuilderManager().register(package.id) else: if latest.status == Build.FAILURE: BuilderManager().register(package.id) elif latest.status == Build.SUCCESS: if latest.package.server in need_check: need_check[latest.package.server].append(latest) else: need_check[latest.package.server] = [latest] if need_check: for k, v in need_check.items(): multiple_info_ = aur.multiple_info([x.package.name for x in v], k) for p in v: package_name = p.package.name if multiple_info_[package_name] and multiple_info_[package_name].Version != p.version: BuilderManager().register(p.package.id)
def build(name): if not _is_registered(name): raise OperationError('{} has not registered'.format(name)) package = Package.objects.get(name=name) sync.system_upgrade() BuilderManager().register(package.id)
def register(name: str, server: str, with_depend: bool = False) -> Dict[str, List[str]]: (is_registered, registered_name) = _register_status(name) if is_registered == RegisterStatus.package: raise OperationError('{} has already registered'.format(name)) elif is_registered == RegisterStatus.artifact: raise OperationError('{} has already registered as Artifact of {}'.format(name, registered_name)) info = aur.detail_info(name, server) native = [] foreign = [] if with_depend: depends = [] if hasattr(info, 'Depends'): depends.append(info.Depends) if hasattr(info, 'MakeDepends'): depends.append(info.MakeDepends) for depend in itertools.chain(*depends): depend_name = depend.translate(str.maketrans('>=', '<<')).split('<')[0] if sync.exist(depend_name): native.append(depend_name) elif aur.exist(depend_name, Package.OFFICIAL): foreign.append(depend_name) else: raise OperationError('{} not found'.format(depend_name)) sync.system_upgrade() sync.install(native, asdeps=True) for package in foreign: if not _is_registered(package): # Dependent package will register from official server r = register(package, Package.OFFICIAL, with_depend=True) native.extend(r['native']) foreign.extend(r['foreign']) for duplicate in (set(foreign) & set(info.pkgnames)): d = Package.objects.filter(name=duplicate) if d.exists(): d.delete() package = Package(name=name, server=server) package.save() for pkgname in info.pkgnames: artifact = Artifact(package=package, name=pkgname) artifact.save() ret = dict() ret['native'] = list(set(native)) ret['foreign'] = list(set(foreign)) return ret
def install(name): if not _is_registered(name): raise OperationError('{} has not registered'.format(name)) package = Package.objects.get(name=name) try: build_ = Build.objects.filter(package_id=package.id).order_by('-id')[0] except IndexError: raise OperationError('{} has no build'.format(name)) if build_.status == Build.SUCCESS: try: path = packager.path.build_to_path(build_) sync.system_upgrade() completed = upgrade.install(path.artifact_file(name)) if completed.returncode: raise OperationError( 'stdout:\n{}\n\nstderr\n:{}'.format(completed.stdout.decode(), completed.stderr.decode())) except FileNotFoundError as e: raise OperationError from e else: raise OperationError('{} latest build has not succeeded'.format(name))
def build_all(): packages = Package.objects.all() sync.system_upgrade() for package in packages: BuilderManager().register(package.id)