summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuhy <huayong.xu@samsung.com>2023-09-05 14:16:01 +0800
committerxuhy <huayong.xu@samsung.com>2023-09-07 10:04:49 +0800
commit4a9f42721c996e6c3dec5ebacc1a41f160435a64 (patch)
treebaeb436093adb65e2ee0c4ba4607e3aef34033da
parent67c629d233b0e85a332652c93de16901aa469bfc (diff)
downloadlibrpm-tizen-4a9f42721c996e6c3dec5ebacc1a41f160435a64.tar.gz
librpm-tizen-4a9f42721c996e6c3dec5ebacc1a41f160435a64.tar.bz2
librpm-tizen-4a9f42721c996e6c3dec5ebacc1a41f160435a64.zip
Add Debian packaging
Change-Id: I2ae5a781db427a02c3622cb6d098eba65c889d5d
-rw-r--r--configure.ac7
-rw-r--r--debian/changelog65
-rw-r--r--debian/compat1
-rw-r--r--debian/control50
-rw-r--r--debian/librpm-tizen.install4
-rwxr-xr-xdebian/rules29
-rw-r--r--packaging/librpm-tizen.spec16
-rw-r--r--python/Makefile.am31
-rw-r--r--python/header-py.c22
-rw-r--r--python/rpm/__init__.py.in12
-rw-r--r--python/rpm/transaction.py.in3
-rw-r--r--python/rpmbmodule.c95
-rw-r--r--python/rpmds-py.c16
-rw-r--r--python/rpmfd-py.c6
-rw-r--r--python/rpmfi-py.c46
-rw-r--r--python/rpmfiles-py.c32
-rw-r--r--python/rpmii-py.c4
-rw-r--r--python/rpmkeyring-py.c2
-rw-r--r--python/rpmmacro-py.c2
-rw-r--r--python/rpmmodule.c74
-rw-r--r--python/rpmps-py.c8
-rw-r--r--python/rpmsmodule.c98
-rw-r--r--python/rpmstrpool-py.c4
-rw-r--r--python/rpmsystem-py.h11
-rw-r--r--python/rpmtd-py.c2
-rw-r--r--python/rpmte-py.c16
-rw-r--r--python/rpmts-py.c25
-rw-r--r--python/setup.py.in39
-rw-r--r--python/spec-py.c8
29 files changed, 354 insertions, 374 deletions
diff --git a/configure.ac b/configure.ac
index a0f9d1ffd..ab533e67a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -803,7 +803,7 @@ esac],
WITH_PYTHON_SUBPACKAGE=0
AS_IF([test "$enable_python" = yes],[
- AM_PATH_PYTHON([2.6],[
+ AM_PATH_PYTHON([3.2],[
PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}], [WITH_PYTHON_SUBPACKAGE=1])
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIB)
@@ -1024,9 +1024,12 @@ AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [build with lua support])],
[],
[with_lua=yes])
+if test X"$LUA_PKGCONFIG_NAME" = X ; then
+ LUA_PKGCONFIG_NAME=lua
+fi
AS_IF([test "$with_lua" != no],[
PKG_CHECK_MODULES([LUA],
- [lua >= 5.1],
+ [${LUA_PKGCONFIG_NAME} >= 5.1],
[AC_DEFINE(WITH_LUA, 1, [Build with lua support?])],
[AC_MSG_ERROR([lua not present (--without-lua to disable)])])
AC_SUBST(LUA_CFLAGS)
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 000000000..3f0942eb2
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,65 @@
+librpm-tizen (4.14.1.1.tizen20230628-20230828) unstable; urgency=low
+
+ * Rebase on latest Tizen
+
+ -- Xu Huayong <huayong.xu@samsung.com> Tue, 05 Sep 2023 14:21:46 +0300
+
+librpm-tizen (4.11.0.1.tizen20140530-tizen20140723) unstable; urgency=low
+
+ * Rebase on latest Tizen 3.0
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Wed, 23 Jul 2014 19:50:46 +0300
+
+librpm-tizen (4.11.0.1.tizen20130618-tizen20140306) unstable; urgency=low
+
+ [ Markus Lehtonen ]
+ * Fix build against Lua 5.2
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Thu, 06 Mar 2014 12:43:43 +0200
+
+librpm-tizen (4.11.0.1.tizen20130618-tizen20131001) unstable; urgency=low
+
+ * Ignore bad expressions in %if conditionals
+ * lua: Enable Lua
+ * lua: fall through failed lua scripts
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Tue, 01 Oct 2013 12:12:43 +0300
+
+librpm-tizen (4.11.0.1.tizen20130618-tizen20130821) unstable; urgency=low
+
+ [ Zhang Qiang ]
+ * fix segmentation fault error while parsing spec
+
+ [ Markus Lehtonen ]
+ * Prevent execution of arbitrary scripts
+ * Bump the log level of "unexpanded script" msg
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Wed, 21 Aug 2013 14:31:24 +0300
+
+librpm-tizen (4.11.0.1.tizen20130618-tizen20130619) unstable; urgency=low
+
+ * Version bump to latest from Tizen 3.0
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Tue, 18 Jun 2013 14:07:13 +0300
+
+librpm-tizen (4.11.0.1.tizen20130304-tizen20130307) unstable; urgency=low
+
+ * Version bump to latest from Tizen
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Thu, 07 Mar 2013 09:27:00 +0200
+
+librpm-tizen (4.10.91.tizen20121215-tizen20130226) unstable; urgency=low
+
+ * Enable lua
+ * Add a provide tag to make gbs depend on new changes
+ * Install Tizen macros
+ * Ignore unknown internal scripts
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Wed, 27 Feb 2013 10:12:00 +0200
+
+librpm-tizen (4.10.91.tizen20121215-tizen20130226) unstable; urgency=low
+
+ * Initial packaging
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com> Tue, 17 Dec 2012 13:22:00 +0200
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 000000000..a8235fff4
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,50 @@
+Source: librpm-tizen
+Section: vcs
+Priority: optional
+Build-Depends: debhelper,
+ dh-python,
+ dpkg-dev,
+ dh-autoreconf,
+ libtool,
+ autoconf,
+ automake,
+ autotools-dev,
+ autopoint,
+ zlib1g-dev,
+ libarchive-dev,
+ libpopt-dev,
+ libxml2-dev,
+ libreadline-dev,
+ libsqlite3-dev,
+ python3-all-dev,
+ python3,
+ pkg-config,
+ libnspr4-dev,
+ libnss3-dev,
+ liblzma-dev,
+ libmagic-dev,
+ libelf-dev,
+ libdw-dev,
+ libdb-dev,
+ liblua5.1-dev
+Maintainer: Markus Lehtonen <markus.lehtonen@linux.intel.com>
+Standards-Version: 3.9.3
+Homepage: http://rpm.org/
+X-Python-Version: >= 3
+
+Package: librpm-tizen
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}
+Description: The RPM libraries for git-buildpackage
+ RPM Package Manager is the main tool for managing the software packages
+ of Tizen.
+ .
+ RPM can be used to install and remove software packages. With rpm, it
+ is easy to update packages. RPM keeps track of all these manipulations
+ in a central database.»·This way it is possible to get an overview of
+ all installed packages. RPM also supports database queries.
+ .
+ This is a special stripped-down version of RPM, only intended to be used by the
+ git-buildpackage tool. Doesn't interfere with the RPM libraries of the host system.
+ This package only contains rpmlib and rpm-python.
+
diff --git a/debian/librpm-tizen.install b/debian/librpm-tizen.install
new file mode 100644
index 000000000..84594ba09
--- /dev/null
+++ b/debian/librpm-tizen.install
@@ -0,0 +1,4 @@
+usr/lib*/*/*.so.*
+usr/lib*/*/rpm/*
+usr/lib/python*/*packages/*/*.so
+usr/lib/python*/*packages/*/*.py*
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..ccf3f5465
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,29 @@
+#!/usr/bin/make -f
+
+python_mod_name := rpm_tizen
+
+CPPFLAGS += $(shell pkg-config --cflags nss)
+
+%:
+ dh $@ --with python3,autoreconf,autotools_dev
+
+override_dh_auto_configure:
+ dh_auto_configure -- --disable-dependency-tracking \
+ --libdir=/usr/lib/librpm-tizen \
+ --with-lua \
+ --without-acl \
+ --without-cap \
+ --enable-shared \
+ --enable-python \
+ --with-external-db \
+ --build=${DEB_BUILD_GNU_CPU}-tizen-linux \
+ PYTHON_MODULENAME=$(python_mod_name) \
+ LUA_PKGCONFIG_NAME=lua5.1 \
+ CPPFLAGS="$(CPPFLAGS)"
+
+override_dh_auto_install:
+ dh_auto_install --destdir=debian/tmp
+ # Install extra sources
+ install -m644 packaging/rpm-tizen_macros debian/tmp/usr/lib/librpm-tizen/rpm/tizen_macros
+ install -d debian/tmp/usr/lib/librpm-tizen/rpm/tizen
+ ln -s ../tizen_macros debian/tmp/usr/lib/librpm-tizen/rpm/tizen/macros
diff --git a/packaging/librpm-tizen.spec b/packaging/librpm-tizen.spec
index a56501764..4eff279d8 100644
--- a/packaging/librpm-tizen.spec
+++ b/packaging/librpm-tizen.spec
@@ -44,7 +44,7 @@ BuildRequires: pkg-config
%if 0%{?centos_ver} || 0%{?centos_version}
BuildRequires: python-devel
%else
-BuildRequires: pkgconfig(python) >= 2.6
+BuildRequires: pkgconfig(python3)
%endif
# Disable security
%if 0
@@ -141,9 +141,9 @@ make install DESTDIR="`pwd`/tmp_install"
# And only copy the files that we want
install -d %{buildroot}%{_libdir}/%{name}
-install -d %{buildroot}%{python_sitearch}
+install -d %{buildroot}%{python3_sitearch}
cp -ax tmp_install/%{_libdir}/%{name} %{buildroot}%{_libdir}/
-cp -ax tmp_install/%{python_sitearch}/%{python_mod_name} %{buildroot}%{python_sitearch}/
+cp -ax tmp_install/%{python3_sitearch}/%{python_mod_name} %{buildroot}%{python3_sitearch}/
# Install extra sources
install -m644 %{SOURCE4} %{buildroot}%{_libdir}/%{name}/rpm/tizen_macros
@@ -158,16 +158,16 @@ rm -rf "%{buildroot}%{_libdir}/%{name}/rpm-plugins"
# Compile python modules (Fedora does this automatically) and find duplicates
%if 0%{?suse_version}
-%py_compile %{buildroot}/%{python_sitearch}/%{python_mod_name}/
-%py_compile -O %{buildroot}/%{python_sitearch}/%{python_mod_name}/
+%py3_compile %{buildroot}/%{python3_sitearch}/%{python_mod_name}/
+%py3_compile -O %{buildroot}/%{python3_sitearch}/%{python_mod_name}/
-%fdupes %{buildroot}/%{python_sitearch}/
+%fdupes %{buildroot}/%{python3_sitearch}/
%endif
%files
%defattr(-,root,root,-)
%dir %{_libdir}/%{name}
-%dir %{python_sitearch}/%{python_mod_name}/
+%dir %{python3_sitearch}/%{python_mod_name}/
%{_libdir}/%{name}/*.so.*
%{_libdir}/%{name}/rpm
-%{python_sitearch}/%{python_mod_name}/*
+%{python3_sitearch}/%{python_mod_name}/*
diff --git a/python/Makefile.am b/python/Makefile.am
index 67502dd31..bf9abd2d3 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -9,17 +9,19 @@ AM_CPPFLAGS = -I$(top_builddir)/include/
AM_CPPFLAGS += -I$(top_srcdir)/python
AM_CPPFLAGS += @PYTHON_CFLAGS@ -DPYTHON_MODULENAME=\"@PYTHON_MODULENAME@\"
-pkgpyexec_LTLIBRARIES = _rpmmodule.la _rpmbmodule.la _rpmsmodule.la
+pkgpyexec_LTLIBRARIES = _rpm.la
pkgpyexec_DATA = rpm/__init__.py rpm/transaction.py
pkgpyexecdir = @pyexecdir@/@PYTHON_MODULENAME@
-_rpmmodule_la_LDFLAGS = -module -avoid-version -shared
-_rpmmodule_la_LIBADD = \
+_rpm_la_LDFLAGS = -module -avoid-version -shared
+_rpm_la_LIBADD = \
$(top_builddir)/lib/librpm.la \
$(top_builddir)/rpmio/librpmio.la \
+ $(top_builddir)/build/librpmbuild.la \
+ $(top_builddir)/sign/librpmsign.la \
@PYTHON_LIBS@
-_rpmmodule_la_SOURCES = rpmmodule.c rpmsystem-py.h \
+_rpm_la_SOURCES = rpmmodule.c rpmsystem-py.h \
header-py.c header-py.h \
rpmarchive-py.c rpmarchive-py.h \
rpmds-py.c rpmds-py.h \
@@ -34,24 +36,5 @@ _rpmmodule_la_SOURCES = rpmmodule.c rpmsystem-py.h \
rpmstrpool-py.c rpmstrpool-py.h \
rpmtd-py.c rpmtd-py.h \
rpmte-py.c rpmte-py.h \
- rpmts-py.c rpmts-py.h
-
-_rpmbmodule_la_LDFLAGS = -module -avoid-version -shared
-_rpmbmodule_la_LIBADD = \
- $(top_builddir)/build/librpmbuild.la \
- $(top_builddir)/lib/librpm.la \
- $(top_builddir)/rpmio/librpmio.la \
- @PYTHON_LIBS@
-
-_rpmbmodule_la_SOURCES = rpmbmodule.c rpmsystem-py.h \
+ rpmts-py.c rpmts-py.h \
spec-py.c spec-py.h
-
-_rpmsmodule_la_LDFLAGS = -module -avoid-version -shared
-_rpmsmodule_la_LIBADD = \
- $(top_builddir)/sign/librpmsign.la \
- $(top_builddir)/lib/librpm.la \
- $(top_builddir)/rpmio/librpmio.la \
- @PYTHON_LIBS@
-
-_rpmsmodule_la_SOURCES = rpmsmodule.c rpmsystem-py.h
-
diff --git a/python/header-py.c b/python/header-py.c
index 6c2ff54f7..04aa96931 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -143,7 +143,7 @@ static PyObject * hdrKeyList(hdrObject * s)
hi = headerInitIterator(s->h);
while ((tag = headerNextTag(hi)) != RPMTAG_NOT_FOUND) {
- PyObject *to = PyInt_FromLong(tag);
+ PyObject *to = PyLong_FromLong(tag);
if (!to) {
headerFreeIterator(hi);
Py_DECREF(keys);
@@ -231,7 +231,7 @@ static PyObject * hdrFormat(hdrObject * s, PyObject * args, PyObject * kwds)
return NULL;
}
- result = Py_BuildValue("s", r);
+ result = utf8FromString(r);
free(r);
return result;
@@ -415,7 +415,7 @@ static PyObject * hdr_iternext(hdrObject *s)
if (s->hi == NULL) s->hi = headerInitIterator(s->h);
if ((tag = headerNextTag(s->hi)) != RPMTAG_NOT_FOUND) {
- res = PyInt_FromLong(tag);
+ res = PyLong_FromLong(tag);
} else {
s->hi = headerFreeIterator(s->hi);
}
@@ -442,9 +442,9 @@ int tagNumFromPyObject (PyObject *item, rpmTagVal *tagp)
rpmTagVal tag = RPMTAG_NOT_FOUND;
PyObject *str = NULL;
- if (PyInt_Check(item)) {
+ if (PyLong_Check(item)) {
/* XXX we should probably validate tag numbers too */
- tag = PyInt_AsLong(item);
+ tag = PyLong_AsLong(item);
} else if (utf8FromPyObject(item, &str)) {
tag = rpmTagGetValue(PyBytes_AsString(str));
Py_DECREF(str);
@@ -483,7 +483,7 @@ static int validItem(rpmTagClass tclass, PyObject *item)
switch (tclass) {
case RPM_NUMERIC_CLASS:
- rc = (PyLong_Check(item) || PyInt_Check(item));
+ rc = (PyLong_Check(item) || PyLong_Check(item));
break;
case RPM_STRING_CLASS:
rc = (PyBytes_Check(item) || PyUnicode_Check(item));
@@ -532,7 +532,7 @@ static int hdrAppendItem(Header h, rpmTagVal tag, rpmTagType type, PyObject *ite
case RPM_STRING_TYPE:
case RPM_STRING_ARRAY_TYPE: {
PyObject *str = NULL;
- if (utf8FromPyObject(item, &str))
+ if (utf8FromPyObject(item, &str))
rc = headerPutString(h, tag, PyBytes_AsString(str));
Py_XDECREF(str);
} break;
@@ -542,20 +542,20 @@ static int hdrAppendItem(Header h, rpmTagVal tag, rpmTagType type, PyObject *ite
rc = headerPutBin(h, tag, val, len);
} break;
case RPM_INT64_TYPE: {
- uint64_t val = PyInt_AsUnsignedLongLongMask(item);
+ uint64_t val = PyLong_AsUnsignedLongLongMask(item);
rc = headerPutUint64(h, tag, &val, 1);
} break;
case RPM_INT32_TYPE: {
- uint32_t val = PyInt_AsUnsignedLongMask(item);
+ uint32_t val = PyLong_AsUnsignedLongMask(item);
rc = headerPutUint32(h, tag, &val, 1);
} break;
case RPM_INT16_TYPE: {
- uint16_t val = PyInt_AsUnsignedLongMask(item);
+ uint16_t val = PyLong_AsUnsignedLongMask(item);
rc = headerPutUint16(h, tag, &val, 1);
} break;
case RPM_INT8_TYPE:
case RPM_CHAR_TYPE: {
- uint8_t val = PyInt_AsUnsignedLongMask(item);
+ uint8_t val = PyLong_AsUnsignedLongMask(item);
rc = headerPutUint8(h, tag, &val, 1);
} break;
default:
diff --git a/python/rpm/__init__.py.in b/python/rpm/__init__.py.in
index e2a7a87af..4d02d2d02 100644
--- a/python/rpm/__init__.py.in
+++ b/python/rpm/__init__.py.in
@@ -46,18 +46,6 @@ _RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
__version__ = _rpm.__version__
__version_info__ = tuple(__version__.split('.'))
-# try to import build bits but dont require it
-try:
- from @PYTHON_MODULENAME@._rpmb import *
-except ImportError:
- pass
-
-# try to import signing bits but dont require it
-try:
- from @PYTHON_MODULENAME@._rpms import *
-except ImportError:
- pass
-
# backwards compatibility + give the same class both ways
ts = TransactionSet
diff --git a/python/rpm/transaction.py.in b/python/rpm/transaction.py.in
index 6a4e7c8b7..764a5cb68 100644
--- a/python/rpm/transaction.py.in
+++ b/python/rpm/transaction.py.in
@@ -38,8 +38,7 @@ class TransactionSet(TransactionSetCore):
return self._wrapSetGet('_probFilter', ignoreSet)
def parseSpec(self, specfile):
- import rpm._rpmb
- return rpm._rpmb.spec(specfile)
+ return rpm.spec(specfile)
def getKeys(self):
keys = []
diff --git a/python/rpmbmodule.c b/python/rpmbmodule.c
deleted file mode 100644
index ad30570e4..000000000
--- a/python/rpmbmodule.c
+++ /dev/null
@@ -1,95 +0,0 @@
-#include "rpmsystem-py.h"
-
-#include "spec-py.h"
-
-static char rpmb__doc__[] =
-"";
-
-/*
- Do any common preliminary work before python 2 vs python 3 module creation:
-*/
-static int prepareInitModule(void)
-{
- if (PyType_Ready(&spec_Type) < 0) return 0;
- if (PyType_Ready(&specPkg_Type) < 0) return 0;
-
- return 1;
-}
-
-static int initModule(PyObject *m)
-{
- Py_INCREF(&spec_Type);
- PyModule_AddObject(m, "spec", (PyObject *) &spec_Type);
- Py_INCREF(&specPkg_Type);
- PyModule_AddObject(m, "specPkg", (PyObject *) &specPkg_Type);
-
-#define REGISTER_ENUM(val) PyModule_AddIntConstant(m, #val, val)
- REGISTER_ENUM(RPMBUILD_ISSOURCE);
- REGISTER_ENUM(RPMBUILD_ISPATCH);
- REGISTER_ENUM(RPMBUILD_ISICON);
- REGISTER_ENUM(RPMBUILD_ISNO);
-
- REGISTER_ENUM(RPMBUILD_NONE);
- REGISTER_ENUM(RPMBUILD_PREP);
- REGISTER_ENUM(RPMBUILD_BUILD);
- REGISTER_ENUM(RPMBUILD_INSTALL);
- REGISTER_ENUM(RPMBUILD_CHECK);
- REGISTER_ENUM(RPMBUILD_CLEAN);
- REGISTER_ENUM(RPMBUILD_FILECHECK);
- REGISTER_ENUM(RPMBUILD_PACKAGESOURCE);
- REGISTER_ENUM(RPMBUILD_PACKAGEBINARY);
- REGISTER_ENUM(RPMBUILD_RMSOURCE);
- REGISTER_ENUM(RPMBUILD_RMBUILD);
- REGISTER_ENUM(RPMBUILD_RMSPEC);
-
- REGISTER_ENUM(RPMBUILD_PKG_NONE);
- REGISTER_ENUM(RPMBUILD_PKG_NODIRTOKENS);
-
- REGISTER_ENUM(RPMSPEC_NONE);
- REGISTER_ENUM(RPMSPEC_ANYARCH);
- REGISTER_ENUM(RPMSPEC_FORCE);
- REGISTER_ENUM(RPMSPEC_NOLANG);
-
- return 1;
-}
-
-#if PY_MAJOR_VERSION >= 3
-static struct PyModuleDef moduledef = {
- PyModuleDef_HEAD_INIT,
- "_rpmb", /* m_name */
- rpmb__doc__, /* m_doc */
- 0, /* m_size */
- NULL, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-
-PyObject * PyInit__rpmb(void); /* XXX eliminate gcc warning */
-PyObject * PyInit__rpmb(void)
-{
- PyObject *m;
-
- if (!prepareInitModule())
- return NULL;
- m = PyModule_Create(&moduledef);
- if (m == NULL || !initModule(m)) {
- Py_XDECREF(m);
- m = NULL;
- }
- return m;
-}
-#else
-void init_rpmb(void); /* XXX eliminate gcc warning */
-void init_rpmb(void)
-{
- PyObject *m;
-
- if (!prepareInitModule())
- return;
-
- m = Py_InitModule3("_rpmb", NULL, rpmb__doc__);
- if (m) initModule(m);
-}
-#endif
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index 7874a2524..86d993f5b 100644
--- a/python/rpmds-py.c
+++ b/python/rpmds-py.c
@@ -31,19 +31,19 @@ rpmds_Ix(rpmdsObject * s)
static PyObject *
rpmds_DNEVR(rpmdsObject * s)
{
- return Py_BuildValue("s", rpmdsDNEVR(s->ds));
+ return utf8FromString(rpmdsDNEVR(s->ds));
}
static PyObject *
rpmds_N(rpmdsObject * s)
{
- return Py_BuildValue("s", rpmdsN(s->ds));
+ return utf8FromString(rpmdsN(s->ds));
}
static PyObject *
rpmds_EVR(rpmdsObject * s)
{
- return Py_BuildValue("s", rpmdsEVR(s->ds));
+ return utf8FromString(rpmdsEVR(s->ds));
}
static PyObject *
@@ -230,14 +230,14 @@ rpmds_subscript(rpmdsObject * s, PyObject * key)
{
int ix;
- if (!PyInt_Check(key)) {
+ if (!PyLong_Check(key)) {
PyErr_SetString(PyExc_TypeError, "integer expected");
return NULL;
}
- ix = (int) PyInt_AsLong(key);
+ ix = (int) PyLong_AsLong(key);
rpmdsSetIx(s->ds, ix);
- return Py_BuildValue("s", rpmdsDNEVR(s->ds));
+ return utf8FromString(rpmdsDNEVR(s->ds));
}
static PyMappingMethods rpmds_as_mapping = {
@@ -258,9 +258,9 @@ static int depflags(PyObject *o, rpmsenseFlags *senseFlags)
PyObject *str = NULL;
rpmsenseFlags flags = RPMSENSE_ANY;
- if (PyInt_Check(o)) {
+ if (PyLong_Check(o)) {
ok = 1;
- flags = PyInt_AsLong(o);
+ flags = PyLong_AsLong(o);
} else if (utf8FromPyObject(o, &str)) {
ok = 1;
for (const char *s = PyBytes_AsString(str); *s; s++) {
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c
index 8b69ecb82..4f9ef92ab 100644
--- a/python/rpmfd-py.c
+++ b/python/rpmfd-py.c
@@ -327,17 +327,17 @@ static PyObject *rpmfd_get_closed(rpmfdObject *s)
static PyObject *rpmfd_get_name(rpmfdObject *s)
{
/* XXX: rpm returns non-paths with [mumble], python files use <mumble> */
- return Py_BuildValue("s", Fdescr(s->fd));
+ return utf8FromString(Fdescr(s->fd));
}
static PyObject *rpmfd_get_mode(rpmfdObject *s)
{
- return Py_BuildValue("s", s->mode);
+ return utf8FromString(s->mode);
}
static PyObject *rpmfd_get_flags(rpmfdObject *s)
{
- return Py_BuildValue("s", s->flags);
+ return utf8FromString(s->flags);
}
static PyGetSetDef rpmfd_getseters[] = {
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c
index 742919f5c..61417c5f5 100644
--- a/python/rpmfi-py.c
+++ b/python/rpmfi-py.c
@@ -41,19 +41,19 @@ rpmfi_DX(rpmfiObject * s, PyObject * unused)
static PyObject *
rpmfi_BN(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiBN(s->fi));
+ return utf8FromString(rpmfiBN(s->fi));
}
static PyObject *
rpmfi_DN(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiDN(s->fi));
+ return utf8FromString(rpmfiDN(s->fi));
}
static PyObject *
rpmfi_FN(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiFN(s->fi));
+ return utf8FromString(rpmfiFN(s->fi));
}
static PyObject *
@@ -98,7 +98,7 @@ rpmfi_Digest(rpmfiObject * s, PyObject * unused)
{
char *digest = rpmfiFDigestHex(s->fi, NULL);
if (digest) {
- PyObject *dig = Py_BuildValue("s", digest);
+ PyObject *dig = utf8FromString(digest);
free(digest);
return dig;
} else {
@@ -109,7 +109,7 @@ rpmfi_Digest(rpmfiObject * s, PyObject * unused)
static PyObject *
rpmfi_FLink(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiFLink(s->fi));
+ return utf8FromString(rpmfiFLink(s->fi));
}
static PyObject *
@@ -133,13 +133,13 @@ rpmfi_FMtime(rpmfiObject * s, PyObject * unused)
static PyObject *
rpmfi_FUser(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiFUser(s->fi));
+ return utf8FromString(rpmfiFUser(s->fi));
}
static PyObject *
rpmfi_FGroup(rpmfiObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmfiFGroup(s->fi));
+ return utf8FromString(rpmfiFGroup(s->fi));
}
static PyObject *
@@ -155,7 +155,7 @@ rpmfi_FClass(rpmfiObject * s, PyObject * unused)
if ((FClass = rpmfiFClass(s->fi)) == NULL)
FClass = "";
- return Py_BuildValue("s", FClass);
+ return utf8FromString(FClass);
}
static PyObject *
@@ -172,7 +172,7 @@ rpmfi_FLinks(rpmfiObject * s, PyObject * unused)
result = PyTuple_New(nlinks);
for (uint32_t i=0; i<nlinks; i++) {
- PyTuple_SET_ITEM(result, i, PyInt_FromLong(files[i]));
+ PyTuple_SET_ITEM(result, i, PyLong_FromLong(files[i]));
}
return result;
}
@@ -208,26 +208,26 @@ rpmfi_iternext(rpmfiObject * s)
Py_INCREF(Py_None);
PyTuple_SET_ITEM(result, 0, Py_None);
} else
- PyTuple_SET_ITEM(result, 0, Py_BuildValue("s", FN));
+ PyTuple_SET_ITEM(result, 0, utf8FromString(FN));
PyTuple_SET_ITEM(result, 1, PyLong_FromLongLong(FSize));
- PyTuple_SET_ITEM(result, 2, PyInt_FromLong(FMode));
- PyTuple_SET_ITEM(result, 3, PyInt_FromLong(FMtime));
- PyTuple_SET_ITEM(result, 4, PyInt_FromLong(FFlags));
- PyTuple_SET_ITEM(result, 5, PyInt_FromLong(FRdev));
- PyTuple_SET_ITEM(result, 6, PyInt_FromLong(FInode));
- PyTuple_SET_ITEM(result, 7, PyInt_FromLong(FNlink));
- PyTuple_SET_ITEM(result, 8, PyInt_FromLong(FState));
- PyTuple_SET_ITEM(result, 9, PyInt_FromLong(VFlags));
+ PyTuple_SET_ITEM(result, 2, PyLong_FromLong(FMode));
+ PyTuple_SET_ITEM(result, 3, PyLong_FromLong(FMtime));
+ PyTuple_SET_ITEM(result, 4, PyLong_FromLong(FFlags));
+ PyTuple_SET_ITEM(result, 5, PyLong_FromLong(FRdev));
+ PyTuple_SET_ITEM(result, 6, PyLong_FromLong(FInode));
+ PyTuple_SET_ITEM(result, 7, PyLong_FromLong(FNlink));
+ PyTuple_SET_ITEM(result, 8, PyLong_FromLong(FState));
+ PyTuple_SET_ITEM(result, 9, PyLong_FromLong(VFlags));
if (FUser == NULL) {
Py_INCREF(Py_None);
PyTuple_SET_ITEM(result, 10, Py_None);
} else
- PyTuple_SET_ITEM(result, 10, Py_BuildValue("s", FUser));
+ PyTuple_SET_ITEM(result, 10, utf8FromString(FUser));
if (FGroup == NULL) {
Py_INCREF(Py_None);
PyTuple_SET_ITEM(result, 11, Py_None);
} else
- PyTuple_SET_ITEM(result, 11, Py_BuildValue("s", FGroup));
+ PyTuple_SET_ITEM(result, 11, utf8FromString(FGroup));
PyTuple_SET_ITEM(result, 12, rpmfi_Digest(s, NULL));
} else
@@ -306,14 +306,14 @@ rpmfi_subscript(rpmfiObject * s, PyObject * key)
{
int ix;
- if (!PyInt_Check(key)) {
+ if (!PyLong_Check(key)) {
PyErr_SetString(PyExc_TypeError, "integer expected");
return NULL;
}
- ix = (int) PyInt_AsLong(key);
+ ix = (int) PyLong_AsLong(key);
rpmfiSetFX(s->fi, ix);
- return Py_BuildValue("s", rpmfiFN(s->fi));
+ return utf8FromString(rpmfiFN(s->fi));
}
static PyMappingMethods rpmfi_as_mapping = {
diff --git a/python/rpmfiles-py.c b/python/rpmfiles-py.c
index d69d1f2ee..5ca3421c4 100644
--- a/python/rpmfiles-py.c
+++ b/python/rpmfiles-py.c
@@ -41,37 +41,37 @@ static PyObject *rpmfile_dx(rpmfileObject *s)
static PyObject *rpmfile_name(rpmfileObject *s)
{
char * fn = rpmfilesFN(s->files, s->ix);
- PyObject *o = Py_BuildValue("s", fn);
+ PyObject *o = utf8FromString(fn);
free(fn);
return o;
}
static PyObject *rpmfile_basename(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesBN(s->files, s->ix));
+ return utf8FromString(rpmfilesBN(s->files, s->ix));
}
static PyObject *rpmfile_dirname(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesDN(s->files, rpmfilesDI(s->files, s->ix)));
+ return utf8FromString(rpmfilesDN(s->files, rpmfilesDI(s->files, s->ix)));
}
static PyObject *rpmfile_orig_name(rpmfileObject *s)
{
char * fn = rpmfilesOFN(s->files, s->ix);
- PyObject *o = Py_BuildValue("s", fn);
+ PyObject *o = utf8FromString(fn);
free(fn);
return o;
}
static PyObject *rpmfile_orig_basename(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesOBN(s->files, s->ix));
+ return utf8FromString(rpmfilesOBN(s->files, s->ix));
}
static PyObject *rpmfile_orig_dirname(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesODN(s->files, rpmfilesODI(s->files, s->ix)));
+ return utf8FromString(rpmfilesODN(s->files, rpmfilesODI(s->files, s->ix)));
}
static PyObject *rpmfile_mode(rpmfileObject *s)
{
@@ -105,17 +105,17 @@ static PyObject *rpmfile_nlink(rpmfileObject *s)
static PyObject *rpmfile_linkto(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFLink(s->files, s->ix));
+ return utf8FromString(rpmfilesFLink(s->files, s->ix));
}
static PyObject *rpmfile_user(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFUser(s->files, s->ix));
+ return utf8FromString(rpmfilesFUser(s->files, s->ix));
}
static PyObject *rpmfile_group(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFGroup(s->files, s->ix));
+ return utf8FromString(rpmfilesFGroup(s->files, s->ix));
}
static PyObject *rpmfile_fflags(rpmfileObject *s)
@@ -145,7 +145,7 @@ static PyObject *rpmfile_digest(rpmfileObject *s)
NULL, &diglen);
if (digest) {
char * hex = pgpHexStr(digest, diglen);
- PyObject *o = Py_BuildValue("s", hex);
+ PyObject *o = utf8FromString(hex);
free(hex);
return o;
}
@@ -154,17 +154,17 @@ static PyObject *rpmfile_digest(rpmfileObject *s)
static PyObject *rpmfile_class(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFClass(s->files, s->ix));
+ return utf8FromString(rpmfilesFClass(s->files, s->ix));
}
static PyObject *rpmfile_caps(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFCaps(s->files, s->ix));
+ return utf8FromString(rpmfilesFCaps(s->files, s->ix));
}
static PyObject *rpmfile_langs(rpmfileObject *s)
{
- return Py_BuildValue("s", rpmfilesFLangs(s->files, s->ix));
+ return utf8FromString(rpmfilesFLangs(s->files, s->ix));
}
static PyObject *rpmfile_links(rpmfileObject *s)
@@ -468,8 +468,8 @@ static PyObject *rpmfiles_subscript(rpmfilesObject *s, PyObject *item)
PyObject *str = NULL;
/* treat numbers as sequence accesses */
- if (PyInt_Check(item)) {
- return rpmfiles_getitem(s, PyInt_AsSsize_t(item));
+ if (PyLong_Check(item)) {
+ return rpmfiles_getitem(s, PyLong_AsSsize_t(item));
} else if (PyLong_Check(item)) {
return rpmfiles_getitem(s, PyLong_AsSsize_t(item));
}
@@ -478,7 +478,7 @@ static PyObject *rpmfiles_subscript(rpmfilesObject *s, PyObject *item)
if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength, i, cur;
PyObject * result;
-
+
if (PySlice_GetIndicesEx(
#if PY_MAJOR_VERSION < 3
(PySliceObject*)
diff --git a/python/rpmii-py.c b/python/rpmii-py.c
index f096cbd22..ceb5c8bbd 100644
--- a/python/rpmii-py.c
+++ b/python/rpmii-py.c
@@ -68,9 +68,9 @@ rpmii_instances(rpmiiObject * s)
for (int i = 0; i < entries; i++) {
tuple = PyTuple_New(2);
PyTuple_SET_ITEM(tuple, 0,
- PyInt_FromLong(rpmdbIndexIteratorPkgOffset(s->ii, i)));
+ PyLong_FromLong(rpmdbIndexIteratorPkgOffset(s->ii, i)));
PyTuple_SET_ITEM(tuple, 1,
- PyInt_FromLong(rpmdbIndexIteratorTagNum(s->ii, i)));
+ PyLong_FromLong(rpmdbIndexIteratorTagNum(s->ii, i)));
PyList_SET_ITEM(list, i, tuple);
}
return list;
diff --git a/python/rpmkeyring-py.c b/python/rpmkeyring-py.c
index 7df847db7..b116f462d 100644
--- a/python/rpmkeyring-py.c
+++ b/python/rpmkeyring-py.c
@@ -38,7 +38,7 @@ static PyObject *rpmPubkey_new(PyTypeObject *subtype,
static PyObject * rpmPubkey_Base64(rpmPubkeyObject *s)
{
char *b64 = rpmPubkeyBase64(s->pubkey);
- PyObject *res = Py_BuildValue("s", b64);
+ PyObject *res = utf8FromString(b64);
free(b64);
return res;
}
diff --git a/python/rpmmacro-py.c b/python/rpmmacro-py.c
index 3cb1a51f5..d8a365547 100644
--- a/python/rpmmacro-py.c
+++ b/python/rpmmacro-py.c
@@ -52,7 +52,7 @@ rpmmacro_ExpandMacro(PyObject * self, PyObject * args, PyObject * kwds)
if (rpmExpandMacros(NULL, macro, &str, 0) < 0)
PyErr_SetString(pyrpmError, "error expanding macro");
else
- res = Py_BuildValue("s", str);
+ res = utf8FromString(str);
free(str);
}
return res;
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index d1390e889..ba58de54c 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -6,6 +6,7 @@
#include <rpm/rpmsq.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmmacro.h>
+#include <rpm/rpmsign.h>
#include "header-py.h"
#include "rpmarchive-py.h"
@@ -22,6 +23,7 @@
#include "rpmtd-py.h"
#include "rpmte-py.h"
#include "rpmts-py.h"
+#include "spec-py.h"
/** \ingroup python
* \name Module: rpm
@@ -156,6 +158,38 @@ static PyObject * setInterruptSafety(PyObject * self, PyObject * args, PyObject
Py_RETURN_NONE;
}
+static int parseSignArgs(PyObject * args, PyObject *kwds,
+ const char **path, struct rpmSignArgs *sargs)
+{
+ char * kwlist[] = { "path", "keyid", "hashalgo", NULL };
+
+ memset(sargs, 0, sizeof(*sargs));
+ return PyArg_ParseTupleAndKeywords(args, kwds, "s|si", kwlist,
+ path, &sargs->keyid, &sargs->hashalgo);
+}
+
+static PyObject * addSign(PyObject * self, PyObject * args, PyObject *kwds)
+{
+ const char *path = NULL;
+ struct rpmSignArgs sargs;
+
+ if (!parseSignArgs(args, kwds, &path, &sargs))
+ return NULL;
+
+ return PyBool_FromLong(rpmPkgSign(path, &sargs) == 0);
+}
+
+static PyObject * delSign(PyObject * self, PyObject * args, PyObject *kwds)
+{
+ const char *path = NULL;
+ struct rpmSignArgs sargs;
+
+ if (!parseSignArgs(args, kwds, &path, &sargs))
+ return NULL;
+
+ return PyBool_FromLong(rpmPkgDelSign(path, &sargs) == 0);
+}
+
static PyMethodDef rpmModuleMethods[] = {
{ "addMacro", (PyCFunction) rpmmacro_AddMacro, METH_VARARGS|METH_KEYWORDS,
"rpmPushMacro(macro, value)\n"
@@ -215,6 +249,8 @@ static PyMethodDef rpmModuleMethods[] = {
"once only at process startup because currently signal handlers will\n"
"not be retroactively applied if a database is open."
},
+ { "addSign", (PyCFunction) addSign, METH_VARARGS|METH_KEYWORDS, NULL },
+ { "delSign", (PyCFunction) delSign, METH_VARARGS|METH_KEYWORDS, NULL },
{ NULL }
} ;
@@ -236,8 +272,8 @@ static void addRpmTags(PyObject *module)
tagval = rpmTagGetValue(shortname);
PyModule_AddIntConstant(module, tagname, tagval);
- pyval = PyInt_FromLong(tagval);
- pyname = Py_BuildValue("s", shortname);
+ pyval = PyLong_FromLong(tagval);
+ pyname = utf8FromString(shortname);
PyDict_SetItem(dict, pyval, pyname);
Py_DECREF(pyval);
Py_DECREF(pyname);
@@ -269,6 +305,8 @@ static int prepareInitModule(void)
#endif
if (PyType_Ready(&rpmte_Type) < 0) return 0;
if (PyType_Ready(&rpmts_Type) < 0) return 0;
+ if (PyType_Ready(&spec_Type) < 0) return 0;
+ if (PyType_Ready(&specPkg_Type) < 0) return 0;
return 1;
}
@@ -388,6 +426,12 @@ static int initModule(PyObject *m)
Py_INCREF(&rpmts_Type);
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
+ Py_INCREF(&spec_Type);
+ PyModule_AddObject(m, "spec", (PyObject *) &spec_Type);
+
+ Py_INCREF(&specPkg_Type);
+ PyModule_AddObject(m, "specPkg", (PyObject *) &specPkg_Type);
+
addRpmTags(m);
PyModule_AddStringConstant(m, "__version__", RPMVERSION);
@@ -596,6 +640,32 @@ static int initModule(PyObject *m)
REGISTER_ENUM(RPMVERIFY_READFAIL);
REGISTER_ENUM(RPMVERIFY_LSTATFAIL);
+ REGISTER_ENUM(RPMBUILD_ISSOURCE);
+ REGISTER_ENUM(RPMBUILD_ISPATCH);
+ REGISTER_ENUM(RPMBUILD_ISICON);
+ REGISTER_ENUM(RPMBUILD_ISNO);
+
+ REGISTER_ENUM(RPMBUILD_NONE);
+ REGISTER_ENUM(RPMBUILD_PREP);
+ REGISTER_ENUM(RPMBUILD_BUILD);
+ REGISTER_ENUM(RPMBUILD_INSTALL);
+ REGISTER_ENUM(RPMBUILD_CHECK);
+ REGISTER_ENUM(RPMBUILD_CLEAN);
+ REGISTER_ENUM(RPMBUILD_FILECHECK);
+ REGISTER_ENUM(RPMBUILD_PACKAGESOURCE);
+ REGISTER_ENUM(RPMBUILD_PACKAGEBINARY);
+ REGISTER_ENUM(RPMBUILD_RMSOURCE);
+ REGISTER_ENUM(RPMBUILD_RMBUILD);
+ REGISTER_ENUM(RPMBUILD_RMSPEC);
+
+ REGISTER_ENUM(RPMBUILD_PKG_NONE);
+ REGISTER_ENUM(RPMBUILD_PKG_NODIRTOKENS);
+
+ REGISTER_ENUM(RPMSPEC_NONE);
+ REGISTER_ENUM(RPMSPEC_ANYARCH);
+ REGISTER_ENUM(RPMSPEC_FORCE);
+ REGISTER_ENUM(RPMSPEC_NOLANG);
+
return 1;
}
diff --git a/python/rpmps-py.c b/python/rpmps-py.c
index 567a632e0..b18e89e55 100644
--- a/python/rpmps-py.c
+++ b/python/rpmps-py.c
@@ -18,12 +18,12 @@ static PyObject *rpmprob_get_type(rpmProblemObject *s, void *closure)
static PyObject *rpmprob_get_pkgnevr(rpmProblemObject *s, void *closure)
{
- return Py_BuildValue("s", rpmProblemGetPkgNEVR(s->prob));
+ return utf8FromString(rpmProblemGetPkgNEVR(s->prob));
}
static PyObject *rpmprob_get_altnevr(rpmProblemObject *s, void *closure)
{
- return Py_BuildValue("s", rpmProblemGetAltNEVR(s->prob));
+ return utf8FromString(rpmProblemGetAltNEVR(s->prob));
}
static PyObject *rpmprob_get_key(rpmProblemObject *s, void *closure)
@@ -38,7 +38,7 @@ static PyObject *rpmprob_get_key(rpmProblemObject *s, void *closure)
static PyObject *rpmprob_get_str(rpmProblemObject *s, void *closure)
{
- return Py_BuildValue("s", rpmProblemGetStr(s->prob));
+ return utf8FromString(rpmProblemGetStr(s->prob));
}
static PyObject *rpmprob_get_num(rpmProblemObject *s, void *closure)
@@ -59,7 +59,7 @@ static PyGetSetDef rpmprob_getseters[] = {
static PyObject *rpmprob_str(rpmProblemObject *s)
{
char *str = rpmProblemString(s->prob);
- PyObject *res = Py_BuildValue("s", str);
+ PyObject *res = utf8FromString(str);
free(str);
return res;
}
diff --git a/python/rpmsmodule.c b/python/rpmsmodule.c
deleted file mode 100644
index 72465221d..000000000
--- a/python/rpmsmodule.c
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "rpmsystem-py.h"
-
-#include <rpm/rpmsign.h>
-
-static char rpms__doc__[] =
-"";
-
-static int parseSignArgs(PyObject * args, PyObject *kwds,
- const char **path, struct rpmSignArgs *sargs)
-{
- char * kwlist[] = { "path", "keyid", "hashalgo", NULL };
-
- memset(sargs, 0, sizeof(*sargs));
- return PyArg_ParseTupleAndKeywords(args, kwds, "s|si", kwlist,
- path, &sargs->keyid, &sargs->hashalgo);
-}
-
-static PyObject * addSign(PyObject * self, PyObject * args, PyObject *kwds)
-{
- const char *path = NULL;
- struct rpmSignArgs sargs;
-
- if (parseSignArgs(args, kwds, &path, &sargs))
- return NULL;
-
- return PyBool_FromLong(rpmPkgSign(path, &sargs) == 0);
-}
-
-static PyObject * delSign(PyObject * self, PyObject * args, PyObject *kwds)
-{
- const char *path = NULL;
- struct rpmSignArgs sargs;
-
- if (parseSignArgs(args, kwds, &path, &sargs))
- return NULL;
-
- return PyBool_FromLong(rpmPkgDelSign(path, &sargs) == 0);
-}
-
-/*
- Do any common preliminary work before python 2 vs python 3 module creation:
-*/
-static int prepareInitModule(void)
-{
- return 1;
-}
-
-static int initModule(PyObject *m)
-{
- return 1;
-}
-
-static PyMethodDef modMethods[] = {
- { "addSign", (PyCFunction) addSign, METH_VARARGS|METH_KEYWORDS, NULL },
- { "delSign", (PyCFunction) delSign, METH_VARARGS|METH_KEYWORDS, NULL },
- { NULL },
-};
-
-#if PY_MAJOR_VERSION >= 3
-static struct PyModuleDef moduledef = {
- PyModuleDef_HEAD_INIT,
- "_rpms", /* m_name */
- rpms__doc__, /* m_doc */
- 0, /* m_size */
- modMethods, /* m_methods */
- NULL, /* m_reload */
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-
-PyObject * PyInit__rpms(void); /* XXX eliminate gcc warning */
-PyObject * PyInit__rpms(void)
-{
- PyObject *m;
-
- if (!prepareInitModule())
- return NULL;
- m = PyModule_Create(&moduledef);
- if (m == NULL || !initModule(m)) {
- Py_XDECREF(m);
- m = NULL;
- }
- return m;
-}
-#else
-void init_rpms(void); /* XXX eliminate gcc warning */
-void init_rpms(void)
-{
- PyObject *m;
-
- if (!prepareInitModule())
- return;
-
- m = Py_InitModule3("_rpms", modMethods, rpms__doc__);
- if (m) initModule(m);
-}
-#endif
diff --git a/python/rpmstrpool-py.c b/python/rpmstrpool-py.c
index 356bd1de5..5c25d15fb 100644
--- a/python/rpmstrpool-py.c
+++ b/python/rpmstrpool-py.c
@@ -44,8 +44,8 @@ static PyObject *strpool_id2str(rpmstrPoolObject *s, PyObject *item)
const char *str = rpmstrPoolStr(s->pool, id);
if (str)
- ret = PyBytes_FromString(str);
- else
+ ret = utf8FromString(str);
+ else
PyErr_SetObject(PyExc_KeyError, item);
}
return ret;
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
index c8423e3dc..ebdbf371b 100644
--- a/python/rpmsystem-py.h
+++ b/python/rpmsystem-py.h
@@ -42,14 +42,11 @@ typedef Py_ssize_t (*lenfunc)(PyObject *);
#define CAPSULE_EXTRACT(obj,name) PyCObject_AsVoidPtr(obj)
#endif
-/* For Python 3, use the PyLong type throughout in place of PyInt */
+/* In Python 3, we return all strings as surrogate-escaped utf-8 */
#if PY_MAJOR_VERSION >= 3
-#define PyInt_Check PyLong_Check
-#define PyInt_AsLong PyLong_AsLong
-#define PyInt_FromLong PyLong_FromLong
-#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
-#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
-#define PyInt_AsSsize_t PyLong_AsSsize_t
+#define utf8FromString(_s) PyUnicode_DecodeUTF8(_s, strlen(_s), "surrogateescape")
+#else
+#define utf8FromString(_s) PyBytes_FromString(_s)
#endif
#endif /* H_SYSTEM_PYTHON */
diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c
index 247c7502a..23ca10517 100644
--- a/python/rpmtd-py.c
+++ b/python/rpmtd-py.c
@@ -17,7 +17,7 @@ PyObject * rpmtd_ItemAsPyobj(rpmtd td, rpmTagClass tclass)
switch (tclass) {
case RPM_STRING_CLASS:
- res = PyBytes_FromString(rpmtdGetString(td));
+ res = utf8FromString(rpmtdGetString(td));
break;
case RPM_NUMERIC_CLASS:
res = PyLong_FromLongLong(rpmtdGetNumber(td));
diff --git a/python/rpmte-py.c b/python/rpmte-py.c
index 5c8be47c8..184aa5ee5 100644
--- a/python/rpmte-py.c
+++ b/python/rpmte-py.c
@@ -56,49 +56,49 @@ rpmte_TEType(rpmteObject * s, PyObject * unused)
static PyObject *
rpmte_N(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteN(s->te));
+ return utf8FromString(rpmteN(s->te));
}
static PyObject *
rpmte_E(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteE(s->te));
+ return utf8FromString(rpmteE(s->te));
}
static PyObject *
rpmte_V(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteV(s->te));
+ return utf8FromString(rpmteV(s->te));
}
static PyObject *
rpmte_R(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteR(s->te));
+ return utf8FromString(rpmteR(s->te));
}
static PyObject *
rpmte_A(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteA(s->te));
+ return utf8FromString(rpmteA(s->te));
}
static PyObject *
rpmte_O(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteO(s->te));
+ return utf8FromString(rpmteO(s->te));
}
static PyObject *
rpmte_NEVR(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteNEVR(s->te));
+ return utf8FromString(rpmteNEVR(s->te));
}
static PyObject *
rpmte_NEVRA(rpmteObject * s, PyObject * unused)
{
- return Py_BuildValue("s", rpmteNEVRA(s->te));
+ return utf8FromString(rpmteNEVRA(s->te));
}
static PyObject *
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 98e1c6642..d6ae23750 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -230,16 +230,17 @@ rpmts_SolveCallback(rpmts ts, rpmds ds, const void * data)
PyEval_RestoreThread(cbInfo->_save);
- args = Py_BuildValue("(Oissi)", cbInfo->tso,
- rpmdsTagN(ds), rpmdsN(ds), rpmdsEVR(ds), rpmdsFlags(ds));
- result = PyEval_CallObject(cbInfo->cb, args);
+ args = Py_BuildValue("(OiNNi)", cbInfo->tso,
+ rpmdsTagN(ds), utf8FromString(rpmdsN(ds)),
+ utf8FromString(rpmdsEVR(ds)), rpmdsFlags(ds));
+ result = PyObject_Call(cbInfo->cb, args, NULL);
Py_DECREF(args);
if (!result) {
die(cbInfo->cb);
} else {
- if (PyInt_Check(result))
- res = PyInt_AsLong(result);
+ if (PyLong_Check(result))
+ res = PyLong_AsLong(result);
Py_DECREF(result);
}
@@ -409,7 +410,7 @@ rpmts_HdrCheck(rpmtsObject * s, PyObject *obj)
rpmrc = headerCheck(s->ts, uh, uc, &msg);
Py_END_ALLOW_THREADS;
- return Py_BuildValue("(is)", rpmrc, msg);
+ return Py_BuildValue("(iN)", rpmrc, utf8FromString(msg));
}
static PyObject *
@@ -498,7 +499,7 @@ rpmtsCallback(const void * hd, const rpmCallbackType what,
/* Synthesize a python object for callback (if necessary). */
if (pkgObj == NULL) {
if (h) {
- pkgObj = Py_BuildValue("s", headerGetString(h, RPMTAG_NAME));
+ pkgObj = utf8FromString(headerGetString(h, RPMTAG_NAME));
} else {
pkgObj = Py_None;
Py_INCREF(pkgObj);
@@ -509,7 +510,7 @@ rpmtsCallback(const void * hd, const rpmCallbackType what,
PyEval_RestoreThread(cbInfo->_save);
args = Py_BuildValue("(iLLOO)", what, amount, total, pkgObj, cbInfo->data);
- result = PyEval_CallObject(cbInfo->cb, args);
+ result = PyObject_Call(cbInfo->cb, args, NULL);
Py_DECREF(args);
Py_DECREF(pkgObj);
@@ -624,8 +625,8 @@ rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds)
return NULL;
if (Key) {
- if (PyInt_Check(Key)) {
- lkey = PyInt_AsLong(Key);
+ if (PyLong_Check(Key)) {
+ lkey = PyLong_AsLong(Key);
key = (char *)&lkey;
len = sizeof(lkey);
} else if (PyLong_Check(Key)) {
@@ -845,7 +846,7 @@ static PyObject *rpmts_get_tid(rpmtsObject *s, void *closure)
static PyObject *rpmts_get_rootDir(rpmtsObject *s, void *closure)
{
- return Py_BuildValue("s", rpmtsRootDir(s->ts));
+ return utf8FromString(rpmtsRootDir(s->ts));
}
static int rpmts_set_scriptFd(rpmtsObject *s, PyObject *value, void *closure)
@@ -968,7 +969,7 @@ static PyGetSetDef rpmts_getseters[] = {
PyTypeObject rpmts_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- PYTHON_MODULENAME".ts", /* tp_name */
+ PYTHON_MODULENAME".ts", /* tp_name */
sizeof(rpmtsObject), /* tp_size */
0, /* tp_itemsize */
(destructor) rpmts_dealloc, /* tp_dealloc */
diff --git a/python/setup.py.in b/python/setup.py.in
index a43bb6d4d..3b87edddb 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -26,34 +26,17 @@ if os.access('Makefile.am', os.F_OK):
rpmmod = Extension('@PYTHON_MODULENAME@._rpm',
- sources = [ 'header-py.c', 'rpmds-py.c', 'rpmfd-py.c',
- 'rpmfi-py.c', 'rpmii-py.c', 'rpmkeyring-py.c',
- 'rpmmacro-py.c', 'rpmmi-py.c', 'rpmps-py.c',
- 'rpmstrpool-py.c', 'rpmfiles-py.c',
- 'rpmarchive-py.c', 'rpmtd-py.c',
- 'rpmte-py.c', 'rpmts-py.c', 'rpmmodule.c',
- ],
+ sources = ['header-py.c', 'rpmds-py.c', 'rpmfd-py.c',
+ 'rpmfi-py.c', 'rpmii-py.c', 'rpmkeyring-py.c',
+ 'rpmmacro-py.c', 'rpmmi-py.c', 'rpmps-py.c',
+ 'rpmstrpool-py.c', 'rpmfiles-py.c',
+ 'rpmarchive-py.c', 'rpmtd-py.c',
+ 'rpmte-py.c', 'rpmts-py.c',
+ 'spec-py',
+ 'rpmmodule.c'],
include_dirs = pkgconfig('--cflags'),
library_dirs = pkgconfig('--libs-only-L'),
- libraries = pkgconfig('--libs-only-l'),
- extra_compile_args = cflags,
- extra_link_args = additional_link_args
- )
-
-rpmbuild_mod = Extension('@PYTHON_MODULENAME@._rpmb',
- sources = ['rpmbmodule.c', 'spec-py.c'],
- include_dirs = pkgconfig('--cflags'),
- library_dirs = pkgconfig('--libs-only-L'),
- libraries = pkgconfig('--libs-only-l') + ['rpmbuild'],
- extra_compile_args = cflags,
- extra_link_args = additional_link_args
- )
-
-rpmsign_mod = Extension('@PYTHON_MODULENAME@._rpms',
- sources = ['rpmsmodule.c'],
- include_dirs = pkgconfig('--cflags'),
- library_dirs = pkgconfig('--libs-only-L'),
- libraries = pkgconfig('--libs-only-l') + ['rpmsign'],
+ libraries = pkgconfig('--libs-only-l') + ['rpmbuild', 'rpmsign'],
extra_compile_args = cflags,
extra_link_args = additional_link_args
)
@@ -63,6 +46,6 @@ setup(name='@PACKAGE_NAME@',
description='Python bindings for @PACKAGE_NAME@',
maintainer_email='@PACKAGE_BUGREPORT@',
url='http://www.rpm.org/',
- packages = ['@PACKAGE_NAME@'],
- ext_modules= [rpmmod, rpmbuild_mod, rpmsign_mod]
+ packages=['@PACKAGE_NAME@'],
+ ext_modules=[rpmmod]
)
diff --git a/python/spec-py.c b/python/spec-py.c
index 392ecc004..ab42ee780 100644
--- a/python/spec-py.c
+++ b/python/spec-py.c
@@ -57,7 +57,7 @@ static PyObject *pkgGetSection(rpmSpecPkg pkg, int section)
{
char *sect = rpmSpecPkgGetSection(pkg, section);
if (sect != NULL) {
- PyObject *ps = PyBytes_FromString(sect);
+ PyObject *ps = utf8FromString(sect);
free(sect);
if (ps != NULL)
return ps;
@@ -158,7 +158,7 @@ static PyObject * getSection(rpmSpec spec, int section)
{
const char *sect = rpmSpecGetSection(spec, section);
if (sect) {
- return Py_BuildValue("s", sect);
+ return utf8FromString(sect);
}
Py_RETURN_NONE;
}
@@ -208,8 +208,8 @@ static PyObject * spec_get_sources(specObject *s, void *closure)
rpmSpecSrcIter iter = rpmSpecSrcIterInit(s->spec);
while ((source = rpmSpecSrcIterNext(iter)) != NULL) {
- PyObject *srcUrl = Py_BuildValue("(sii)",
- rpmSpecSrcFilename(source, 1),
+ PyObject *srcUrl = Py_BuildValue("(Nii)",
+ utf8FromString(rpmSpecSrcFilename(source, 1)),
rpmSpecSrcNum(source),
rpmSpecSrcFlags(source));
if (!srcUrl) {