Question

I am allowing the users to upload a .rpm file from my website.
I am using sudo rpm -ivh $1 --nodeps command inside a script file to extract .rpm whose name is being passed as parameter. I want to to check that the file user just uploaded and want to install is already there in the system or not and display proper message to the user before running the above command (or is there a way to check so that my script returns a value on bases of which i can take decision)..

The output of the command is
Preparing... ########################################### [100%]
package testing_rpm is already installed
It doesn't return some numeric value..

Is there a way(better way) to do that.?

Was it helpful?

Solution 2

IF you want to see the files associated with an RPM, run an rpm -qpl against it. This will give you a list of the files that the rpm has in it without trying to install it.

Here's the command run against the tomcat rpm where you can see all the files that this package will install:

example of rpm -qpl

You could also just do an rpm -q and look for "not installed":

example of -q

OTHER TIPS

See this answer.

rpm returns a non-zero exit status when one or more of the specified actions fail and thus apparently 1 if the package is already installed on your system which seems indistinguishable from failing to install one package, you have to parse the output of the rpm command. If the installation of the package(s) succeed it should return with a zero exit code 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top