}
/*
- * Gets the next package field from package_buffer, seperated into the field name
+ * Gets the next package field from package_buffer, separated into the field name
* and field value, it returns the int offset to the first character of the next field
*/
static int read_package_field(const char *package_buffer, char **field_name, char **field_value)
write_flag = FALSE;
tmp_string = strstr(control_buffer, "Status:");
if (tmp_string != NULL) {
- /* Seperate the status value from the control buffer */
+ /* Separate the status value from the control buffer */
tmp_string += 7;
tmp_string += strspn(tmp_string, " \n\t");
status_from_file = xstrndup(tmp_string, strcspn(tmp_string, "\n"));
free_array(exclude_files);
free_array(remove_files);
- /* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
- exclude_files = xzalloc(sizeof(char*) * 3);
+ /* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
+ exclude_files = xzalloc(sizeof(exclude_files[0]) * 3);
exclude_files[0] = xstrdup(conffile_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
- exclude_files = xzalloc(sizeof(char*));
-
/* Some directories cant be removed straight away, so do multiple passes */
- while (remove_file_array(remove_files, exclude_files)) /* repeat */;
+ while (remove_file_array(remove_files, NULL))
+ continue;
free_array(remove_files);
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
+
+ /* Delete all of them except the postrm script */
+ exclude_files = xzalloc(sizeof(exclude_files[0]) * 2);
+ exclude_files[0] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
remove_file_array(remove_files, exclude_files);
- free_array(remove_files);
- free(exclude_files);
+ free_array(exclude_files);
- /* Run postrm script */
+ /* Run and remove postrm script */
run_package_script_or_die(package_name, "postrm");
+ remove_file_array(remove_files, NULL);
+
+ free_array(remove_files);
/* Change package status */
set_status(status_num, "not-installed", 3);
archive_handle->sub_archive->filter = filter_accept_list;
archive_handle->sub_archive->action_data = data_extract_all_prefix;
archive_handle->sub_archive->buffer = info_prefix;
- archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
+ archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
/* Run the preinst prior to extracting */
init_archive_deb_data(archive_handle);
archive_handle->sub_archive->action_data = data_extract_all_prefix;
archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
- archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
+ archive_handle->sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
/* Create the list file */