summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-03-09 00:39:22 (EDT)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-03-09 00:39:22 (EDT)
commit3d39889a7b2689be560a92b4d0bf1e086e6605b2 (patch)
treed144982228f0718183f21582807f01d7fba5bbfb /libopkg
parent81777847f4e745f75504ae1767d49f0711e56b1b (diff)
because of the file_hash_set_file_owner may break the file list of pkgs
it should be iterated more carefully. Dealing with http://code.google.com/p/opkg/issues/detail?id=9 git-svn-id: http://opkg.googlecode.com/svn/trunk@204 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/opkg_install.c25
-rw-r--r--libopkg/pkg.c6
2 files changed, 21 insertions, 10 deletions
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index f9bf732..15a5ecc 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -432,9 +432,11 @@ static int check_conflicts_for(opkg_conf_t *conf, pkg_t *pkg)
static int update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_pkg)
{
str_list_t *new_list = pkg_get_installed_files(new_pkg);
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
- for (iter = str_list_first(new_list); iter; iter = str_list_next(new_list, iter)) {
+ for (iter = str_list_first(new_list), niter = str_list_next(new_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(new_list, niter)) {
char *new_file = (char *)iter->data;
pkg_t *owner = file_hash_get_file_owner(conf, new_file);
if (!new_file)
@@ -444,7 +446,9 @@ static int update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_p
}
if (old_pkg) {
str_list_t *old_list = pkg_get_installed_files(old_pkg);
- for (iter = str_list_first(old_list); iter; iter = str_list_next(old_list, iter)) {
+ for (iter = str_list_first(old_list), niter = str_list_next(old_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(old_list, niter)) {
char *old_file = (char *)iter->data;
pkg_t *owner = file_hash_get_file_owner(conf, old_file);
if (owner == old_pkg) {
@@ -1217,12 +1221,14 @@ static int check_data_file_clashes(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg
other package.
*/
str_list_t *files_list;
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
int clashes = 0;
files_list = pkg_get_installed_files(pkg);
- for (iter = str_list_first(files_list); iter; iter = str_list_next(files_list, iter)) {
+ for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(files_list, iter)) {
char *root_filename;
char *filename = (char *) iter->data;
root_filename = root_filename_alloc(conf, filename);
@@ -1304,14 +1310,16 @@ static int check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *
@@@ To change after 1.0 release.
*/
str_list_t *files_list;
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
char *root_filename = NULL;
int clashes = 0;
files_list = pkg_get_installed_files(pkg);
- for (iter = str_list_first(files_list); iter; iter = str_list_next(files_list, iter)) {
+ for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(files_list, niter)) {
char *filename = (char *) iter->data;
if (root_filename) {
free(root_filename);
@@ -1321,13 +1329,14 @@ static int check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *
if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
pkg_t *owner;
+ owner = file_hash_get_file_owner(conf, filename);
+
if (conf->force_overwrite) {
/* but we need to change who owns this file */
file_hash_set_file_owner(conf, filename, pkg);
continue;
}
- owner = file_hash_get_file_owner(conf, filename);
/* Pre-existing files are OK if owned by a package replaced by new pkg. */
if (owner) {
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 98a929c..6e0f396 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -1761,12 +1761,14 @@ int pkg_info_preinstall_check(opkg_conf_t *conf)
for (i = 0; i < installed_pkgs->len; i++) {
pkg_t *pkg = installed_pkgs->pkgs[i];
str_list_t *installed_files = pkg_get_installed_files(pkg); /* this causes installed_files to be cached */
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
if (installed_files == NULL) {
opkg_message(conf, OPKG_ERROR, "No installed files for pkg %s\n", pkg->name);
break;
}
- for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ for (iter = str_list_first(installed_files), niter = str_list_next(installed_files, iter);
+ iter;
+ iter = niter, niter = str_list_next(installed_files, iter)) {
char *installed_file = (char *) iter->data;
// opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
file_hash_set_file_owner(conf, installed_file, pkg);