My program is basically a C-based MySQL server, it needs gcc, mysql-server, mysql-devel in order to run successfully.
Now I have to pack the program into RPM package, and it should be able to auto install the dependencies so that the RPM package can be installed on a clean RHEL machine, and the program can run instantly after the installation.
Problem is if I write the below script in SPEC file %pre section, it gets stuck during "transaction".
sudo yum groupinstall "Development Tools" -y
sudo yum install mysql-server mysql-client -y
It seems you can't use another rpm installation tool in SPEC file.
How do I do this?
You can't do it directly, you cannot install another RPM from within your RPM spec file.
The normal way, which you should follow, is to make your RPM depends on the other RPMs it needs, e.g. by adding this to your .spec file:
Requires: gcc, mysql-server, mysql-devel
When you then try to install your rpm with the rpm command:
rpm -ivh yourrpm-1.0.0.rpm
it will fail and tell you which packages to install, and you have to install those packages manually first.
Or you can use yum to install your rpm file:
yum install ./yourrpm.1.0.0.rpm
and yum will download and install the required dependencies before it installs your RPM package.