mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-14 22:45:47 +00:00
improve setup command by --makeflags-jobs argument and fix repository sign on creation
This commit is contained in:
@ -632,6 +632,8 @@ def _set_repo_setup_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
parser.add_argument("--build-command", help="build command prefix", default="ahriman")
|
||||
parser.add_argument("--from-configuration", help="path to default devtools pacman configuration",
|
||||
type=Path, default=Path("/usr/share/devtools/pacman-extra.conf"))
|
||||
parser.add_argument("--makeflags-jobs", help="append MAKEFLAGS variable with parallelism set to number of cores",
|
||||
action=argparse.BooleanOptionalAction, default=True)
|
||||
parser.add_argument("--multilib", help="add or do not multilib repository",
|
||||
action=argparse.BooleanOptionalAction, default=True)
|
||||
parser.add_argument("--packager", help="packager name and email", required=True)
|
||||
|
@ -64,7 +64,7 @@ class Setup(Handler):
|
||||
|
||||
application = Application(architecture, configuration, report=report, unsafe=unsafe)
|
||||
|
||||
Setup.configuration_create_makepkg(args.packager, application.repository.paths)
|
||||
Setup.configuration_create_makepkg(args.packager, args.makeflags_jobs, application.repository.paths)
|
||||
Setup.executable_create(application.repository.paths, args.build_command, architecture)
|
||||
Setup.configuration_create_devtools(args.build_command, architecture, args.from_configuration,
|
||||
args.multilib, args.repository, application.repository.paths)
|
||||
@ -170,17 +170,23 @@ class Setup(Handler):
|
||||
configuration.write(devtools_configuration)
|
||||
|
||||
@staticmethod
|
||||
def configuration_create_makepkg(packager: str, paths: RepositoryPaths) -> None:
|
||||
def configuration_create_makepkg(packager: str, makeflags_jobs: bool, paths: RepositoryPaths) -> None:
|
||||
"""
|
||||
create configuration for makepkg
|
||||
|
||||
Args:
|
||||
packager(str): packager identifier (e.g. name, email)
|
||||
makeflags_jobs(bool): set MAKEFLAGS variable to number of cores
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
"""
|
||||
|
||||
content = f"PACKAGER='{packager}'\n"
|
||||
if makeflags_jobs:
|
||||
content += """MAKEFLAGS="-j$(nproc)"\n"""
|
||||
|
||||
uid, _ = paths.root_owner
|
||||
home_dir = Path(getpwuid(uid).pw_dir)
|
||||
(home_dir / ".makepkg.conf").write_text(f"PACKAGER='{packager}'\n", encoding="utf8")
|
||||
(home_dir / ".makepkg.conf").write_text(content, encoding="utf8")
|
||||
|
||||
@staticmethod
|
||||
def configuration_create_sudo(paths: RepositoryPaths, prefix: str, architecture: str) -> None:
|
||||
|
@ -27,6 +27,7 @@ import subprocess
|
||||
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from pwd import getpwuid
|
||||
from typing import Any, Dict, Generator, IO, Iterable, List, Optional, Type, Union
|
||||
|
||||
from ahriman.core.exceptions import OptionError, UnsafeRunError
|
||||
@ -84,10 +85,11 @@ def check_output(*args: str, exception: Optional[Exception] = None, cwd: Optiona
|
||||
if logger is not None:
|
||||
logger.debug(single)
|
||||
|
||||
environment = {"HOME": getpwuid(user).pw_dir} if user is not None else {}
|
||||
# FIXME additional workaround for linter and type check which do not know that user arg is supported
|
||||
# pylint: disable=unexpected-keyword-arg
|
||||
with subprocess.Popen(args, cwd=cwd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
user=user, text=True, encoding="utf8", bufsize=1) as process:
|
||||
user=user, env=environment, text=True, encoding="utf8", bufsize=1) as process:
|
||||
if input_data is not None:
|
||||
input_channel = get_io(process, "stdin")
|
||||
input_channel.write(input_data)
|
||||
|
Reference in New Issue
Block a user