free(pkg->depends_str);
pkg->depends_str = NULL;
- for (i = 0; i < pkg->provides_count-1; i++)
- free (pkg->provides_str[i]);
- free(pkg->provides_str);
- pkg->provides_str = NULL;
-
- for (i = 0; i < pkg->conflicts_count; i++)
- free (pkg->conflicts_str[i]);
- free(pkg->conflicts_str);
- pkg->conflicts_str = NULL;
-
- for (i = 0; i < pkg->replaces_count; i++)
- free (pkg->replaces_str[i]);
- free(pkg->replaces_str);
- pkg->replaces_str = NULL;
-
for (i = 0; i < pkg->recommends_count; i++)
free (pkg->recommends_str[i]);
free(pkg->recommends_str);
}
int
-pkg_init_from_file(pkg_t *pkg, const char *filename)
+pkg_init_from_file(opkg_conf_t *conf, pkg_t *pkg, const char *filename)
{
int fd, err = 0;
FILE *control_file;
pkg->local_filename = xstrdup(filename);
- sprintf_alloc(&control_path, "%s.control.XXXXXX", filename);
+ sprintf_alloc(&control_path, "%s/%s.control.XXXXXX",
+ conf->tmp_dir,
+ basename(filename));
fd = mkstemp(control_path);
if (fd == -1) {
perror_msg("%s: mkstemp(%s)", __FUNCTION__, control_path);
goto err0;
}
- control_file = fdopen(fd, "rw+");
+ control_file = fdopen(fd, "r+");
if (control_file == NULL) {
perror_msg("%s: fdopen", __FUNCTION__, control_path);
close(fd);
return 0;
}
+ if (!oldpkg->auto_installed)
+ oldpkg->auto_installed = newpkg->auto_installed;
+
if (!oldpkg->src)
oldpkg->src = newpkg->src;
if (!oldpkg->dest)
newpkg->suggests_count = 0;
}
- if (!oldpkg->provides_str) {
- oldpkg->provides_str = newpkg->provides_str;
- newpkg->provides_str = NULL;
+ if (oldpkg->provides_count <= 1) {
oldpkg->provides_count = newpkg->provides_count;
newpkg->provides_count = 0;
}
}
- if (!oldpkg->conflicts_str) {
- oldpkg->conflicts_str = newpkg->conflicts_str;
- newpkg->conflicts_str = NULL;
+ if (!oldpkg->conflicts_count) {
oldpkg->conflicts_count = newpkg->conflicts_count;
newpkg->conflicts_count = 0;
newpkg->conflicts = NULL;
}
- if (!oldpkg->replaces_str) {
- oldpkg->replaces_str = newpkg->replaces_str;
- newpkg->replaces_str = NULL;
+ if (!oldpkg->replaces_count) {
oldpkg->replaces_count = newpkg->replaces_count;
newpkg->replaces_count = 0;
}
}
} else if (strcasecmp(field, "Conflicts") == 0) {
+ struct depend *cdep;
if (pkg->conflicts_count) {
fprintf(fp, "Conflicts:");
for(i = 0; i < pkg->conflicts_count; i++) {
- fprintf(fp, "%s %s", i == 0 ? "" : ",", pkg->conflicts_str[i]);
+ cdep = pkg->conflicts[i].possibilities[0];
+ fprintf(fp, "%s %s", i == 0 ? "" : ",",
+ cdep->pkg->name);
+ if (cdep->version) {
+ fprintf(fp, "(%s%s)",
+ constraint_to_str(cdep->constraint),
+ cdep->version);
+ }
}
fprintf(fp, "\n");
}
if (pkg->depends_count) {
fprintf(fp, "Depends:");
for(i = 0; i < pkg->depends_count; i++) {
- fprintf(fp, "%s %s", i == 0 ? "" : ",", pkg->depends_str[i]);
+ char *str = pkg_depend_str(pkg, i);
+ fprintf(fp, "%s %s", i == 0 ? "" : ",", str);
+ free(str);
}
fprintf(fp, "\n");
}
} else if (strcasecmp(field, "Provides") == 0) {
if (pkg->provides_count) {
fprintf(fp, "Provides:");
- for(i = 0; i < pkg->provides_count-1; i++) {
- fprintf(fp, "%s %s", i == 0 ? "" : ",", pkg->provides_str[i]);
+ for(i = 1; i < pkg->provides_count; i++) {
+ fprintf(fp, "%s %s", i == 1 ? "" : ",",
+ pkg->provides[i]->name);
}
fprintf(fp, "\n");
}
if (pkg->replaces_count) {
fprintf(fp, "Replaces:");
for (i = 0; i < pkg->replaces_count; i++) {
- fprintf(fp, "%s %s", i == 0 ? "" : ",", pkg->replaces_str[i]);
+ fprintf(fp, "%s %s", i == 0 ? "" : ",",
+ pkg->replaces[i]->name);
}
fprintf(fp, "\n");
}
free(list_file_name);
return pkg->installed_files;
}
- list_file = fdopen(fd, "rw+");
+ list_file = fdopen(fd, "r+");
if (list_file == NULL) {
opkg_message(conf, OPKG_ERROR, "%s: fdopen: %s",
__FUNCTION__, strerror(errno));