Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
01-17-2004, 09:39 PM
|
#1
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Rep:
|
writing a RPM management application
Hi, guys!
Can anybody give me a little help here?
I want to write a small rpm management application. I installed rpm-devel rpm in my mandrake system. I have the .h files right there.... however, where do I find documentation about the RPM API?
I've being looking around, but found nothing useful.
Any ideas?
|
|
|
01-18-2004, 08:05 AM
|
#2
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
|
|
|
01-18-2004, 04:49 PM
|
#3
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
Well, I took a look at that... it's anything BUT comprehensive.
Is there a guide to start one application? I liked this much better: http://linux.tnc.edu.tw/techdoc/maxi...k/node503.html
However, I'm writing the example # 1 and I'm getting compiler errors (undefined stuff and so on).
I'd like to download one single compressed file to be able to study everything without being on-line... is there anything like that?
And last, but not least.. thanks Hko!
|
|
|
01-18-2004, 06:43 PM
|
#4
|
Member
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569
Rep:
|
|
|
|
01-18-2004, 11:15 PM
|
#5
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
I'll take a look at that... seems like the information provided by the link I suplied..... it's just that I only download a single page with the whole stuff in this new link.... Thanx, man!
|
|
|
01-19-2004, 12:52 PM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
I'm trying example # 2.
I commented a section of the code because the variables weren't defined:
/*printf("The database path is: %s\n",
rpmGetVar(RPMVAR_DBPATH) ? rpmGetVar(RPM_DBPATH) : "(none)");
rpmReadConfigFiles(NULL, NULL, NULL, 0);
printf("The database path is: %s\n",
rpmGetVar(RPMVAR_DBPATH) ? rpmGetVar(RPM_DBPATH) : "(none)");*/
After that, it went a fine... however (there's always a however)
When I try to buid I get error messages (linker related).. here I go:
[antoranz@galileo src]$ gcc rpm2.c -o rpm2 -lrpm
rpm2.c: In function `main':
rpm2.c:69: warning: assignment makes pointer from integer without a cast
/home/antoranz/tmp/ccNOHRFg.o(.text+0x61): In function `main':
: undefined reference to `rpmdbFirstRecNum'
/home/antoranz/tmp/ccNOHRFg.o(.text+0x80): In function `main':
: undefined reference to `rpmdbGetRecord'
/home/antoranz/tmp/ccNOHRFg.o(.text+0x117): In function `main':
: undefined reference to `rpmdbNextRecNum'
collect2: ld returned 1 exit status
Any ideas now? What library should I recall?
|
|
|
01-19-2004, 02:26 PM
|
#7
|
LQ Newbie
Registered: Jan 2004
Posts: 5
Rep:
|
I recall this happening on gentoo. Maybe the libarys are corrupted?
|
|
|
01-19-2004, 02:40 PM
|
#8
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
Man·... I just registered to the rpm-devel mail list... as soon as I get info, I'll be posting it here, OK?
|
|
|
01-19-2004, 04:50 PM
|
#9
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
Update:
I opened a different thread ( http://www.linuxquestions.org/questi...hreadid=136460) because the problem is getting more specific. I found out (by trial aand error) that the documentation where the examples are is (seemingly) not up-to-date. For example:
int rpmReadConfigFiles(char * file, char * arch, char * os, int building) seems to be deprecated.... so I had to check in rpm/rpmlib.h and found this:
int rpmReadConfigFiles(/*@null@*/ const char * file, /*@null@*/ const char * target)
Thererore, the code is now: rpmReadConfigFiles(NULL, NULL);
It works just fine like that.
i was able to open the database.
However, when i try to use the database traversion functions, I get this message:
gcc rpm4.c -o rpm4 -lrpm
rpm4.c: In function `main':
rpm4.c:32: warning: assignment makes pointer from integer without a cast
/home/antoranz/tmp/cctmhgcw.o(.text+0x91): In function `main':
: undefined reference to `rpmdbFirstRecNum'
/home/antoranz/tmp/cctmhgcw.o(.text+0xad): In function `main':
: undefined reference to `rpmdbGetRecord'
/home/antoranz/tmp/cctmhgcw.o(.text+0xc1): In function `main':
: undefined reference to `rpmdbGetNextRecNum'
collect2: ld returned 1 exit status
which is very similar to the messages I was getting earlier.... but at least i think I'm closer to the "Problem"... maybe just a couple of inches.
What do you think?
Last edited by eantoranz; 01-19-2004 at 04:52 PM.
|
|
|
01-21-2004, 12:11 AM
|
#10
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
Guys.. I just founf out that the RPM API apapently doesn't support rpmdbFirstRecNum, rpmdbGetRecord, rpmdbGetNextErcNum since RPM 4.0 .... but one has to implement Iterators instead. Take a look here:
http://www.rpm.org/rpmapi-4.1/group__rpmdb.html#a18
|
|
|
01-21-2004, 01:18 AM
|
#11
|
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Original Poster
Rep:
|
After having spent some hours moving back and forth... here is the code:
#include <fcntl.h>
#include <rpm/rpmlib.h>
int main(int argc, char ** argv) {
rpmdb * pdb;
rpmReadConfigFiles(NULL, NULL);
printf("Config files read\n");
int dbStatus = rpmdbOpen("", &pdb, O_RDONLY, 0644);
if (dbStatus) {
// error opening
printf("Error on opening RPM Database: (%d) %s\n", rpmErrorCode(), rpmErrorString());
exit;
} else {
printf("RPM Database opened!\n");
}
rpmdbMatchIterator mi = rpmdbInitIterator(pdb, RPMDBI_PACKAGES, NULL, 0);
printf("Iterator initialized!\n");
Header header;
HeaderIterator hi;
int_32 type, count;
char * name;
while (header = rpmdbNextIterator(mi)) {
headerGetEntry(header, RPMTAG_NAME, &type, (void **) &name, &count);
printf("%s\n", strdup(name));
}
printf("Finished Iteration!\n");
rpmdbFreeIterator(mi);
printf("Iterator Finished!\n");
rpmdbClose(pdb);
printf("RPM Database closed!\n");
}
Now I have to figure out what I did.
Have fun!
|
|
|
All times are GMT -5. The time now is 06:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|