--- rpm-4.10.91.tizen20121215.orig/debian/librpm-tizen.install
+++ rpm-4.10.91.tizen20121215/debian/librpm-tizen.install
@@ -0,0 +1,4 @@
+usr/lib*/*/*.so.*
+usr/lib*/*/rpm/*
+usr/lib/python*/dist-packages/*/*.so
+usr/lib/python*/dist-packages/*/*.py*
--- rpm-4.10.91.tizen20121215.orig/debian/control
+++ rpm-4.10.91.tizen20121215/debian/control
@@ -0,0 +1,46 @@
+Source: librpm-tizen
+Section: vcs
+Priority: optional
+Build-Depends: debhelper,
+               dpkg-dev,
+               dh-autoreconf,
+               libtool,
+               autoconf,
+               automake,
+               autotools-dev,
+               autopoint,
+               zlib1g-dev,
+               libpopt-dev,
+               libxml2-dev,
+               libreadline-dev,
+               libsqlite3-dev,
+               python-all-dev,
+               pkg-config,
+               libnspr4-dev,
+               libnss3-dev,
+               liblzma-dev,
+               libmagic-dev,
+               libelf-dev,
+               libdw-dev,
+               libdb-dev
+Maintainer: Markus Lehtonen <markus.lehtonen@linux.intel.com>
+Standards-Version: 3.9.3
+Homepage: http://rpm.org/
+X-Python-Version: >= 2.6
+
+Package: librpm-tizen
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python: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.
+
--- rpm-4.10.91.tizen20121215.orig/debian/compat
+++ rpm-4.10.91.tizen20121215/debian/compat
@@ -0,0 +1,1 @@
+7
--- rpm-4.10.91.tizen20121215.orig/debian/rules
+++ rpm-4.10.91.tizen20121215/debian/rules
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+python_mod_name := rpm_tizen
+
+CPPFLAGS += $(shell pkg-config --cflags nss)
+
+%:
+	dh $@ --with python2,autoreconf,autotools_dev
+
+override_dh_auto_configure:
+	dh_auto_configure -- --disable-dependency-tracking \
+			--libdir=/usr/lib/librpm-tizen \
+			--without-lua \
+			--without-acl \
+			--without-cap \
+			--enable-shared \
+			--enable-python \
+			--with-external-db \
+			PYTHON_MODULENAME=$(python_mod_name) \
+			CPPFLAGS="$(CPPFLAGS)"
+
+override_dh_auto_install:
+	dh_auto_install --destdir=debian/tmp
+
+override_dh_python2:
+	dh_python2 --no-guessing-versions
+
--- rpm-4.10.91.tizen20121215.orig/debian/changelog
+++ rpm-4.10.91.tizen20121215/debian/changelog
@@ -0,0 +1,6 @@
+librpm-tizen (4.10.91.tizen20121215) unstable; urgency=low
+
+  * Initial packaging
+
+ -- Markus Lehtonen <markus.lehtonen@linux.intel.com>  Tue, 17 Dec 2012 13:22:00 +0200
+
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Fri, 18 May 2012 19:03:36 +0300
Subject: Python module: rename .py files to .in

In order to make them modifiable by autotools.
---
 configure.ac                 |    2 +
 python/rpm/__init__.py       |   84 ----------------------
 python/rpm/__init__.py.in    |   84 ++++++++++++++++++++++
 python/rpm/transaction.py    |  156 ------------------------------------------
 python/rpm/transaction.py.in |  156 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 242 insertions(+), 240 deletions(-)
 delete mode 100644 python/rpm/__init__.py
 create mode 100644 python/rpm/__init__.py.in
 delete mode 100644 python/rpm/transaction.py
 create mode 100644 python/rpm/transaction.py.in

diff --git a/configure.ac b/configure.ac
index 01f3fff..cbb2ac3 100644
--- rpm-4.10.91.tizen20121215.orig/configure.ac
+++ rpm-4.10.91.tizen20121215/configure.ac
@@ -842,6 +842,8 @@ AC_CONFIG_FILES([Makefile
 	misc/Makefile 
 	doc/Makefile
 	python/Makefile
+	python/rpm/__init__.py
+	python/rpm/transaction.py
  	luaext/Makefile
  	tests/Makefile
  	plugins/Makefile
diff --git a/python/rpm/__init__.py b/python/rpm/__init__.py
deleted file mode 100644
index d868d19..0000000
--- rpm-4.10.91.tizen20121215.orig/python/rpm/__init__.py
+++ /dev/null
@@ -1,84 +0,0 @@
-r"""RPM Module
-
-This module enables you to manipulate rpms and the rpm database.
-
-"""
-
-import warnings
-import os
-from rpm._rpm import *
-from rpm.transaction import *
-import rpm._rpm as _rpm
-_RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
-_RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
-_RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
-_RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
-
-__version__ = _rpm.__version__
-__version_info__ = tuple(__version__.split('.'))
-
-# try to import build bits but dont require it
-try:
-    from rpm._rpmb import *
-except ImportError:
-    pass
-
-# try to import signing bits but dont require it
-try:
-    from rpm._rpms import *
-except ImportError:
-    pass
-
-# backwards compatibility + give the same class both ways
-ts = TransactionSet
-
-def headerLoad(*args, **kwds):
-    warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
-    return hdr(*args, **kwds)
-
-def _doHeaderListFromFD(rpm_fd, retrofit):
-    hlist = []
-    while 1:
-        try:
-            h = hdr(rpm_fd)
-            if retrofit:
-                h.convert(HEADERCONV_RETROFIT_V3)
-            hlist.append(h)
-        except _rpm.error:
-            break
-
-    return hlist
-
-def readHeaderListFromFD(file_desc, retrofit = True):
-    if not isinstance(file_desc, fd):
-        file_desc = fd(file_desc)
-    return _doHeaderListFromFD(file_desc, retrofit)
-        
-def readHeaderListFromFile(path, retrofit = True):
-    f = fd(path)
-    hlist = _doHeaderListFromFD(f, retrofit)
-    f.close()
-    return hlist
-    
-def readHeaderFromFD(file_desc):
-    if not isinstance(file_desc, fd):
-        file_desc = fd(file_desc)
-    try:
-        offset = file_desc.tell()
-        h = hdr(file_desc)
-    except (_rpm.error, IOError):
-        offset = None
-        h = None
-
-    return (h, offset)
-
-def signalsCaught(siglist):
-    caught = []
-    for sig in siglist:
-        if signalCaught(sig):
-            caught.append(sig)
-
-    return caught
-
-def dsSingle(TagN, N, EVR = "", Flags = RPMSENSE_ANY):
-    return ds((N, EVR, Flags), TagN)
diff --git a/python/rpm/__init__.py.in b/python/rpm/__init__.py.in
new file mode 100644
index 0000000..d868d19
--- /dev/null
+++ rpm-4.10.91.tizen20121215/python/rpm/__init__.py.in
@@ -0,0 +1,84 @@
+r"""RPM Module
+
+This module enables you to manipulate rpms and the rpm database.
+
+"""
+
+import warnings
+import os
+from rpm._rpm import *
+from rpm.transaction import *
+import rpm._rpm as _rpm
+_RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
+_RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
+_RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
+_RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
+
+__version__ = _rpm.__version__
+__version_info__ = tuple(__version__.split('.'))
+
+# try to import build bits but dont require it
+try:
+    from rpm._rpmb import *
+except ImportError:
+    pass
+
+# try to import signing bits but dont require it
+try:
+    from rpm._rpms import *
+except ImportError:
+    pass
+
+# backwards compatibility + give the same class both ways
+ts = TransactionSet
+
+def headerLoad(*args, **kwds):
+    warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
+    return hdr(*args, **kwds)
+
+def _doHeaderListFromFD(rpm_fd, retrofit):
+    hlist = []
+    while 1:
+        try:
+            h = hdr(rpm_fd)
+            if retrofit:
+                h.convert(HEADERCONV_RETROFIT_V3)
+            hlist.append(h)
+        except _rpm.error:
+            break
+
+    return hlist
+
+def readHeaderListFromFD(file_desc, retrofit = True):
+    if not isinstance(file_desc, fd):
+        file_desc = fd(file_desc)
+    return _doHeaderListFromFD(file_desc, retrofit)
+        
+def readHeaderListFromFile(path, retrofit = True):
+    f = fd(path)
+    hlist = _doHeaderListFromFD(f, retrofit)
+    f.close()
+    return hlist
+    
+def readHeaderFromFD(file_desc):
+    if not isinstance(file_desc, fd):
+        file_desc = fd(file_desc)
+    try:
+        offset = file_desc.tell()
+        h = hdr(file_desc)
+    except (_rpm.error, IOError):
+        offset = None
+        h = None
+
+    return (h, offset)
+
+def signalsCaught(siglist):
+    caught = []
+    for sig in siglist:
+        if signalCaught(sig):
+            caught.append(sig)
+
+    return caught
+
+def dsSingle(TagN, N, EVR = "", Flags = RPMSENSE_ANY):
+    return ds((N, EVR, Flags), TagN)
diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py
deleted file mode 100644
index 73e4b3c..0000000
--- rpm-4.10.91.tizen20121215.orig/python/rpm/transaction.py
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/python
-
-import rpm
-from rpm._rpm import ts as TransactionSetCore
-
-# TODO: migrate relevant documentation from C-side
-class TransactionSet(TransactionSetCore):
-    _probFilter = 0
-
-    def _wrapSetGet(self, attr, val):
-        oval = getattr(self, attr)
-        setattr(self, attr, val)
-        return oval
-        
-    def setVSFlags(self, flags):
-        return self._wrapSetGet('_vsflags', flags)
-
-    def getVSFlags(self):
-        return self._vsflags
-
-    def setColor(self, color):
-        return self._wrapSetGet('_color', color)
-
-    def setPrefColor(self, color):
-        return self._wrapSetGet('_prefcolor', color)
-
-    def setFlags(self, flags):
-        return self._wrapSetGet('_flags', flags)
-
-    def setProbFilter(self, ignoreSet):
-        return self._wrapSetGet('_probFilter', ignoreSet)
-
-    def parseSpec(self, specfile):
-        import _rpmb
-        return _rpmb.spec(specfile)
-
-    def getKeys(self):
-        keys = []
-        for te in self:
-            keys.append(te.Key())
-        # Backwards compatibility goo - WTH does this return a *tuple* ?!
-        if not keys:
-            return None
-        else:
-            return tuple(keys)
-
-    def addInstall(self, item, key, how="u"):
-        if isinstance(item, basestring):
-            f = file(item)
-            header = self.hdrFromFdno(f)
-            f.close()
-        elif isinstance(item, file):
-            header = self.hdrFromFdno(item)
-        else:
-            header = item
-
-        if not how in ['u', 'i']:
-            raise ValueError('how argument must be "u" or "i"')
-        upgrade = (how == "u")
-
-        if not TransactionSetCore.addInstall(self, header, key, upgrade):
-            raise rpm.error("adding package to transaction failed")
-
-    def addErase(self, item):
-        hdrs = []
-        if isinstance(item, rpm.hdr):
-            hdrs = [item]
-        elif isinstance(item, rpm.mi):
-            hdrs = item
-        elif isinstance(item, int):
-            hdrs = self.dbMatch(rpm.RPMDBI_PACKAGES, item)
-        elif isinstance(item, basestring):
-            hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item)
-        else:
-            raise TypeError("invalid type %s" % type(item))
-
-        for h in hdrs:
-            if not TransactionSetCore.addErase(self, h):
-                raise rpm.error("package not installed")
-
-        # garbage collection should take care but just in case...
-        if isinstance(hdrs, rpm.mi):
-            del hdrs
-
-    def run(self, callback, data):
-        rc = TransactionSetCore.run(self, callback, data, self._probFilter)
-
-        # crazy backwards compatibility goo: None for ok, list of problems
-        # if transaction didnt complete and empty list if it completed
-        # with errors
-        if rc == 0:
-            return None
-
-        res = []
-        if rc > 0:
-            for prob in self.problems():
-                item = ("%s" % prob, (prob.type, prob._str, prob._num))
-                res.append(item)
-        return res
-
-    def check(self, *args, **kwds):
-        TransactionSetCore.check(self, *args, **kwds)
-
-        # compatibility: munge problem strings into dependency tuples of doom
-        res = []
-        for p in self.problems():
-            # is it anything we need to care about?
-            if p.type == rpm.RPMPROB_CONFLICT:
-                sense = rpm.RPMDEP_SENSE_CONFLICTS
-            elif p.type == rpm.RPMPROB_REQUIRES:
-                sense = rpm.RPMDEP_SENSE_REQUIRES
-            else:
-                continue
-
-            # strip arch, split to name, version, release
-            nevr = p.altNEVR.rsplit('.', 1)[0]
-            n, v, r = nevr.rsplit('-', 2)
-
-            # extract the dependency information
-            needs = p._str.split()
-            needname = needs[0]
-            needflags = rpm.RPMSENSE_ANY
-            if len(needs) == 3:
-                needop = needs[1]
-                if needop.find('<') >= 0: needflags |= rpm.RPMSENSE_LESS
-                if needop.find('=') >= 0: needflags |= rpm.RPMSENSE_EQUAL
-                if needop.find('>') >= 0: needflags |= rpm.RPMSENSE_GREATER
-                needver = needs[2]
-            else:
-                needver = ""
-
-            res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
-
-        return res
-
-    def hdrCheck(self, blob):
-        res, msg = TransactionSetCore.hdrCheck(self, blob)
-        # generate backwards compatibly broken exceptions
-        if res == rpm.RPMRC_NOKEY:
-            raise rpm.error("public key not available")
-        elif res == rpm.RPMRC_NOTTRUSTED:
-            raise rpm.error("public key not trusted")
-        elif res != rpm.RPMRC_OK:
-            raise rpm.error(msg)
-
-    def hdrFromFdno(self, fd):
-        res, h = TransactionSetCore.hdrFromFdno(self, fd)
-        # generate backwards compatibly broken exceptions
-        if res == rpm.RPMRC_NOKEY:
-            raise rpm.error("public key not available")
-        elif res == rpm.RPMRC_NOTTRUSTED:
-            raise rpm.error("public key not trusted")
-        elif res != rpm.RPMRC_OK:
-            raise rpm.error("error reading package header")
-
-        return h
diff --git a/python/rpm/transaction.py.in b/python/rpm/transaction.py.in
new file mode 100644
index 0000000..73e4b3c
--- /dev/null
+++ rpm-4.10.91.tizen20121215/python/rpm/transaction.py.in
@@ -0,0 +1,156 @@
+#!/usr/bin/python
+
+import rpm
+from rpm._rpm import ts as TransactionSetCore
+
+# TODO: migrate relevant documentation from C-side
+class TransactionSet(TransactionSetCore):
+    _probFilter = 0
+
+    def _wrapSetGet(self, attr, val):
+        oval = getattr(self, attr)
+        setattr(self, attr, val)
+        return oval
+        
+    def setVSFlags(self, flags):
+        return self._wrapSetGet('_vsflags', flags)
+
+    def getVSFlags(self):
+        return self._vsflags
+
+    def setColor(self, color):
+        return self._wrapSetGet('_color', color)
+
+    def setPrefColor(self, color):
+        return self._wrapSetGet('_prefcolor', color)
+
+    def setFlags(self, flags):
+        return self._wrapSetGet('_flags', flags)
+
+    def setProbFilter(self, ignoreSet):
+        return self._wrapSetGet('_probFilter', ignoreSet)
+
+    def parseSpec(self, specfile):
+        import _rpmb
+        return _rpmb.spec(specfile)
+
+    def getKeys(self):
+        keys = []
+        for te in self:
+            keys.append(te.Key())
+        # Backwards compatibility goo - WTH does this return a *tuple* ?!
+        if not keys:
+            return None
+        else:
+            return tuple(keys)
+
+    def addInstall(self, item, key, how="u"):
+        if isinstance(item, basestring):
+            f = file(item)
+            header = self.hdrFromFdno(f)
+            f.close()
+        elif isinstance(item, file):
+            header = self.hdrFromFdno(item)
+        else:
+            header = item
+
+        if not how in ['u', 'i']:
+            raise ValueError('how argument must be "u" or "i"')
+        upgrade = (how == "u")
+
+        if not TransactionSetCore.addInstall(self, header, key, upgrade):
+            raise rpm.error("adding package to transaction failed")
+
+    def addErase(self, item):
+        hdrs = []
+        if isinstance(item, rpm.hdr):
+            hdrs = [item]
+        elif isinstance(item, rpm.mi):
+            hdrs = item
+        elif isinstance(item, int):
+            hdrs = self.dbMatch(rpm.RPMDBI_PACKAGES, item)
+        elif isinstance(item, basestring):
+            hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item)
+        else:
+            raise TypeError("invalid type %s" % type(item))
+
+        for h in hdrs:
+            if not TransactionSetCore.addErase(self, h):
+                raise rpm.error("package not installed")
+
+        # garbage collection should take care but just in case...
+        if isinstance(hdrs, rpm.mi):
+            del hdrs
+
+    def run(self, callback, data):
+        rc = TransactionSetCore.run(self, callback, data, self._probFilter)
+
+        # crazy backwards compatibility goo: None for ok, list of problems
+        # if transaction didnt complete and empty list if it completed
+        # with errors
+        if rc == 0:
+            return None
+
+        res = []
+        if rc > 0:
+            for prob in self.problems():
+                item = ("%s" % prob, (prob.type, prob._str, prob._num))
+                res.append(item)
+        return res
+
+    def check(self, *args, **kwds):
+        TransactionSetCore.check(self, *args, **kwds)
+
+        # compatibility: munge problem strings into dependency tuples of doom
+        res = []
+        for p in self.problems():
+            # is it anything we need to care about?
+            if p.type == rpm.RPMPROB_CONFLICT:
+                sense = rpm.RPMDEP_SENSE_CONFLICTS
+            elif p.type == rpm.RPMPROB_REQUIRES:
+                sense = rpm.RPMDEP_SENSE_REQUIRES
+            else:
+                continue
+
+            # strip arch, split to name, version, release
+            nevr = p.altNEVR.rsplit('.', 1)[0]
+            n, v, r = nevr.rsplit('-', 2)
+
+            # extract the dependency information
+            needs = p._str.split()
+            needname = needs[0]
+            needflags = rpm.RPMSENSE_ANY
+            if len(needs) == 3:
+                needop = needs[1]
+                if needop.find('<') >= 0: needflags |= rpm.RPMSENSE_LESS
+                if needop.find('=') >= 0: needflags |= rpm.RPMSENSE_EQUAL
+                if needop.find('>') >= 0: needflags |= rpm.RPMSENSE_GREATER
+                needver = needs[2]
+            else:
+                needver = ""
+
+            res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
+
+        return res
+
+    def hdrCheck(self, blob):
+        res, msg = TransactionSetCore.hdrCheck(self, blob)
+        # generate backwards compatibly broken exceptions
+        if res == rpm.RPMRC_NOKEY:
+            raise rpm.error("public key not available")
+        elif res == rpm.RPMRC_NOTTRUSTED:
+            raise rpm.error("public key not trusted")
+        elif res != rpm.RPMRC_OK:
+            raise rpm.error(msg)
+
+    def hdrFromFdno(self, fd):
+        res, h = TransactionSetCore.hdrFromFdno(self, fd)
+        # generate backwards compatibly broken exceptions
+        if res == rpm.RPMRC_NOKEY:
+            raise rpm.error("public key not available")
+        elif res == rpm.RPMRC_NOTTRUSTED:
+            raise rpm.error("public key not trusted")
+        elif res != rpm.RPMRC_OK:
+            raise rpm.error("error reading package header")
+
+        return h
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Fri, 18 May 2012 18:04:11 +0300
Subject: Make python module name configurable

---
 configure.ac                 |    8 ++++++++
 python/Makefile.am           |    6 ++++--
 python/header-py.c           |    6 +++---
 python/rpm/__init__.py.in    |   10 +++++-----
 python/rpm/transaction.py.in |    4 ++--
 python/rpmds-py.c            |    2 +-
 python/rpmfd-py.c            |    2 +-
 python/rpmfi-py.c            |    2 +-
 python/rpmii-py.c            |    2 +-
 python/rpmkeyring-py.c       |    4 ++--
 python/rpmmi-py.c            |    2 +-
 python/rpmps-py.c            |    2 +-
 python/rpmsystem-py.h        |    2 ++
 python/rpmtd-py.c            |    4 ++--
 python/rpmte-py.c            |    4 ++--
 python/rpmts-py.c            |    4 ++--
 python/setup.py.in           |    8 ++++----
 python/spec-py.c             |    8 ++++----
 18 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/configure.ac b/configure.ac
index cbb2ac3..b9c4c18 100644
--- rpm-4.10.91.tizen20121215.orig/configure.ac
+++ rpm-4.10.91.tizen20121215/configure.ac
@@ -832,6 +832,14 @@ AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
 
+AC_ARG_VAR([PYTHON_MODULENAME], [Name of the rpm python module. Defaults to 'rpm'])
+if test X"$PYTHON_MODULENAME" = X ; then
+    PYTHON_MODULENAME="$PACKAGE"
+fi
+AC_DEFINE_UNQUOTED(PYTHON_MODULENAME, ["$PYTHON_MODULENAME"],[python module name])
+AC_SUBST(PYTHON_MODULENAME)
+
+
 AC_PATH_PROG(AUTOM4TE,autom4te,:)
 
 AC_SUBST([dirstamp],[\${am__leading_dot}dirstamp])
diff --git a/python/Makefile.am b/python/Makefile.am
index fff51ae..914bf3d 100644
--- rpm-4.10.91.tizen20121215.orig/python/Makefile.am
+++ rpm-4.10.91.tizen20121215/python/Makefile.am
@@ -5,9 +5,11 @@ EXTRA_DIST = rpm/__init__.py rpm/transaction.py
 AM_CPPFLAGS = -I$(top_builddir)/include/
 AM_CPPFLAGS += -I$(top_srcdir)/python
 AM_CPPFLAGS += -I@WITH_PYTHON_INCLUDE@
+AM_CPPFLAGS += -I$(top_srcdir)
 
-pkgpyexec_LTLIBRARIES = _rpmmodule.la _rpmbmodule.la _rpmsmodule.la
-pkgpyexec_DATA = rpm/__init__.py rpm/transaction.py
+rpmpyexec_LTLIBRARIES = _rpmmodule.la _rpmbmodule.la _rpmsmodule.la
+rpmpyexec_DATA = rpm/__init__.py rpm/transaction.py
+rpmpyexecdir = @pyexecdir@/@PYTHON_MODULENAME@
 
 _rpmmodule_la_LDFLAGS = -module -avoid-version -shared
 _rpmmodule_la_LIBADD = \
diff --git a/python/header-py.c b/python/header-py.c
index d194fdc..ff581f1 100644
--- rpm-4.10.91.tizen20121215.orig/python/header-py.c
+++ rpm-4.10.91.tizen20121215/python/header-py.c
@@ -393,7 +393,7 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
     if (obj == NULL) {
 	h = headerNew();
     } else if (CAPSULE_CHECK(obj)) {
-	h = CAPSULE_EXTRACT(obj, "rpm._C_Header");
+	h = CAPSULE_EXTRACT(obj, PYTHON_MODULENAME"._C_Header");
     } else if (hdrObject_Check(obj)) {
 	h = headerCopy(((hdrObject*) obj)->h);
     } else if (PyBytes_Check(obj)) {
@@ -404,7 +404,7 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
 	Py_END_ALLOW_THREADS;
 	Py_XDECREF(fdo);
     } else {
-    	PyErr_SetString(PyExc_TypeError, "header, blob or file expected");
+    	PyErr_SetString(PyExc_TypeError, "header, blob or file expected!!");
 	return NULL;
     }
 
@@ -684,7 +684,7 @@ static char hdr_doc[] =
 
 PyTypeObject hdr_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.hdr",			/* tp_name */
+	PYTHON_MODULENAME".hdr",	/* tp_name */
 	sizeof(hdrObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) hdr_dealloc, 	/* tp_dealloc */
diff --git a/python/rpm/__init__.py.in b/python/rpm/__init__.py.in
index d868d19..df1e3a2 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpm/__init__.py.in
+++ rpm-4.10.91.tizen20121215/python/rpm/__init__.py.in
@@ -6,9 +6,9 @@ This module enables you to manipulate rpms and the rpm database.
 
 import warnings
 import os
-from rpm._rpm import *
-from rpm.transaction import *
-import rpm._rpm as _rpm
+from @PYTHON_MODULENAME@._rpm import *
+from @PYTHON_MODULENAME@.transaction import *
+import @PYTHON_MODULENAME@._rpm as _rpm
 _RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
 _RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
 _RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
@@ -19,13 +19,13 @@ __version_info__ = tuple(__version__.split('.'))
 
 # try to import build bits but dont require it
 try:
-    from rpm._rpmb import *
+    from @PYTHON_MODULENAME@._rpmb import *
 except ImportError:
     pass
 
 # try to import signing bits but dont require it
 try:
-    from rpm._rpms import *
+    from @PYTHON_MODULENAME@._rpms import *
 except ImportError:
     pass
 
diff --git a/python/rpm/transaction.py.in b/python/rpm/transaction.py.in
index 73e4b3c..e730759 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpm/transaction.py.in
+++ rpm-4.10.91.tizen20121215/python/rpm/transaction.py.in
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
-import rpm
-from rpm._rpm import ts as TransactionSetCore
+import @PYTHON_MODULENAME@ as rpm
+from @PYTHON_MODULENAME@._rpm import ts as TransactionSetCore
 
 # TODO: migrate relevant documentation from C-side
 class TransactionSet(TransactionSetCore):
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index 30fb908..4b44220 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmds-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmds-py.c
@@ -341,7 +341,7 @@ static char rpmds_doc[] =
 
 PyTypeObject rpmds_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.ds",			/* tp_name */
+	PYTHON_MODULENAME".ds",		/* tp_name */
 	sizeof(rpmdsObject),		/* tp_basicsize */
 	0,				/* tp_itemsize */
 	/* methods */
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c
index a266ad6..79eb5b6 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmfd-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmfd-py.c
@@ -310,7 +310,7 @@ static PyGetSetDef rpmfd_getseters[] = {
 
 PyTypeObject rpmfd_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.fd",			/* tp_name */
+	PYTHON_MODULENAME".fd",		/* tp_name */
 	sizeof(rpmfdObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	/* methods */
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c
index 458e721..14e89df 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmfi-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmfi-py.c
@@ -320,7 +320,7 @@ static char rpmfi_doc[] =
 
 PyTypeObject rpmfi_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.fi",			/* tp_name */
+	PYTHON_MODULENAME".fi",		/* tp_name */
 	sizeof(rpmfiObject),		/* tp_basicsize */
 	0,				/* tp_itemsize */
 	/* methods */
diff --git a/python/rpmii-py.c b/python/rpmii-py.c
index d7713af..17fe79e 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmii-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmii-py.c
@@ -103,7 +103,7 @@ static char rpmii_doc[] =
 
 PyTypeObject rpmii_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.ii",			/* tp_name */
+	PYTHON_MODULENAME".ii",		/* tp_name */
 	sizeof(rpmiiObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) rpmii_dealloc, 	/* tp_dealloc */
diff --git a/python/rpmkeyring-py.c b/python/rpmkeyring-py.c
index d5f131e..7df847d 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmkeyring-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmkeyring-py.c
@@ -52,7 +52,7 @@ static char rpmPubkey_doc[] = "";
 
 PyTypeObject rpmPubkey_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.pubkey",			/* tp_name */
+	PYTHON_MODULENAME".pubkey",	/* tp_name */
 	sizeof(rpmPubkeyObject),	/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) rpmPubkey_dealloc,/* tp_dealloc */
@@ -133,7 +133,7 @@ static char rpmKeyring_doc[] =
 
 PyTypeObject rpmKeyring_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.keyring",			/* tp_name */
+	PYTHON_MODULENAME".keyring",	/* tp_name */
 	sizeof(rpmKeyringObject),	/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) rpmKeyring_dealloc,/* tp_dealloc */
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c
index 8e670ce..6c34c98 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmmi-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmmi-py.c
@@ -164,7 +164,7 @@ static char rpmmi_doc[] =
 
 PyTypeObject rpmmi_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.mi",			/* tp_name */
+	PYTHON_MODULENAME".mi",		/* tp_name */
 	sizeof(rpmmiObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) rpmmi_dealloc, 	/* tp_dealloc */
diff --git a/python/rpmps-py.c b/python/rpmps-py.c
index bdc899a..3ee9d4a 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmps-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmps-py.c
@@ -72,7 +72,7 @@ static void rpmprob_dealloc(rpmProblemObject *s)
 
 PyTypeObject rpmProblem_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.prob",			/* tp_name */
+	PYTHON_MODULENAME".prob",		/* tp_name */
 	sizeof(rpmProblemObject),		/* tp_basicsize */
 	0,				/* tp_itemsize */
 	/* methods */
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
index 58ac1ba..c7286a2 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmsystem-py.h
+++ rpm-4.10.91.tizen20121215/python/rpmsystem-py.h
@@ -8,6 +8,8 @@
 #include <Python.h>
 #include <structmember.h>
 
+#include "config.h"
+
 #if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0205
 typedef ssize_t Py_ssize_t;
 typedef Py_ssize_t (*lenfunc)(PyObject *);
diff --git a/python/rpmtd-py.c b/python/rpmtd-py.c
index 7655755..ed3a145 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmtd-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmtd-py.c
@@ -167,7 +167,7 @@ static PyGetSetDef rpmtd_getseters[] = {
 
 PyTypeObject rpmtd_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.td",			/* tp_name */
+	PYTHON_MODULENAME".td",		/* tp_name */
 	sizeof(rpmtdObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor) rpmtd_dealloc, 	/* tp_dealloc */
@@ -214,7 +214,7 @@ int rpmtdFromPyObject(PyObject *obj, rpmtd *td)
 	*td = &(((rpmtdObject *)obj)->td);
 	return 1;
     } else {
-	PyErr_SetString(PyExc_TypeError, "rpm.td type expected");
+	PyErr_SetString(PyExc_TypeError, PYTHON_MODULENAME".td type expected");
 	return 0;
     }
 }
diff --git a/python/rpmte-py.c b/python/rpmte-py.c
index 2204a52..6b33826 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmte-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmte-py.c
@@ -192,7 +192,7 @@ rpmte_FI(rpmteObject * s, PyObject * args, PyObject * kwds)
 static struct PyMethodDef rpmte_methods[] = {
     {"Type",	(PyCFunction)rpmte_TEType,	METH_NOARGS,
 "te.Type() -> Type\n\
-- Return element type (rpm.TR_ADDED | rpm.TR_REMOVED).\n" },
+- Return element type ("PYTHON_MODULENAME".TR_ADDED | "PYTHON_MODULENAME".TR_REMOVED).\n" },
     {"N",	(PyCFunction)rpmte_N,		METH_NOARGS,
 "te.N() -> N\n\
 - Return element name.\n" },
@@ -250,7 +250,7 @@ static char rpmte_doc[] =
 
 PyTypeObject rpmte_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.te",			/* tp_name */
+	PYTHON_MODULENAME".te",		/* tp_name */
 	sizeof(rpmteObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	(destructor)0,		 	/* tp_dealloc */
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index 5c6e9ba..1072f35 100644
--- rpm-4.10.91.tizen20121215.orig/python/rpmts-py.c
+++ rpm-4.10.91.tizen20121215/python/rpmts-py.c
@@ -440,7 +440,7 @@ static PyObject *rpmts_setKeyring(rpmtsObject *s, PyObject *arg)
     if (arg == Py_None || rpmKeyringFromPyObject(arg, &keyring)) {
 	return PyBool_FromLong(rpmtsSetKeyring(s->ts, keyring) == 0);
     } else {
-	PyErr_SetString(PyExc_TypeError, "rpm.keyring or None expected");
+	PyErr_SetString(PyExc_TypeError, PYTHON_MODULENAME".keyring or None expected");
 	return NULL;
     }
 }
@@ -872,7 +872,7 @@ static PyGetSetDef rpmts_getseters[] = {
 
 PyTypeObject rpmts_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.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 619b0ac..14be973 100644
--- rpm-4.10.91.tizen20121215.orig/python/setup.py.in
+++ rpm-4.10.91.tizen20121215/python/setup.py.in
@@ -20,7 +20,7 @@ def mksources(names):
 
 cflags = ['-std=c99']
 
-rpmmod = Extension('rpm._rpm',
+rpmmod = Extension('@PYTHON_MODULENAME@._rpm',
                    sources = mksources([
                                 'header', 'rpmds', 'rpmfd', 'rpmfi', 'rpmii',
                                 'rpmkeyring', 'rpmmacro', 'rpmmi', 'rpmps',
@@ -31,21 +31,21 @@ rpmmod = Extension('rpm._rpm',
                    extra_compile_args = cflags
                   )
 
-rpmbuild_mod = Extension('rpm._rpmb',
+rpmbuild_mod = Extension('@PYTHON_MODULENAME@._rpmb',
                    sources = mksources(['rpmbmodule', 'spec']),
                    include_dirs = pkgconfig('--cflags'),
                    libraries = pkgconfig('--libs') + ['rpmbuild'],
                    extra_compile_args = cflags
                   )
 
-rpmsign_mod = Extension('rpm._rpms',
+rpmsign_mod = Extension('@PYTHON_MODULENAME@._rpms',
                    sources = mksources(['rpmbmodule']),
                    include_dirs = pkgconfig('--cflags'),
                    libraries = pkgconfig('--libs') + ['rpmsign'],
                    extra_compile_args = cflags
                   )
 
-setup(name='@PACKAGE_NAME@-python',
+setup(name='@PACKAGE_NAME@',
       version='@VERSION@',
       description='Python bindings for @PACKAGE_NAME@',
       maintainer_email='@PACKAGE_BUGREPORT@',
diff --git a/python/spec-py.c b/python/spec-py.c
index 1850a50..8224520 100644
--- rpm-4.10.91.tizen20121215.orig/python/spec-py.c
+++ rpm-4.10.91.tizen20121215/python/spec-py.c
@@ -31,10 +31,10 @@
 /* Header objects are in another module, some hoop jumping required... */
 static PyObject *makeHeader(Header h)
 {
-    PyObject *rpmmod = PyImport_ImportModuleNoBlock("rpm");
+    PyObject *rpmmod = PyImport_ImportModuleNoBlock(PYTHON_MODULENAME);
     if (rpmmod == NULL) return NULL;
 
-    PyObject *ptr = CAPSULE_BUILD(h, "rpm._C_Header");
+    PyObject *ptr = CAPSULE_BUILD(h, PYTHON_MODULENAME"._C_Header");
     PyObject *hdr = PyObject_CallMethod(rpmmod, "hdr", "(O)", ptr);
     Py_XDECREF(ptr);
     Py_XDECREF(rpmmod);
@@ -62,7 +62,7 @@ static PyGetSetDef specpkg_getseters[] = {
 
 PyTypeObject specPkg_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
-	"rpm.specpkg",			/* tp_name */
+	PYTHON_MODULENAME".specpkg",	/* tp_name */
 	sizeof(specPkgObject),		/* tp_size */
 	0,				/* tp_itemsize */
 	0, 				/* tp_dealloc */
@@ -263,7 +263,7 @@ static struct PyMethodDef spec_methods[] = {
 
 PyTypeObject spec_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
-    "rpm.spec",               /*tp_name*/
+    PYTHON_MODULENAME".spec",  /*tp_name*/
     sizeof(specObject),        /*tp_basicsize*/
     0,                         /*tp_itemsize*/
     (destructor) spec_dealloc, /*tp_dealloc*/
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Fri, 18 May 2012 18:20:15 +0300
Subject: Relocate {prefix}/lib/rpm under {libdir}/rpm

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 configure.ac |    2 +-
 rpm.am       |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index b9c4c18..187160c 100644
--- rpm-4.10.91.tizen20121215.orig/configure.ac
+++ rpm-4.10.91.tizen20121215/configure.ac
@@ -819,7 +819,7 @@ else
     usrprefix=$prefix
 fi
 
-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIR="`echo ${libdir}/rpm`"
 AC_SUBST(RPMCONFIGDIR)
 
 AC_SUBST(OBJDUMP)
diff --git a/rpm.am b/rpm.am
index d3bad87..1f2303a 100644
--- rpm-4.10.91.tizen20121215.orig/rpm.am
+++ rpm-4.10.91.tizen20121215/rpm.am
@@ -1,7 +1,7 @@
 # Internal binaries
 ## HACK: It probably should be $(libexecdir)/rpm or $(libdir)/rpm
-rpmlibexecdir = $(prefix)/lib/rpm
+rpmlibexecdir = $(libdir)/rpm
 
 # Host independent config files
 ## HACK: it probably should be $(datadir)/rpm
-rpmconfigdir = $(prefix)/lib/rpm
+rpmconfigdir = $(libdir)/rpm
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Wed, 19 Dec 2012 10:43:14 +0200
Subject: Enable building using --with-external-db

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 Makefile.am            |    2 +-
 configure.ac           |    1 +
 lib/backend/dbconfig.c |    2 ++
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d9bfc67..d2074fa 100644
--- rpm-4.10.91.tizen20121215.orig/Makefile.am
+++ rpm-4.10.91.tizen20121215/Makefile.am
@@ -175,7 +175,7 @@ dist_bin_SCRIPTS =	scripts/gendiff
 
 bin_PROGRAMS +=		rpmqpack
 rpmqpack_SOURCES =      rpmqpack.c
-rpmqpack_LDADD =        lib/librpm.la
+rpmqpack_LDADD =        lib/librpm.la @WITH_DB_LIB@
 
 rpmconfig_DATA = rpmrc
 rpmrc: $(top_srcdir)/rpmrc.in
diff --git a/configure.ac b/configure.ac
index 187160c..7792143 100644
--- rpm-4.10.91.tizen20121215.orig/configure.ac
+++ rpm-4.10.91.tizen20121215/configure.ac
@@ -359,6 +359,7 @@ yes )
   ],[
     AC_MSG_ERROR([missing required header db.h])
   ])
+  AC_DEFINE(WITH_EXTERNAL_DB, 1, [Use external db?])
   ;;
 * ) # Fall back to internal db if available
   if [ test -x db/dist/configure ]; then
diff --git a/lib/backend/dbconfig.c b/lib/backend/dbconfig.c
index fe7c01e..446be13 100644
--- rpm-4.10.91.tizen20121215.orig/lib/backend/dbconfig.c
+++ rpm-4.10.91.tizen20121215/lib/backend/dbconfig.c
@@ -71,8 +71,10 @@ static const struct poptOption rdbOptions[] = {
 	NULL, NULL },
  { "lockdbfd",	0,POPT_ARG_NONE,	&staticdbi.dbi_lockdbfd, 0,
 	NULL, NULL },
+#ifndef WITH_EXTERNAL_DB
  { "nofsync",	0,POPT_BIT_SET,		&staticdbi.dbi_oflags, DB_NOFSYNC,
 	NULL, NULL },
+#endif
 
     POPT_TABLEEND
 };
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Date: Thu, 3 Jan 2013 08:28:49 +0200
Subject: Ignore unknown tags

Might be e.g. a macro defined only in target distro. We're only
interested in a few tags i.e. name, version, release etc.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 build/parsePreamble.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 78891db..0df784d 100644
--- rpm-4.10.91.tizen20121215.orig/build/parsePreamble.c
+++ rpm-4.10.91.tizen20121215/build/parsePreamble.c
@@ -1034,16 +1034,16 @@ int parsePreamble(rpmSpec spec, int initialPackage)
 	    SKIPSPACE(linep);
 	    if (*linep != '\0') {
 		if (findPreambleTag(spec, &tag, &macro, lang)) {
-		    rpmlog(RPMLOG_ERR, _("line %d: Unknown tag: %s\n"),
+		    rpmlog(RPMLOG_INFO, _("line %d: Unknown tag: %s\n"),
 				spec->lineNum, spec->line);
-		    goto exit;
-		}
-		if (handlePreambleTag(spec, pkg, tag, macro, lang)) {
-		    goto exit;
-		}
-		if (spec->BANames && !spec->recursing) {
-		    res = PART_BUILDARCHITECTURES;
-		    goto exit;
+		} else {
+			if (handlePreambleTag(spec, pkg, tag, macro, lang)) {
+			    goto exit;
+			}
+			if (spec->BANames && !spec->recursing) {
+			    res = PART_BUILDARCHITECTURES;
+			    goto exit;
+			}
 		}
 	    }
 	    if ((rc =
