void component_union(RUN *ra, RUN *rb) { /* Union the components of the two runs. */ RUN *arep = component_find(ra); RUN *brep = component_find(rb); arep->component = brep; }
RUN *component_find(RUN *r) { /* Find the representative run for r. */ if(r == NULL || r->component == NULL) return NULL; if(r->component == r) return r; // r is representative r->component = component_find(r->component); // Path compression return r->component; }
static retvalue deb_preparelocation(struct debpackage *pkg, component_t forcecomponent, const struct atomlist *forcearchitectures, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const struct overridedata **oinfo_ptr, const char *debfilename){ const struct atomlist *components; const struct overridefile *binoverride; const struct overridedata *oinfo; retvalue r; if (packagetype == pt_udeb) { binoverride = distribution->overrides.udeb; components = &distribution->udebcomponents; } else { binoverride = distribution->overrides.deb; components = &distribution->components; } oinfo = override_search(binoverride, pkg->deb.name); *oinfo_ptr = oinfo; if (forcesection == NULL) { forcesection = override_get(oinfo, SECTION_FIELDNAME); } if (forcepriority == NULL) { forcepriority = override_get(oinfo, PRIORITY_FIELDNAME); } if (!atom_defined(forcecomponent)) { const char *fc; fc = override_get(oinfo, "$Component"); if (fc != NULL) { forcecomponent = component_find(fc); if (!atom_defined(forcecomponent)) { fprintf(stderr, "Unparseable component '%s' in $Component override of '%s'\n", fc, pkg->deb.name); return RET_ERROR; } } } if (forcesection != NULL) { free(pkg->deb.section); pkg->deb.section = strdup(forcesection); if (FAILEDTOALLOC(pkg->deb.section)) { return RET_ERROR_OOM; } } if (forcepriority != NULL) { free(pkg->deb.priority); pkg->deb.priority = strdup(forcepriority); if (FAILEDTOALLOC(pkg->deb.priority)) { return RET_ERROR_OOM; } } if (pkg->deb.section == NULL) { fprintf(stderr, "No section given for '%s', skipping.\n", pkg->deb.name); return RET_ERROR; } if (pkg->deb.priority == NULL) { fprintf(stderr, "No priority given for '%s', skipping.\n", pkg->deb.name); return RET_ERROR; } if (strcmp(pkg->deb.section, "unknown") == 0 && verbose >= 0) { fprintf(stderr, "Warning: strange section '%s'!\n", pkg->deb.section); } /* decide where it has to go */ r = guess_component(distribution->codename, components, pkg->deb.name, pkg->deb.section, forcecomponent, &pkg->component); if (RET_WAS_ERROR(r)) return r; if (verbose > 0 && !atom_defined(forcecomponent)) { fprintf(stderr, "%s: component guessed as '%s'\n", debfilename, atoms_components[pkg->component]); } /* some sanity checks: */ if (forcearchitectures != NULL && pkg->deb.architecture != architecture_all && !atomlist_in(forcearchitectures, pkg->deb.architecture)) { fprintf(stderr, "Cannot add '%s', as it is architecture '%s' and you specified to only include ", debfilename, atoms_architectures[pkg->deb.architecture]); atomlist_fprint(stderr, at_architecture, forcearchitectures); fputs(".\n", stderr); return RET_ERROR; } else if (pkg->deb.architecture != architecture_all && !atomlist_in(&distribution->architectures, pkg->deb.architecture)) { (void)fprintf(stderr, "Error looking at '%s': '%s' is not one of the valid architectures: '", debfilename, atoms_architectures[pkg->deb.architecture]); (void)atomlist_fprint(stderr, at_architecture, &distribution->architectures); (void)fputs("'\n", stderr); return RET_ERROR; } if (!atomlist_in(components, pkg->component)) { fprintf(stderr, "Error looking at %s': Would be placed in unavailable component '%s'!\n", debfilename, atoms_components[pkg->component]); /* this cannot be ignored * as there is not data structure available */ return RET_ERROR; } r = binaries_calcfilekeys(pkg->component, &pkg->deb, packagetype, &pkg->filekeys); if (RET_WAS_ERROR(r)) return r; pkg->filekey = pkg->filekeys.values[0]; return RET_OK; }