[Rpm-maint] Logging rpm installation logs to file

Panu Matilainen pmatilai at redhat.com
Mon Jan 7 11:48:57 UTC 2008


On Mon, 7 Jan 2008, viren.sharma at tcs.com wrote:

> Hi Panu,
>
> I've tried redirecting output using rpmtsSetScriptFd()but it is not
> working.
>
> I've done something like this:
> ****************************************
>>     FILE *fdLogFile;
>>     fdLogFile = fopen("LogFile.txt", "w");
>>     if (fdLogFile == NULL)
>>     {
>>         printf("Unable to open file LogFile.txt");
>>         return RPM_FAILURE;
>>     }
>>
> ..
> ..
>> rpmtsSetScriptFd(ts, (FD_t)&fdLogFile);
> ..
> ..
>>     fclose(fdLogFile);
>
> ****************************************
>
> On running this I am getting the following error:
>
> testRpm: ./rpmio_internal.h:525: c2f: Assertion `fd && fd->magic ==
> 0x04463138' failed.
> Aborted

FD_t is not something you can just cast to FILE, it's rpm's own io subsys 
type. Try something like this instead:

FD_t fdLogFile;
fdLogFile = Fopen("LogFile.txt", "w.fdio");
if (fdLogFile == NULL)
    ...
rpmtsSetScriptFd(ts, fdLogFile);

Fopen() and the related rpmio functions can be found in rpmio.h.

 	- Panu -



More information about the Rpm-maint mailing list