Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Main change: add a cleanup_dist() func...



details:   https://anonhg.NetBSD.org/src/rev/c0a155802277
branches:  trunk
changeset: 471866:c0a155802277
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Apr 13 20:17:47 1999 +0000

description:
Main change: add a cleanup_dist() function in util.c which will do the needed
cleanups before extracting a set. Should'nt do anything for an install,
as the filesystem shouldn't contain files that need to be removed.
cleanup_dist() is called before extract_file() for each set (the set name
is passed as parameter). It will open a file /dist/<set name>_obsolete
if it exists. This file should contain a list of files (absolutes
pathnames) that needs to be removed. cleanup_dist() will lstat() each file
to determine if it's there and if it's a directory or not.
It will then unlink() entries that are not directories and then rmdir()
directories. If a directory is not empty (it should now if the list of files
is correct) it will be renamed to <directory.old> and the user will be warned.

Other changes:
- move prototype of target_prefix() in defs.h, don't maintain a copy
  of it in each file.
- in install.c, after MSG_disksetupdone, do a wclear(stdscr) (display was
  clobbered after it).
- kill MSG_openmsgbuf, it's not used anywhere
- after MSG_disksetupdone in upgrade, don't call MENU_ok, do it the
  same way as in install.
- add wclear(stdscr);/wrefresh(stdscr); before calling MENU_distset (another
  display problem ...)
- While I'm there, move ask_verbose_dist() before MENU_distmedium. This way,
  if all go well the user can go away one ftp starts and come back once
  sets are extracted.

diffstat:

 distrib/utils/sysinst/defs.h     |    3 +-
 distrib/utils/sysinst/disks.c    |    5 +-
 distrib/utils/sysinst/install.c  |    3 +-
 distrib/utils/sysinst/msg.mi.eng |   39 +++++++-
 distrib/utils/sysinst/msg.mi.fr  |   39 +++++++-
 distrib/utils/sysinst/net.c      |    5 +-
 distrib/utils/sysinst/target.c   |    5 +-
 distrib/utils/sysinst/upgrade.c  |    7 +-
 distrib/utils/sysinst/util.c     |  186 +++++++++++++++++++++++++++++++++++++-
 9 files changed, 266 insertions(+), 26 deletions(-)

diffs (truncated from 476 to 300 lines):

diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/defs.h
--- a/distrib/utils/sysinst/defs.h      Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/defs.h      Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.39 1999/04/11 22:40:19 bouyer Exp $ */
+/*     $NetBSD: defs.h,v 1.40 1999/04/13 20:17:47 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -308,6 +308,7 @@
 void   echo_to_target_file __P(( const char *path, const char *string));
 void   sprintf_to_target_file __P(( const char *path, const char *fmt, ...));
 void   trunc_target_file __P((const char *path));
+const  char* target_prefix __P((void));
 int    target_chdir __P(( const char *path));
 void   target_chdir_or_die __P((const char *dir));
 int    target_already_root __P((void));
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c     Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/disks.c     Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.25 1999/04/11 22:40:19 bouyer Exp $ */
+/*     $NetBSD: disks.c,v 1.26 1999/04/13 20:17:47 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -70,9 +70,6 @@
 static int target_mount_with_error_menu(const char *opt, char *diskpart,
                                        const char *mntpt);
 
-/* external */
-const char* target_prefix __P((void));
-
 
 static void get_disks(void)
 {
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/install.c
--- a/distrib/utils/sysinst/install.c   Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/install.c   Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.15 1999/04/11 22:40:20 bouyer Exp $      */
+/*     $NetBSD: install.c,v 1.16 1999/04/13 20:17:47 bouyer Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -118,6 +118,7 @@
 
        getchar();
        puts(CL); /* just to make sure */
+       wclear(stdscr);
        wrefresh(stdscr);
 
        /* Unpack the distribution. */
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/msg.mi.eng
--- a/distrib/utils/sysinst/msg.mi.eng  Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/msg.mi.eng  Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.eng,v 1.39 1999/04/13 14:49:56 bouyer Exp $     */
+/*     $NetBSD: msg.mi.eng,v 1.40 1999/04/13 20:17:47 bouyer Exp $     */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -255,6 +255,39 @@
 unpack the distribution filesets.  Press <return> to proceed.
 }
 
+message openfail
+{Could not open %s, error message was: %s.
+}
+
+message statfail
+{Can't get properties of %s, error message was: %s.
+}
+
+message unlink_fail
+{I was unable to delete %s, error message was: %s.
+}
+
+message rename_fail
+{I was unable to rename %s to %s, error message was: %s.
+}
+
+message deleting_files
+{As part of the upgrade procedure, the following have to be deleted:
+}
+
+message deleting_dirs
+{As part of the upgrade procedure, the following directories have to be
+deleted (I will rename those that are not empty):
+}
+
+message renamed_dir
+{The directory %s has been renamed to %s because it was not empty.
+}
+
+message cleanup_warn
+{Cleanup of the existing install failed. This may cause cause the extraction
+of the set to fail.
+}
 
 message nomount
 {Partition %c's type is not 4.2BSD or msdos and therefore does not have
@@ -522,10 +555,6 @@
 again.
 }
 
-message openmsgbuf
-{Could not open /kern/msgbuf.
-}
-
 message anonprog
 {sysinst: running "%s"
 }
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/msg.mi.fr
--- a/distrib/utils/sysinst/msg.mi.fr   Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/msg.mi.fr   Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.16 1999/04/13 14:49:56 bouyer Exp $      */
+/*     $NetBSD: msg.mi.fr,v 1.17 1999/04/13 20:17:47 bouyer Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -259,6 +259,43 @@
 recopier les différents composants. Appuyer sur <entrée> pour continuer.
 }
 
+message openfail
+{Je n'ai pas pu ouvrir %s, le message d'erreur était: %s.
+}
+
+message statfail
+{Je n'ai pas pu avoir les propriétées de %s, le message d'erreur
+etait: %s.
+}
+
+message unlink_fail
+{Je n'ai pas pu effacer %s, le message d'erreur était: %s.
+}
+
+message rename_fail
+{je n'ai pas pu renomer %s en %s, le message d'erreur était: %s.
+}
+
+message deleting_files
+{Pour la procédure de mise à jour, les fichiers suivant doivent etre
+supprimés:
+}
+
+message deleting_dirs
+{Pour la procédude de mise à jour, les répertoires suivants doivent
+etre supprimés (je renomerais ceux qui ne sont pas vides):
+}
+
+message renamed_dir
+{Le répertoire %s a été renomé en %s.
+}
+
+message cleanup_warn
+{Les ajustements nécessaire à la mise à niveau de l'installation
+existante ont échouées. Cela peut empêcher l'extraction du composant
+suivant.
+}
+
 message nomount
 {La partition %c n'est ni 4.2BSD, ni msdos c'est pour cela qu'elle n'a pas de
 point de montage.
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/net.c
--- a/distrib/utils/sysinst/net.c       Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/net.c       Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.43 1999/04/13 14:49:56 bouyer Exp $  */
+/*     $NetBSD: net.c,v 1.44 1999/04/13 20:17:48 bouyer Exp $  */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -63,9 +63,6 @@
 static void get_ifconfig_info __P((void));
 static void get_ifinterface_info __P((void));
 
-/* external */
-const char* target_prefix __P((void));
-
 /*
  * URL encode unsafe characters.  See RFC 1738.
  *
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/target.c
--- a/distrib/utils/sysinst/target.c    Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/target.c    Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: target.c,v 1.20 1999/04/09 10:24:39 bouyer Exp $       */
+/*     $NetBSD: target.c,v 1.21 1999/04/13 20:17:48 bouyer Exp $       */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.20 1999/04/09 10:24:39 bouyer Exp $");
+__RCSID("$NetBSD: target.c,v 1.21 1999/04/13 20:17:48 bouyer Exp $");
 #endif
 
 /*
@@ -74,7 +74,6 @@
 int must_mount_root __P((void));
 
 static void make_prefixed_dir __P((const char *prefix, const char *path));
-const char* target_prefix __P((void));
 static int do_target_chdir __P((const char *dir, int flag));
 static const char* concat_paths __P((const char *prefix, const char *suffix));
 int    target_test(const char *test, const char *path);
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/upgrade.c
--- a/distrib/utils/sysinst/upgrade.c   Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/upgrade.c   Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: upgrade.c,v 1.16 1998/11/16 02:28:13 simonb Exp $      */
+/*     $NetBSD: upgrade.c,v 1.17 1999/04/13 20:17:48 bouyer Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -96,7 +96,10 @@
 
        /* Done with disks. Ready to get and unpack tarballs. */
        msg_display(MSG_disksetupdone);
-       process_menu(MENU_ok);
+       getchar();
+       puts(CL); /* just to make sure */
+       wclear(stdscr);
+       wrefresh(stdscr);
 
        get_and_unpack_sets(MSG_upgrcomplete, MSG_abortupgr);
 
diff -r a2a7e7b195e0 -r c0a155802277 distrib/utils/sysinst/util.c
--- a/distrib/utils/sysinst/util.c      Tue Apr 13 19:14:47 1999 +0000
+++ b/distrib/utils/sysinst/util.c      Tue Apr 13 20:17:47 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.36 1999/04/11 22:40:22 bouyer Exp $ */
+/*     $NetBSD: util.c,v 1.37 1999/04/13 20:17:48 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -46,6 +46,7 @@
 #include <sys/sysctl.h>
 #include <sys/stat.h>
 #include <curses.h>
+#include <errno.h>
 #include "defs.h"
 #include "md.h"
 #include "msg_defs.h"
@@ -64,6 +65,7 @@
 
 void   extract_file __P((char *path));
 int    extract_dist __P((void));
+int    cleanup_dist __P((const char *path));
 int    distribution_sets_exist_p __P((const char *path));
 static int check_for __P((const char *type, const char *pathname));
 
@@ -502,7 +504,7 @@
 
 
 /*
-* Extract_dist **REQUIRES** an absolute path in ext_dir.  Any code
+ * Extract_dist **REQUIRES** an absolute path in ext_dir.  Any code
  * that sets up dist_dir for use by extract_dist needs to put in the
  * full path name to the directory. 
  */
@@ -522,6 +524,10 @@
        while (list->name) {
                if (list->getit) {
                        tarstats.nselected++;
+                       if (cleanup_dist(list->name) == 0) {
+                               msg_display(MSG_cleanup_warn);
+                               process_menu(MENU_ok);
+                       }
                        (void)snprintf(distname, STRSIZE, "%s%s", list->name,
                            dist_postfix);
                        (void)snprintf(fname, STRSIZE, "%s/%s", ext_dir,
@@ -549,6 +555,174 @@
 }
 
 /*
+ * Do pre-extract cleanup for set 'name':
+ * open a file named '/dist/<name>_obsolete file', 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 renaned to <directory.old>.
+ */
+
+/* definition for a list of files. */
+struct filelist {
+       struct filelist *next;
+       char name[MAXPATHLEN];
+       mode_t type;
+};
+
+int 
+cleanup_dist(name)
+       const char *name;
+{



Home | Main Index | Thread Index | Old Index