Bug 496961

Summary: Unable to install packages in %post - cannot open Packages database in /var/lib/rpm
Product: [Fedora] Fedora Reporter: James Laska <jlaska>
Component: anacondaAssignee: Jeremy Katz <katzj>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 11CC: bpeck, c.shoemaker, iand, jturner, kvolny, pjones, pmatilai, rmaximo, sameer, vanmeeuwen+fedora, wwoods
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-07-21 18:31:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
anaconda-logs.tgz
none
strace rpm -q kernel
none
strace rpm -qa in chroot none

Description James Laska 2009-04-21 20:11:40 UTC
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 21:17:45 UTC
Can you strace rpm -qa after you chroot and attach the results to this bug too?  Thanks.

Comment 2 Jeremy Katz 2009-04-21 21:43:27 UTC
Also, see if 'rm -f /var/lib/rpm/__db*' before trying to install the snake package helps

Comment 3 James Laska 2009-04-22 01:02:31 UTC
Created attachment 340656 [details]
strace rpm -q kernel

Comment 4 James Laska 2009-04-22 01:04:04 UTC
(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 14:49:09 UTC
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 18:10:16 UTC
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 18:38:08 UTC
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 11:01:28 UTC
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 13:50:13 UTC
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 15:18:25 UTC
The fix is in anaconda-11.5.0.48. Preview had .47.

Comment 11 Chris Shoemaker 2009-05-27 18:49:25 UTC
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 18:54:13 UTC
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 19:06:43 UTC
*** Bug 503475 has been marked as a duplicate of this bug. ***

Comment 14 Panu Matilainen 2009-06-05 06:53:21 UTC
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>
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 14:21:10 UTC
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 15:57:39 UTC
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 18:31:30 UTC
Closing out bug that's been in MODIFIED for a while.