diff options
author | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-16 00:29:13 (EST) |
---|---|---|
committer | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-16 00:29:13 (EST) |
commit | f3b6367701e4d9062b30f44c18fd867a0c038fde (patch) | |
tree | 5f6e3af49d39f43066c8295d526b20f07acd5379 | |
parent | 4260b8f96c594c5653772a8f718e4cdb53a671ce (diff) |
Fix pkg_get_installed_files() to work with an offline_root + dest.
git-svn-id: http://opkg.googlecode.com/svn/trunk@318 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r-- | libopkg/opkg_cmd.c | 4 | ||||
-rw-r--r-- | libopkg/opkg_install.c | 12 | ||||
-rw-r--r-- | libopkg/opkg_remove.c | 7 | ||||
-rw-r--r-- | libopkg/pkg.c | 30 | ||||
-rw-r--r-- | libopkg/pkg.h | 2 | ||||
-rw-r--r-- | libopkg/pkg_hash.c | 2 |
6 files changed, 31 insertions, 26 deletions
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index c40694e..b86e670 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -1028,7 +1028,7 @@ static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv) return 0; } - files = pkg_get_installed_files(pkg); + files = pkg_get_installed_files(conf, pkg); pkg_version = pkg_version_str_alloc(pkg); printf("Package %s (%s) is installed on %s and has the following files:\n", @@ -1323,7 +1323,7 @@ static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv) for (i=0; i < installed->len; i++) { pkg = installed->pkgs[i]; - installed_files = pkg_get_installed_files(pkg); + installed_files = pkg_get_installed_files(conf, pkg); for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) { installed_file = (char *)iter->data; diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index b57c10e..834916d 100644 --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c @@ -427,7 +427,7 @@ 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_t *new_list = pkg_get_installed_files(conf, new_pkg); str_list_elt_t *iter, *niter; for (iter = str_list_first(new_list), niter = str_list_next(new_list, iter); @@ -441,7 +441,7 @@ static int update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_p file_hash_set_file_owner(conf, new_file, new_pkg); } if (old_pkg) { - str_list_t *old_list = pkg_get_installed_files(old_pkg); + str_list_t *old_list = pkg_get_installed_files(conf, old_pkg); for (iter = str_list_first(old_list), niter = str_list_next(old_list, iter); iter; iter = niter, niter = str_list_next(old_list, niter)) { @@ -1223,7 +1223,7 @@ static int check_data_file_clashes(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg int clashes = 0; - files_list = pkg_get_installed_files(pkg); + files_list = pkg_get_installed_files(conf, pkg); for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter); iter; iter = niter, niter = str_list_next(files_list, iter)) { @@ -1314,7 +1314,7 @@ static int check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t * int clashes = 0; - files_list = pkg_get_installed_files(pkg); + files_list = pkg_get_installed_files(conf, pkg); for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter); iter; iter = niter, niter = str_list_next(files_list, niter)) { @@ -1398,8 +1398,8 @@ static int remove_obsolesced_files(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg return 0; } - old_files = pkg_get_installed_files(old_pkg); - new_files = pkg_get_installed_files(pkg); + old_files = pkg_get_installed_files(conf, old_pkg); + new_files = pkg_get_installed_files(conf, pkg); new_files_table.entries = NULL; hash_table_init("new_files" , &new_files_table, 20); diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c index eb03714..aadfa6a 100644 --- a/libopkg/opkg_remove.c +++ b/libopkg/opkg_remove.c @@ -334,13 +334,14 @@ int remove_data_files_and_list(opkg_conf_t *conf, pkg_t *pkg) conffile_t *conffile; int removed_a_dir; pkg_t *owner; - int rootdirlen; + 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 */ - rootdirlen = strlen(pkg->dest->root_dir) -1; + 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; diff --git a/libopkg/pkg.c b/libopkg/pkg.c index 1802ff0..78b6cad 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -969,14 +969,14 @@ pkg_version_str_alloc(pkg_t *pkg) return version; } -str_list_t *pkg_get_installed_files(pkg_t *pkg) +str_list_t *pkg_get_installed_files(opkg_conf_t *conf, pkg_t *pkg) { int err; char *list_file_name = NULL; FILE *list_file = NULL; char *line; char *installed_file_name; - int rootdirlen; + int rootdirlen = 0; pkg->installed_files_ref_cnt++; @@ -1024,7 +1024,9 @@ str_list_t *pkg_get_installed_files(pkg_t *pkg) free(list_file_name); } - rootdirlen = strlen( pkg->dest->root_dir ); + if (conf->offline_root) + rootdirlen = strlen(conf->offline_root); + while (1) { char *file_name; @@ -1035,22 +1037,24 @@ str_list_t *pkg_get_installed_files(pkg_t *pkg) str_chomp(line); file_name = line; - /* Take pains to avoid uglies like "/./" in the middle of file_name. */ - if( strncmp( pkg->dest->root_dir, - file_name, - rootdirlen ) ) { + if (pkg->state_status == SS_NOT_INSTALLED) { if (*file_name == '.') { file_name++; } if (*file_name == '/') { file_name++; } - - /* Freed in pkg_free_installed_files */ - sprintf_alloc(&installed_file_name, "%s%s", pkg->dest->root_dir, file_name); + sprintf_alloc(&installed_file_name, "%s%s", + pkg->dest->root_dir, file_name); } else { - // already contains root_dir as header -> ABSOLUTE - sprintf_alloc(&installed_file_name, "%s", file_name); + if (conf->offline_root && + strncmp(conf->offline_root, file_name, rootdirlen)) { + sprintf_alloc(&installed_file_name, "%s%s", + conf->offline_root, file_name); + } else { + // already contains root_dir as header -> ABSOLUTE + sprintf_alloc(&installed_file_name, "%s", file_name); + } } str_list_append(pkg->installed_files, installed_file_name); free(installed_file_name); @@ -1394,7 +1398,7 @@ int pkg_info_preinstall_check(opkg_conf_t *conf) pkg_hash_fetch_all_installed(pkg_hash, installed_pkgs); 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_t *installed_files = pkg_get_installed_files(conf, pkg); /* this causes installed_files to be cached */ str_list_elt_t *iter, *niter; if (installed_files == NULL) { opkg_message(conf, OPKG_ERROR, "No installed files for pkg %s\n", pkg->name); diff --git a/libopkg/pkg.h b/libopkg/pkg.h index d95eed3..2e25443 100644 --- a/libopkg/pkg.h +++ b/libopkg/pkg.h @@ -212,7 +212,7 @@ void pkg_formatted_field(FILE *fp, pkg_t *pkg, const char *field); void set_flags_from_control(opkg_conf_t *conf, pkg_t *pkg); void pkg_print_status(pkg_t * pkg, FILE * file); -str_list_t *pkg_get_installed_files(pkg_t *pkg); +str_list_t *pkg_get_installed_files(opkg_conf_t *conf, pkg_t *pkg); int pkg_free_installed_files(pkg_t *pkg); int pkg_remove_installed_files_list(opkg_conf_t *conf, pkg_t *pkg); conffile_t *pkg_get_conffile(pkg_t *pkg, const char *file_name); diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 38e3455..ace26bf 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -644,7 +644,7 @@ int file_hash_set_file_owner(opkg_conf_t *conf, const char *file_name, pkg_t *ow // opkg_message(conf, OPKG_DEBUG2, "owning_pkg=%s filename=%s\n", owning_pkg->name, file_name); hash_table_insert(file_hash, file_name, owning_pkg); if (old_owning_pkg) { - pkg_get_installed_files(old_owning_pkg); + pkg_get_installed_files(conf, old_owning_pkg); str_list_remove_elt(old_owning_pkg->installed_files, file_name); pkg_free_installed_files(old_owning_pkg); /* mark this package to have its filelist written */ |