mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-26 19:39:57 +00:00
sign by repo* commands
This commit is contained in:
@ -48,7 +48,7 @@ class Application:
|
||||
if not no_aur:
|
||||
updates.extend(self.repository.updates_aur(checked))
|
||||
if not no_manual:
|
||||
updates.extend(self.repository.updates_aur(checked))
|
||||
updates.extend(self.repository.updates_manual(checked))
|
||||
|
||||
for package in updates:
|
||||
log_fn(f'{package.name} = {package.version}')
|
||||
|
@ -20,6 +20,8 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from ahriman.core.exceptions import BuildFailed
|
||||
from ahriman.core.util import check_output
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
@ -27,18 +29,23 @@ from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
class RepoWrapper:
|
||||
|
||||
def __init__(self, name: str, paths: RepositoryPaths) -> None:
|
||||
def __init__(self, name: str, paths: RepositoryPaths, pgp_key: Optional[str]) -> None:
|
||||
self.logger = logging.getLogger('build_details')
|
||||
self.name = name
|
||||
self.paths = paths
|
||||
self.pgp_key = pgp_key
|
||||
|
||||
@property
|
||||
def repo_path(self) -> str:
|
||||
return os.path.join(self.paths.repository, f'{self.name}.db.tar.gz')
|
||||
|
||||
def _with_sign(self, cmd: List[str]) -> List[str]:
|
||||
return (cmd + ['-s', '-k', self.pgp_key]) if self.pgp_key else cmd
|
||||
|
||||
def add(self, path: str) -> None:
|
||||
cmd = self._with_sign(['repo-add'])
|
||||
check_output(
|
||||
'repo-add', '-R', self.repo_path, path,
|
||||
*cmd, '-R', self.repo_path, path,
|
||||
exception=BuildFailed(path),
|
||||
cwd=self.paths.repository,
|
||||
logger=self.logger)
|
||||
@ -48,8 +55,9 @@ class RepoWrapper:
|
||||
sign_path = f'{path}.sig'
|
||||
if os.path.exists(sign_path):
|
||||
os.remove(sign_path)
|
||||
cmd = self._with_sign(['repo-remove'])
|
||||
check_output(
|
||||
'repo-remove', self.repo_path, package,
|
||||
*cmd, self.repo_path, package,
|
||||
exception=BuildFailed(path),
|
||||
cwd=self.paths.repository,
|
||||
logger=self.logger)
|
||||
|
@ -47,7 +47,7 @@ class Repository:
|
||||
self.paths.create_tree()
|
||||
|
||||
self.sign = GPGWrapper(config)
|
||||
self.wrapper = RepoWrapper(self.name, self.paths)
|
||||
self.wrapper = RepoWrapper(self.name, self.paths, self.sign.repository_sign_key)
|
||||
|
||||
def _clear_build(self) -> None:
|
||||
for package in os.listdir(self.paths.sources):
|
||||
@ -114,7 +114,6 @@ class Repository:
|
||||
self.logger.exception(f'could not load package from {fn}', exc_info=True)
|
||||
continue
|
||||
|
||||
self.sign.sign_repository(self.wrapper.repo_path)
|
||||
return self.wrapper.repo_path
|
||||
|
||||
def process_report(self, targets: Optional[List[str]]) -> None:
|
||||
@ -139,7 +138,6 @@ class Repository:
|
||||
self.wrapper.add(package_fn)
|
||||
self._clear_packages()
|
||||
|
||||
self.sign.sign_repository(self.wrapper.repo_path)
|
||||
return self.wrapper.repo_path
|
||||
|
||||
def updates_aur(self, checked: List[str]) -> List[Package]:
|
||||
|
@ -20,7 +20,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import BuildFailed
|
||||
@ -36,6 +36,10 @@ class GPGWrapper:
|
||||
self.key = config.get('sign', 'key', fallback=None)
|
||||
self.sign = SignSettings.from_option(config.get('sign', 'enabled'))
|
||||
|
||||
@property
|
||||
def repository_sign_key(self) -> Optional[str]:
|
||||
return self.key if self.sign == SignSettings.SignRepository else None
|
||||
|
||||
def process(self, path: str) -> List[str]:
|
||||
check_output(
|
||||
*self.sign_cmd(path),
|
||||
|
Reference in New Issue
Block a user