Automatically install build dependencies prior to building an RPM package
Solution 1:
You can use the yum-builddep
command from the yum-utils
package to install all the build dependencies for a package.
The arguments can either be paths to spec files, paths to source RPMs or the names of packages which exist as source RPMs in a configured repository, for example:
yum-builddep my-package.spec
or
yum-builddep my-package.src.rpm
The same thing can be achieved on newer versions of Fedora that use dnf
as their package manager by making sure that dnf-plugins-core
is installed and then doing:
dnf builddep my-package.spec
or
dnf builddep my-package.src.rpm
Solution 2:
yum-builddep
doesn't seem to work if the mirror you use doesn't serve source RPMs. This may not handle all cases, but it usually works for me:
sudo yum install -y $(<rpmbuild> | fgrep 'is needed by' | awk '{print $1}')
where <rpmbuild>
is your rpmbuild
command (e.g., rpmbuild -ba foo.spec
).