Esempio n. 1
0
def test_absolute_path_for_absolute(configuration: Configuration) -> None:
    """
    must not change path for absolute path in settings
    """
    path = Path("/a/b/c")
    configuration.set("build", "path", str(path))
    assert configuration.getpath("build", "path") == path
Esempio n. 2
0
def setup_service(architecture: str,
                  configuration: Configuration) -> web.Application:
    """
    create web application
    :param architecture: repository architecture
    :param configuration: configuration instance
    :return: web application instance
    """
    application = web.Application(logger=logging.getLogger("http"))
    application.on_shutdown.append(on_shutdown)
    application.on_startup.append(on_startup)

    application.middlewares.append(
        web.normalize_path_middleware(append_slash=False, remove_slash=True))
    application.middlewares.append(exception_handler(application.logger))

    application.logger.info("setup routes")
    setup_routes(application)

    application.logger.info("setup templates")
    aiohttp_jinja2.setup(application,
                         loader=jinja2.FileSystemLoader(
                             configuration.getpath("web", "templates")))

    application.logger.info("setup configuration")
    application["configuration"] = configuration

    application.logger.info("setup watcher")
    application["watcher"] = Watcher(architecture, configuration)

    return application
Esempio n. 3
0
 def __init__(self, configuration: Configuration) -> None:
     """
     default constructor
     :param configuration: configuration instance
     """
     root = configuration.get("alpm", "root")
     pacman_root = configuration.getpath("alpm", "database")
     self.handle = Handle(root, str(pacman_root))
     for repository in configuration.getlist("alpm", "repositories"):
         self.handle.register_syncdb(repository, 0)  # 0 is pgp_level
Esempio n. 4
0
def test_absolute_path_for_relative(configuration: Configuration) -> None:
    """
    must prepend root path to relative path
    """
    path = Path("a")
    configuration.set("build", "path", str(path))
    result = configuration.getpath("build", "path")
    assert result.is_absolute()
    assert result.parent == configuration.path.parent
    assert result.name == path.name
Esempio n. 5
0
    def __init__(self, architecture: str,
                 configuration: Configuration) -> None:
        """
        default constructor
        :param architecture: repository architecture
        :param configuration: configuration instance
        """
        Report.__init__(self, architecture, configuration)
        JinjaTemplate.__init__(self, "html", configuration)

        self.report_path = configuration.getpath("html", "path")
Esempio n. 6
0
    def __init__(self, section: str, configuration: Configuration) -> None:
        """
        default constructor
        :param section: settings section name
        :param configuration: configuration instance
        """
        self.link_path = configuration.get(section, "link_path")
        self.template_path = configuration.getpath(section, "template_path")

        # base template vars
        self.homepage = configuration.get(section, "homepage", fallback=None)
        self.name = configuration.get("repository", "name")

        self.sign_targets, self.default_pgp_key = GPG.sign_options(
            configuration)
Esempio n. 7
0
    def __init__(self, architecture: str,
                 configuration: Configuration) -> None:
        self.logger = logging.getLogger("builder")
        self.architecture = architecture
        self.configuration = configuration

        self.aur_url = configuration.get("alpm", "aur_url")
        self.name = configuration.get("repository", "name")

        self.paths = RepositoryPaths(
            configuration.getpath("repository", "root"), architecture)
        self.paths.create_tree()

        self.ignore_list = configuration.getlist("build", "ignore_packages")
        self.pacman = Pacman(configuration)
        self.sign = GPG(architecture, configuration)
        self.repo = Repo(self.name, self.paths, self.sign.repository_sign_args)
        self.reporter = Client.load(configuration)
Esempio n. 8
0
    def extract_architectures(cls: Type[Handler], args: argparse.Namespace) -> Set[str]:
        """
        get known architectures
        :param args: command line args
        :return: list of architectures for which tree is created
        """
        if args.architecture is None:
            raise MissingArchitecture(args.command)
        if args.architecture:
            return set(args.architecture)

        config = Configuration()
        config.load(args.configuration)
        root = config.getpath("repository", "root")
        architectures = RepositoryPaths.known_architectures(root)

        if not architectures:
            raise MissingArchitecture(args.command)
        return architectures
Esempio n. 9
0
def repository_paths(configuration: Configuration) -> RepositoryPaths:
    return RepositoryPaths(architecture="x86_64",
                           root=configuration.getpath("repository", "root"))