#include <libbb/libbb.h>
+struct errlist* error_list;
+
struct _opkg_t
{
args_t *args;
/** Private Functions ***/
+/**
+ * Clone a pkg_t
+ */
static opkg_package_t*
-old_pkg_to_new (pkg_t *old)
+pkg_clone (pkg_t *old)
{
opkg_package_t *new;
new->tags = sstrdup (old->tags);
new->url = sstrdup (old->url);
+#undef sstrdup
+
new->size = (old->size) ? atoi (old->size) : 0;
new->installed = (old->state_status == SS_INSTALLED);
opkg_package_t *p;
- p = malloc (sizeof (opkg_package_t));
- memset (p, 0, sizeof (opkg_package_t));
+ p = calloc (1, sizeof (opkg_package_t));
return p;
}
opkg_t *opkg;
int err;
- opkg = malloc (sizeof (opkg_t));
+ opkg = calloc (1, sizeof (opkg_t));
- opkg->args = malloc (sizeof (args_t));
+ opkg->args = calloc (1, sizeof (args_t));
err = args_init (opkg->args);
if (err)
{
return NULL;
}
- opkg->conf = malloc (sizeof (opkg_conf_t));
+ opkg->conf = calloc (1, sizeof (opkg_conf_t));
err = opkg_conf_init (opkg->conf, opkg->args);
if (err)
{
a->offline_root_post_script_cmd = strdup (c->offline_root_post_script_cmd);
}
+ if (c->cache) {
+ if (a->cache)
+ free (a->cache);
+ a->cache = strdup(c->cache);
+ }
+
/* throw away old opkg_conf and start again */
opkg_conf_deinit (opkg->conf);
opkg_conf_init (opkg->conf, opkg->args);
new->state_flag |= SF_USER;
pdata.action = OPKG_INSTALL;
- pdata.package = old_pkg_to_new (new);
+ pdata.package = pkg_clone (new);
progress (pdata, 0);
continue;
opkg_package_free (pdata.package);
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
pdata.action = OPKG_DOWNLOAD;
if (pkg->src == NULL)
/* 75% of "install" progress is for downloading */
opkg_package_free (pdata.package);
- pdata.package = old_pkg_to_new (new);
+ pdata.package = pkg_clone (new);
pdata.action = OPKG_INSTALL;
progress (pdata, 75);
}
pdata.action = OPKG_REMOVE;
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 0);
}
pdata.action = OPKG_INSTALL;
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 0);
err = opkg_upgrade_pkg (opkg->conf, pkg);
{
pkg = installed->pkgs[i];
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 99 * i / installed->len);
opkg_package_free (pdata.package);
free (list_file_name);
free (url);
#else
- /* XXX: Note: Signiture check for %s skipped because GPG support was not
+ /* XXX: Note: Signature check for %s skipped because GPG support was not
* enabled in this build
*/
#endif
pkg = all->pkgs[i];
- package = old_pkg_to_new (pkg);
+ package = pkg_clone (pkg);
callback (opkg, package, user_data);
opkg_package_free (package);
}
int
opkg_list_upgradable_packages (opkg_t *opkg, opkg_package_callback_t callback, void *user_data)
{
- pkg_vec_t *all;
- int i;
+ pkg_vec_t *all;
+ int i;
- opkg_assert (opkg);
- opkg_assert (callback);
+ opkg_assert (opkg);
+ opkg_assert (callback);
- /* ensure all data is valid */
- pkg_info_preinstall_check (opkg->conf);
+ /* ensure all data is valid */
+ pkg_info_preinstall_check (opkg->conf);
- all = pkg_vec_alloc ();
- pkg_hash_fetch_available (&opkg->conf->pkg_hash, all);
- for (i = 0; i < all->len; i++)
- {
- pkg_t *old, *new;
- int cmp;
- opkg_package_t *package;
+ all = opkg_upgrade_all_list_get (opkg->conf);
+ for (i = 0; i < all->len; i++)
+ {
+ pkg_t *old, *new;
+ opkg_package_t *package;
- old = all->pkgs[i];
-
- if (old->state_status != SS_INSTALLED)
- continue;
+ old = all->pkgs[i];
- new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name, NULL);
- if (new == NULL) {
- /* XXX: Notice: Assuming locally install package is up to date */
- continue;
- }
-
- cmp = pkg_compare_versions(old, new);
+ new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name, NULL);
- if (cmp < 0)
- {
- package = old_pkg_to_new (new);
- callback (opkg, package, user_data);
- opkg_package_free (package);
+ package = pkg_clone (new);
+ callback (opkg, package, user_data);
+ opkg_package_free (package);
}
- }
- pkg_vec_free (all);
+ pkg_vec_free (all);
- return 0;
+ return 0;
}
opkg_package_t*
}
/* match found */
- package = old_pkg_to_new (pkg);
+ package = pkg_clone (pkg);
break;
}