#include "opkg_remove.h"
#include "opkg_error.h"
-#include "opkg_state.h"
+#include "opkg_cmd.h"
#include "file_util.h"
#include "sprintf_alloc.h"
#include "str_util.h"
+#include "libbb/libbb.h"
/*
* Returns number of the number of packages depending on the packages provided by this package.
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;
/* if caller requested the set of installed dependents */
if (pdependents) {
int p = 0;
- abstract_pkg_t **dependents = (abstract_pkg_t **)calloc((n_installed_dependents+1), sizeof(abstract_pkg_t *));
-
- if ( dependents == NULL ){
- fprintf(stderr,"%s Unable to allocate memory. REPORT THIS BUG IN BUGZILLA PLEASE\n", __FUNCTION__);
- return -1;
- }
+ 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;
int x = 0;
pkg_t *p;
d_str = pkg->depends_str[i];
- buffer = calloc (1, strlen (d_str) + 1);
- if (!buffer)
- {
- fprintf(stderr,"%s Unable to allocate memory.\n", __FUNCTION__);
- return -1;
- }
+ buffer = xcalloc(1, strlen (d_str) + 1);
while (d_str[x] != '\0' && d_str[x] != ' ')
{
++x;
}
buffer[x] = '\0';
- buffer = realloc (buffer, strlen (buffer) + 1);
+ buffer = xrealloc (buffer, strlen (buffer) + 1);
p = pkg_hash_fetch_installed_by_name (&conf->pkg_hash, buffer);
/* if the package is not installed, this could have been a circular
if (!conf->force_removal_of_dependent_packages
&& !user_prefers_removing_dependents(conf, parent_pkg, pkg, dependents)) {
+ free(dependents);
return OPKG_PKG_HAS_DEPENDENTS;
}
conffile_t *conffile;
int removed_a_dir;
pkg_t *owner;
+ int rootdirlen = 0;
str_list_init(&installed_dirs);
- installed_files = pkg_get_installed_files(pkg);
+ installed_files = pkg_get_installed_files(conf, pkg);
+
+ /* don't include trailing slash */
+ if (conf->offline_root)
+ rootdirlen = strlen(conf->offline_root);
for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
file_name = (char *)iter->data;
continue;
}
- conffile = pkg_get_conffile(pkg, file_name);
+ conffile = pkg_get_conffile(pkg, file_name+rootdirlen);
if (conffile) {
/* XXX: QUESTION: Is this right? I figure we only need to
save the conffile if it has been modified. Is that what