RPM API to install rpms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I am trying to install rpms using rpminstall() API and rpmAddInstallElement() method. I want to relocate my rpm installation to a different location, but its not working.
Here is what i am doing:
Using rpminstall() API:
 
int main()
{
ts = rpmtsCreate();
rpmtsSetRootDir(ts, NULL);
add_for_install(ts, optarg, upgrade);
tsi = rpmtsiInit(ts);
rc = rpmtsCheck(ts);
probs = rpmtsProblems(ts);
if (rc || probs->numProblems > 0) {
rpmpsPrint(fp, probs); // trying to redirect install logs to a file
while(fgets(buf,128,fp))
{
data.append(buf);
}
 
rpmpsFree(probs);
rpmtsFree(ts);
exit(rc);
}
/* Create ordering for the transaction */
rc = rpmtsOrder(ts);
if (rc > 0) {
printf("Ordering failed\n");
rpmtsFree(ts);
exit(rc);
}
rpmtsClean(ts);
/* Set callback routine & flags, for example -vh */
notifyFlags |= INSTALL_LABEL | INSTALL_HASH;
rpmtsSetNotifyCallback(ts, rpmShowProgress, (void *)notifyFlags);
/* Set transaction flags and run the actual transaction */
rpmtsSetFlags(ts, (rpmtransFlags)(rpmtsFlags(ts) | tsFlags));
rc = rpmtsRun(ts, NULL, (rpmprobFilterFlags)probFilter);
/* Check for results .. */
if (rc || probs->numProblems > 0)
rpmpsPrint(fp, probs);
while(fgets(buf,128,fp))
{
data.append(buf);  // trying to redirect logs to a file
}
rpmpsFree(probs);
rpmtsFree(ts);
exit(rc);
}
 
 
int add_for_install(rpmts ts, char *file, int upgrade)
{
FD_t fd;
Header hdr;
int rc = 0;
rpmRelocation * relocs;
relocs = (rpmRelocation *)malloc(2*sizeof(rpmRelocation));
relocs->oldPath = "/opt/";
relocs->newPath = "/mnt/tmp"; // trying to relocate installation to a diff directory
/* Read package header */
fd = Fopen(file, "r.ufdio");
if (fd == NULL) {
printf("Unable to open file %s\n", file);
return 1;
}
 
rc = rpmReadPackageFile(ts, fd, file, &hdr);
if (rc != RPMRC_OK) {
printf("Unable to read package %s\n", file);
return rc;
}
/* Add it to the transaction set */
rc = rpmtsAddInstallElement(ts, hdr, file, upgrade,relocs);
 
if (rc) {
printf("Error adding %s to transaction\n", file);
goto out;
}
out:
headerFree(hdr);
Fclose(fd);
return rc;
}
 
I dont understand why the installation is not happening into a different directory.Can any one guide please.
 
Thanks,
Shruthi 


Bollywood news, movie reviews, film trailers and more! Click here.
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux