summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libopkg/opkg_remove.c4
-rw-r--r--libopkg/pkg.c27
-rw-r--r--libopkg/pkg_depends.c62
-rw-r--r--libopkg/pkg_depends.h12
-rw-r--r--libopkg/pkg_parse.c53
5 files changed, 19 insertions, 139 deletions
diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
index ec7540b..12d5d0c 100644
--- a/libopkg/opkg_remove.c
+++ b/libopkg/opkg_remove.c
@@ -39,7 +39,7 @@ int pkg_has_installed_dependents(opkg_conf_t *conf, abstract_pkg_t *parent_apkg,
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;
@@ -58,7 +58,7 @@ int pkg_has_installed_dependents(opkg_conf_t *conf, abstract_pkg_t *parent_apkg,
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;
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 3b1f21b..13415c7 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -417,8 +417,10 @@ int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg, int set_status)
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) {
@@ -546,7 +548,6 @@ void set_flags_from_control(opkg_conf_t *conf, pkg_t *pkg){
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;
@@ -655,23 +656,11 @@ void pkg_formatted_field(FILE *fp, pkg_t *pkg, const char *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;
diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c
index b894d9b..e059a25 100644
--- a/libopkg/pkg_depends.c
+++ b/libopkg/pkg_depends.c
@@ -448,47 +448,6 @@ static int is_pkg_in_pkg_vec(pkg_vec_t * vec, pkg_t * pkg)
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.
@@ -497,14 +456,11 @@ int pkg_replaces(pkg_t *pkg, pkg_t *replacee)
{
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;
}
@@ -612,18 +568,16 @@ void buildProvides(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
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);
}
diff --git a/libopkg/pkg_depends.h b/libopkg/pkg_depends.h
index 18570cb..32461f6 100644
--- a/libopkg/pkg_depends.h
+++ b/libopkg/pkg_depends.h
@@ -64,18 +64,6 @@ 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.
*/
diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c
index 98d7a9b..12aabbe 100644
--- a/libopkg/pkg_parse.c
+++ b/libopkg/pkg_parse.c
@@ -156,38 +156,6 @@ int parseVersion(pkg_t *pkg, char *raw)
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
@@ -208,9 +176,7 @@ int alterProvidesLine(char *raw, char *temp)
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;
@@ -226,17 +192,7 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *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);
@@ -370,13 +326,6 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
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;