コード例 #1
0
ファイル: pkg_depends.c プロジェクト: beyonwiz/opkg
void buildReplaces(abstract_pkg_t * ab_pkg, pkg_t * pkg)
{
    unsigned int i;

    if (!pkg->replaces_count)
        return;

    pkg->replaces = xcalloc(pkg->replaces_count, sizeof(abstract_pkg_t *));

    for (i = 0; i < pkg->replaces_count; i++) {
        abstract_pkg_t *old_abpkg = ensure_abstract_pkg_by_name(pkg->replaces_str[i]);

        pkg->replaces[i] = old_abpkg;
        free(pkg->replaces_str[i]);

        if (!old_abpkg->replaced_by)
            old_abpkg->replaced_by = abstract_pkg_vec_alloc();
        /* if a package pkg both replaces and conflicts old_abpkg,
         * then add it to the replaced_by vector so that old_abpkg
         * will be upgraded to ab_pkg automatically */
        if (pkg_conflicts_abstract(pkg, old_abpkg))
            abstract_pkg_vec_insert(old_abpkg->replaced_by, ab_pkg);
    }

    free(pkg->replaces_str);
}
コード例 #2
0
ファイル: pkg_hash.c プロジェクト: DgINC/USP
pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,ipkg_conf_t *conf)
{
     abstract_pkg_t * ab_pkg;
     int arch_priority;

     if(!pkg)
	  return pkg;

     arch_priority = pkg->arch_priority;

     if (buildDepends(hash, pkg)<0){
        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
        return NULL;
     }
     ab_pkg = ensure_abstract_pkg_by_name(hash, pkg->name);

     if (set_status) {
	  if (pkg->state_status == SS_INSTALLED) {
	       ab_pkg->state_status = SS_INSTALLED;
	  } else if (pkg->state_status == SS_UNPACKED) {
	       ab_pkg->state_status = SS_UNPACKED;
	  }
     }

     if(!ab_pkg->pkgs)
	  ab_pkg->pkgs = pkg_vec_alloc();
    
     /* pkg_vec_insert_merge might munge package, but it returns an unmunged pkg */
     pkg = pkg_vec_insert_merge(ab_pkg->pkgs, pkg, set_status,conf );
     pkg->parent = ab_pkg;

     if (buildProvides(hash, ab_pkg, pkg)<0){
        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
        return NULL;
     }
     /* need to build the conflicts graph before replaces for correct calculation of replaced_by relation */
     if (buildConflicts(hash, ab_pkg, pkg)<0){
        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
        return NULL;
     }
     if (buildReplaces(hash, ab_pkg, pkg)<0) {
        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
        return NULL;
     }
    
     buildDependedUponBy(pkg, ab_pkg);
     return pkg;
}
コード例 #3
0
ファイル: pkg_depends.c プロジェクト: beyonwiz/opkg
void buildProvides(abstract_pkg_t * ab_pkg, pkg_t * pkg)
{
    unsigned int i;

    /* every pkg provides itself */
    pkg->provides_count++;
    abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
    pkg->provides = xcalloc(pkg->provides_count, sizeof(abstract_pkg_t *));
    pkg->provides[0] = ab_pkg;

    for (i = 1; i < pkg->provides_count; i++) {
        abstract_pkg_t *provided_abpkg = ensure_abstract_pkg_by_name(pkg->provides_str[i - 1]);
        free(pkg->provides_str[i - 1]);

        pkg->provides[i] = provided_abpkg;

        abstract_pkg_vec_insert(provided_abpkg->provided_by, ab_pkg);
    }
    free(pkg->provides_str);
}
コード例 #4
0
ファイル: pkg_depends.c プロジェクト: beyonwiz/opkg
static int parseDepends(compound_depend_t * compound_depend,
                        const char *depend_str)
{
    char *pkg_name, buffer[2048];
    unsigned int num_of_ors = 0;
    unsigned int i;
    const char *src;
    char *dest;
    depend_t **possibilities;

    /* first count the number of ored possibilities for satisfying dependency */
    src = depend_str;
    while (*src)
        if (*src++ == '|')
            num_of_ors++;

    compound_depend->type = DEPEND;

    compound_depend->possibility_count = num_of_ors + 1;
    possibilities = xcalloc((num_of_ors + 1), sizeof(depend_t *));
    compound_depend->possibilities = possibilities;

    src = depend_str;
    for (i = 0; i < num_of_ors + 1; i++) {
        possibilities[i] = depend_init();
        /* gobble up just the name first */
        dest = buffer;
        while (*src && !isspace(*src) && (*src != '(') && (*src != '*')
               && (*src != '|'))
            *dest++ = *src++;
        *dest = '\0';
        pkg_name = trim_xstrdup(buffer);

        /* now look at possible version info */

        /* skip to next chars */
        if (isspace(*src))
            while (*src && isspace(*src))
                src++;

        /* extract constraint and version */
        if (*src == '(') {
            src++;
            possibilities[i]->constraint = str_to_constraint(&src);

            /* now we have any constraint, pass space to version string */
            while (isspace(*src))
                src++;

            /* this would be the version string */
            dest = buffer;
            while (*src && *src != ')')
                *dest++ = *src++;
            *dest = '\0';

            possibilities[i]->version = trim_xstrdup(buffer);
        }
        /* hook up the dependency to its abstract pkg */
        possibilities[i]->pkg = ensure_abstract_pkg_by_name(pkg_name);

        free(pkg_name);

        /* now get past the ) and any possible | chars */
        while (*src && (isspace(*src) || (*src == ')') || (*src == '|')))
            src++;
        if (*src == '*') {
            compound_depend->type = GREEDY_DEPEND;
            src++;
        }
    }

    return 0;
}