Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Oct 2008 15:54:33 +0000 (UTC)
From:      Ken Smith <kensmith@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r183921 - head/usr.sbin/sysinstall
Message-ID:  <200810151554.m9FFsXGK037543@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kensmith
Date: Wed Oct 15 15:54:33 2008
New Revision: 183921
URL: http://svn.freebsd.org/changeset/base/183921

Log:
  Package installation is handled by starting off with the list of packages
  the user selected and then recursively installing their dependencies, finally
  installing the ones the user selected after the recursion unwinds.  Since
  users often select "high-level" packages that are on a higher numbered
  disc for the multi-volume release CDROMS this resulted in excessive disc
  swapping while installing things like kde, gnome, etc.
  
  Cut down on disc swapping by iterating through the disc volumes one at a
  time if we notice the package set is on multiple volumes.  If a package
  is on a higher volume don't install it yet, but still "process it" so we
  get its dependencies installed.  Because of the way the package sets for
  releases get assembled we're guaranteed dependencies will be on the same
  volume or lower.
  
  Reviewed by:	jhb
  MFC after:	1 week

Modified:
  head/usr.sbin/sysinstall/config.c
  head/usr.sbin/sysinstall/globals.c
  head/usr.sbin/sysinstall/index.c
  head/usr.sbin/sysinstall/package.c
  head/usr.sbin/sysinstall/sysinstall.h

Modified: head/usr.sbin/sysinstall/config.c
==============================================================================
--- head/usr.sbin/sysinstall/config.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/config.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -737,6 +737,7 @@ configPackages(dialogMenuItem *self)
 
     while (1) {
 	int ret, pos, scroll;
+	int current, low, high;
 
 	/* Bring up the packages menu */
 	pos = scroll = 0;
@@ -751,8 +752,14 @@ configPackages(dialogMenuItem *self)
 	    else if (DITEM_STATUS(ret) != DITEM_FAILURE) {
 		dialog_clear();
 		restoreflag = 1;
-		for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
-		    (void)index_extract(mediaDevice, &Top, tmp, FALSE);
+		if (have_volumes) {
+		    low = low_volume;
+		    high = high_volume;
+		} else
+		    low = high = 0;
+		for (current = low; current <= high; current++)
+		    for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
+		        (void)index_extract(mediaDevice, &Top, tmp, FALSE, current);
 		break;
 	    }
 	}

Modified: head/usr.sbin/sysinstall/globals.c
==============================================================================
--- head/usr.sbin/sysinstall/globals.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/globals.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -48,10 +48,13 @@ Boolean		DialogActive;	/* Is libdialog i
 Boolean		ColorDisplay;	/* Are we on a color display? */
 Boolean		OnVTY;		/* Are we on a VTY? */
 Boolean		Restarting;	/* Are we restarting sysinstall? */
+Boolean		have_volumes;	/* Media has more than one volume. */
 Variable	*VarHead;	/* The head of the variable chain */
 Device		*mediaDevice;	/* Where we're installing from */
 int		BootMgr;	/* Which boot manager we're using */
 int		StatusLine;	/* Where to stick our status messages */
+int		low_volume;	/* Lowest volume number */
+int		high_volume;	/* Highest volume number */
 jmp_buf		BailOut;	/* Beam me up, scotty! The natives are pissed! */
 
 Chunk		*HomeChunk;

Modified: head/usr.sbin/sysinstall/index.c
==============================================================================
--- head/usr.sbin/sysinstall/index.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/index.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -225,7 +225,17 @@ new_index(char *name, char *pathto, char
     tmp->deps =		_strdup(deps);
     tmp->depc =		0;
     tmp->installed =	package_installed(name);
+    tmp->vol_checked =	0;
     tmp->volume =	volume;
+    if (volume != 0) {
+	have_volumes = TRUE;
+	if (low_volume == 0)
+	    low_volume = volume;
+	else if (low_volume > volume)
+	    low_volume = volume;
+	if (high_volume < volume)
+	    high_volume = volume;
+    }
     return tmp;
 }
 
@@ -682,9 +692,11 @@ recycle:
 }
 
 int
-index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended)
+index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended,
+    int current_volume)
 {
     int status = DITEM_SUCCESS;
+    Boolean notyet = FALSE;
     PkgNodePtr tmp2;
     IndexEntryPtr id = who->data;
     WINDOW *w;
@@ -699,7 +711,7 @@ index_extract(Device *dev, PkgNodePtr to
      * a certain faulty INDEX file. 
      */
 
-    if (id->installed == 1)
+    if (id->installed == 1 || (have_volumes && id->vol_checked == current_volume))
 	return DITEM_SUCCESS;
 
     w = savescr();
@@ -712,9 +724,13 @@ index_extract(Device *dev, PkgNodePtr to
 	    if ((cp2 = index(cp, ' ')) != NULL)
 		*cp2 = '\0';
 	    if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
-		status = index_extract(dev, top, tmp2, TRUE);
+		status = index_extract(dev, top, tmp2, TRUE, current_volume);
 		if (DITEM_STATUS(status) != DITEM_SUCCESS) {
-		    if (variable_get(VAR_NO_CONFIRM))
+		    /* package probably on a future disc volume */
+		    if (status & DITEM_CONTINUE) {
+			status = DITEM_SUCCESS;
+			notyet = TRUE;
+		    } else if (variable_get(VAR_NO_CONFIRM))
 			msgNotify("Loading of dependent package %s failed", cp);
 		    else
 			msgConfirm("Loading of dependent package %s failed", cp);
@@ -732,10 +748,38 @@ index_extract(Device *dev, PkgNodePtr to
 		cp = NULL;
 	}
     }
-    /* Done with the deps?  Load the real m'coy */
+
+    /*
+     * If iterating through disc volumes one at a time indicate failure if
+     * dependency install failed due to package being on a higher volume
+     * numbered disc, but that we should continue anyway.  Note that this
+     * package has already been processed for this disc volume so we don't
+     * need to do it again.
+     */
+
+    if (notyet) {
+    	restorescr(w);
+	id->vol_checked = current_volume;
+	return DITEM_FAILURE | DITEM_CONTINUE;
+    }
+
+    /*
+     * Done with the deps?  Try to load the real m'coy.  If iterating
+     * through a multi-volume disc set fail the install if the package
+     * is on a higher numbered volume to cut down on disc switches the
+     * user needs to do, but indicate caller should continue processing
+     * despite error return.  Note this package was processed for the
+     * current disc being checked.
+     */
+
     if (DITEM_STATUS(status) == DITEM_SUCCESS) {
 	/* Prompt user if the package is not available on the current volume. */
 	if(mediaDevice->type == DEVICE_TYPE_CDROM) {
+	    if (current_volume != 0 && id->volume > current_volume) {
+		restorescr(w);
+		id->vol_checked = current_volume;
+		return DITEM_FAILURE | DITEM_CONTINUE;
+	    }
 	    while (id->volume != dev->volume) {
 		if (!msgYesNo("This is disc #%d.  Package %s is on disc #%d\n"
 			  "Would you like to switch discs now?\n", dev->volume,
@@ -801,6 +845,8 @@ index_initialize(char *path)
     if (!index_initted) {
 	w = savescr();
 	dialog_clear_norefresh();
+	have_volumes = FALSE;
+	low_volume = high_volume = 0;
 
 	/* Got any media? */
 	if (!mediaVerify()) {

Modified: head/usr.sbin/sysinstall/package.c
==============================================================================
--- head/usr.sbin/sysinstall/package.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/package.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -69,7 +69,7 @@ package_add(char *name)
 
     tmp = index_search(&Top, name, &tmp);
     if (tmp)
-	return index_extract(mediaDevice, &Top, tmp, FALSE);
+	return index_extract(mediaDevice, &Top, tmp, FALSE, 0);
     else {
 	msgConfirm("Sorry, package %s was not found in the INDEX.", name);
 	return DITEM_FAILURE;

Modified: head/usr.sbin/sysinstall/sysinstall.h
==============================================================================
--- head/usr.sbin/sysinstall/sysinstall.h	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/sysinstall.h	Wed Oct 15 15:54:33 2008	(r183921)
@@ -384,6 +384,7 @@ typedef struct _indexEntry {	/* A single
     char *deps;			/* packages this depends on	*/
     int  depc;			/* how many depend on me	*/
     int  installed;		/* indicates if it is installed */
+    int  vol_checked;		/* disc volume last checked for */
     char *maintainer;		/* maintainer			*/
     unsigned int volume;	/* Volume of package            */
 } IndexEntry;
@@ -416,6 +417,7 @@ extern Boolean		RunningAsInit;		/* Are w
 extern Boolean		DialogActive;		/* Is the dialog() stuff up?			*/
 extern Boolean		ColorDisplay;		/* Are we on a color display?			*/
 extern Boolean		OnVTY;			/* On a syscons VTY?				*/
+extern Boolean		have_volumes;		/* Media has multiple volumes                   */
 extern Variable		*VarHead;		/* The head of the variable chain		*/
 extern Device		*mediaDevice;		/* Where we're getting our distribution from	*/
 extern unsigned int	Dists;			/* Which distributions we want			*/
@@ -479,6 +481,8 @@ extern int              FixItMode;      
 extern const char *	StartName;		/* Which name we were started as */
 extern const char *	ProgName;		/* Program's proper name */
 extern int		NCpus;			/* # cpus on machine */
+extern int		low_volume;		/* Lowest volume number */
+extern int		high_volume;		/* Highest volume number */
 
 /* Important chunks. */
 extern Chunk *HomeChunk;
@@ -670,7 +674,7 @@ void		index_init(PkgNodePtr top, PkgNode
 void		index_node_free(PkgNodePtr top, PkgNodePtr plist);
 void		index_sort(PkgNodePtr top);
 void		index_print(PkgNodePtr top, int level);
-int		index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended);
+int		index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended, int current_volume);
 int		index_initialize(char *path);
 PkgNodePtr	index_search(PkgNodePtr top, char *str, PkgNodePtr *tp);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810151554.m9FFsXGK037543>