static int opkg_install_pending_cmd(opkg_conf_t *conf, int argc, char **argv);
static int opkg_install_cmd(opkg_conf_t *conf, int argc, char **argv);
static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv);
static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv);
static int opkg_purge_cmd(opkg_conf_t *conf, int argc, char **argv);
static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv);
{"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd},
{"list", 0, (opkg_cmd_fun_t)opkg_list_cmd},
{"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd},
+ {"list_upgradable", 0, (opkg_cmd_fun_t)opkg_list_upgradable_cmd},
{"info", 0, (opkg_cmd_fun_t)opkg_info_cmd},
{"flag", 1, (opkg_cmd_fun_t)opkg_flag_cmd},
{"status", 0, (opkg_cmd_fun_t)opkg_status_cmd},
error_list = error_list->next;
}
- free_error_list(&error_list);
+ free_error_list();
}
}
free (tmp_file_name);
free (url);
#else
- opkg_message (conf, OPKG_NOTICE, "Signiture check for %s skipped "
+ opkg_message (conf, OPKG_NOTICE, "Signature check for %s skipped "
"because GPG support was not enabled in this build\n", src->name);
#endif
free(list_file_name);
static opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf)
{
opkg_intercept_t ctx;
+ char *oldpath;
char *newpath;
int gen;
- ctx = malloc (sizeof (*ctx));
- ctx->oldpath = strdup (getenv ("PATH"));
+ ctx = calloc (1, sizeof (*ctx));
+ oldpath = getenv ("PATH");
+ if (oldpath) {
+ ctx->oldpath = strdup (oldpath);
+ } else {
+ ctx->oldpath = 0;
+ }
+
sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
setenv ("PATH", newpath, 1);
DIR *dir;
int err = 0;
- setenv ("PATH", ctx->oldpath, 1);
- free (ctx->oldpath);
+ if (ctx->oldpath) {
+ setenv ("PATH", ctx->oldpath, 1);
+ free (ctx->oldpath);
+ } else {
+ unsetenv("PATH");
+ }
dir = opendir (ctx->statedir);
if (dir) {
perror (ctx->statedir);
sprintf_alloc (&cmd, "rm -rf %s", ctx->statedir);
- system (cmd);
+ err = system (cmd);
free (cmd);
free (ctx->statedir);
return 0;
}
+static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+ pkg_vec_t *all = opkg_upgrade_all_list_get(conf);
+ pkg_t *_old_pkg, *_new_pkg;
+ char *old_v, *new_v;
+ int i;
+ for (i=0;i<all->len;i++) {
+ _old_pkg = all->pkgs[i];
+ _new_pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, _old_pkg->name, NULL);
+ old_v = pkg_version_str_alloc(_old_pkg);
+ new_v = pkg_version_str_alloc(_new_pkg);
+ if (opkg_cb_list)
+ opkg_cb_list(_old_pkg->name, new_v, old_v, _old_pkg->state_status, p_userdata);
+ free(old_v);
+ free(new_v);
+ }
+ pkg_vec_free(all);
+ return 0;
+}
+
static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int installed_only)
{
int i;
available = pkg_vec_alloc();
pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
for (i=0; i < argc; i++) {
- pkg_name = malloc(strlen(argv[i])+2);
+ pkg_name = calloc(1, strlen(argv[i])+2);
strcpy(pkg_name,argv[i]);
for (a=0; a < available->len; a++) {
pkg = available->pkgs[a];
size_t used_len;
char *buff ;
- buff = (char *)malloc(buff_len);
+ buff = (char *)calloc(1, buff_len);
if ( buff == NULL ) {
fprintf( stderr,"%s: Unable to allocate memory \n",__FUNCTION__);
return ENOMEM;