Bug 1016148 - yum localinstall throws: ValueError: <any rpm> has no attribute basepath
yum localinstall throws: ValueError: <any rpm> has no attribute basepath
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: yum (Show other bugs)
6.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Valentina Mukhamedzhanova
Marek Marusic
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-07 11:32 EDT by Michal Karm Babacek
Modified: 2015-07-22 03:21 EDT (History)
6 users (show)

See Also:
Fixed In Version: yum-3.2.29-61.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-07-22 03:21:07 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michal Karm Babacek 2013-10-07 11:32:14 EDT
Dearest,
we managed to get a fresh RHEL 6.4 box to a state, when any attempt to localinstall fails with:
 
    ValueError: your.rpm has no attribute basepath

For instance,

    yum localinstall ~/rpm/* --disablerepo=beaker-*

results in: http://pastebin.com/v1LLWyQh


The events preceding this state consisted purely of registering to RHN channels, doing yum groupinstall, remove, update, install. No manual configuration of yum whatsoever. I will share the exact log internally.

THX 4 any info
Comment 3 Zdeněk Pavlas 2013-10-08 07:18:01 EDT
While I have no idea where yum-checksum plugin comes from (it's neither from "yum" or "yum-utils"), it very likely just treats YumLocalPackage instances as YumAvailablePackage instances. The following patch should fix this issue on Yum side.

diff --git a/yum/packages.py b/yum/packages.py
index deb44e4..042a50b 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -1333,6 +1333,9 @@ def _rpm_long_size_hack(hdr, size):
 # which are actual rpms.
 class YumHeaderPackage(YumAvailablePackage):
     """Package object built from an rpm header"""
+
+    remote_url = '<local>'
+
     def __init__(self, repo, hdr):
         """hand in an rpm header, we'll assume it's installed and query from there"""
Comment 4 Aleksandar Kostadinov 2013-10-08 09:31:32 EDT
Zdeněk, this is a plug-in to help us verify our RPMs are what we actually expect them to be.

Here is the plug-in source:
https://svn.devel.redhat.com/repos/jboss-qa/beaker/trunk/eap/6.2/yum_checksum.py

I'm not an expert, this is first thing I write in python and first thing I write for yum. So please let me know if something is wrong. It just logs the sha1 of every installed package through yum.

Thank you!
Comment 5 Zdeněk Pavlas 2013-10-08 09:50:08 EDT
Np, the plugin code seems correct, it just does not handle local packages. pkg.remote_url is probably the only problem there. My patch from comment 3 should work this around.  Alternatively, you can fix the plugin with something like:

--- yum_checksum.py.orig	2013-10-08 15:43:05.592878389 +0200
+++ yum_checksum.py	2013-10-08 15:45:57.386388083 +0200
@@ -52,6 +52,10 @@
       for pkg in conduit.getDownloadPackages():
          # see remote_url() and checksum()
          fname = pkg.localPkg()
-         log.write('%s %s %s %s %s\n' % (hashfile(fname), fname, pkg.name, pkg.checksum, pkg.remote_url))
+         if getattr(pkg, 'pkgtype', None) == 'local':
+             url = '<local package at %s>' % fname
+         else:
+             url = pkg.remote_url
+         log.write('%s %s %s %s %s\n' % (hashfile(fname), fname, pkg.name, pkg.checksum, url))
    finally:
       log.close()
Comment 6 Aleksandar Kostadinov 2013-10-08 10:17:23 EDT
Zdeněk, thank you for the advice. 

I see value in your patch to packages.py because the fact that a package is local does not mean it should not have an URL defined as well it's easier to code plug-ins wen attributes are always there.

Do you think your patch will go upstream or should I use the method you suggest above to fix for yum_checksum only?

btw I think it will be most straightforward to have packages.py like:
>    remote_url = 'file://' + urllib.pathname2url(os.path.abspath(pkg.localPkg()))

because otherwise url would not really be an url and next time I decide to write some weird plugin incarnation of non-sense it may break again..
WDYT?
Comment 7 Zdeněk Pavlas 2013-10-08 11:45:18 EDT
If you need to track the package source, then file:// URL would certainly help. I was just trying to return a dummy string instead.

http://lists.baseurl.org/pipermail/yum-devel/2013-October/010387.html
Comment 8 Zdeněk Pavlas 2013-10-09 06:27:36 EDT
Merged upstream. http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=da3b4624
Comment 9 RHEL Product and Program Management 2013-10-13 19:03:27 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.
Comment 10 Aleksandar Kostadinov 2013-10-16 09:05:21 EDT
Zdeněk, I tried your suggested patch but it fails badly for me:
>     if getattr(pkg, 'pkgtype', None) == 'local':
>  File "/usr/lib/python2.6/site-packages/yum/sqlitesack.py", line 270, in __getattr__
>    raise KeyError, str(e)
> KeyError: 'no such column: pkgtype'

This is RHEL6 but I need it working on RHEL5 as well. Since your other patch will not be backported to RHEL at least for the time being, I thought it's better to have a fix locally.
Comment 11 Aleksandar Kostadinov 2013-10-16 09:06:00 EDT
Forgot to say I'm seeing the error trying to install a package from remote repo.
Comment 12 Zdeněk Pavlas 2013-10-16 09:31:44 EDT
Sorry, was too quick writing this. Try to replace the above with:

- if getattr(pkg, 'pkgtype', None) == 'local':
+ if hasattr(pkg, 'pkgtype') and po.pkgtype == 'local':

Usually these are equivalent, but sqlitesack overrides __getattr__ ..
Comment 13 Aleksandar Kostadinov 2013-10-16 09:39:32 EDT
Thank you!
Comment 14 Zdeněk Pavlas 2013-10-16 10:39:16 EDT
+ if hasattr(pkg, 'pkgtype') and pkg.pkgtype == 'local':

..to fix the obvious copy-paste error.
Comment 15 Michal Karm Babacek 2014-11-06 09:19:02 EST
Guys? Ain't we gonna close this one or something? :-)
Comment 16 Jan Zeleny 2014-11-07 02:46:50 EST
Not yet. It seems simple enough, I'm proposing this to be fixed in RHEL 6.7 ...
Comment 19 Valentina Mukhamedzhanova 2014-12-09 05:53:17 EST
Patch to backport - comment 8.
Comment 23 errata-xmlrpc 2015-07-22 03:21:07 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1384.html

Note You need to log in before you can comment on or make changes to this bug.