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(conf, new_pkg);
+ str_list_t *new_list, *old_list;
str_list_elt_t *iter, *niter;
+ new_list = pkg_get_installed_files(conf, new_pkg);
+ if (new_list == NULL)
+ return -1;
+
for (iter = str_list_first(new_list), niter = str_list_next(new_list, iter);
iter;
iter = niter, niter = str_list_next(new_list, niter)) {
if (!owner || (owner == old_pkg))
file_hash_set_file_owner(conf, new_file, new_pkg);
}
+
if (old_pkg) {
- str_list_t *old_list = pkg_get_installed_files(conf, old_pkg);
+ old_list = pkg_get_installed_files(conf, old_pkg);
+ if (old_list == NULL) {
+ pkg_free_installed_files(new_pkg);
+ return -1;
+ }
+
for (iter = str_list_first(old_list), niter = str_list_next(old_list, iter);
iter;
iter = niter, niter = str_list_next(old_list, niter)) {
opkg_message(conf, OPKG_ERROR,
"%s: Failed to create temporary directory '%s': %s\n",
__FUNCTION__, pkg->tmp_unpack_dir, strerror(errno));
- return errno;
+ return -1;
}
err = pkg_extract_control_files_to_dir(pkg, pkg->tmp_unpack_dir);
fprintf(stderr, "%s: failed to open %s: %s\n",
__FUNCTION__, conffiles_file_name, strerror(errno));
free(conffiles_file_name);
- return errno;
+ return -1;
}
free(conffiles_file_name);
int clashes = 0;
files_list = pkg_get_installed_files(conf, pkg);
+ if (files_list == NULL)
+ return -1;
+
for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
iter;
iter = niter, niter = str_list_next(files_list, iter)) {
return clashes;
}
+/*
+ * XXX: This function sucks, as does the below comment.
+ */
static int
check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
{
char *root_filename = NULL;
- int clashes = 0;
-
files_list = pkg_get_installed_files(conf, pkg);
+ if (files_list == NULL)
+ return -1;
+
for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
iter;
iter = niter, niter = str_list_next(files_list, niter)) {
}
pkg_free_installed_files(pkg);
- return clashes;
+ return 0;
}
static int
str_list_elt_t *nf;
hash_table_t new_files_table;
- if (old_pkg == NULL) {
- return 0;
- }
-
old_files = pkg_get_installed_files(conf, old_pkg);
+ if (old_files == NULL)
+ return -1;
+
new_files = pkg_get_installed_files(conf, pkg);
+ if (new_files == NULL) {
+ pkg_free_installed_files(old_pkg);
+ return -1;
+ }
new_files_table.entries = NULL;
hash_table_init("new_files" , &new_files_table, 20);
#endif
if (pkg->tmp_unpack_dir == NULL) {
- unpack_pkg_control_files(conf, pkg);
+ if (unpack_pkg_control_files(conf, pkg) == -1) {
+ opkg_message(conf, OPKG_ERROR, "Failed to unpack control"
+ " files from %s.\n", pkg->local_filename);
+ return -1;
+ }
}
/* We should update the filelist here, so that upgrades of packages that split will not fail. -Jamey 27-MAR-03 */
} else {
opkg_message(conf, OPKG_INFO,
" removing obsolesced files\n");
- remove_obsolesced_files(conf, pkg, old_pkg);
+ if (remove_obsolesced_files(conf, pkg, old_pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to determine "
+ "obsolete files from previously "
+ "installed %s\n", old_pkg->name);
+ }
}
/* removing files from old package, to avoid ghost files */
opkg_message(conf, OPKG_INFO,
" installing maintainer scripts\n");
- install_maintainer_scripts(conf, pkg, old_pkg);
+ if (install_maintainer_scripts(conf, pkg, old_pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to extract maintainer"
+ " scripts for %s. Package debris may remain!\n",
+ pkg->name);
+ goto pkg_is_hosed;
+ }
/* the following just returns 0 */
remove_disappeared(conf, pkg);
opkg_message(conf, OPKG_INFO,
" installing data files\n");
- install_data_files(conf, pkg);
-/* read comments from function for detail but I will execute this here as all other tests are ok.*/
+ if (install_data_files(conf, pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to extract data files "
+ "for %s. Package debris may remain!\n",
+ pkg->name);
+ goto pkg_is_hosed;
+ }
+
err = check_data_file_clashes_change(conf, pkg, old_pkg);
+ if (err) {
+ opkg_message(conf, OPKG_ERROR,
+ "check_data_file_clashes_change() failed for "
+ "for files belonging to %s.\n",
+ pkg->name);
+ }
opkg_message(conf, OPKG_INFO,
" resolving conf files\n");
UNWIND_REMOVE_INSTALLED_REPLACEES:
pkg_remove_installed_replacees_unwind(conf, replacees);
+pkg_is_hosed:
opkg_message(conf, OPKG_INFO,
"Failed.\n");