|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "apt_pkgmodule.h" |
|
#include "generic.h" |
|
|
|
#include <apt-pkg/configuration.h> |
|
#include <apt-pkg/acquire-item.h> |
|
#include <apt-pkg/packagemanager.h> |
|
#include <apt-pkg/version.h> |
|
#include <apt-pkg/deblistparser.h> |
|
#include <apt-pkg/pkgcache.h> |
|
#include <apt-pkg/tagfile.h> |
|
#include <apt-pkg/hashes.h> |
|
#include <apt-pkg/init.h> |
|
#include <apt-pkg/pkgsystem.h> |
|
#include <apt-pkg/orderlist.h> |
|
#include <apt-pkg/aptconfiguration.h> |
|
#include <apt-pkg/fileutl.h> |
|
#include <apt-pkg/gpgv.h> |
|
|
|
#include <sys/stat.h> |
|
#include <libintl.h> |
|
#include <unistd.h> |
|
#include <Python.h> |
|
|
|
|
|
static char PyAptError_Doc[] = |
|
"Exception class for most python-apt exceptions.\n" |
|
"\n" |
|
"This class replaces the use of :class:`SystemError` in previous versions\n" |
|
"of python-apt. It inherits from :class:`SystemError`, so make sure to\n" |
|
"catch this class first.\n\n" |
|
".. versionadded:: 1.1"; |
|
|
|
PyObject *PyAptError; |
|
|
|
static char PyAptCacheMismatchError_Doc[] = |
|
"Raised when passing an object from a different cache to\n" |
|
":class:`apt_pkg.DepCache` methods\n\n" |
|
".. versionadded:: 1.6.1"; |
|
|
|
PyObject *PyAptCacheMismatchError; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *py_gettext(PyObject *self, PyObject *Args) { |
|
const char *msg; |
|
char *domain = "python-apt"; |
|
if (PyArg_ParseTuple(Args,"s|s:gettext",&msg, &domain) == 0) |
|
return 0; |
|
|
|
return CppPyString(dgettext(domain, msg)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *doc_VersionCompare = |
|
"version_compare(a: str, b: str) -> int\n\n" |
|
"Compare the given versions; return a strictly negative value if 'a' is \n" |
|
"smaller than 'b', 0 if they are equal, and a strictly positive value if\n" |
|
"'a' is larger than 'b'."; |
|
static PyObject *VersionCompare(PyObject *Self,PyObject *Args) |
|
{ |
|
char *A; |
|
char *B; |
|
Py_ssize_t LenA; |
|
Py_ssize_t LenB; |
|
|
|
if (PyArg_ParseTuple(Args,"s#s#",&A,&LenA,&B,&LenB) == 0) |
|
return 0; |
|
|
|
if (_system == 0) |
|
{ |
|
PyErr_SetString(PyExc_ValueError,"_system not initialized"); |
|
return 0; |
|
} |
|
|
|
return MkPyNumber(_system->VS->DoCmpVersion(A,A+LenA,B,B+LenB)); |
|
} |
|
|
|
static char *doc_CheckDep = |
|
"check_dep(pkg_ver: str, dep_op: str, dep_ver: str) -> bool\n\n" |
|
"Check that the given requirement is fulfilled; i.e. that the version\n" |
|
"string given by 'pkg_ver' matches the version string 'dep_ver' under\n" |
|
"the condition specified by the operator 'dep_op' (<,<=,=,>=,>).\n\n" |
|
"Return True if 'pkg_ver' matches 'dep_ver' under the\n" |
|
"condition 'dep_op'; for example, this returns True:\n\n" |
|
" apt_pkg.check_dep('1', '<=', '2')"; |
|
static PyObject *CheckDep(PyObject *Self,PyObject *Args) |
|
{ |
|
char *A; |
|
char *B; |
|
char *OpStr; |
|
unsigned int Op = 0; |
|
|
|
if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) |
|
return 0; |
|
|
|
if (strcmp(OpStr, ">") == 0) OpStr = ">>"; |
|
if (strcmp(OpStr, "<") == 0) OpStr = "<<"; |
|
if (*debListParser::ConvertRelation(OpStr,Op) != 0) |
|
{ |
|
PyErr_SetString(PyExc_ValueError,"Bad comparison operation"); |
|
return 0; |
|
} |
|
|
|
if (_system == 0) |
|
{ |
|
PyErr_SetString(PyExc_ValueError,"_system not initialized"); |
|
return 0; |
|
} |
|
|
|
return PyBool_FromLong(_system->VS->CheckDep(A,Op,B)); |
|
} |
|
|
|
|
|
static char *doc_UpstreamVersion = |
|
"upstream_version(ver: str) -> str\n\n" |
|
"Return the upstream version for the package version given by 'ver'."; |
|
static PyObject *UpstreamVersion(PyObject *Self,PyObject *Args) |
|
{ |
|
char *Ver; |
|
if (PyArg_ParseTuple(Args,"s",&Ver) == 0) |
|
return 0; |
|
return CppPyString(_system->VS->UpstreamVersion(Ver)); |
|
} |
|
|
|
static const char *doc_ParseDepends = |
|
"parse_depends(s: str[, strip_multi_arch : bool = True[, architecture : string]]) -> list\n" |
|
"\n" |
|
"Parse the dependencies given by 's' and return a list of lists. Each of\n" |
|
"these lists represents one or more options for an 'or' dependency in\n" |
|
"the form of '(pkg, ver, comptype)' tuples. The tuple element 'pkg'\n" |
|
"is the name of the package; the element 'ver' is the version, or ''\n" |
|
"if no version was requested. The element 'ver' is a comparison\n" |
|
"operator ('<', '<=', '=', '>=', or '>').\n\n" |
|
"If 'strip_multi_arch' is True, :any (and potentially other special values)\n" |
|
"will be stripped from the full package name" |
|
"The 'architecture' parameter may be used to specify a non-native architecture\n" |
|
"for the dependency parsing."; |
|
|
|
static const char *parse_src_depends_doc = |
|
"parse_src_depends(s: str[, strip_multi_arch : bool = True[, architecture : string]]) -> list\n" |
|
"\n" |
|
"Parse the dependencies given by 's' and return a list of lists. Each of\n" |
|
"these lists represents one or more options for an 'or' dependency in\n" |
|
"the form of '(pkg, ver, comptype)' tuples. The tuple element 'pkg'\n" |
|
"is the name of the package; the element 'ver' is the version, or ''\n" |
|
"if no version was requested. The element 'ver' is a comparison\n" |
|
"operator ('<', '<=', '=', '>=', or '>')." |
|
"\n\n" |
|
"Dependencies may be restricted to certain architectures and the result\n" |
|
"only contains those dependencies for the architecture set in the\n" |
|
"configuration variable APT::Architecture\n\n" |
|
"If 'strip_multi_arch' is True, :any (and potentially other special values)\n" |
|
"will be stripped from the full package name" |
|
"The 'architecture' parameter may be used to specify a non-native architecture\n" |
|
"for the dependency parsing."; |
|
static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,PyObject *Kwds, |
|
bool ParseArchFlags, bool ParseRestrictionsList, |
|
std::string name, bool debStyle=false) |
|
{ |
|
std::string Package; |
|
std::string Version; |
|
unsigned int Op; |
|
bool StripMultiArch=true; |
|
|
|
const char *Start; |
|
const char *Stop; |
|
Py_ssize_t Len; |
|
const char *Arch = NULL; |
|
char *kwlist[] = {"s", "strip_multi_arch", "architecture", 0}; |
|
|
|
if (PyArg_ParseTupleAndKeywords(Args,Kwds,(char *)("s#|bs:" + name).c_str(), kwlist, |
|
&Start, &Len, &StripMultiArch, &Arch) == 0) |
|
return 0; |
|
Stop = Start + Len; |
|
PyObject *List = PyList_New(0); |
|
PyObject *LastRow = 0; |
|
while (1) |
|
{ |
|
if (Start == Stop) |
|
break; |
|
if (Arch == NULL) |
|
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op, |
|
ParseArchFlags, StripMultiArch, |
|
ParseRestrictionsList); |
|
else |
|
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op, |
|
ParseArchFlags, StripMultiArch, |
|
ParseRestrictionsList, Arch); |
|
|
|
if (Start == 0) |
|
{ |
|
PyErr_SetString(PyExc_ValueError,"Problem Parsing Dependency"); |
|
Py_DECREF(List); |
|
return 0; |
|
} |
|
|
|
if (LastRow == 0) |
|
LastRow = PyList_New(0); |
|
|
|
if (Package.empty() == false) |
|
{ |
|
PyObject *Obj; |
|
PyList_Append(LastRow,Obj = Py_BuildValue("sss",Package.c_str(), |
|
Version.c_str(), |
|
debStyle ? pkgCache::CompTypeDeb(Op) : pkgCache::CompType(Op))); |
|
Py_DECREF(Obj); |
|
} |
|
|
|
|
|
if ((Op & pkgCache::Dep::Or) != pkgCache::Dep::Or) |
|
{ |
|
if (PyList_Size(LastRow) != 0) |
|
PyList_Append(List,LastRow); |
|
Py_DECREF(LastRow); |
|
LastRow = 0; |
|
} |
|
} |
|
return List; |
|
} |
|
static PyObject *ParseDepends(PyObject *Self,PyObject *Args, PyObject *Kwds) |
|
{ |
|
return RealParseDepends(Self, Args, Kwds, false, false, "parse_depends"); |
|
} |
|
static PyObject *ParseSrcDepends(PyObject *Self,PyObject *Args, PyObject *Kwds) |
|
{ |
|
return RealParseDepends(Self, Args, Kwds, true, true, "parse_src_depends"); |
|
} |
|
|
|
|
|
|
|
static const char *doc_md5sum = |
|
"md5sum(object) -> str\n\n" |
|
"Return the md5sum of the object. 'object' may either be a string, in\n" |
|
"which case the md5sum of the string is returned, or a file() object\n" |
|
"(or file descriptor), in which case the md5sum of its contents is\n" |
|
"returned."; |
|
static PyObject *md5sum(PyObject *Self,PyObject *Args) |
|
{ |
|
PyObject *Obj; |
|
if (PyArg_ParseTuple(Args,"O",&Obj) == 0) |
|
return 0; |
|
|
|
if (PyErr_WarnEx(PyExc_DeprecationWarning, |
|
"apt_pkg.md5sum is deprecated, use apt_pkg.Hashes", 1) == -1) |
|
return NULL; |
|
|
|
|
|
if (PyBytes_Check(Obj) != 0) |
|
{ |
|
char *s; |
|
Py_ssize_t len; |
|
Hashes Sum(Hashes::MD5SUM); |
|
PyBytes_AsStringAndSize(Obj, &s, &len); |
|
Sum.Add((const unsigned char*)s, len); |
|
return CppPyString(Sum.GetHashString(Hashes::MD5SUM).HashValue()); |
|
} |
|
|
|
|
|
int Fd = PyObject_AsFileDescriptor(Obj); |
|
if (Fd != -1) |
|
{ |
|
Hashes Sum(Hashes::MD5SUM); |
|
struct stat St; |
|
if (fstat(Fd,&St) != 0 || |
|
Sum.AddFD(Fd,St.st_size) == false) |
|
{ |
|
PyErr_SetFromErrno(PyAptError); |
|
return 0; |
|
} |
|
|
|
return CppPyString(Sum.GetHashString(Hashes::MD5SUM).HashValue()); |
|
} |
|
|
|
PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); |
|
return 0; |
|
} |
|
|
|
|
|
|
|
static const char *doc_sha1sum = |
|
"sha1sum(object) -> str\n\n" |
|
"Return the sha1sum of the object. 'object' may either be a string, in\n" |
|
"which case the sha1sum of the string is returned, or a file() object\n" |
|
"(or file descriptor), in which case the sha1sum of its contents is\n" |
|
"returned."; |
|
static PyObject *sha1sum(PyObject *Self,PyObject *Args) |
|
{ |
|
PyObject *Obj; |
|
if (PyArg_ParseTuple(Args,"O",&Obj) == 0) |
|
return 0; |
|
|
|
if (PyErr_WarnEx(PyExc_DeprecationWarning, |
|
"apt_pkg.sha1sum is deprecated, use apt_pkg.Hashes", 1) == -1) |
|
return NULL; |
|
|
|
|
|
if (PyBytes_Check(Obj) != 0) |
|
{ |
|
char *s; |
|
Py_ssize_t len; |
|
Hashes Sum(Hashes::SHA1SUM); |
|
PyBytes_AsStringAndSize(Obj, &s, &len); |
|
Sum.Add((const unsigned char*)s, len); |
|
return CppPyString(Sum.GetHashString(Hashes::SHA1SUM).HashValue()); |
|
} |
|
|
|
|
|
int Fd = PyObject_AsFileDescriptor(Obj); |
|
if (Fd != -1) |
|
{ |
|
Hashes Sum(Hashes::SHA1SUM); |
|
struct stat St; |
|
if (fstat(Fd,&St) != 0 || |
|
Sum.AddFD(Fd,St.st_size) == false) |
|
{ |
|
PyErr_SetFromErrno(PyAptError); |
|
return 0; |
|
} |
|
|
|
return CppPyString(Sum.GetHashString(Hashes::SHA1SUM).HashValue()); |
|
} |
|
|
|
PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); |
|
return 0; |
|
} |
|
|
|
|
|
|
|
static const char *doc_sha256sum = |
|
"sha256sum(object) -> str\n\n" |
|
"Return the sha256sum of the object. 'object' may either be a string, in\n" |
|
"which case the sha256sum of the string is returned, or a file() object\n" |
|
"(or file descriptor), in which case the sha256sum of its contents is\n" |
|
"returned.";; |
|
static PyObject *sha256sum(PyObject *Self,PyObject *Args) |
|
{ |
|
PyObject *Obj; |
|
if (PyArg_ParseTuple(Args,"O",&Obj) == 0) |
|
return 0; |
|
|
|
if (PyErr_WarnEx(PyExc_DeprecationWarning, |
|
"apt_pkg.sha256sum is deprecated, use apt_pkg.Hashes", 1) == -1) |
|
return NULL; |
|
|
|
|
|
if (PyBytes_Check(Obj) != 0) |
|
{ |
|
char *s; |
|
Py_ssize_t len; |
|
Hashes Sum(Hashes::SHA256SUM); |
|
PyBytes_AsStringAndSize(Obj, &s, &len); |
|
Sum.Add((const unsigned char*)s, len); |
|
return CppPyString(Sum.GetHashString(Hashes::SHA256SUM).HashValue()); |
|
} |
|
|
|
|
|
int Fd = PyObject_AsFileDescriptor(Obj); |
|
if (Fd != -1) |
|
{ |
|
Hashes Sum(Hashes::SHA256SUM); |
|
struct stat St; |
|
if (fstat(Fd,&St) != 0 || |
|
Sum.AddFD(Fd,St.st_size) == false) |
|
{ |
|
PyErr_SetFromErrno(PyAptError); |
|
return 0; |
|
} |
|
|
|
return CppPyString(Sum.GetHashString(Hashes::SHA256SUM).HashValue()); |
|
} |
|
|
|
PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); |
|
return 0; |
|
} |
|
|
|
|
|
|
|
static const char *doc_sha512sum = |
|
"sha512sum(object) -> str\n\n" |
|
"Return the sha512sum of the object. 'object' may either be a string, in\n" |
|
"which case the sha512sum of the string is returned, or a file() object\n" |
|
"(or file descriptor), in which case the sha512sum of its contents is\n" |
|
"returned.";; |
|
static PyObject *sha512sum(PyObject *Self,PyObject *Args) |
|
{ |
|
PyObject *Obj; |
|
if (PyArg_ParseTuple(Args,"O",&Obj) == 0) |
|
return 0; |
|
|
|
if (PyErr_WarnEx(PyExc_DeprecationWarning, |
|
"apt_pkg.sha512sum is deprecated, use apt_pkg.Hashes", 1) == -1) |
|
return NULL; |
|
|
|
|
|
if (PyBytes_Check(Obj) != 0) |
|
{ |
|
char *s; |
|
Py_ssize_t len; |
|
Hashes Sum(Hashes::SHA512SUM); |
|
PyBytes_AsStringAndSize(Obj, &s, &len); |
|
Sum.Add((const unsigned char*)s, len); |
|
return CppPyString(Sum.GetHashString(Hashes::SHA512SUM).HashValue()); |
|
} |
|
|
|
|
|
int Fd = PyObject_AsFileDescriptor(Obj); |
|
if (Fd != -1) |
|
{ |
|
Hashes Sum(Hashes::SHA512SUM); |
|
struct stat St; |
|
if (fstat(Fd,&St) != 0 || |
|
Sum.AddFD(Fd,St.st_size) == false) |
|
{ |
|
PyErr_SetFromErrno(PyAptError); |
|
return 0; |
|
} |
|
|
|
return CppPyString(Sum.GetHashString(Hashes::SHA512SUM).HashValue()); |
|
} |
|
|
|
PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); |
|
return 0; |
|
} |
|
|
|
|
|
|
|
static const char *doc_GetArchitectures = |
|
"get_architectures() -> list\n\n" |
|
"Return the list of supported architectures on this system. On a \n" |
|
"multiarch system this can be more than one. The main architectures\n" |
|
"is the first item in the list.";; |
|
static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) |
|
{ |
|
PyObject *Obj; |
|
if (PyArg_ParseTuple(Args,"",&Obj) == 0) |
|
return 0; |
|
|
|
PyObject *List = PyList_New(0); |
|
std::vector<std::string> arches = APT::Configuration::getArchitectures(); |
|
std::vector<std::string>::const_iterator I; |
|
for (I = arches.begin(); I != arches.end(); I++) |
|
{ |
|
PyList_Append(List, CppPyString(*I)); |
|
} |
|
|
|
return List; |
|
} |
|
|
|
|
|
|
|
static char *doc_Init = |
|
"init()\n\n" |
|
"Shorthand for doing init_config() and init_system(). When working\n" |
|
"with command line arguments, first call init_config() then parse\n" |
|
"the command line and finally call init_system()."; |
|
static PyObject *Init(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
pkgInitConfig(*_config); |
|
pkgInitSystem(*_config,_system); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(Py_None); |
|
} |
|
|
|
static char *doc_InitConfig = |
|
"init_config()\n\n" |
|
"Load the default configuration and the config file."; |
|
static PyObject *InitConfig(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
pkgInitConfig(*_config); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(Py_None); |
|
} |
|
|
|
static char *doc_InitSystem = |
|
"init_system()\n\n" |
|
"Construct the apt_pkg system."; |
|
static PyObject *InitSystem(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
pkgInitSystem(*_config,_system); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(Py_None); |
|
} |
|
|
|
|
|
|
|
static char *doc_OpenMaybeClearSignedFile = |
|
"open_maybe_clear_signed_file(file: str) -> int\n\n" |
|
"Open a file and ignore a PGP clear signature.\n" |
|
"Return a open file descriptor or a error."; |
|
static PyObject *PyOpenMaybeClearSignedFile(PyObject *Self,PyObject *Args) |
|
{ |
|
PyApt_Filename file; |
|
char errors = false; |
|
if (PyArg_ParseTuple(Args,"O&",PyApt_Filename::Converter, &file,&errors) == 0) |
|
return 0; |
|
|
|
FileFd Fd; |
|
if (OpenMaybeClearSignedFile(file, Fd) == false) |
|
return HandleErrors(MkPyNumber(-1)); |
|
|
|
return HandleErrors(MkPyNumber(dup(Fd.Fd()))); |
|
} |
|
|
|
|
|
|
|
static char *doc_GetLock = |
|
"get_lock(file: str, errors: bool) -> int\n\n" |
|
"Create an empty file of the given name and lock it. If the locking\n" |
|
"succeeds, return the file descriptor of the lock file. Afterwards,\n" |
|
"locking the file from another process will fail and thus cause\n" |
|
"get_lock() to return -1 or raise an Error (if 'errors' is True).\n\n" |
|
"From Python 2.6 on, it is recommended to use the context manager\n" |
|
"provided by apt_pkg.FileLock instead using the with-statement."; |
|
static PyObject *GetLock(PyObject *Self,PyObject *Args) |
|
{ |
|
PyApt_Filename file; |
|
char errors = false; |
|
if (PyArg_ParseTuple(Args,"O&|b",PyApt_Filename::Converter, &file,&errors) == 0) |
|
return 0; |
|
|
|
int fd = GetLock(file, errors); |
|
|
|
return HandleErrors(MkPyNumber(fd)); |
|
} |
|
|
|
static char *doc_PkgSystemLock = |
|
"pkgsystem_lock() -> bool\n\n" |
|
"Acquire the global lock for the package system by using /var/lib/dpkg/lock-frontend\n" |
|
"and /var/lib/dpkg/lock to do the locking. From Python 2.6 on, the apt_pkg.SystemLock context\n" |
|
"manager is available and should be used instead."; |
|
static PyObject *PkgSystemLock(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
bool res = _system->Lock(); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(PyBool_FromLong(res)); |
|
} |
|
|
|
static char *doc_PkgSystemUnLock = |
|
"pkgsystem_unlock() -> bool\n\n" |
|
"Release the global lock for the package system."; |
|
static PyObject *PkgSystemUnLock(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
bool res = _system->UnLock(); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(PyBool_FromLong(res)); |
|
} |
|
|
|
static char *doc_PkgSystemLockInner = |
|
"pkgsystem_lock_inner() -> bool\n\n" |
|
"Reacquire the dpkg 'lock' lock file. Must be called only after\n" |
|
":meth:`pkgsystem_unlock_inner` and only around invocations of dpkg.\n" |
|
"\n" |
|
".. versionadded:: 1.7"; |
|
static PyObject *PkgSystemLockInner(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
bool res = _system->LockInner(); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(PyBool_FromLong(res)); |
|
} |
|
|
|
static char *doc_PkgSystemUnLockInner = |
|
"pkgsystem_unlock_inner() -> bool\n\n" |
|
"Release the dpkg lock file 'lock'. To be called before manually\n" |
|
"invoking dpkg.\n" |
|
"\n" |
|
".. versionadded:: 1.7"; |
|
static PyObject *PkgSystemUnLockInner(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
bool res = _system->UnLockInner(); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(PyBool_FromLong(res)); |
|
} |
|
|
|
static char *doc_PkgSystemIsLocked = |
|
"pkgsystem_is_locked() -> bool\n\n" |
|
"Check if the system is locked. Can be used to check whether the inner\n" |
|
"lock needs to be released or not in generic code.\n" |
|
"\n" |
|
".. versionadded:: 1.7"; |
|
static PyObject *PkgSystemIsLocked(PyObject *Self,PyObject *Args) |
|
{ |
|
if (PyArg_ParseTuple(Args,"") == 0) |
|
return 0; |
|
|
|
bool res = _system->IsLocked(); |
|
|
|
Py_INCREF(Py_None); |
|
return HandleErrors(PyBool_FromLong(res)); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyMethodDef methods[] = |
|
{ |
|
|
|
{"init",Init,METH_VARARGS,doc_Init}, |
|
{"init_config",InitConfig,METH_VARARGS,doc_InitConfig}, |
|
{"init_system",InitSystem,METH_VARARGS,doc_InitSystem}, |
|
|
|
|
|
{"gettext",py_gettext,METH_VARARGS, |
|
"gettext(msg: str[, domain: str = 'python-apt']) -> str\n\n" |
|
"Translate the given string. This is much faster than Python's version\n" |
|
"and only does translations after setlocale() has been called."}, |
|
|
|
|
|
|
|
{"open_maybe_clear_signed_file",PyOpenMaybeClearSignedFile,METH_VARARGS, |
|
doc_OpenMaybeClearSignedFile}, |
|
|
|
|
|
{"get_lock",GetLock,METH_VARARGS,doc_GetLock}, |
|
{"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, |
|
{"pkgsystem_unlock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, |
|
{"pkgsystem_lock_inner",PkgSystemLockInner,METH_VARARGS,doc_PkgSystemLockInner}, |
|
{"pkgsystem_unlock_inner",PkgSystemUnLockInner,METH_VARARGS,doc_PkgSystemUnLockInner}, |
|
{"pkgsystem_is_locked",PkgSystemIsLocked,METH_VARARGS,doc_PkgSystemIsLocked}, |
|
|
|
|
|
{"read_config_file",LoadConfig,METH_VARARGS,doc_LoadConfig}, |
|
{"read_config_dir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, |
|
{"read_config_file_isc",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, |
|
{"parse_commandline",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, |
|
|
|
|
|
{"version_compare",VersionCompare,METH_VARARGS,doc_VersionCompare}, |
|
{"check_dep",CheckDep,METH_VARARGS,doc_CheckDep}, |
|
{"upstream_version",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion}, |
|
|
|
|
|
{"parse_depends",reinterpret_cast<PyCFunction>(static_cast<PyCFunctionWithKeywords>(ParseDepends)),METH_VARARGS|METH_KEYWORDS,doc_ParseDepends}, |
|
{"parse_src_depends",reinterpret_cast<PyCFunction>(static_cast<PyCFunctionWithKeywords>(ParseSrcDepends)),METH_VARARGS|METH_KEYWORDS,parse_src_depends_doc}, |
|
|
|
|
|
{"md5sum",md5sum,METH_VARARGS,doc_md5sum}, |
|
{"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, |
|
{"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, |
|
{"sha512sum",sha512sum,METH_VARARGS,doc_sha512sum}, |
|
|
|
|
|
{"get_architectures", GetArchitectures, METH_VARARGS, doc_GetArchitectures}, |
|
|
|
|
|
{"check_domain_list",StrCheckDomainList,METH_VARARGS, |
|
"check_domain_list(host: str, domains: str) -> bool\n\n" |
|
"Check if the host given by 'host' belongs to one of the domains\n" |
|
"specified in the comma separated string 'domains'. An example\n" |
|
"would be:\n\n" |
|
" check_domain_list('alioth.debian.org','debian.net,debian.org')\n\n" |
|
"which would return True because alioth belongs to debian.org."}, |
|
{"quote_string",StrQuoteString,METH_VARARGS, |
|
"quote_string(string: str, repl: str) -> str\n\n" |
|
"Escape the string 'string', replacing any character not allowed in a URL" |
|
"or specified by 'repl' with its ASCII value preceded by a percent sign" |
|
"(so for example ' ' becomes '%20')."}, |
|
{"dequote_string",StrDeQuote,METH_VARARGS, |
|
"dequote_string(string: str) -> str\n\n" |
|
"Dequote the given string by replacing all HTTP encoded values such\n" |
|
"as '%20' with their decoded value (in this case, ' ')."}, |
|
{"size_to_str",StrSizeToStr,METH_VARARGS, |
|
"size_to_str(bytes: int) -> str\n\n" |
|
"Return a string describing the size in a human-readable manner using\n" |
|
"SI prefix and base-10 units, e.g. '1k' for 1000, '1M' for 1000000, etc."}, |
|
{"time_to_str",StrTimeToStr,METH_VARARGS, |
|
"time_to_str(seconds: int) -> str\n\n" |
|
"Return a string describing the number of seconds in a human\n" |
|
"readable manner using days, hours, minutes and seconds."}, |
|
{"uri_to_filename",StrURItoFileName,METH_VARARGS, |
|
"uri_to_filename(uri: str) -> str\n\n" |
|
"Return a filename based on the given URI after replacing some\n" |
|
"parts not suited for filenames (e.g. '/')."}, |
|
{"base64_encode",StrBase64Encode,METH_VARARGS, |
|
"base64_encode(value: bytes) -> str\n\n" |
|
"Encode the given bytestring into Base64. The input may not\n" |
|
"contain a null byte character (use the base64 module for this)."}, |
|
{"string_to_bool",StrStringToBool,METH_VARARGS, |
|
"string_to_bool(string: str) -> int\n\n" |
|
"Return 1 if the string is a value such as 'yes', 'true', '1';\n" |
|
"0 if the string is a value such as 'no', 'false', '0'; -1 if\n" |
|
"the string is not recognized."}, |
|
{"time_rfc1123",StrTimeRFC1123,METH_VARARGS, |
|
"time_rfc1123(unixtime: int) -> str\n\n" |
|
"Format the given Unix time according to the requirements of\n" |
|
"RFC 1123."}, |
|
{"str_to_time",StrStrToTime,METH_VARARGS, |
|
"str_to_time(rfc_time: str) -> int\n\n" |
|
"Convert the given RFC 1123 formatted string to a Unix timestamp."}, |
|
|
|
|
|
|
|
{} |
|
}; |
|
|
|
static struct _PyAptPkgAPIStruct API = { |
|
&PyAcquire_Type, |
|
&PyAcquire_FromCpp, |
|
&PyAcquire_ToCpp, |
|
&PyAcquireFile_Type, |
|
&PyAcquireFile_FromCpp, |
|
&PyAcquireFile_ToCpp, |
|
&PyAcquireItem_Type, |
|
&PyAcquireItem_FromCpp, |
|
&PyAcquireItem_ToCpp, |
|
&PyAcquireItemDesc_Type, |
|
&PyAcquireItemDesc_FromCpp, |
|
&PyAcquireItemDesc_ToCpp, |
|
&PyAcquireWorker_Type, |
|
&PyAcquireWorker_FromCpp, |
|
&PyAcquireWorker_ToCpp, |
|
&PyActionGroup_Type, |
|
&PyActionGroup_FromCpp, |
|
&PyActionGroup_ToCpp, |
|
&PyCache_Type, |
|
&PyCache_FromCpp, |
|
&PyCache_ToCpp, |
|
&PyCacheFile_Type, |
|
&PyCacheFile_FromCpp, |
|
&PyCacheFile_ToCpp, |
|
&PyCdrom_Type, |
|
&PyCdrom_FromCpp, |
|
&PyCdrom_ToCpp, |
|
&PyConfiguration_Type, |
|
&PyConfiguration_FromCpp, |
|
&PyConfiguration_ToCpp, |
|
&PyDepCache_Type, |
|
&PyDepCache_FromCpp, |
|
&PyDepCache_ToCpp, |
|
&PyDependency_Type, |
|
&PyDependency_FromCpp, |
|
&PyDependency_ToCpp, |
|
&PyDependencyList_Type, |
|
0, |
|
0, |
|
&PyDescription_Type, |
|
&PyDescription_FromCpp, |
|
&PyDescription_ToCpp, |
|
&PyHashes_Type, |
|
&PyHashes_FromCpp, |
|
&PyHashes_ToCpp, |
|
&PyHashString_Type, |
|
&PyHashString_FromCpp, |
|
&PyHashString_ToCpp, |
|
&PyMetaIndex_Type, |
|
&PyMetaIndex_FromCpp, |
|
&PyMetaIndex_ToCpp, |
|
&PyPackage_Type, |
|
&PyPackage_FromCpp, |
|
&PyPackage_ToCpp, |
|
&PyPackageFile_Type, |
|
&PyPackageFile_FromCpp, |
|
&PyPackageFile_ToCpp, |
|
&PyIndexFile_Type, |
|
&PyIndexFile_FromCpp, |
|
&PyIndexFile_ToCpp, |
|
&PyPackageList_Type, |
|
0, |
|
0, |
|
&PyPackageManager_Type, |
|
&PyPackageManager_FromCpp, |
|
&PyPackageManager_ToCpp, |
|
&PyPackageRecords_Type, |
|
0, |
|
0, |
|
&PyPolicy_Type, |
|
&PyPolicy_FromCpp, |
|
&PyPolicy_ToCpp, |
|
&PyProblemResolver_Type, |
|
&PyProblemResolver_FromCpp, |
|
&PyProblemResolver_ToCpp, |
|
&PySourceList_Type, |
|
&PySourceList_FromCpp, |
|
&PySourceList_ToCpp, |
|
&PySourceRecords_Type, |
|
0, |
|
0, |
|
&PyTagFile_Type, |
|
&PyTagFile_FromCpp, |
|
&PyTagFile_ToCpp, |
|
&PyTagSection_Type, |
|
&PyTagSection_FromCpp, |
|
&PyTagSection_ToCpp, |
|
&PyVersion_Type, |
|
&PyVersion_FromCpp, |
|
&PyVersion_ToCpp, |
|
&PyGroup_Type, |
|
&PyGroup_FromCpp, |
|
&PyGroup_ToCpp, |
|
&PyOrderList_Type, |
|
&PyOrderList_FromCpp, |
|
&PyOrderList_ToCpp, |
|
&PySourceRecordFiles_Type, |
|
0, |
|
0, |
|
}; |
|
|
|
|
|
#define ADDTYPE(mod,name,type) { \ |
|
if (PyType_Ready(type) == -1) INIT_ERROR; \ |
|
Py_INCREF(type); \ |
|
PyModule_AddObject(mod,name,(PyObject *)type); } |
|
|
|
|
|
static const char *apt_pkg_doc = |
|
"Classes and functions wrapping the apt-pkg library.\n\n" |
|
"The apt_pkg module provides several classes and functions for accessing\n" |
|
"the functionality provided by the apt-pkg library. Typical uses might\n" |
|
"include reading APT index files and configuration files and installing\n" |
|
"or removing packages."; |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
static struct PyModuleDef moduledef = { |
|
PyModuleDef_HEAD_INIT, |
|
"apt_pkg", |
|
apt_pkg_doc, |
|
-1, |
|
methods, |
|
0, |
|
0, |
|
0, |
|
0, |
|
}; |
|
|
|
#define INIT_ERROR return 0 |
|
extern "C" PyObject * PyInit_apt_pkg() |
|
#else |
|
#define INIT_ERROR return |
|
extern "C" void initapt_pkg() |
|
#endif |
|
{ |
|
|
|
if (PyType_Ready(&PyConfiguration_Type) == -1) INIT_ERROR; |
|
if (PyType_Ready(&PyCacheFile_Type) == -1) INIT_ERROR; |
|
PyAptError = PyErr_NewExceptionWithDoc("apt_pkg.Error", PyAptError_Doc, PyExc_SystemError, NULL); |
|
if (PyAptError == NULL) |
|
INIT_ERROR; |
|
|
|
PyAptCacheMismatchError = PyErr_NewExceptionWithDoc("apt_pkg.CacheMismatchError", PyAptCacheMismatchError_Doc, PyExc_ValueError, NULL); |
|
if (PyAptCacheMismatchError == NULL) |
|
INIT_ERROR; |
|
|
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
PyObject *Module = PyModule_Create(&moduledef); |
|
#else |
|
PyObject *Module = Py_InitModule3("apt_pkg",methods, apt_pkg_doc); |
|
#endif |
|
|
|
|
|
CppPyObject<Configuration*> *Config = CppPyObject_NEW<Configuration*>(NULL, &PyConfiguration_Type); |
|
Config->Object = _config; |
|
|
|
Config->NoDelete = true; |
|
PyModule_AddObject(Module,"config",Config); |
|
PyModule_AddObject(Module,"Error",PyAptError); |
|
PyModule_AddObject(Module,"CacheMismatchError", PyAptCacheMismatchError); |
|
|
|
|
|
|
|
|
|
|
|
ADDTYPE(Module,"TagSection",&PyTagSection_Type); |
|
ADDTYPE(Module,"TagFile",&PyTagFile_Type); |
|
ADDTYPE(Module,"Tag",&PyTag_Type); |
|
ADDTYPE(Module,"TagRewrite",&PyTagRewrite_Type); |
|
ADDTYPE(Module,"TagRename",&PyTagRename_Type); |
|
ADDTYPE(Module,"TagRemove",&PyTagRemove_Type); |
|
|
|
ADDTYPE(Module,"Acquire",&PyAcquire_Type); |
|
ADDTYPE(Module,"AcquireFile",&PyAcquireFile_Type); |
|
ADDTYPE(Module,"AcquireItem",&PyAcquireItem_Type); |
|
ADDTYPE(Module,"AcquireWorker",&PyAcquireWorker_Type); |
|
|
|
ADDTYPE(Module,"Cache",&PyCache_Type); |
|
ADDTYPE(Module,"Dependency",&PyDependency_Type); |
|
ADDTYPE(Module,"Description",&PyDescription_Type); |
|
ADDTYPE(Module,"PackageFile",&PyPackageFile_Type); |
|
ADDTYPE(Module,"PackageList",&PyPackageList_Type); |
|
ADDTYPE(Module,"DependencyList",&PyDependencyList_Type); |
|
ADDTYPE(Module,"Package",&PyPackage_Type); |
|
ADDTYPE(Module,"Version",&PyVersion_Type); |
|
ADDTYPE(Module,"Group", &PyGroup_Type); |
|
ADDTYPE(Module,"GroupList", &PyGroupList_Type); |
|
|
|
ADDTYPE(Module,"Cdrom",&PyCdrom_Type); |
|
|
|
ADDTYPE(Module,"Configuration",&PyConfiguration_Type); |
|
|
|
ADDTYPE(Module,"ActionGroup",&PyActionGroup_Type); |
|
ADDTYPE(Module,"DepCache",&PyDepCache_Type); |
|
ADDTYPE(Module,"ProblemResolver",&PyProblemResolver_Type); |
|
|
|
ADDTYPE(Module,"IndexFile",&PyIndexFile_Type); |
|
|
|
ADDTYPE(Module,"MetaIndex",&PyMetaIndex_Type); |
|
|
|
ADDTYPE(Module,"_PackageManager",&PyPackageManager_Type); |
|
ADDTYPE(Module,"PackageManager",&PyPackageManager2_Type); |
|
|
|
ADDTYPE(Module,"PackageRecords",&PyPackageRecords_Type); |
|
|
|
ADDTYPE(Module,"SourceRecords",&PySourceRecords_Type); |
|
ADDTYPE(Module,"SourceRecordFiles",&PySourceRecordFiles_Type); |
|
|
|
ADDTYPE(Module,"SourceList",&PySourceList_Type); |
|
ADDTYPE(Module,"HashString",&PyHashString_Type); |
|
ADDTYPE(Module,"Policy",&PyPolicy_Type); |
|
ADDTYPE(Module,"Hashes",&PyHashes_Type); |
|
ADDTYPE(Module,"AcquireItemDesc",&PyAcquireItemDesc_Type); |
|
ADDTYPE(Module,"SystemLock",&PySystemLock_Type); |
|
ADDTYPE(Module,"FileLock",&PyFileLock_Type); |
|
ADDTYPE(Module,"OrderList",&PyOrderList_Type); |
|
ADDTYPE(Module,"HashStringList",&PyHashStringList_Type); |
|
|
|
PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", |
|
CharCharToList(TFRewritePackageOrder)); |
|
|
|
PyModule_AddObject(Module,"REWRITE_SOURCE_ORDER", |
|
CharCharToList(TFRewriteSourceOrder)); |
|
|
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_ADDED", MkPyNumber(pkgOrderList::Added)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_ADD_PENDIG", MkPyNumber(pkgOrderList::AddPending)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_IMMEDIATE", MkPyNumber(pkgOrderList::Immediate)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_LOOP", MkPyNumber(pkgOrderList::Loop)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_UNPACKED", MkPyNumber(pkgOrderList::UnPacked)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_CONFIGURED", MkPyNumber(pkgOrderList::Configured)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_REMOVED", MkPyNumber(pkgOrderList::Removed)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_IN_LIST", MkPyNumber(pkgOrderList::InList)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_AFTER", MkPyNumber(pkgOrderList::After)); |
|
PyDict_SetItemString(PyOrderList_Type.tp_dict, "FLAG_STATES_MASK", MkPyNumber(pkgOrderList::States)); |
|
|
|
|
|
|
|
PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_CANCELLED", |
|
MkPyNumber(pkgAcquire::Cancelled)); |
|
PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_CONTINUE", |
|
MkPyNumber(pkgAcquire::Continue)); |
|
PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_FAILED", |
|
MkPyNumber(pkgAcquire::Failed)); |
|
|
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_DEPENDS", |
|
MkPyNumber(pkgCache::Dep::Depends)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_PREDEPENDS", |
|
MkPyNumber(pkgCache::Dep::PreDepends)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_SUGGESTS", |
|
MkPyNumber(pkgCache::Dep::Suggests)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_RECOMMENDS", |
|
MkPyNumber(pkgCache::Dep::Recommends)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_CONFLICTS", |
|
MkPyNumber(pkgCache::Dep::Conflicts)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_REPLACES", |
|
MkPyNumber(pkgCache::Dep::Replaces)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_OBSOLETES", |
|
MkPyNumber(pkgCache::Dep::Obsoletes)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_DPKG_BREAKS", |
|
MkPyNumber(pkgCache::Dep::DpkgBreaks)); |
|
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_ENHANCES", |
|
MkPyNumber(pkgCache::Dep::Enhances)); |
|
|
|
|
|
|
|
PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_COMPLETED", |
|
MkPyNumber(pkgPackageManager::Completed)); |
|
PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_FAILED", |
|
MkPyNumber(pkgPackageManager::Failed)); |
|
PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_INCOMPLETE", |
|
MkPyNumber(pkgPackageManager::Incomplete)); |
|
|
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_NO", |
|
MkPyNumber(pkgCache::Version::No)); |
|
|
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_NONE", |
|
MkPyNumber(pkgCache::Version::No)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_ALL", |
|
MkPyNumber(pkgCache::Version::All)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_FOREIGN", |
|
MkPyNumber(pkgCache::Version::Foreign)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_SAME", |
|
MkPyNumber(pkgCache::Version::Same)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_ALLOWED", |
|
MkPyNumber(pkgCache::Version::Allowed)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_ALL_FOREIGN", |
|
MkPyNumber(pkgCache::Version::AllForeign)); |
|
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_ALL_ALLOWED", |
|
MkPyNumber(pkgCache::Version::AllAllowed)); |
|
|
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_IDLE", |
|
MkPyNumber(pkgAcquire::Item::StatIdle)); |
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_FETCHING", |
|
MkPyNumber(pkgAcquire::Item::StatFetching)); |
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_DONE", |
|
MkPyNumber(pkgAcquire::Item::StatDone)); |
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_TRANSIENT_NETWORK_ERROR", |
|
MkPyNumber(pkgAcquire::Item::StatTransientNetworkError)); |
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_ERROR", |
|
MkPyNumber(pkgAcquire::Item::StatError)); |
|
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_AUTH_ERROR", |
|
MkPyNumber(pkgAcquire::Item::StatAuthError)); |
|
|
|
PyDict_SetItemString(PyTag_Type.tp_dict, "REMOVE", |
|
MkPyNumber(pkgTagSection::Tag::REMOVE)); |
|
PyDict_SetItemString(PyTag_Type.tp_dict, "REWRITE", |
|
MkPyNumber(pkgTagSection::Tag::REWRITE)); |
|
PyDict_SetItemString(PyTag_Type.tp_dict, "RENAME", |
|
MkPyNumber(pkgTagSection::Tag::RENAME)); |
|
|
|
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 |
|
PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL); |
|
#else |
|
PyObject *PyCapsule = PyCObject_FromVoidPtr(&API, NULL); |
|
#endif |
|
PyModule_AddObject(Module, "_C_API", PyCapsule); |
|
|
|
PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion); |
|
PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion); |
|
#ifdef DATE |
|
PyModule_AddStringConstant(Module,"DATE",DATE); |
|
PyModule_AddStringConstant(Module,"TIME",TIME); |
|
#else |
|
PyModule_AddStringConstant(Module,"DATE", "Jan 1 1970"); |
|
PyModule_AddStringConstant(Module,"TIME", "00:00:00"); |
|
#endif |
|
|
|
|
|
PyModule_AddIntConstant(Module,"PRI_IMPORTANT",pkgCache::State::Important); |
|
PyModule_AddIntConstant(Module,"PRI_REQUIRED",pkgCache::State::Required); |
|
PyModule_AddIntConstant(Module,"PRI_STANDARD",pkgCache::State::Standard); |
|
PyModule_AddIntConstant(Module,"PRI_OPTIONAL",pkgCache::State::Optional); |
|
PyModule_AddIntConstant(Module,"PRI_EXTRA",pkgCache::State::Extra); |
|
|
|
PyModule_AddIntConstant(Module,"CURSTATE_NOT_INSTALLED",pkgCache::State::NotInstalled); |
|
PyModule_AddIntConstant(Module,"CURSTATE_UNPACKED",pkgCache::State::UnPacked); |
|
PyModule_AddIntConstant(Module,"CURSTATE_HALF_CONFIGURED",pkgCache::State::HalfConfigured); |
|
PyModule_AddIntConstant(Module,"CURSTATE_HALF_INSTALLED",pkgCache::State::HalfInstalled); |
|
PyModule_AddIntConstant(Module,"CURSTATE_CONFIG_FILES",pkgCache::State::ConfigFiles); |
|
PyModule_AddIntConstant(Module,"CURSTATE_INSTALLED",pkgCache::State::Installed); |
|
|
|
PyModule_AddIntConstant(Module,"SELSTATE_UNKNOWN",pkgCache::State::Unknown); |
|
PyModule_AddIntConstant(Module,"SELSTATE_INSTALL",pkgCache::State::Install); |
|
PyModule_AddIntConstant(Module,"SELSTATE_HOLD",pkgCache::State::Hold); |
|
PyModule_AddIntConstant(Module,"SELSTATE_DEINSTALL",pkgCache::State::DeInstall); |
|
PyModule_AddIntConstant(Module,"SELSTATE_PURGE",pkgCache::State::Purge); |
|
|
|
PyModule_AddIntConstant(Module,"INSTSTATE_OK",pkgCache::State::Ok); |
|
PyModule_AddIntConstant(Module,"INSTSTATE_REINSTREQ",pkgCache::State::ReInstReq); |
|
PyModule_AddIntConstant(Module,"INSTSTATE_HOLD",pkgCache::State::Hold); |
|
PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_REINSTREQ",pkgCache::State::HoldReInstReq); |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
return Module; |
|
#endif |
|
} |
|
|
|
|
|
|