mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
refactor: fix warnings and typos, cleanup code
This commit is contained in:
parent
1a2327cefd
commit
e9116741a5
@ -96,7 +96,7 @@ All subcommands are divided into several groups depending on the role they are d
|
||||
* ``aur`` (``aur-search``) group is for AUR operations.
|
||||
* ``help`` (e.g. ``help``) are system commands.
|
||||
* ``package`` subcommands (e.g. ``package-add``) allow to perform single package actions.
|
||||
* ``patch`` subcommands (e.g. ``pacth-list``) are the special case of ``package`` subcommands introduced in order to control patches for packages.
|
||||
* ``patch`` subcommands (e.g. ``patch-list``) are the special case of ``package`` subcommands introduced in order to control patches for packages.
|
||||
* ``repo`` subcommands (e.g. ``repo-check``) usually perform actions on whole repository.
|
||||
* ``service`` subcommands (e.g. ``service-setup``) perform actions which are related to whole service managing: create repository, show configuration.
|
||||
* ``user`` subcommands (``user-add``) are intended for user management.
|
||||
|
16
docs/faq.rst
16
docs/faq.rst
@ -545,7 +545,7 @@ In this example we are going to use files and packages which are provided by off
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
wget https://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
pacman -U archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
|
||||
#.
|
||||
@ -553,7 +553,7 @@ In this example we are going to use files and packages which are provided by off
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst
|
||||
wget https://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst
|
||||
pacman -U devtools-20221208-1.2-any.pkg.tar.zst
|
||||
|
||||
Alternatively, you can create your own ``makepkg`` configuration and save it as ``/usr/share/devtools/makepkg.conf.d/i686.conf``.
|
||||
@ -563,7 +563,7 @@ In this example we are going to use files and packages which are provided by off
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ahriman -a i686 service-setup --mirror 'http://de.mirror.archlinux32.org/$arch/$repo'--no-multilib ...
|
||||
ahriman -a i686 service-setup --mirror 'https://de.mirror.archlinux32.org/$arch/$repo'--no-multilib ...
|
||||
|
||||
In addition to usual options, you need to specify the following options:
|
||||
|
||||
@ -598,8 +598,8 @@ There are two possible ways to achieve same setup, by using docker container. Th
|
||||
.. code-block:: dockerfile
|
||||
|
||||
RUN pacman --noconfirm -Sy wget
|
||||
RUN wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.2-any.pkg.tar.zst
|
||||
RUN wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
RUN wget https://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.2-any.pkg.tar.zst
|
||||
RUN wget https://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
|
||||
#.
|
||||
At that point you should have full ``Dockerfile`` like:
|
||||
@ -611,8 +611,8 @@ There are two possible ways to achieve same setup, by using docker container. Th
|
||||
RUN pacman-key --init
|
||||
|
||||
RUN pacman --noconfirm -Sy wget
|
||||
RUN wget http://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.2-any.pkg.tar.zst
|
||||
RUN wget http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
RUN wget https://pool.mirror.archlinux32.org/i686/extra/devtools-20221208-1.2-any.pkg.tar.zst && pacman --noconfirm -U devtools-20221208-1.2-any.pkg.tar.zst
|
||||
RUN wget https://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-20230705-1.0-any.pkg.tar.zst && pacman --noconfirm -U archlinux32-keyring-20230705-1.0-any.pkg.tar.zst
|
||||
|
||||
#.
|
||||
After that you can build you own container, e.g.:
|
||||
@ -626,7 +626,7 @@ There are two possible ways to achieve same setup, by using docker container. Th
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
docker run --privileged -p 8080:8080 -e AHRIMAN_ARCHITECTURE=i686 -e AHRIMAN_PACMAN_MIRROR='http://de.mirror.archlinux32.org/$arch/$repo' -e AHRIMAN_MULTILIB= ahriman-i686:latest
|
||||
docker run --privileged -p 8080:8080 -e AHRIMAN_ARCHITECTURE=i686 -e AHRIMAN_PACMAN_MIRROR='https://de.mirror.archlinux32.org/$arch/$repo' -e AHRIMAN_MULTILIB= ahriman-i686:latest
|
||||
|
||||
Remote synchronization
|
||||
----------------------
|
||||
|
@ -7,7 +7,7 @@ Collection of the examples of docker compose configuration files, which covers s
|
||||
* [Check](check): double process service; one with periodic checks (automatic build disabled) and other one is with the web service.
|
||||
* [Daemon](daemon): service with periodic repository checks.
|
||||
* [Distributed](distributed): cluster of three nodes, one with web interface and two workers which are responsible for build process.
|
||||
* [Distrubuted manual](distributed-manual): same as [distributed](distributed), but two nodes and update process must be run on worker node manually.
|
||||
* [Distributed manual](distributed-manual): same as [distributed](distributed), but two nodes and update process must be run on worker node manually.
|
||||
* [i686](i686): non-x86_64 architecture setup.
|
||||
* [Multi repo](multirepo): run web service with two separated repositories.
|
||||
* [Pull](pull): normal service, but in addition with pulling packages from another source (e.g. GitHub repository).
|
||||
|
@ -5,5 +5,5 @@ ENV ARCH32_KEYRING_VERSION="20231126-1.0"
|
||||
RUN pacman-key --init
|
||||
|
||||
RUN pacman -Sy --noconfirm wget && \
|
||||
wget -nv http://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-${ARCH32_KEYRING_VERSION}-any.pkg.tar.zst && \
|
||||
wget -nv https://pool.mirror.archlinux32.org/i686/core/archlinux32-keyring-${ARCH32_KEYRING_VERSION}-any.pkg.tar.zst && \
|
||||
pacman -U --noconfirm archlinux32-keyring-${ARCH32_KEYRING_VERSION}-any.pkg.tar.zst
|
||||
|
@ -34,9 +34,6 @@ from ahriman.models.worker import Worker
|
||||
class Updater(LazyLogging):
|
||||
"""
|
||||
updater handler interface
|
||||
|
||||
Attributes:
|
||||
split_method(Callable[[Iterable[Package]], list[list[Package]]]): method to split packages into chunks
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
|
@ -170,7 +170,7 @@ class Handler:
|
||||
# extract repository names first
|
||||
if (from_args := args.repository) is not None:
|
||||
repositories: Iterable[str] = [from_args]
|
||||
elif (from_filesystem := RepositoryPaths.known_repositories(root)):
|
||||
elif from_filesystem := RepositoryPaths.known_repositories(root):
|
||||
repositories = from_filesystem
|
||||
else: # try to read configuration now
|
||||
repositories = [configuration.get("repository", "name")]
|
||||
|
@ -344,7 +344,7 @@ class Sources(LazyLogging):
|
||||
str: HEAD commit hash
|
||||
"""
|
||||
# we might want to parse git files instead though
|
||||
return check_output("git", "rev-parse", ref_name, cwd=sources_dir)
|
||||
return check_output("git", "rev-parse", ref_name, cwd=sources_dir, logger=self.logger)
|
||||
|
||||
def move(self, pkgbuild_dir: Path, sources_dir: Path) -> None:
|
||||
"""
|
||||
|
@ -38,7 +38,7 @@ class Task(LazyLogging):
|
||||
archbuild_flags(list[str]): command flags for archbuild command
|
||||
architecture(str): repository architecture
|
||||
build_command(str): build command
|
||||
makechroootpkg_flags(list[str]): command flags for makechrootpkg command
|
||||
makechrootpkg_flags(list[str]): command flags for makechrootpkg command
|
||||
makepkg_flags(list[str]): command flags for makepkg command
|
||||
package(Package): package definitions
|
||||
paths(RepositoryPaths): repository paths instance
|
||||
|
@ -41,7 +41,7 @@ class Client:
|
||||
load client from settings
|
||||
|
||||
Args:
|
||||
repository_id(RepositoryId): repository unqiue identifier
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
|
||||
|
@ -276,8 +276,8 @@ class Tree:
|
||||
unprocessed = sorted(self.leaves, key=lambda leaf: leaf.package.base)
|
||||
while unprocessed:
|
||||
# pick one and append it to the most free partition and build chunk
|
||||
leaf = unprocessed.pop()
|
||||
chunk = [leaf]
|
||||
first_leaf = unprocessed.pop()
|
||||
chunk = [first_leaf]
|
||||
|
||||
while True: # python doesn't allow to use walrus operator to unpack tuples
|
||||
# get packages which depend on packages in chunk
|
||||
|
@ -46,7 +46,7 @@ class Result:
|
||||
default constructor
|
||||
|
||||
Args:
|
||||
addded(Iterable[Package] | None, optional): initial list of successfully added packages
|
||||
added(Iterable[Package] | None, optional): initial list of successfully added packages
|
||||
(Default value = None)
|
||||
updated(Iterable[Package] | None, optional): initial list of successfully updated packages
|
||||
(Default value = None)
|
||||
|
@ -1,6 +1,4 @@
|
||||
import argparse
|
||||
import configparser
|
||||
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
@ -565,6 +565,7 @@ def watcher(repository_id: RepositoryId, database: SQLite, repository: Repositor
|
||||
Args:
|
||||
repository_id(RepositoryId): repository identifier fixture
|
||||
database(SQLite): database fixture
|
||||
repository(Repository): repository fixture
|
||||
|
||||
Returns:
|
||||
Watcher: package status watcher test instance
|
||||
|
@ -510,7 +510,7 @@ def test_head(sources: Sources, mocker: MockerFixture) -> None:
|
||||
local = Path("local")
|
||||
|
||||
assert sources.head(local) == "sha"
|
||||
check_output_mock.assert_called_once_with("git", "rev-parse", "HEAD", cwd=local)
|
||||
check_output_mock.assert_called_once_with("git", "rev-parse", "HEAD", cwd=local, logger=sources.logger)
|
||||
|
||||
|
||||
def test_head_specific(sources: Sources, mocker: MockerFixture) -> None:
|
||||
@ -521,7 +521,7 @@ def test_head_specific(sources: Sources, mocker: MockerFixture) -> None:
|
||||
local = Path("local")
|
||||
|
||||
assert sources.head(local, "master") == "sha"
|
||||
check_output_mock.assert_called_once_with("git", "rev-parse", "master", cwd=local)
|
||||
check_output_mock.assert_called_once_with("git", "rev-parse", "master", cwd=local, logger=sources.logger)
|
||||
|
||||
|
||||
def test_move(sources: Sources, mocker: MockerFixture) -> None:
|
||||
|
@ -145,7 +145,7 @@ def update_printer(package_ahriman: Package) -> UpdatePrinter:
|
||||
package_ahriman(Package): package fixture
|
||||
|
||||
Returns:
|
||||
UpdatePrinter: udpate printer test instance
|
||||
UpdatePrinter: update printer test instance
|
||||
"""
|
||||
return UpdatePrinter(package_ahriman, None)
|
||||
|
||||
|
@ -15,6 +15,7 @@ from ahriman.core.util import check_output, check_user, dataclass_view, enum_val
|
||||
srcinfo_property, srcinfo_property_list, trim_package, unquote, utcnow, walk
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
|
||||
@ -150,11 +151,11 @@ def test_check_output_empty_line(mocker: MockerFixture) -> None:
|
||||
logger_mock.assert_has_calls([MockCall(""), MockCall("hello")])
|
||||
|
||||
|
||||
def test_check_user(mocker: MockerFixture) -> None:
|
||||
def test_check_user(repository_id: RepositoryId, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must check user correctly
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
paths = RepositoryPaths(Path.cwd(), repository_id)
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0])
|
||||
check_user(paths, unsafe=False)
|
||||
|
||||
@ -167,22 +168,22 @@ def test_check_user_no_directory(repository_paths: RepositoryPaths, mocker: Mock
|
||||
check_user(repository_paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_exception(mocker: MockerFixture) -> None:
|
||||
def test_check_user_exception(repository_id: RepositoryId, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception if user differs
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
paths = RepositoryPaths(Path.cwd(), repository_id)
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0] + 1)
|
||||
|
||||
with pytest.raises(UnsafeRunError):
|
||||
check_user(paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_unsafe(mocker: MockerFixture) -> None:
|
||||
def test_check_user_unsafe(repository_id: RepositoryId, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip check if unsafe flag is set
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
paths = RepositoryPaths(Path.cwd(), repository_id)
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0] + 1)
|
||||
check_user(paths, unsafe=True)
|
||||
|
||||
|
@ -37,7 +37,9 @@ def test_load_trigger(trigger_loader: TriggerLoader, configuration: Configuratio
|
||||
"""
|
||||
must load trigger
|
||||
"""
|
||||
loaded = trigger_loader.load_trigger("ahriman.core.report.ReportTrigger", "x86_64", configuration)
|
||||
_, repository_id = configuration.check_loaded()
|
||||
|
||||
loaded = trigger_loader.load_trigger("ahriman.core.report.ReportTrigger", repository_id, configuration)
|
||||
assert loaded
|
||||
assert isinstance(loaded, ReportTrigger)
|
||||
|
||||
|
@ -54,8 +54,7 @@ def test_from_json_2(aur_package_ahriman: AURPackage, mocker: MockerFixture) ->
|
||||
assert AURPackage.from_json(asdict(aur_package_ahriman)) == aur_package_ahriman
|
||||
|
||||
|
||||
def test_from_pacman(pyalpm_package_ahriman: pyalpm.Package, aur_package_ahriman: AURPackage,
|
||||
resource_path_root: Path) -> None:
|
||||
def test_from_pacman(pyalpm_package_ahriman: pyalpm.Package, aur_package_ahriman: AURPackage) -> None:
|
||||
"""
|
||||
must load package from repository database
|
||||
"""
|
||||
|
@ -320,7 +320,7 @@ def test_local_files_empty(mocker: MockerFixture, resource_path_root: Path) -> N
|
||||
assert list(Package.local_files(Path("path"))) == []
|
||||
|
||||
|
||||
def test_local_files_error(mocker: MockerFixture, resource_path_root: Path) -> None:
|
||||
def test_local_files_error(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception on package parsing for local sources
|
||||
"""
|
||||
|
@ -139,7 +139,7 @@ async def test_exception_handler_head() -> None:
|
||||
|
||||
async def test_exception_handler_method_not_allowed() -> None:
|
||||
"""
|
||||
must handle not allowed methodss
|
||||
must handle not allowed methods
|
||||
"""
|
||||
request = pytest.helpers.request("", "", "POST")
|
||||
request_handler = AsyncMock(side_effect=HTTPMethodNotAllowed("POST", ["GET"]))
|
||||
|
Loading…
Reference in New Issue
Block a user