mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-14 22:45:47 +00:00
count epoch
This commit is contained in:
@ -51,7 +51,7 @@ def sync(args: argparse.Namespace) -> None:
|
||||
def update(args: argparse.Namespace) -> None:
|
||||
app = Application.from_args(args)
|
||||
log_fn = lambda line: print(line) if args.dry_run else app.logger.info(line)
|
||||
packages = app.get_updates(args.no_aur, args.no_manual, args.no_vcs, log_fn)
|
||||
packages = app.get_updates(args.package, args.no_aur, args.no_manual, args.no_vcs, log_fn)
|
||||
if args.dry_run:
|
||||
return
|
||||
app.update(packages)
|
||||
@ -79,6 +79,7 @@ if __name__ == '__main__':
|
||||
add_parser.set_defaults(fn=add)
|
||||
|
||||
check_parser = subparsers.add_parser('check', description='check for updates')
|
||||
check_parser.add_argument('package', help='filter check by packages', nargs='*')
|
||||
check_parser.set_defaults(fn=update, no_aur=False, no_manual=True, no_vcs=False, dry_run=True)
|
||||
|
||||
rebuild_parser = subparsers.add_parser('rebuild', description='rebuild whole repository')
|
||||
@ -97,6 +98,7 @@ if __name__ == '__main__':
|
||||
sync_parser.set_defaults(fn=sync)
|
||||
|
||||
update_parser = subparsers.add_parser('update', description='run updates')
|
||||
update_parser.add_argument('package', help='filter check by packages', nargs='*')
|
||||
update_parser.add_argument('--dry-run', help='just perform check for updates, same as check command', action='store_true')
|
||||
update_parser.add_argument('--no-aur', help='do not check for AUR updates', action='store_true')
|
||||
update_parser.add_argument('--no-manual', help='do not include manual updates', action='store_true')
|
||||
|
@ -58,12 +58,12 @@ class Application:
|
||||
self.report()
|
||||
self.sync()
|
||||
|
||||
def get_updates(self, no_aur: bool, no_manual: bool, no_vcs: bool,
|
||||
def get_updates(self, filter_packages: List[str], no_aur: bool, no_manual: bool, no_vcs: bool,
|
||||
log_fn: Callable[[str], None]) -> List[Package]:
|
||||
updates = []
|
||||
|
||||
if not no_aur:
|
||||
updates.extend(self.repository.updates_aur(no_vcs))
|
||||
updates.extend(self.repository.updates_aur(filter_packages, no_vcs))
|
||||
if not no_manual:
|
||||
updates.extend(self.repository.updates_manual())
|
||||
|
||||
|
@ -157,7 +157,7 @@ class Repository:
|
||||
|
||||
return self.repo.repo_path
|
||||
|
||||
def updates_aur(self, no_vcs: bool) -> List[Package]:
|
||||
def updates_aur(self, filter_packages: Iterable[str], no_vcs: bool) -> List[Package]:
|
||||
result: List[Package] = []
|
||||
|
||||
build_section = self.config.get_section_name('build', self.architecture)
|
||||
@ -168,6 +168,8 @@ class Repository:
|
||||
continue
|
||||
if local.is_vcs and no_vcs:
|
||||
continue
|
||||
if filter_packages and local.base not in filter_packages:
|
||||
continue
|
||||
|
||||
try:
|
||||
remote = Package.load(local.base, self.pacman, self.aur_url)
|
||||
|
@ -25,9 +25,8 @@ import shutil
|
||||
import tempfile
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pyalpm import Handle
|
||||
from srcinfo.parse import parse_srcinfo
|
||||
from typing import List, Set, Type
|
||||
from typing import List, Optional, Set, Type
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
@ -76,7 +75,7 @@ class Package:
|
||||
src_info, errors = parse_srcinfo(src_info_source)
|
||||
if errors:
|
||||
raise InvalidPackageInfo(errors)
|
||||
return f'{src_info["pkgver"]}-{src_info["pkgrel"]}'
|
||||
return self.full_version(src_info.get('epoch'), src_info['pkgver'], src_info['pkgrel'])
|
||||
finally:
|
||||
shutil.rmtree(clone_dir, ignore_errors=True)
|
||||
|
||||
@ -97,8 +96,9 @@ class Package:
|
||||
if errors:
|
||||
raise InvalidPackageInfo(errors)
|
||||
packages = set(src_info['packages'].keys())
|
||||
version = cls.full_version(src_info.get('epoch'), src_info['pkgver'], src_info['pkgrel'])
|
||||
|
||||
return cls(src_info['pkgbase'], f'{src_info["pkgver"]}-{src_info["pkgrel"]}', aur_url, packages)
|
||||
return cls(src_info['pkgbase'], version, aur_url, packages)
|
||||
|
||||
@staticmethod
|
||||
def dependencies(path: str) -> Set[str]:
|
||||
@ -115,6 +115,11 @@ class Package:
|
||||
packages = set(src_info['packages'].keys())
|
||||
return set(depends + makedepends) - packages
|
||||
|
||||
@staticmethod
|
||||
def full_version(epoch: Optional[str], pkgver: str, pkgrel: str) -> str:
|
||||
prefix = f'{epoch}:' if epoch else ''
|
||||
return f'{prefix}{pkgver}-{pkgrel}'
|
||||
|
||||
@staticmethod
|
||||
def load(path: str, pacman: Pacman, aur_url: str) -> Package:
|
||||
try:
|
||||
|
Reference in New Issue
Block a user