abstract_pkg_t **provides = pkg->provides;
int n_installed_dependents = 0;
int i;
- for (i = 0; i <= nprovides; i++) {
+ for (i = 0; i < nprovides; i++) {
abstract_pkg_t *providee = provides[i];
abstract_pkg_t **dependers = providee->depended_upon_by;
abstract_pkg_t *dep_ab_pkg;
abstract_pkg_t **dependents = xcalloc((n_installed_dependents+1), sizeof(abstract_pkg_t *));
*pdependents = dependents;
- for (i = 0; i <= nprovides; i++) {
+ for (i = 0; i < nprovides; i++) {
abstract_pkg_t *providee = provides[i];
abstract_pkg_t **dependers = providee->depended_upon_by;
abstract_pkg_t *dep_ab_pkg;
oldpkg->provides_count = newpkg->provides_count;
newpkg->provides_count = 0;
- oldpkg->provides = newpkg->provides;
- newpkg->provides = NULL;
+ if (!oldpkg->provides) {
+ oldpkg->provides = newpkg->provides;
+ newpkg->provides = NULL;
+ }
}
if (!oldpkg->conflicts_str) {
void pkg_formatted_field(FILE *fp, pkg_t *pkg, const char *field)
{
int i;
- int flag_provide_false = 0;
if (strlen(field) < PKG_MINIMUM_FIELD_NAME_LEN) {
goto UNKNOWN_FMT_FIELD;
fprintf(fp, "Priority: %s\n", pkg->priority);
} else if (strcasecmp(field, "Provides") == 0) {
if (pkg->provides_count) {
- /* Here we check if the opkg_internal_use_only is used, and we discard it.*/
- for ( i=0; i < pkg->provides_count; i++ ){
- if (strstr(pkg->provides_str[i],"opkg_internal_use_only")!=NULL) {
- memset (pkg->provides_str[i],'\x0',strlen(pkg->provides_str[i])); /* Pigi clear my trick flag, just in case */
- flag_provide_false = 1;
- }
- }
- if ( !flag_provide_false || /* Pigi there is not my trick flag */
- ((flag_provide_false) && (pkg->provides_count > 1))){ /* Pigi There is, but we also have others Provides */
- fprintf(fp, "Provides:");
- for(i = 0; i < pkg->provides_count; i++) {
- if (strlen(pkg->provides_str[i])>0) {
- fprintf(fp, "%s %s", i == 1 ? "" : ",", pkg->provides_str[i]);
- }
- }
- fprintf(fp, "\n");
+ fprintf(fp, "Provides:");
+ for(i = 0; i < pkg->provides_count-1; i++) {
+ fprintf(fp, "%s %s", i == 0 ? "" : ",", pkg->provides_str[i]);
}
+ fprintf(fp, "\n");
}
} else {
goto UNKNOWN_FMT_FIELD;
return 0;
}
-
-#ifdef DeadCode
-/**
- * pkg_has_common_provides returns 1 if pkg and replacee both provide
- * the same abstract package and 0 otherwise.
- */
-int pkg_has_common_provides(pkg_t *pkg, pkg_t *replacee)
-{
- abstract_pkg_t **provides = pkg->provides;
- int provides_count = pkg->provides_count;
- abstract_pkg_t **replacee_provides = replacee->provides;
- int replacee_provides_count = replacee->provides_count;
- int i, j;
- for (i = 0; i < provides_count; i++) {
- abstract_pkg_t *apkg = provides[i];
- for (j = 0; j < replacee_provides_count; j++) {
- abstract_pkg_t *replacee_apkg = replacee_provides[i];
- if (apkg == replacee_apkg)
- return 1;
- }
- }
- return 0;
-}
-#endif
-
-/**
- * pkg_provides_abstract returns 1 if pkg->provides contains providee
- * and 0 otherwise.
- */
-int pkg_provides_abstract(pkg_t *pkg, abstract_pkg_t *providee)
-{
- abstract_pkg_t **provides = pkg->provides;
- int provides_count = pkg->provides_count;
- int i;
- for (i = 0; i < provides_count; i++) {
- if (provides[i] == providee)
- return 1;
- }
- return 0;
-}
-
/**
* pkg_replaces returns 1 if pkg->replaces contains one of replacee's provides and 0
* otherwise.
{
abstract_pkg_t **replaces = pkg->replaces;
int replaces_count = pkg->replaces_count;
- /* abstract_pkg_t **replacee_provides = pkg->provides;
- int replacee_provides_count = pkg->provides_count; */
+ int replacee_provides_count = replacee->provides_count;
int i, j;
for (i = 0; i < replaces_count; i++) {
abstract_pkg_t *abstract_replacee = replaces[i];
- for (j = 0; j < replaces_count; j++) {
- /* opkg_message(NULL, OPKG_DEBUG2, "Searching pkg-name %s repprovname %s absrepname %s \n",
- pkg->name,replacee->provides[j]->name, abstract_replacee->name); */
+ for (j = 0; j < replacee_provides_count; j++) {
if (replacee->provides[j] == abstract_replacee)
return 1;
}
int i;
/* every pkg provides itself */
+ pkg->provides_count++;
abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
-
- if (!pkg->provides_count)
- return;
-
- pkg->provides = xcalloc((pkg->provides_count + 1), sizeof(abstract_pkg_t *));
+ pkg->provides = xcalloc(pkg->provides_count, sizeof(abstract_pkg_t *));
pkg->provides[0] = ab_pkg;
- for(i = 0; i < pkg->provides_count; i++){
- abstract_pkg_t *provided_abpkg = ensure_abstract_pkg_by_name(hash, pkg->provides_str[i]);
+ for (i=1; i<pkg->provides_count; i++) {
+ abstract_pkg_t *provided_abpkg = ensure_abstract_pkg_by_name(hash,
+ pkg->provides_str[i-1]);
- pkg->provides[i+1] = provided_abpkg;
+ pkg->provides[i] = provided_abpkg;
abstract_pkg_vec_insert(provided_abpkg->provided_by, ab_pkg);
}
void buildReplaces(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg);
void buildDepends(hash_table_t * hash, pkg_t * pkg);
-/**
- * pkg_has_common_provides returns 1 if pkg and replacee both provide
- * the same abstract package and 0 otherwise.
- */
-int pkg_has_common_provides(pkg_t *pkg, pkg_t *replacee);
-
-/**
- * pkg_provides returns 1 if pkg->provides contains providee and 0
- * otherwise.
- */
-int pkg_provides_abstract(pkg_t *pkg, abstract_pkg_t *providee);
-
/**
* pkg_replaces returns 1 if pkg->replaces contains one of replacee's provides and 0
* otherwise.
return 0;
}
-
-/* This code is needed to insert in first position the keyword for the aligning bug */
-
-int alterProvidesLine(char *raw, char *temp)
-{
-
-
- if (!*raw) {
- fprintf(stderr, "%s: ERROR: Provides string is empty", __FUNCTION__);
- return -EINVAL;
- }
-
- if ( temp == NULL ) {
- fprintf(stderr, "%s: out of memory \n", __FUNCTION__);
- return -ENOMEM;
- }
-
- if (strncmp(raw, "Provides:", 9) == 0) {
- raw += 9;
- }
- while (*raw && isspace(*raw)) {
- raw++;
- }
-
- snprintf ( temp, 35, "Provides: opkg_internal_use_only, "); /* First part of the line */
- while (*raw) {
- strncat( temp, raw++, 1);
- }
- return 0;
-
-}
-
/* Some random thoughts from Carl:
This function could be considerably simplified if we just kept
int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
{
int reading_conffiles, reading_description;
- int pkg_false_provides=1;
char ** lines;
- char * provide=NULL;
pkg->src = src;
pkg->dest = dest;
else if(isGenericFieldType("Priority:", *lines))
pkg->priority = parseGenericFieldType("Priority", *lines);
else if(isGenericFieldType("Provides", *lines)){
-/* Here we add the internal_use to align the off by one problem between provides_str and provides */
- provide = xcalloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
- if ( alterProvidesLine(*lines,provide) ){
- return EINVAL;
- }
- pkg->provides_str = parseDependsString( provide, &pkg->provides_count);
-/* Let's try to hack a bit here.
- The idea is that if a package has no Provides, we would add one generic, to permit the check of dependencies
- in alot of other places. We will remove it before writing down the status database */
- pkg_false_provides=0;
- free(provide);
+ pkg->provides_str = parseDependsString(*lines, &pkg->provides_count);
}
else if(isGenericFieldType("Pre-Depends", *lines))
pkg->pre_depends_str = parseDependsString(*lines, &pkg->pre_depends_count);
out:;
*raw = lines;
-/* If the opk has not a Provides line, we insert our false line */
- if ( pkg_false_provides==1)
- {
- pkg->provides_count = 1;
- pkg->provides_str = xcalloc(1, sizeof (char*));
- pkg->provides_str[0] = xstrdup("opkg_internal_use_only");
- }
if (pkg->name) {
return 0;