Re: rpmInstallPackage woes

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

 




On Dec 9, 2006, at 4:28 AM, R. Tyler Ballance wrote:

I've noticed a tendency of my installation code to every now and again crash. Fun.

When it doesn't crash, I get error messages like this (my own messages prefixed by ====>)

====> Installing package: data/openssh-4.1p1-10.9.i586.rpm
Instaling package located: data/openssh-4.1p1-10.9.i586.rpm
error: File not found by glob:
error: File not found by glob:
error: File not found by glob:
error: open of ? failed: No such file or directory
error: error reading from file data/openssh-4.1p1-10.9.i586.rpm
Unable to properly install package!


I can't quite figure it out, but the glob thing is something that I'll see in the crash stack trace (sporadically). The code used to install these packages is included below, it seems that every 1 out of 5 tries, depending on whether or not I am demonstrating the software to a client, boss, or other person with authority ;)


Cheers

int installPackage(char *path)
{
        fprintf(stderr, "Instaling package located: %s\n", path);

        char *files[] = { path };

This line needs to be
	    char *files[] = { path, NULL };

argv arrays are terminated with NULL.

So your program is wandering off the end-of the array.

For any path arg (and you program wandering found many ;-) that
could not be opened as a *.rpm package,  rpmInstall() globs the arg,
inserts into the argv array, and attempts to read as a manifest (i.e. a
list of packages.

        rpmts transaction;

struct rpmInstallArguments_s *rpmargs = malloc(sizeof (struct rpmInstallArguments_s));
        bzero(rpmargs, sizeof(struct rpmInstallArguments_s));
rpmargs->installInterfaceFlags = INSTALL_INSTALL | INSTALL_HASH;

        int ret = rpmReadConfigFiles(NULL, NULL);

        if (ret != RPMRC_OK)
        {
fprintf(stderr, "Unable to read the RPM configuration!\n");
                goto failure;
        }

        transaction = rpmtsCreate();
ret = rpmInstall(transaction, rpmargs, (const char **) (files));

        if (ret != 0)
        {
fprintf(stderr, "Unable to properly install package! \n");
                goto failure;
        }

        transaction = rpmtsFree(transaction);
        free(rpmargs);
        return QUERY_SUCCESS;

failure:
        transaction = rpmtsFree(transaction);
        free(rpmargs);
        return QUERY_FAILURE;
}


To see the behavior, assuming you have a foo*.rpm package in
the current directory, do this

    echo 'foo*.rpm' > bar.manifest
    cat bar.manifest
    rpm -ivv bar.manifest

You should see rpmInstall() open bar.manifest, read the glob
pattern, expand the glob, insert the results into the argv array,
and finall install foo*.rpm.

hth

73 de Jeff

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/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