]> code.ossystems Code Review - openembedded-core.git/commitdiff
package_rpm: Add capability to directly query packageorigin
authorMark Hatle <mark.hatle@windriver.com>
Mon, 11 Jun 2012 18:18:55 +0000 (13:18 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 12 Jun 2012 10:05:53 +0000 (11:05 +0100)
Add functionality to RPM to directly query the packageorigin (path) from
the resolver database, instead of having to do this via an indirect method.

This results in a minor performance improvement.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/package_rpm.bbclass
meta/recipes-devtools/rpm/rpm/rpm-packageorigin.patch [new file with mode: 0644]
meta/recipes-devtools/rpm/rpm_5.4.9.bb

index 35928abb9168587e60634f397890ad12eab5b746..097fa1227a9b39d221dfc4a550fb4f9fe66a7bca 100644 (file)
@@ -130,12 +130,12 @@ resolve_package_rpm () {
        shift
        local pkg_name=""
        for solve in `cat ${conffile}`; do
-               pkg_name=$(${RPM} -D "_dbpath $solve" -D "__dbi_txn create nofsync" -q --yaml $@ | grep -i 'Packageorigin' | cut -d : -f 2)
-               if [ -n "$pkg_name" ]; then
+               pkg_name=$(${RPM} -D "_dbpath $solve" -D "__dbi_txn create nofsync" -q --qf "%{packageorigin}\n" "$@" | grep -v "is not installed" || true)
+               if [ -n "$pkg_name" -a "$pkg_name" != "(none)" ]; then
+                       echo $pkg_name
                        break;
                fi
        done
-       echo $pkg_name
 }
 
 # rpm common command and options
@@ -401,9 +401,9 @@ package_install_internal_rpm () {
 
        # Now that we have a solution, pull out a list of what to install...
        echo "Manifest: ${target_rootfs}/install/install.manifest"
-       ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --yaml \
+       ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --qf "%{packageorigin}\n" \
                -D "__dbi_txn create nofsync private" \
-               | grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/install_solution.manifest
+               > ${target_rootfs}/install/install_solution.manifest
 
        touch ${target_rootfs}/install/install_multilib_solution.manifest
 
@@ -421,9 +421,9 @@ package_install_internal_rpm () {
 
                # Now that we have a solution, pull out a list of what to install...
                echo "Manifest: ${target_rootfs}/install/install_multilib.manifest"
-               ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --yaml \
+               ${RPM} -D "_dbpath ${target_rootfs}/install" -qa --qf "%{packageorigin}\n" \
                        -D "__dbi_txn create nofsync private" \
-                       | grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/install_multilib_solution.manifest
+                       > ${target_rootfs}/install/install_multilib_solution.manifest
 
        fi
 
@@ -478,9 +478,9 @@ EOF
                        -U --justdb --noscripts --notriggers --noparentdirs --nolinktos --ignoresize \
                        ${target_rootfs}/install/initial_install.manifest
 
-               ${RPM} -D "_dbpath ${target_rootfs}/initial" -qa --yaml \
+               ${RPM} -D "_dbpath ${target_rootfs}/initial" -qa --qf "%{packageorigin}\n" \
                        -D "__dbi_txn create nofsync private" \
-                       | grep -i 'Packageorigin' | cut -d : -f 2 > ${target_rootfs}/install/initial_solution.manifest
+                       > ${target_rootfs}/install/initial_solution.manifest
 
                rpm_update_pkg ${target_rootfs}/install/initial_solution.manifest
                
diff --git a/meta/recipes-devtools/rpm/rpm/rpm-packageorigin.patch b/meta/recipes-devtools/rpm/rpm/rpm-packageorigin.patch
new file mode 100644 (file)
index 0000000..3c6dad4
--- /dev/null
@@ -0,0 +1,23 @@
+Add the ability to query the packageorigin
+
+Written by jbj at rpm5.org
+
+Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
+
+Index: rpm-5.4.8/rpmdb/hdrfmt.c
+===================================================================
+--- rpm-5.4.8.orig/rpmdb/hdrfmt.c
++++ rpm-5.4.8/rpmdb/hdrfmt.c
+@@ -2403,8 +2403,10 @@ static int pkgoriginTag(Header h, HE_t 
+     int rc = 1;
+     he->tag = RPMTAG_PACKAGEORIGIN;
+-    if (!headerGet(h, he, HEADERGET_NOEXTENSION)
+-     && (origin = headerGetOrigin(h)) != NULL)
++    /* XXX two sources for tag data: what search precedence? */
++    if (headerGet(h, he, HEADERGET_NOEXTENSION))
++      rc = 0;
++    else if ((origin = headerGetOrigin(h)) != NULL)
+     {
+       he->t = RPM_STRING_TYPE;
+       he->p.str = xstrdup(origin);
index 2ca0f58ff0ff6c8c93f0030a8ea5cb5be9b046b1..a38a684ff43fe0eb480bd15c41406a35c90717c7 100644 (file)
@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1"
 LIC_FILES_CHKSUM = "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1"
 
 DEPENDS = "libpcre attr acl popt ossp-uuid file"
-PR = "r41"
+PR = "r42"
 
 # rpm2cpio is a shell script, which is part of the rpm src.rpm.  It is needed
 # in order to extract the distribution SRPM into a format we can extract...
@@ -70,6 +70,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex
           file://rpm-macros.patch \
           file://rpm-lua.patch \
           file://rpm-ossp-uuid.patch \
+          file://rpm-packageorigin.patch \
          "
 
 SRC_URI[md5sum] = "60d56ace884340c1b3fcac6a1d58e768"