Bug 496961 - Unable to install packages in %post - cannot open Packages database in /var/lib/rpm
Unable to install packages in %post - cannot open Packages database in /var/l...
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: anaconda (Show other bugs)
11
All Linux
low Severity medium
: ---
: ---
Assigned To: Jeremy Katz
Fedora Extras Quality Assurance
:
: 503475 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-21 16:11 EDT by James Laska
Modified: 2013-09-02 02:35 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-07-21 14:31:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
anaconda-logs.tgz (20.45 KB, application/octet-stream)
2009-04-21 16:11 EDT, James Laska
no flags Details
strace rpm -q kernel (47.78 KB, text/plain)
2009-04-21 21:02 EDT, James Laska
no flags Details
strace rpm -qa in chroot (44.58 KB, text/plain)
2009-05-27 14:54 EDT, Chris Shoemaker
no flags Details

  None (edit)
Description James Laska 2009-04-21 16:11:40 EDT
Created attachment 340623 [details]
anaconda-logs.tgz

Description of problem:

Unable to install packages (with rpm or yum) in a %post script when kickstarting rawhide.  This impacts provisioning systems with beaker/rhts

Version-Release number of selected component (if applicable):
anaconda-11.5.0.46

How reproducible:
everytime

Steps to Reproduce:
1. Create a kickstart file based on /root/anaconda-ks.cfg
2. Add a %post section as follows:

%post
yum -y install snake
%end

3. Initiate kickstart install 
  
Actual results:

Installation completes but snake package not installed.  Console logs from RHTS show the following messages while attempting to install packages during %post

error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm
error: cannot open Packages database in /var/lib/rpm
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm

Expected results:

Packages requested in %post should be installed

Additional info:
 * See attached log files
-rw-r--r-- root/root     20109 2009-04-21 15:39 install.log
-rw-r--r-- root/root      3226 2009-04-21 15:39 install.log.syslog
-rw------- root/root      1607 2009-04-21 15:39 anaconda-ks.cfg
-rw------- root/root     47762 2009-04-21 15:39 var/log/anaconda.log
-rw------- root/root     30823 2009-04-21 15:39 var/log/anaconda.syslog

 * This bug was discovered during RHTS provisions
   > Failure msg - http://cobbler.pastebin.com/me3624eb
   > https://rhts.redhat.com/testlogs/55312/185599/1552497/anaconda.log
   > https://rhts.redhat.com/testlogs/55312/185599/1552497/ks.cfg

 * At the end of the install, if I chroot into /mnt/sysimage ... rpm commands fail.

    ┌────────────────────────────┤ Complete ├─────────────────────────────┐
    │                                                                     │
    │ Congratulations, your Fedora installation is complete.              │
    │                                                                     │
    │ Please reboot to use the installed system.  Note that updates may   │     
    │ be available to ensure the proper functioning of your system and    │     
    │ installation of these updates is recommended after the reboot.      │     
    │                                                                     │     
    │                             ┌────────┐                              │     
    │                             │ Reboot │                              │
    │                             └────────┘                              │
    │                                                                     │
    │                                                                     │
    └─────────────────────────────────────────────────────────────────────┘
press <ctrl>-z

Type <exit> to return to the install program.

sh-4.0# chroot /mnt/sysimage/
sh-4.0# rpm -qa
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm
error: cannot open Packages database in /var/lib/rpm
Comment 1 Chris Lumens 2009-04-21 17:17:45 EDT
Can you strace rpm -qa after you chroot and attach the results to this bug too?  Thanks.
Comment 2 Jeremy Katz 2009-04-21 17:43:27 EDT
Also, see if 'rm -f /var/lib/rpm/__db*' before trying to install the snake package helps
Comment 3 James Laska 2009-04-21 21:02:31 EDT
Created attachment 340656 [details]
strace rpm -q kernel
Comment 4 James Laska 2009-04-21 21:04:04 EDT
(In reply to comment #2)
> Also, see if 'rm -f /var/lib/rpm/__db*' before trying to install the snake
> package helps  

That seems to resolve the issue.  So what does this mean?

sh-4.0# chroot /mnt/sysimage /bin/su -

[root@i386-70 ~]# rpm -q kernel
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm
error: cannot open Packages database in /var/lib/rpm

[root@i386-70 ~]# rm -f /var/lib/rpm/__db.00*

[root@i386-70 ~]# rpm -q kernel
kernel-2.6.29.1-100.fc11.x86_64
Comment 5 Jeremy Katz 2009-04-22 10:49:09 EDT
It means that the different rpmdb flags we use from outside the chroot are making the environment incompatible.  On a reboot, they'd get wiped but that won't help here

Can you see if updates=http://katzj.fedorapeople.org/updates.cgz helps?
Comment 6 James Laska 2009-04-22 14:10:16 EDT
Using the provided updates.img yields ...

Running anaconda 11.5.0.46, the Fedora system installer - please wait...       
Traceback (most recent call last):
  File "/usr/bin/anaconda", line 551, in <module>
    import dispatch
  File "/usr/lib/anaconda/dispatch.py", line 26, in <module>
    from packages import writeKSConfiguration, turnOnFilesystems
  File "/tmp/updates/packages.py", line 29, in <module>
    import timer
ImportError: No module named timer
install exited abnormally [1/1] 
disabling swap...
unmounting filesystems...
Comment 7 Jeremy Katz 2009-04-22 14:38:08 EDT
Doh, that's because I gave you the wrong url.  Suspiciously close and one that exists, but long different :)

http://katzj.fedorapeople.org/updates.img ought to work better
Comment 8 James Laska 2009-04-23 07:01:28 EDT
Using the provided updates.img works.

sh-4.0# chroot /mnt/sysimage /bin/su -
[root@i386-70 ~]# rpm -q kernel
kernel-2.6.29.1-102.fc11.x86_64

Is this something we can target for F-11-Preview?  This impacts RHTS/beaker automation of Fedora.
Comment 9 Jeremy Katz 2009-04-23 09:50:13 EDT
I've pushed the fix to git.  Not sure where things are in the compose process to know if we can get in another build.  jkeating should know and then just ask in #anaconda if we need to get a build done
Comment 10 Will Woods 2009-04-29 11:18:25 EDT
The fix is in anaconda-11.5.0.48. Preview had .47.
Comment 11 Chris Shoemaker 2009-05-27 14:49:25 EDT
I just saw this again with anaconda-11.5.0.54-1.fc11.x86_64.  Is it possible this bug came back?

I'm doing the same thing - running rpm as the first thing in a %post.
Comment 12 Chris Shoemaker 2009-05-27 14:54:13 EDT
Created attachment 345663 [details]
strace rpm -qa in chroot

Here's an strace of rpm -qa inside the chroot.
Comment 13 seth vidal 2009-06-04 15:06:43 EDT
*** Bug 503475 has been marked as a duplicate of this bug. ***
Comment 14 Panu Matilainen 2009-06-05 02:53:21 EDT
Hum... from the strace in c#12:
open("/var/tmp/imgcreate-OnSfl_/install_root/var/lib/rpm/Packages", O_RDONLY) = -1 ENOENT (No such file or directory)

AFAICT that's a leftover by livecd-tools, you certainly dont want the db environment in images. This is supposedly already taken care of:

commit c80a302bda3cc1fc55fac088613bbaa86467fe86
Author: Jeremy Katz <katzj@redhat.com>
Date:   Fri Oct 10 10:18:19 2008 -0400

    Clean up rpmdb locks after installing packages also
    
    With new versions of RPM, people can otherwise run into things they don't
    expect inside of their %post scripts.  So make things simpler for them

...but maybe something has changed since then.
Comment 15 Bug Zapper 2009-06-09 10:21:10 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 16 Karel Volný 2009-06-11 11:57:39 EDT
btw, I experienced this too - something broke during installation under qemu, so I tried rescue mode of the installer, and I have found that rpm is not installed, so that I used the one provided by the installer ... after installing rpm and chrooting into /mnt/sysimage, I got the same error ... comment #2 helped
Comment 17 Jeremy Katz 2009-07-21 14:31:30 EDT
Closing out bug that's been in MODIFIED for a while.

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