From 0c254de0115e8a7e534cf90560a74011a4ab83c2 Mon Sep 17 00:00:00 2001 From: dsl Date: Sun, 18 Apr 2004 20:42:19 +0000 Subject: [PATCH] Delete a load of code that has been under '#if 0' for a while --- distrib/utils/sysinst/util.c | 190 +---------------------------------- 1 file changed, 1 insertion(+), 189 deletions(-) diff --git a/distrib/utils/sysinst/util.c b/distrib/utils/sysinst/util.c index 63406b527d08..05bf32fde583 100644 --- a/distrib/utils/sysinst/util.c +++ b/distrib/utils/sysinst/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.117 2004/01/29 08:48:23 lukem Exp $ */ +/* $NetBSD: util.c,v 1.118 2004/04/18 20:42:19 dsl Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -758,12 +758,6 @@ extract_dist(void) tarstats.nskipped++; continue; } -#if 0 - if (cleanup_dist(list->name) == 0) { - msg_display(MSG_cleanup_warn); - process_menu(MENU_ok, NULL); - } -#endif (void)snprintf(fname, sizeof fname, "%s/%s%s", ext_dir, list->name, dist_postfix); @@ -791,188 +785,6 @@ extract_dist(void) return extracted == 0; } -#if 0 /* { NOMORE */ - -/* - * Do pre-extract cleanup for set 'name': - * open a file named '/var/db/obsolete/', which contain a list of - * files to kill from the target. For each file, test if it is present on - * the target. Then display the list of files which will be removed, - * ask user for confirmation, and process. - * Non-empty directories will be renamed to . - */ - -/* definition for a list of files. */ -struct filelist { - struct filelist *next; - char name[MAXPATHLEN]; - mode_t type; -}; - -int -cleanup_dist(const char *name) -{ - char file_path[MAXPATHLEN]; - char file_name[MAXPATHLEN]; - const char *file_prefix; - FILE *list_file; - struct filelist *head = NULL; - struct filelist *current; - int saved_errno; - struct stat st; - int retval = 1; - int needok = 0; - - snprintf(file_path, MAXPATHLEN, "/var/db/obsolete/%s", name); - list_file = fopen(file_path, "r"); - if (list_file == NULL) { - saved_errno = errno; - if (logging) - fprintf(logfp, "Open of %s failed: %s\n", file_path, - strerror(saved_errno)); - if (saved_errno == ENOENT) - return 1; - msg_display_add(MSG_openfail, name, strerror(saved_errno)); - process_menu(MENU_ok, NULL); - return 0; - } - file_prefix = target_prefix(); - while (fgets(file_name, MAXPATHLEN, list_file)) { - /* Remove trailing \n if any */ - if (file_name[strlen(file_name)-1] == '\n') - file_name[strlen(file_name)-1] = '\0'; - snprintf(file_path, MAXPATHLEN, "%s/%s", file_prefix, - file_name); - if (lstat(file_path, &st) != 0) { - saved_errno = errno; - if (logging) - fprintf(logfp, "stat() of %s failed: %s\n", - file_path, strerror(saved_errno)); - if (saved_errno == ENOENT) - continue; - msg_display_add(MSG_statfail, file_path, - strerror(saved_errno)); - process_menu(MENU_ok, NULL); - return 0; - } - if (head == NULL) { - head = current = malloc(sizeof(struct filelist)); - if (head == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } - } else { - current->next = malloc(sizeof(struct filelist)); - if (current->next == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } - current = current->next; - } - current->next = NULL; - snprintf(current->name, MAXPATHLEN, "%s", file_path); - current->type = st.st_mode & S_IFMT; - if (logging) - fprintf(logfp, "Adding file %s, type %d to list of " - "obsolete file\n", current->name, current->type); - } - fclose(list_file); - if (head == NULL) - return 1; -#if 0 - /* XXX doesn't work, too many files printed ! */ - msg_display(MSG_deleting_files); - for (current = head; current != NULL; current = current->next) { - if (current->type != S_IFDIR) { - /* XXX msg_printf_add going/gone away */ - msg_printf_add("%s ", current->name); - } - } - msg_display_add(MSG_deleting_dirs); - for (current = head; current != NULL; current = current->next) { - if (current->type == S_IFDIR) { - /* XXX msg_printf_add going/gone away */ - msg_printf_add("%s ", current->name); - } - } - process_menu(MENU_ok, NULL); -#endif - /* first remove files */ - for (current = head; current != NULL; current = current->next) { - if (current->type == S_IFDIR) - continue; - if (scripting) - (void)fprintf(script, "rm %s\n", current->name); - if (unlink(current->name) != 0) { - saved_errno = errno; - if (saved_errno == ENOENT) - continue; /* don't worry about - non-existing files */ - if (logging) - fprintf(logfp, "rm %s failed: %s\n", - current->name, strerror(saved_errno)); - msg_display_add(MSG_unlink_fail, current->name, - strerror(saved_errno)); - retval = 0; - needok = 1; - } - - } - /* now dirs */ - for (current = head; current != NULL; current = current->next) { - if (current->type != S_IFDIR) - continue; - if (rmdir(current->name) == 0) { - if (scripting) - (void)fprintf(script, "rmdir %s\n", - current->name); - continue; - } - saved_errno = errno; - if (saved_errno == ENOTEMPTY) { - if (logging) - fprintf(logfp, "dir %s not empty, " - "trying to rename to %s.old\n", - current->name, current->name); - snprintf(file_path, MAXPATHLEN, - "%s.old", current->name); - if (scripting) - (void)fprintf(script, "mv %s %s\n", - current->name, file_path); - needok = 1; - if (rename(current->name, file_path) != 0) { - saved_errno = errno; - if (logging) - fprintf(logfp, "mv %s %s failed: %s\n", - current->name, file_path, - strerror(saved_errno)); - msg_display_add(MSG_rename_fail, current->name, - file_path, strerror(errno)); - retval = 0; - } - msg_display_add(MSG_renamed_dir, current->name, - file_path); - } else { /* rmdir error */ - /* - * Don't worry about non-existing directories. - */ - if (saved_errno == ENOENT) - continue; - if (logging) - fprintf(logfp, "rm %s failed: %s\n", - current->name, strerror(saved_errno)); - msg_display_add(MSG_unlink_fail, current->name, - strerror(saved_errno)); - retval = 0; - needok = 1; - } - } - if (needok) - process_menu(MENU_ok, NULL); - return retval; -} -#endif /* } NOMORE */ - /* * Get and unpack the distribution. * Show success_msg if installation completes.