Bug 980502

Summary: libguestfs is not able to be built with yum cache from multiple repos
Product: Red Hat Enterprise Linux 6 Reporter: Tomas Tomecek <ttomecek>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: bfan, kdudka, leiwang, lkong, ttomecek, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.20.9-7.el6 Doc Type: Bug Fix
Doc Text:
(This is a build-time problem, and does not need to be documented)
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 04:45:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomas Tomecek 2013-07-02 14:23:11 UTC
If yum cache at /var/cache/yum contains packages from multiple repos and there are duplicate rpms, build fails:

cp: will not overwrite just-created `repo/file-devel-5.04-15.el6.x86_64.rpm' with `/var/cache/yum/build-released/packages/file-devel-5.04-15.el6.x86_64.rpm'

Unfortunately this is happening quite often when we try to run static analysis scans on this package in mock chroot environment. We have to modify SRPM to scan it properly.

Slight modification was working for me fine (cp won't mind overwrite now):
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -649,7 +649,9 @@ if ping -c 3 -w 20 8.8.8.8 && wget http://libguestfs.org -O /dev/null; then
   extra=
 else
   mkdir repo
-  find /var/cache/yum -type f -name '*.rpm' -print0 | xargs -0 cp -t repo
+  for package in $(find /var/cache/yum -type f -name '*.rpm') ; do
+   cp $package repo ;
+  done
   createrepo repo
   cat > yum.conf <<EOF
 [main]


RPMs we had problem with:
  libguestfs-1.16.34-2.el6
  libguestfs-1.20.9-6.el6

Comment 2 Richard W.M. Jones 2013-07-02 15:09:53 UTC
Cheers, yes this is a bug and I'll include this shortly.

Comment 3 Richard W.M. Jones 2013-07-03 14:58:28 UTC
I fixed this in a slightly different way:

--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -548,7 +548,8 @@ if ping -c 3 -w 20 8.8.8.8 && wget http://libguestfs.org -O /dev/null; then
   extra=
 else
   mkdir repo
-  find /var/cache/yum -type f -name '*.rpm' -print0 | xargs -0 cp -t repo
+  # -n 1 because of RHBZ#980502.
+  find /var/cache/yum -type f -name '*.rpm' -print0 | xargs -0 -n 1 cp -t repo
   createrepo repo
   cat > yum.conf <<EOF
 [main]

Comment 4 Tomas Tomecek 2013-07-04 12:05:36 UTC
Well, your fix is much more secure than mine. I verified it and it works very well. Thank you.

Comment 5 bfan 2013-07-30 05:55:28 UTC
Hello Tomas, 
May I know you verified this bug with developer's patch or a new build package?

If only using patch, could you please help us to verify it with libguestfs-1.20.9-7.el6, thanks

Comment 6 Tomas Tomecek 2013-07-30 08:57:36 UTC
(In reply to bfan from comment #5)
> Hello Tomas, 
> May I know you verified this bug with developer's patch or a new build
> package?
> 
> If only using patch, could you please help us to verify it with
> libguestfs-1.20.9-7.el6, thanks

I've just rebuilt it (with multiple yum repos enabled) and it passed.

This was the problematic part (no errors or even warnings anymore):

+ mkdir repo
+ find /var/cache/yum -type f -name '*.rpm' -print0
+ xargs -0 -n 1 cp -t repo 

So, I can verify that the bug is fixed.

Comment 9 Lingfei Kong 2013-10-21 05:41:37 UTC
Hello Tomas, 
As I see, this bug occurred when build the libguestfs package, I spent time to read libguestfs.spec and try to build the package,but failed.  It would be easier for you to build the libguestfs package than me, so could you help to reproduce and verify this bug with the latest version of libguestfs: libguestfs-1.20.11-2.el6 ?

Thanks & Best regards

Comment 10 Lingfei Kong 2013-10-21 05:56:37 UTC
Hello Tomas, 
As I see, this bug occurred when build the libguestfs package, I spent time to read libguestfs.spec and try to build the package,but failed.  It would be easier for you to build the libguestfs package than me, so could you help to reproduce and verify this bug with the latest version of libguestfs: libguestfs-1.20.11-2.el6 ?

Thanks & Best regards

Comment 13 Lingfei Kong 2013-10-22 00:37:41 UTC
Hello Tomas,
Thanks for your help. Also, I checked libguestfs.spec of libguestfs-1.20.11-2.el6, it have been changed like Comment 3. So, this bug is fixed.

Comment 15 errata-xmlrpc 2013-11-21 04:45:44 UTC
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.

http://rhn.redhat.com/errata/RHSA-2013-1536.html