General Public License for more details.
*/
-#include "config.h"
-
#include <stdio.h>
#include <string.h>
#include <ctype.h>
blob_for_each_attr(cur, pkg->blob.head, rem) {
if (blob_id(cur) == id) {
if (blob_len(cur) < len) {
- fprintf(stderr, "ERROR: truncating field %d <%p> to %d byte",
+ fprintf(stderr, "ERROR: truncating field %d <%p> to %zu byte",
id, val, blob_len(cur));
}
memcpy(blob_data(cur), val, blob_len(cur));
free(ptr);
}
+ pkg_set_ptr(pkg, blob_id(cur), NULL);
+ break;
+ case PKG_ALTERNATIVES:
+ ptr = pkg_get_ptr(pkg, blob_id(cur));
+
+ if (ptr) {
+ struct pkg_alternatives *pkg_alts = ptr;
+
+ while (pkg_alts->nalts)
+ free(pkg_alts->alts[--pkg_alts->nalts]);
+ free(pkg_alts->alts);
+ free(pkg_alts);
+ }
+
pkg_set_ptr(pkg, blob_id(cur), NULL);
break;
}
pkg_init(pkg);
+ if (!(pkg->state_flag & SF_NEED_DETAIL)) {
+ opkg_msg(DEBUG, "applying abpkg flag to %s\n", filename);
+ pkg->state_flag |= SF_NEED_DETAIL;
+ }
+
pkg_set_string(pkg, PKG_LOCAL_FILENAME, filename);
tmp = xstrdup(filename);
pkg_set_string(oldpkg, PKG_PRIORITY, pkg_get_string(newpkg, PKG_PRIORITY));
if (!pkg_get_string(oldpkg, PKG_SOURCE))
pkg_set_string(oldpkg, PKG_SOURCE, pkg_get_string(newpkg, PKG_SOURCE));
+ if (!pkg_get_string(oldpkg, PKG_ABIVERSION))
+ pkg_set_string(oldpkg, PKG_ABIVERSION, pkg_get_string(newpkg, PKG_ABIVERSION));
if (!pkg_get_ptr(oldpkg, PKG_CONFFILES)) {
pkg_set_ptr(oldpkg, PKG_CONFFILES, pkg_get_ptr(newpkg, PKG_CONFFILES));
if (!oldpkg->essential)
oldpkg->essential = newpkg->essential;
+ if (!oldpkg->provided_by_hand)
+ oldpkg->provided_by_hand = newpkg->provided_by_hand;
+
return 0;
}
return ab_pkg;
}
-void set_flags_from_control(pkg_t * pkg)
-{
- char *file_name;
- FILE *fp;
-
- sprintf_alloc(&file_name, "%s/%s.control", pkg->dest->info_dir,
- pkg->name);
-
- fp = fopen(file_name, "r");
- if (fp == NULL) {
- opkg_perror(ERROR, "Failed to open %s", file_name);
- free(file_name);
- return;
- }
-
- free(file_name);
-
- if (pkg_parse_from_stream(pkg, fp, PFM_ALL ^ PFM_ESSENTIAL)) {
- opkg_msg(DEBUG,
- "Unable to read control file for %s. May be empty.\n",
- pkg->name);
- }
-
- fclose(fp);
-
- return;
-}
-
static const char *pkg_state_want_to_str(pkg_state_want_t sw)
{
int i;
switch (field[0]) {
case 'a':
case 'A':
- if (strcasecmp(field, "Architecture") == 0) {
+ if (strcasecmp(field, "ABIVersion") == 0) {
+ p = pkg_get_string(pkg, PKG_ABIVERSION);
+ if (p) {
+ fprintf(fp, "ABIVersion: %s\n", p);
+ }
+ } else if (strcasecmp(field, "Alternatives") == 0) {
+ struct pkg_alternatives *pkg_alts = pkg_get_ptr(pkg, PKG_ALTERNATIVES);
+
+ if (pkg_alts && pkg_alts->nalts > 0) {
+ int i;
+ struct pkg_alternative *alt;
+
+ alt = pkg_alts->alts[0];
+ fprintf(fp, "Alternatives: %d:%s:%s", alt->prio, alt->path, alt->altpath);
+ for (i = 1; i < pkg_alts->nalts; i++) {
+ alt = pkg_alts->alts[i];
+ fprintf(fp, ", %d:%s:%s", alt->prio, alt->path, alt->altpath);
+ }
+ fputs("\n", fp);
+ }
+ } else if (strcasecmp(field, "Architecture") == 0) {
p = pkg_get_architecture(pkg);
if (p) {
fprintf(fp, "Architecture: %s\n",
case 'R':
if (strcasecmp(field, "Replaces") == 0) {
ab_pkg = pkg_get_ptr(pkg, PKG_REPLACES);
- if (ab_pkg && *ab_pkg) {
+ if (ab_pkg && ab_pkg[0]) {
fprintf(fp, "Replaces:");
- for (i = 0; *ab_pkg; i++, ab_pkg++) {
+ for (i = 0; ab_pkg[i]; i++) {
fprintf(fp, "%s %s", i == 0 ? "" : ",",
- (*ab_pkg)->name);
+ ab_pkg[i]->name);
}
fprintf(fp, "\n");
}
if (p) {
fprintf(fp, "Section: %s\n", p);
}
-#if defined HAVE_SHA256
} else if (strcasecmp(field, "SHA256sum") == 0) {
p = pkg_get_string(pkg, PKG_SHA256SUM);
if (p) {
fprintf(fp, "SHA256sum: %s\n", p);
}
-#endif
} else if (strcasecmp(field, "Size") == 0) {
i = pkg_get_int(pkg, PKG_SIZE);
if (i) {
}
pkg_formatted_field(file, pkg, "Package");
+ pkg_formatted_field(file, pkg, "ABIVersion");
pkg_formatted_field(file, pkg, "Version");
pkg_formatted_field(file, pkg, "Depends");
pkg_formatted_field(file, pkg, "Recommends");
pkg_formatted_field(file, pkg, "Conffiles");
pkg_formatted_field(file, pkg, "Installed-Time");
pkg_formatted_field(file, pkg, "Auto-Installed");
+ pkg_formatted_field(file, pkg, "Alternatives");
fputs("\n", file);
}
/* Installed packages have scripts in pkg->dest->info_dir, uninstalled packages
have scripts in tmp_unpack_dir. */
if (pkg->state_status == SS_INSTALLED
- || pkg->state_status == SS_UNPACKED) {
+ || pkg->state_status == SS_UNPACKED
+ || pkg->state_status == SS_HALF_INSTALLED) {
if (pkg->dest == NULL) {
opkg_msg(ERROR, "Internal error: %s has a NULL dest.\n",
pkg->name);
sprintf_alloc(&cmd, "%s %s", path, args);
free(path);
{
- const char *argv[] = { "sh", "-c", cmd, NULL };
+ const char *argv[] = { "/bin/sh", "-c", cmd, NULL };
err = xsystem(argv);
}
free(cmd);