mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-02 16:45:51 +00:00
more options in setup command
This commit is contained in:
@ -28,6 +28,8 @@ from ahriman.models.build_status import BuildStatusEnum
|
||||
|
||||
# pylint thinks it is bad idea, but get the fuck off
|
||||
# pylint: disable=protected-access
|
||||
from ahriman.models.sign_settings import SignSettings
|
||||
|
||||
SubParserAction = argparse._SubParsersAction
|
||||
|
||||
|
||||
@ -181,7 +183,11 @@ def _set_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
default="/usr/share/devtools/pacman-extra.conf")
|
||||
parser.add_argument("--no-multilib", help="do not add multilib repository", action="store_true")
|
||||
parser.add_argument("--packager", help="packager name and email", required=True)
|
||||
parser.add_argument("--repository", help="repository name", default="aur-clone")
|
||||
parser.add_argument("--repository", help="repository name", required=True)
|
||||
parser.add_argument("--sign-key", help="sign key id")
|
||||
parser.add_argument("--sign-target", help="sign options",
|
||||
choices=[sign.name.lower() for sign in SignSettings], nargs="*")
|
||||
parser.add_argument("--web-port", help="port of the web service", type=int)
|
||||
parser.set_defaults(handler=handlers.Setup, lock=None, no_report=True, unsafe=True)
|
||||
return parser
|
||||
|
||||
|
@ -56,7 +56,7 @@ class Setup(Handler):
|
||||
Setup.create_executable(args.build_command, architecture)
|
||||
Setup.create_devtools_configuration(args.build_command, architecture, Path(args.from_configuration),
|
||||
args.no_multilib, args.repository, application.repository.paths)
|
||||
Setup.create_ahriman_configuration(args.build_command, architecture, args.repository, configuration.include)
|
||||
Setup.create_ahriman_configuration(args, architecture, args.repository, configuration.include)
|
||||
Setup.create_sudo_configuration(args.build_command, architecture)
|
||||
|
||||
@staticmethod
|
||||
@ -70,23 +70,36 @@ class Setup(Handler):
|
||||
return Setup.BIN_DIR_PATH / f"{prefix}-{architecture}-build"
|
||||
|
||||
@staticmethod
|
||||
def create_ahriman_configuration(prefix: str, architecture: str, repository: str, include_path: Path) -> None:
|
||||
def create_ahriman_configuration(args: argparse.Namespace, architecture: str, repository: str,
|
||||
include_path: Path) -> None:
|
||||
"""
|
||||
create service specific configuration
|
||||
:param prefix: command prefix in {prefix}-{architecture}-build
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param repository: repository name
|
||||
:param include_path: path to directory with configuration includes
|
||||
"""
|
||||
configuration = configparser.ConfigParser()
|
||||
|
||||
configuration.add_section("build")
|
||||
configuration.set("build", "build_command", str(Setup.build_command(prefix, architecture)))
|
||||
section = Configuration.section_name("build", architecture)
|
||||
configuration.add_section(section)
|
||||
configuration.set(section, "build_command", str(Setup.build_command(args.build_command, architecture)))
|
||||
|
||||
configuration.add_section("repository")
|
||||
configuration.set("repository", "name", repository)
|
||||
|
||||
target = include_path / "build-overrides.ini"
|
||||
if args.sign_key is not None:
|
||||
section = Configuration.section_name("sign", architecture)
|
||||
configuration.add_section(section)
|
||||
configuration.set(section, "target", " ".join(args.sign_target))
|
||||
configuration.set(section, "key", args.sign_key)
|
||||
|
||||
if args.web_port is not None:
|
||||
section = Configuration.section_name("web", architecture)
|
||||
configuration.add_section(section)
|
||||
configuration.set(section, "port", str(args.web_port))
|
||||
|
||||
target = include_path / "setup-overrides.ini"
|
||||
with target.open("w") as ahriman_configuration:
|
||||
configuration.write(ahriman_configuration)
|
||||
|
||||
|
@ -112,8 +112,8 @@ class HTML(Report):
|
||||
html = template.render(
|
||||
homepage=self.homepage,
|
||||
link_path=self.link_path,
|
||||
has_package_signed=SignSettings.SignPackages in self.sign_targets,
|
||||
has_repo_signed=SignSettings.SignRepository in self.sign_targets,
|
||||
has_package_signed=SignSettings.Packages in self.sign_targets,
|
||||
has_repo_signed=SignSettings.Repository in self.sign_targets,
|
||||
packages=sorted(content, key=comparator),
|
||||
pgp_key=self.default_pgp_key,
|
||||
repository=self.name)
|
||||
|
@ -56,7 +56,7 @@ class GPG:
|
||||
"""
|
||||
:return: command line arguments for repo-add command to sign database
|
||||
"""
|
||||
if SignSettings.SignRepository not in self.targets:
|
||||
if SignSettings.Repository not in self.targets:
|
||||
return []
|
||||
if self.default_key is None:
|
||||
self.logger.error("no default key set, skip repository sign")
|
||||
@ -107,7 +107,7 @@ class GPG:
|
||||
:param base: package base required to check for key overrides
|
||||
:return: list of generated files including original file
|
||||
"""
|
||||
if SignSettings.SignPackages not in self.targets:
|
||||
if SignSettings.Packages not in self.targets:
|
||||
return [path]
|
||||
key = self.configuration.get("sign", f"key_{base}", fallback=self.default_key)
|
||||
if key is None:
|
||||
@ -122,7 +122,7 @@ class GPG:
|
||||
:param path: path to repository database
|
||||
:return: list of generated files including original file
|
||||
"""
|
||||
if SignSettings.SignRepository not in self.targets:
|
||||
if SignSettings.Repository not in self.targets:
|
||||
return [path]
|
||||
if self.default_key is None:
|
||||
self.logger.error("no default key set, skip repository sign")
|
||||
|
@ -28,12 +28,12 @@ from ahriman.core.exceptions import InvalidOption
|
||||
class SignSettings(Enum):
|
||||
"""
|
||||
sign targets enumeration
|
||||
:cvar SignPackages: sign each package
|
||||
:cvar SignRepository: sign repository database file
|
||||
:cvar Packages: sign each package
|
||||
:cvar Repository: sign repository database file
|
||||
"""
|
||||
|
||||
SignPackages = auto()
|
||||
SignRepository = auto()
|
||||
Packages = auto()
|
||||
Repository = auto()
|
||||
|
||||
@classmethod
|
||||
def from_option(cls: Type[SignSettings], value: str) -> SignSettings:
|
||||
@ -43,7 +43,7 @@ class SignSettings(Enum):
|
||||
:return: parsed value
|
||||
"""
|
||||
if value.lower() in ("package", "packages", "sign-package"):
|
||||
return cls.SignPackages
|
||||
return cls.Packages
|
||||
if value.lower() in ("repository", "sign-repository"):
|
||||
return cls.SignRepository
|
||||
return cls.Repository
|
||||
raise InvalidOption(value)
|
||||
|
Reference in New Issue
Block a user