# ------------------------------------------------------------------------------
-pakfire_PYTHON = \
- src/pakfire/__init__.py \
- src/pakfire/__version__.py \
- src/pakfire/config.py \
- src/pakfire/constants.py \
- src/pakfire/errors.py \
- src/pakfire/i18n.py \
- src/pakfire/logger.py \
- src/pakfire/util.py
-
-pakfiredir = $(pythondir)/pakfire
-
-# ------------------------------------------------------------------------------
-
pkgpyexec_LTLIBRARIES += \
- _pakfire.la
-
-_pakfire_la_SOURCES = \
- src/_pakfire/_pakfiremodule.c \
- src/_pakfire/archive.c \
- src/_pakfire/archive.h \
- src/_pakfire/archive_file.c \
- src/_pakfire/archive_file.h \
- src/_pakfire/ctx.c \
- src/_pakfire/ctx.h \
- src/_pakfire/errors.h \
- src/_pakfire/file.c \
- src/_pakfire/file.h \
- src/_pakfire/key.c \
- src/_pakfire/key.h \
- src/_pakfire/package.c \
- src/_pakfire/package.h \
- src/_pakfire/pakfire.c \
- src/_pakfire/pakfire.h \
- src/_pakfire/problem.c \
- src/_pakfire/problem.h \
- src/_pakfire/repo.c \
- src/_pakfire/repo.h \
- src/_pakfire/solution.c \
- src/_pakfire/solution.h \
- src/_pakfire/util.c \
- src/_pakfire/util.h
-
-_pakfire_la_CPPFLAGS = \
+ pakfire.la
+
+pakfire_la_SOURCES = \
+ src/python/pakfiremodule.c \
+ src/python/archive.c \
+ src/python/archive.h \
+ src/python/archive_file.c \
+ src/python/archive_file.h \
+ src/python/ctx.c \
+ src/python/ctx.h \
+ src/python/errors.h \
+ src/python/file.c \
+ src/python/file.h \
+ src/python/key.c \
+ src/python/key.h \
+ src/python/package.c \
+ src/python/package.h \
+ src/python/pakfire.c \
+ src/python/pakfire.h \
+ src/python/problem.c \
+ src/python/problem.h \
+ src/python/repo.c \
+ src/python/repo.h \
+ src/python/solution.c \
+ src/python/solution.h \
+ src/python/util.c \
+ src/python/util.h
+
+pakfire_la_CPPFLAGS = \
-include $(top_builddir)/config.h \
$(PAKFIRE_CPPFLAGS)
-_pakfire_la_CFLAGS = \
+pakfire_la_CFLAGS = \
$(AM_CFLAGS) \
$(PYTHON_DEVEL_CFLAGS) \
- $(JSON_C_CFLAGS) \
- -Wno-cast-function-type
+ -Wno-cast-function-type \
+ -Wno-redundant-decls \
+ -Wno-strict-aliasing
-_pakfire_la_LDFLAGS = \
+pakfire_la_LDFLAGS = \
$(AM_LDFLAGS) \
-shared \
-module \
-avoid-version
-_pakfire_la_LIBADD = \
+pakfire_la_LIBADD = \
$(PYTHON_DEVEL_LIBS) \
$(PAKFIRE_LIBS)
# Test the Python modules we just built
TESTS_ENVIRONMENT += \
- PYTHONPATH=$(top_srcdir)/src:$(top_srcdir)/.libs:$(PYTHONPATH)
+ PYTHONPATH=$(top_srcdir)/.libs:$(PYTHONPATH)
dist_check_SCRIPTS = \
tests/python/archive.py \
AC_CONFIG_FILES([
Makefile
po/Makefile.in
- src/pakfire/__version__.py
])
AC_OUTPUT
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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 version
-from .__version__ import PAKFIRE_VERSION as __version__
-
-# Import everything from the C module
-try:
- from ._pakfire import *
-except ImportError:
- from _pakfire import *
+++ /dev/null
-# this file is autogenerated by the buildsystem
-PAKFIRE_VERSION = "@PACKAGE_VERSION@"
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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 configparser
-import logging
-import os
-
-log = logging.getLogger("pakfire.config")
-log.propagate = 1
-
-from .constants import *
-
-class Config(object):
- def __init__(self, *files):
- self._config = configparser.ConfigParser(
- interpolation=configparser.ExtendedInterpolation()
- )
-
- # Read any passed configuration files
- for f in files:
- self.read(f)
-
- def read(self, path):
- """
- Reads configuration from the given file
- """
- if not path.startswith("/"):
- path = os.path.join(CONFIG_DIR, path)
-
- # Silently return if nothing is found
- if not os.path.exists(path):
- return
-
- log.debug("Reading configuration from %s" % path)
-
- with open(path) as f:
- self._config.read_file(f)
-
- def parse(self, s):
- """
- Takes configuration as a string and parses it
- """
- self._config.read_string(s)
-
- def get(self, section, option=None, default=None):
- if option is None:
- try:
- section = self._config.items(section)
- except configparser.NoSectionError:
- return default
-
- return dict(section)
-
- return self._config.get(section, option, fallback=default)
-
- def get_bool(self, section, option, default=None):
- return self._config.getboolean(section, option, fallback=default)
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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 os.path
-
-from .errors import *
-
-from .__version__ import PAKFIRE_VERSION
-
-# The default hub to connect to.
-PAKFIRE_HUB = "https://pakfire.ipfire.org/"
-
-SYSCONFDIR = "/etc"
-
-CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire")
-CONFIG_DISTRO_DIR = os.path.join(CONFIG_DIR, "distros")
-
-PACKAGE_EXTENSION = "pfm"
-MAKEFILE_EXTENSION = "nm"
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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/>. #
-# #
-###############################################################################
-
-from .i18n import _
-
-from ._pakfire import (
- CommandExecutionError,
- DependencyError,
-)
-
-class Error(Exception):
- exit_code = 1
-
- message = _("An unhandled error occured.")
-
-
-class BuildError(Error):
- pass
-
-
-class DownloadError(Error):
- message = _("An error occured when pakfire tried to download files.")
-
-
-class TransportError(Error):
- pass
-
-
-class TransportMaxTriesExceededError(TransportError):
- pass
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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/>. #
-# #
-###############################################################################
-
-"""
- The translation process of all strings is done in here.
-"""
-
-import gettext
-
-"""
- A function that returnes the same string.
-"""
-N_ = lambda x: x
-
-def _(singular, plural=None, n=None):
- """
- A function that returnes the translation of a string if available.
-
- The language is taken from the system environment.
- """
- if not plural is None:
- assert n is not None
- return gettext.dngettext("pakfire", singular, plural, n)
-
- return gettext.dgettext("pakfire", singular)
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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
-import sys
-import systemd.journal
-import time
-
-def setup(name, syslog_identifier="pakfire", enable_console=True, debug=False):
- level = logging.INFO
-
- # Enable debug logging
- if debug:
- level = logging.DEBUG
-
- log = logging.getLogger(name)
- log.setLevel(level)
-
- # Do not propagate anything
- log.propagate = False
-
- # Clear any previous handlers
- log.handlers.clear()
-
- # Enable console output
- if enable_console:
- console = ConsoleHandler()
- log.addHandler(console)
-
- # Do not send any debug output to the console
- console.setLevel(logging.INFO)
-
- # Enable logging to journald
- journal = systemd.journal.JournalHandler(
- SYSLOG_IDENTIFIER=syslog_identifier,
- )
- log.addHandler(journal)
-
- return log
-
-class BuildFormatter(logging.Formatter):
- def __init__(self):
- self._fmt = "[%(asctime)s] %(message)s"
- self.datefmt = None
-
- self.starttime = time.time()
-
- def converter(self, recordtime):
- """
- This returns a timestamp relatively to the time when we started
- the build.
- """
- recordtime -= self.starttime
-
- return time.gmtime(recordtime)
-
- def formatTime(self, record, datefmt=None):
- ct = self.converter(record.created)
- t = time.strftime("%H:%M:%S", ct)
- s = "%s,%03d" % (t, record.msecs)
- return s
-
-
-class ConsoleHandler(logging.Handler):
- """
- This simply writes everything to the console it receives.
- """
- def emit(self, record):
- try:
- msg = self.format(record)
-
- # Append newline if necessary
- if not msg.endswith("\n"):
- msg = "%s\n" % msg
-
- # Select output file
- if record.levelno == logging.DEBUG or record.levelno >= logging.ERROR:
- fd = sys.stderr
- else:
- fd = sys.stdout
-
- # Write the output
- fd.write(msg)
-
- # Immediately flush
- self.flush()
- except Exception:
- self.handleError(record)
-
- def flush(self):
- sys.stdout.flush()
- sys.stderr.flush()
+++ /dev/null
-#!/usr/bin/python3
-###############################################################################
-# #
-# 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 platform
-
-def get_distro_name():
- """
- Returns the distro name of the host
- """
- try:
- release = platform.freedesktop_os_release()
- except AttributeError:
- release = _read_os_release()
-
- return release.get("PRETTY_NAME") or release.get("NAME")
-
-def _read_os_release():
- """
- This is a simple implementation to read /etc/os-release and /var/lib/os-release
- """
- for file in ("/etc/os-release", "/var/lib/os-release"):
- try:
- with open(file, "r") as f:
- release = {}
-
- for line in f:
- key, delim, value = line.partition("=")
-
- release[key] = value
-
- return release
- except FileNotFoundError:
- pass
-
- raise OSError("Could not find os-release")
#include "solution.h"
#include "util.h"
-PyMODINIT_FUNC PyInit__pakfire(void);
+PyMODINIT_FUNC PyInit_pakfire(void);
PyObject* PyExc_BadSignatureError;
PyObject* PyExc_CommandExecutionError;
PyObject* PyExc_CheckError;
PyObject* PyExc_CheckFileVerificationError;
-static PyObject* _pakfire_supported_arches(void) {
+static PyObject* Pakfire_supported_arches(void) {
int r;
// Fetch all architectures
return NULL;
}
-static PyObject* _pakfire_version_compare(PyObject* self, PyObject* args) {
+static PyObject* Pakfire_version_compare(PyObject* self, PyObject* args) {
const char* evr1 = NULL;
const char* evr2 = NULL;
int r;
}
static PyMethodDef pakfireModuleMethods[] = {
- {"supported_arches", (PyCFunction)_pakfire_supported_arches, METH_NOARGS, NULL },
+ {"supported_arches", (PyCFunction)Pakfire_supported_arches, METH_NOARGS, NULL },
{
"version_compare",
- (PyCFunction)_pakfire_version_compare,
+ (PyCFunction)Pakfire_version_compare,
METH_VARARGS,
NULL,
},
static struct PyModuleDef moduledef = {
.m_base = PyModuleDef_HEAD_INIT,
- .m_name = "_pakfire",
+ .m_name = "pakfire",
.m_size = -1,
.m_methods = pakfireModuleMethods,
};
-PyMODINIT_FUNC PyInit__pakfire(void) {
- int r;
-
+PyMODINIT_FUNC PyInit_pakfire(void) {
/* Initialize locale */
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE_TARNAME, "/usr/share/locale");
if (!module)
return NULL;
- PyExc_BadSignatureError = PyErr_NewException("_pakfire.BadSignatureError", NULL, NULL);
+ PyExc_BadSignatureError = PyErr_NewException("pakfire.BadSignatureError", NULL, NULL);
Py_INCREF(PyExc_BadSignatureError);
PyModule_AddObject(module, "BadSignatureError", PyExc_BadSignatureError);
- PyExc_CommandExecutionError = PyErr_NewException("_pakfire.CommandExecutionError", NULL, NULL);
+ PyExc_CommandExecutionError = PyErr_NewException("pakfire.CommandExecutionError", NULL, NULL);
Py_INCREF(PyExc_CommandExecutionError);
PyModule_AddObject(module, "CommandExecutionError", PyExc_CommandExecutionError);
- PyExc_DependencyError = PyErr_NewException("_pakfire.DependencyError", NULL, NULL);
+ PyExc_DependencyError = PyErr_NewException("pakfire.DependencyError", NULL, NULL);
Py_INCREF(PyExc_DependencyError);
PyModule_AddObject(module, "DependencyError", PyExc_DependencyError);
// Check Exceptions
// CheckError
- PyExc_CheckError = PyErr_NewException("_pakfire.CheckError", NULL, NULL);
+ PyExc_CheckError = PyErr_NewException("pakfire.CheckError", NULL, NULL);
Py_INCREF(PyExc_CheckError);
if (PyModule_AddObject(module, "CheckError", PyExc_CheckError) < 0) {
Py_XDECREF(PyExc_CheckError);
// CheckFileVerificationError based on CheckError
PyExc_CheckFileVerificationError = PyErr_NewExceptionWithDoc(
- "_pakfire.CheckFileVerificationError",
+ "pakfire.CheckFileVerificationError",
"The file verification process failed",
PyExc_CheckError,
NULL