Sunday, March 13, 2022

[SOLVED] Why do src rpms differ

Issue

I have been building rpms using mock. It is a 2 step process like so.

mkdir buildsrpm
mock buildsrpm --spec myprogram-1.spec --sources myprogram-1.tar.gz --resultdir buildsrpm
mkdir rebuild
mock rebuild buildsrpm/myprogram-1.src.rpm --resultdir rebuild

The first step is building a source rpm. The second step is building an rpm.

In the process I use, I create directories to store results.

I have noticed when I run diff -qrs buildsrpm/myprogram-1.src.rpm rebuild/myprogram-1.src.rpm the result is they are different.

So my questions are:

  1. Why does mock rebuild generate a source rpm? Obviously I do not need one as I provided a source rpm as the input for the rebuild.
  2. Why are they different?
  3. If I am creating a repository is one better than the other?

Solution

Try to run it in different chroot. E.g:

mock -r fedora-23-x86_64  foo-1.0.16-1.fc22.src.rpm

And you will notice that it will create (beside binary package) foo-1.0.16-1.fc23.src.rpm. See the difference in disttag.

The resulting SRPM is build inside of the chroot using rpmbuild command from that chroot. This may or may not result in difference (try rpm -qpi on those src.rpm). Between Fedora 22 and 23 there will be likely no difference but 'Build Date' (and therefore they are binary different always). But Epel-5 and Fedora-23 will have even differences in used checksum (MD5 vs. SHA).

And if you use Mock's sign plugin then the resulting SRPM can be even signed.

To sum it up - you should rather use the rebuilt SRPM to stay on safe side. However the original SRPM will usually work as well.



Answered By - msuchy
Answer Checked By - Marilyn (WPSolving Volunteer)