# ------------------------------------------------------------------------------
-pakfire_repository_PYTHON = \
- src/pakfire/repository/__init__.py
-
-pakfire_repositorydir = $(pythondir)/pakfire/repository
-
-# ------------------------------------------------------------------------------
-
pakfire_ui_PYTHON = \
src/pakfire/ui/__init__.py \
src/pakfire/ui/base.py \
src/libpakfire/relation.c \
src/libpakfire/relationlist.c \
src/libpakfire/repo.c \
+ src/libpakfire/repolist.c \
src/libpakfire/request.c \
src/libpakfire/scriptlet.c \
src/libpakfire/selector.c \
src/libpakfire/include/pakfire/relation.h \
src/libpakfire/include/pakfire/relationlist.h \
src/libpakfire/include/pakfire/repo.h \
+ src/libpakfire/include/pakfire/repolist.h \
src/libpakfire/include/pakfire/request.h \
src/libpakfire/include/pakfire/scriptlet.h \
src/libpakfire/include/pakfire/selector.h \
#include <pakfire/pakfire.h>
#include <pakfire/key.h>
#include <pakfire/repo.h>
+#include <pakfire/repolist.h>
#include <pakfire/snapshot.h>
#include <pakfire/util.h>
Py_RETURN_NONE;
}
+static PyObject* Pakfire_get_repos(PakfireObject* self) {
+ struct pakfire_repolist* repos = pakfire_get_repos(self->pakfire);
+ if (!repos) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ const size_t l = pakfire_repolist_size(repos);
+
+ PyObject* list = PyList_New(l);
+ if (!list)
+ goto ERROR;
+
+ for (unsigned int i = 0; i < l; i++) {
+ PakfireRepo repo = pakfire_repolist_get(repos, i);
+ if (!repo)
+ continue;
+
+ PyObject* obj = new_repo(&RepoType, repo);
+ PyList_SET_ITEM(list, i, obj);
+
+ pakfire_repo_unref(repo);
+ }
+
+ERROR:
+ pakfire_repolist_unref(repos);
+
+ return list;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"bind",
NULL,
NULL
},
+ {
+ "repos",
+ (getter)Pakfire_get_repos,
+ NULL,
+ NULL,
+ NULL
+ },
{ NULL },
};
#include <time.h>
#include <pakfire/parser.h>
+#include <pakfire/repolist.h>
#include <pakfire/types.h>
int pakfire_create(Pakfire* pakfire, const char* path, const char* arch, const char* conf);
size_t pakfire_count_packages(Pakfire pakfire);
+struct pakfire_repolist* pakfire_get_repos(Pakfire pakfire);
PakfireRepo pakfire_get_repo(Pakfire pakfire, const char* name);
PakfireRepo pakfire_get_installed_repo(Pakfire pakfire);
pakfire_get_path;
pakfire_get_pool;
pakfire_get_repo;
+ pakfire_get_repos;
pakfire_make_cache_path;
pakfire_make_path;
pakfire_read_makefile;
pakfire_repo_write_solv_fp;
pakfire_repo_unref;
+ # repolist
+ pakfire_repolist_append;
+ pakfire_repolist_clear;
+ pakfire_repolist_create;
+ pakfire_repolist_empty;
+ pakfire_repolist_get;
+ pakfire_repolist_size;
+ pakfire_repolist_ref;
+ pakfire_repolist_unref;
+
# relation
pakfire_relation_create;
pakfire_relation_create_from_id;
}
}
+PAKFIRE_EXPORT struct pakfire_repolist* pakfire_get_repos(Pakfire pakfire) {
+ struct pakfire_repolist* list;
+
+ int r = pakfire_repolist_create(&list);
+ if (r)
+ return NULL;
+
+ Pool* pool = pakfire_get_solv_pool(pakfire);
+ Repo* solv_repo;
+ int i;
+
+ FOR_REPOS(i, solv_repo) {
+ PakfireRepo repo = pakfire_repo_create_from_repo(pakfire, solv_repo);
+ if (!repo) {
+ r = 1;
+ goto ERROR;
+ }
+
+ r = pakfire_repolist_append(list, repo);
+ if (r) {
+ pakfire_repo_unref(repo);
+ goto ERROR;
+ }
+
+ pakfire_repo_unref(repo);
+ }
+
+ return list;
+
+ERROR:
+ pakfire_repolist_unref(list);
+ return NULL;
+}
+
PAKFIRE_EXPORT PakfireRepo pakfire_get_repo(Pakfire pakfire, const char* name) {
Pool* pool = pakfire_get_solv_pool(pakfire);
from . import distro
from . import logger
from . import packages
-from . import repository
from . import util
from .config import Config
# Load configuration
self.config = config or Config("general.conf")
- self.repos = repository.Repositories(self)
-
def _setup_logger(self):
log = logging.getLogger("pakfire")
log.propagate = 0
+++ /dev/null
-#!/usr/bin/python
-###############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2011 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-import logging
-log = logging.getLogger("pakfire")
-
-class Repositories(object):
- """
- Class that loads all repositories from the configuration files.
-
- This is the place where repositories can be activated or deactivated.
- """
-
- def __init__(self, pakfire):
- self.pakfire = pakfire
-
- # Place to store the repositories
- self.__repos = {}
-
- def __iter__(self):
- repositories = list(self.__repos.values())
- repositories.sort()
-
- return iter(repositories)
-
- def __len__(self):
- """
- Return the count of enabled repositories.
- """
- return len([r for r in self if r.enabled])
-
- @property
- def distro(self):
- return self.pakfire.distro
-
- def get_repo(self, name):
- """
- Get the repository with the given name, if not available, return
- the dummy repository.
- """
- try:
- return self.__repos[name]
- except KeyError:
- pass
-
- def clean(self):
- log.info("Cleaning up all repository caches...")
-
- for repo in self:
- repo.clean()