From eb2438d595b8ab3d6d059253779643df9be84acf Mon Sep 17 00:00:00 2001 From: xq2005 Date: Tue, 11 Dec 2012 13:42:01 +0000 Subject: [PATCH] rebuild the rpm db for stateless genimage in cross distro scenario git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14617 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/netboot/rh/genimage | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index e404ab895..52528291e 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -406,6 +406,29 @@ unless ($onlyinitrd) { postscripts(); #run 'postscripts' } +#get the rpm version, if the rpm version is different then the db verison may change. +my $mnrpmver = `rpm --version | awk '{print \$3}'`; +my $cnrpmver = `chroot $rootimg_dir rpm --version | awk '{print \$3}'`; +if ( $mnrpmver ne $cnrpmver ){ + #fine all db file witch should be rebuided + my $filelist = `file $rootimg_dir/var/lib/rpm/* | grep 'Berkeley DB' | awk -F : '{print \$1}'`; + + my @files = split '\n', $filelist; + + system("rm -rf $rootimg_dir/var/lib/rpm/__db*"); + foreach my $file ( @files ){ + my $filename = basename($file); + #dump the db file to a normal test file with the db_dump on the mn + system("db_dump $file > $rootimg_dir/tmp/$filename.dbtmp9"); + unlink("$rootimg_dir/var/lib/rpm/$filename"); + #chroot to the rootimage and run db_load + system(" chroot $rootimg_dir db_load -f /tmp/$filename.dbtmp9 /var/lib/rpm/$filename"); + } + system("rm -rf $rootimg_dir/tmp/*.dbtmp9"); + #rebuild rpm db file in rootimage for cn + system(" chroot $rootimg_dir rpm --rebuilddb"); +} + # Default to the first kernel found in the install image if nothing specified explicitly. # A more accurate guess than whatever the image build server happens to be running # If specified, that takes precedence.