How to find the installed version of a rpm package in a system??
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to find the installed version of a rpm package in a system??
Hi Experts,
I am a newbie in linux. For my project i need to find out the installed version of a rpm package from the rpmdb. This i need to do with C codes. Can anybody throw some light about this to help me out???
Looks like a good homework exercize - write a C program to check the installed version of an rpm package.
You understand how to find the version with the rpm command right?
There are actually several ways to do this in C. You can consider how the rpms are stored and where the version information lives, then you will realize how to access it ... or you can see how to execute another program from within C and just get it to run rpm.
You understand how to find the version with the rpm command right?
Yes, i know i can check out by the command rpm -qa.
Quote:
Originally Posted by Simon Bridge
There are actually several ways to do this in C. You can consider how the rpms are stored and where the version information lives, then you will realize how to access it ... or you can see how to execute another program from within C and just get it to run rpm.
I don't have sufficient knowledge about handling rpmdb. Maybe if i can find out the list of all the installed packages, and then checking with the desired rpm name (say for e.g. libsecurity) if any installed rpm name matches with it, then that will be the desired output.Please confirm me.
If i am correct in my approach then can you plz tell me how to check from the rpmdb, the list of all the installed package?
Using the rpm lib should give a more elegant solution, and you can always get hints by examining the source code for the rpm utility. You do know you can get the source right? However, the exact solution you choose should be appropriate to your course ... maybe your teacher wants to see if you can figure out how to execute an external program from within your own? You havn't confirmed this is homework but notice that everyone is replying on that assumption. Without the context, it is hard to pick the proper method for you.
This is not a school homework. :P Due to some restrictions i can not use rpm binaries in my codes, rather i have to use the rpmlib version 5.6 APIs. So i wud be grateful to you if u can mention here, what are the APIs i can use to find the list of all installed package, which are stored in rpmdb...
You have already been given a link to the rpmlib functions and specification - that is all the api anyone usually needs. What? You want us to write the actual code for you? We have already provided example code. Perhaps I should send you a schedule of my fees?
I don't understand what restrictions, other than homework, would prevent you from calling the rpm binary from within a C wrapper. As observed, this would be the usual way and it is one of the things it is designed for. Without the specifics of what you are doing, nobody can produce code any better suited to you than the examples already given to you.
(Note: linux does not, iirc, have a formal api - it does not need one: you have the entire source code.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.