summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-06-08 07:02:21 +0000
committerjkh <jkh@FreeBSD.org>1996-06-08 07:02:21 +0000
commit2a03e988da43e97ce7ad936d8d66606c4db8e434 (patch)
tree9d5e42a609d74826c3430900e01edf845acf1643
parentf26a3ce6a2a8fbc774d07ae08e9f77d87500f70f (diff)
downloadFreeBSD-src-2a03e988da43e97ce7ad936d8d66606c4db8e434.zip
FreeBSD-src-2a03e988da43e97ce7ad936d8d66606c4db8e434.tar.gz
Make CDROMs automagically select as the default media type.
If you're running multi-user, check off items in the packages menu based on whether or not they're actually installed.
-rw-r--r--release/sysinstall/cdrom.c54
-rw-r--r--release/sysinstall/config.c3
-rw-r--r--release/sysinstall/index.c27
-rw-r--r--release/sysinstall/main.c8
-rw-r--r--release/sysinstall/media.c13
-rw-r--r--usr.sbin/sade/config.c3
-rw-r--r--usr.sbin/sade/main.c8
-rw-r--r--usr.sbin/sysinstall/cdrom.c54
-rw-r--r--usr.sbin/sysinstall/config.c3
-rw-r--r--usr.sbin/sysinstall/index.c27
-rw-r--r--usr.sbin/sysinstall/main.c8
-rw-r--r--usr.sbin/sysinstall/media.c13
12 files changed, 123 insertions, 98 deletions
diff --git a/release/sysinstall/cdrom.c b/release/sysinstall/cdrom.c
index 5e1dbcf..4f2aca2 100644
--- a/release/sysinstall/cdrom.c
+++ b/release/sysinstall/cdrom.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: cdrom.c,v 1.12 1996/04/13 13:31:23 jkh Exp $
+ * $Id: cdrom.c,v 1.13 1996/04/23 01:29:10 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -51,6 +51,10 @@
#include <sys/mount.h>
#undef CD9660
+#define CD_UNMOUNTED 0
+#define CD_ALREADY_MOUNTED 1
+#define CD_WE_MOUNTED_IT 2
+
/*
* This isn't static, like the others, since it's often useful to know whether
* or not we have a CDROM available in some of the other installation screens.
@@ -65,10 +69,8 @@ Boolean
mediaInitCDROM(Device *dev)
{
struct iso_args args;
- struct stat sb;
- char specialrel[80];
- if (!RunningAsInit || cdromMounted)
+ if (cdromMounted != CD_UNMOUNTED)
return TRUE;
if (Mkdir("/cdrom", NULL))
@@ -78,31 +80,17 @@ mediaInitCDROM(Device *dev)
args.fspec = dev->devname;
args.flags = 0;
- if (directory_exists("/cdrom/dists"))
- cdromMounted = 2;
- else if (mount(MOUNT_CD9660, "/cdrom", MNT_RDONLY, (caddr_t) &args) == -1) {
- msgConfirm("Error mounting %s on /cdrom: %s (%u)", dev->devname, strerror(errno), errno);
- return FALSE;
- }
- /*
- * Do a very simple check to see if this looks roughly like a FreeBSD CDROM
- * Unfortunately FreeBSD won't let us read the ``label'' AFAIK, which is one
- * sure way of telling the disc version :-(
- */
- snprintf(specialrel, 80, "/cdrom/%s/dists", variable_get(VAR_RELNAME));
- if (stat("/cdrom/dists", &sb) && stat(specialrel, &sb)) {
- if (errno == ENOENT) {
- msgConfirm("Couldn't locate the directory `dists' anywhere on the CD.\n"
- "Is this a FreeBSD CDROM? Is the release version set properly\n"
- "in the Options editor?");
- return FALSE;
- }
- else {
- msgConfirm("Error trying to stat the CDROM's dists directory: %s", strerror(errno));
+ /* If this cdrom's not already mounted or can't be mounted, yell */
+ if (!directory_exists("/cdrom/dists")) {
+ if (mount(MOUNT_CD9660, "/cdrom", MNT_RDONLY, (caddr_t) &args) == -1) {
+ msgConfirm("Error mounting %s on /cdrom: %s (%u)", dev->devname, strerror(errno), errno);
return FALSE;
}
+ else
+ cdromMounted = CD_WE_MOUNTED_IT;
}
- cdromMounted = 1;
+ else
+ cdromMounted = CD_ALREADY_MOUNTED;
msgDebug("Mounted CDROM device %s on /cdrom\n", dev->devname);
return TRUE;
}
@@ -129,12 +117,16 @@ mediaGetCDROM(Device *dev, char *file, Boolean probe)
void
mediaShutdownCDROM(Device *dev)
{
- if (!RunningAsInit || !cdromMounted || cdromMounted == 2)
+ /* Only undo it if we did it */
+ if (cdromMounted != CD_WE_MOUNTED_IT)
return;
msgDebug("Unmounting %s from /cdrom\n", dev->devname);
- if (unmount("/cdrom", MNT_FORCE) != 0)
+ if (unmount("/cdrom", MNT_FORCE) != 0) {
msgConfirm("Could not unmount the CDROM from /cdrom: %s", strerror(errno));
- msgDebug("Unmount successful\n");
- cdromMounted = 0;
- return;
+ cdromMounted = CD_ALREADY_MOUNTED; /* Guess somebody else got it */
+ }
+ else {
+ msgDebug("Unmount successful\n");
+ cdromMounted = CD_UNMOUNTED;
+ }
}
diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c
index 85eb685..7b0e6f8 100644
--- a/release/sysinstall/config.c
+++ b/release/sysinstall/config.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: config.c,v 1.32 1996/05/23 16:34:24 jkh Exp $
+ * $Id: config.c,v 1.33 1996/05/29 01:35:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -473,6 +473,7 @@ configPackages(dialogMenuItem *self)
}
}
else {
+ dialog_clear();
msgConfirm("No packages were selected for extraction.");
break;
}
diff --git a/release/sysinstall/index.c b/release/sysinstall/index.c
index af5214f..d08f98b 100644
--- a/release/sysinstall/index.c
+++ b/release/sysinstall/index.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: index.c,v 1.29 1996/05/16 11:47:29 jkh Exp $
+ * $Id: index.c,v 1.30 1996/05/23 16:34:27 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -384,8 +384,15 @@ pkg_checked(dialogMenuItem *self)
{
PkgNodePtr kp = self->data, plist = (PkgNodePtr)self->aux;
- if (kp->type == PACKAGE && plist)
- return index_search(plist, kp->name, NULL) ? TRUE : FALSE;
+ if (kp->type == PACKAGE && kp->name && plist) {
+ int i;
+
+ i = index_search(plist, kp->name, NULL) ? TRUE : FALSE;
+ if (!RunningAsInit)
+ return i || package_exists(kp->name);
+ else
+ return i;
+ }
else
return FALSE;
}
@@ -402,14 +409,16 @@ pkg_fire(dialogMenuItem *self)
sp = index_search(plist, kp->name, NULL);
/* Not already selected? */
if (!sp) {
- PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
+ if (RunningAsInit || !package_exists(kp->name)) {
+ PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
- *np = *kp;
- np->next = plist->kids;
- plist->kids = np;
- msgInfo("Added %s to selection list", kp->name);
+ *np = *kp;
+ np->next = plist->kids;
+ plist->kids = np;
+ msgInfo("Added %s to selection list", kp->name);
+ }
}
- else if (sp) {
+ else {
msgInfo("Removed %s from selection list", kp->name);
index_delete(sp);
}
diff --git a/release/sysinstall/main.c b/release/sysinstall/main.c
index 60d292c..c7cdffe 100644
--- a/release/sysinstall/main.c
+++ b/release/sysinstall/main.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
- * $Id: main.c,v 1.19 1996/05/16 11:47:33 jkh Exp $
+ * $Id: main.c,v 1.20 1996/05/28 18:30:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -83,6 +83,12 @@ main(int argc, char **argv)
/* Probe for all relevant devices on the system */
deviceGetAll();
+ /* Try to set ourselves up as a CDROM if we can do that first */
+ if (DITEM_STATUS(mediaSetCDROM(NULL)) == DITEM_SUCCESS) {
+ /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
+ if (!mediaDevice->init(mediaDevice))
+ mediaDevice = NULL;
+ }
if (argc > 1 && !RunningAsInit) {
int i;
diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c
index d61654d..cd5d9c6 100644
--- a/release/sysinstall/media.c
+++ b/release/sysinstall/media.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: media.c,v 1.37 1996/04/28 01:07:24 jkh Exp $
+ * $Id: media.c,v 1.38 1996/04/28 03:27:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -85,10 +85,11 @@ mediaSetCDROM(dialogMenuItem *self)
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
if (!cnt) {
- msgConfirm("No CDROM devices found! Please check that your system's\n"
- "configuration is correct and that the CDROM drive is of a supported\n"
- "type. For more information, consult the hardware guide\n"
- "in the Doc menu.");
+ if (self) /* Interactive? */
+ msgConfirm("No CDROM devices found! Please check that your system's\n"
+ "configuration is correct and that the CDROM drive is of a supported\n"
+ "type. For more information, consult the hardware guide\n"
+ "in the Doc menu.");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
@@ -105,7 +106,7 @@ mediaSetCDROM(dialogMenuItem *self)
}
else
mediaDevice = devs[0];
- return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE | DITEM_RECREATE;
+ return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE | DITEM_RECREATE;
}
static int
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c
index 85eb685..7b0e6f8 100644
--- a/usr.sbin/sade/config.c
+++ b/usr.sbin/sade/config.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: config.c,v 1.32 1996/05/23 16:34:24 jkh Exp $
+ * $Id: config.c,v 1.33 1996/05/29 01:35:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -473,6 +473,7 @@ configPackages(dialogMenuItem *self)
}
}
else {
+ dialog_clear();
msgConfirm("No packages were selected for extraction.");
break;
}
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
index 60d292c..c7cdffe 100644
--- a/usr.sbin/sade/main.c
+++ b/usr.sbin/sade/main.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
- * $Id: main.c,v 1.19 1996/05/16 11:47:33 jkh Exp $
+ * $Id: main.c,v 1.20 1996/05/28 18:30:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -83,6 +83,12 @@ main(int argc, char **argv)
/* Probe for all relevant devices on the system */
deviceGetAll();
+ /* Try to set ourselves up as a CDROM if we can do that first */
+ if (DITEM_STATUS(mediaSetCDROM(NULL)) == DITEM_SUCCESS) {
+ /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
+ if (!mediaDevice->init(mediaDevice))
+ mediaDevice = NULL;
+ }
if (argc > 1 && !RunningAsInit) {
int i;
diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c
index 5e1dbcf..4f2aca2 100644
--- a/usr.sbin/sysinstall/cdrom.c
+++ b/usr.sbin/sysinstall/cdrom.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: cdrom.c,v 1.12 1996/04/13 13:31:23 jkh Exp $
+ * $Id: cdrom.c,v 1.13 1996/04/23 01:29:10 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -51,6 +51,10 @@
#include <sys/mount.h>
#undef CD9660
+#define CD_UNMOUNTED 0
+#define CD_ALREADY_MOUNTED 1
+#define CD_WE_MOUNTED_IT 2
+
/*
* This isn't static, like the others, since it's often useful to know whether
* or not we have a CDROM available in some of the other installation screens.
@@ -65,10 +69,8 @@ Boolean
mediaInitCDROM(Device *dev)
{
struct iso_args args;
- struct stat sb;
- char specialrel[80];
- if (!RunningAsInit || cdromMounted)
+ if (cdromMounted != CD_UNMOUNTED)
return TRUE;
if (Mkdir("/cdrom", NULL))
@@ -78,31 +80,17 @@ mediaInitCDROM(Device *dev)
args.fspec = dev->devname;
args.flags = 0;
- if (directory_exists("/cdrom/dists"))
- cdromMounted = 2;
- else if (mount(MOUNT_CD9660, "/cdrom", MNT_RDONLY, (caddr_t) &args) == -1) {
- msgConfirm("Error mounting %s on /cdrom: %s (%u)", dev->devname, strerror(errno), errno);
- return FALSE;
- }
- /*
- * Do a very simple check to see if this looks roughly like a FreeBSD CDROM
- * Unfortunately FreeBSD won't let us read the ``label'' AFAIK, which is one
- * sure way of telling the disc version :-(
- */
- snprintf(specialrel, 80, "/cdrom/%s/dists", variable_get(VAR_RELNAME));
- if (stat("/cdrom/dists", &sb) && stat(specialrel, &sb)) {
- if (errno == ENOENT) {
- msgConfirm("Couldn't locate the directory `dists' anywhere on the CD.\n"
- "Is this a FreeBSD CDROM? Is the release version set properly\n"
- "in the Options editor?");
- return FALSE;
- }
- else {
- msgConfirm("Error trying to stat the CDROM's dists directory: %s", strerror(errno));
+ /* If this cdrom's not already mounted or can't be mounted, yell */
+ if (!directory_exists("/cdrom/dists")) {
+ if (mount(MOUNT_CD9660, "/cdrom", MNT_RDONLY, (caddr_t) &args) == -1) {
+ msgConfirm("Error mounting %s on /cdrom: %s (%u)", dev->devname, strerror(errno), errno);
return FALSE;
}
+ else
+ cdromMounted = CD_WE_MOUNTED_IT;
}
- cdromMounted = 1;
+ else
+ cdromMounted = CD_ALREADY_MOUNTED;
msgDebug("Mounted CDROM device %s on /cdrom\n", dev->devname);
return TRUE;
}
@@ -129,12 +117,16 @@ mediaGetCDROM(Device *dev, char *file, Boolean probe)
void
mediaShutdownCDROM(Device *dev)
{
- if (!RunningAsInit || !cdromMounted || cdromMounted == 2)
+ /* Only undo it if we did it */
+ if (cdromMounted != CD_WE_MOUNTED_IT)
return;
msgDebug("Unmounting %s from /cdrom\n", dev->devname);
- if (unmount("/cdrom", MNT_FORCE) != 0)
+ if (unmount("/cdrom", MNT_FORCE) != 0) {
msgConfirm("Could not unmount the CDROM from /cdrom: %s", strerror(errno));
- msgDebug("Unmount successful\n");
- cdromMounted = 0;
- return;
+ cdromMounted = CD_ALREADY_MOUNTED; /* Guess somebody else got it */
+ }
+ else {
+ msgDebug("Unmount successful\n");
+ cdromMounted = CD_UNMOUNTED;
+ }
}
diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c
index 85eb685..7b0e6f8 100644
--- a/usr.sbin/sysinstall/config.c
+++ b/usr.sbin/sysinstall/config.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: config.c,v 1.32 1996/05/23 16:34:24 jkh Exp $
+ * $Id: config.c,v 1.33 1996/05/29 01:35:25 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -473,6 +473,7 @@ configPackages(dialogMenuItem *self)
}
}
else {
+ dialog_clear();
msgConfirm("No packages were selected for extraction.");
break;
}
diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c
index af5214f..d08f98b 100644
--- a/usr.sbin/sysinstall/index.c
+++ b/usr.sbin/sysinstall/index.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: index.c,v 1.29 1996/05/16 11:47:29 jkh Exp $
+ * $Id: index.c,v 1.30 1996/05/23 16:34:27 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -384,8 +384,15 @@ pkg_checked(dialogMenuItem *self)
{
PkgNodePtr kp = self->data, plist = (PkgNodePtr)self->aux;
- if (kp->type == PACKAGE && plist)
- return index_search(plist, kp->name, NULL) ? TRUE : FALSE;
+ if (kp->type == PACKAGE && kp->name && plist) {
+ int i;
+
+ i = index_search(plist, kp->name, NULL) ? TRUE : FALSE;
+ if (!RunningAsInit)
+ return i || package_exists(kp->name);
+ else
+ return i;
+ }
else
return FALSE;
}
@@ -402,14 +409,16 @@ pkg_fire(dialogMenuItem *self)
sp = index_search(plist, kp->name, NULL);
/* Not already selected? */
if (!sp) {
- PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
+ if (RunningAsInit || !package_exists(kp->name)) {
+ PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
- *np = *kp;
- np->next = plist->kids;
- plist->kids = np;
- msgInfo("Added %s to selection list", kp->name);
+ *np = *kp;
+ np->next = plist->kids;
+ plist->kids = np;
+ msgInfo("Added %s to selection list", kp->name);
+ }
}
- else if (sp) {
+ else {
msgInfo("Removed %s from selection list", kp->name);
index_delete(sp);
}
diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c
index 60d292c..c7cdffe 100644
--- a/usr.sbin/sysinstall/main.c
+++ b/usr.sbin/sysinstall/main.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
- * $Id: main.c,v 1.19 1996/05/16 11:47:33 jkh Exp $
+ * $Id: main.c,v 1.20 1996/05/28 18:30:30 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -83,6 +83,12 @@ main(int argc, char **argv)
/* Probe for all relevant devices on the system */
deviceGetAll();
+ /* Try to set ourselves up as a CDROM if we can do that first */
+ if (DITEM_STATUS(mediaSetCDROM(NULL)) == DITEM_SUCCESS) {
+ /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
+ if (!mediaDevice->init(mediaDevice))
+ mediaDevice = NULL;
+ }
if (argc > 1 && !RunningAsInit) {
int i;
diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c
index d61654d..cd5d9c6 100644
--- a/usr.sbin/sysinstall/media.c
+++ b/usr.sbin/sysinstall/media.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: media.c,v 1.37 1996/04/28 01:07:24 jkh Exp $
+ * $Id: media.c,v 1.38 1996/04/28 03:27:11 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -85,10 +85,11 @@ mediaSetCDROM(dialogMenuItem *self)
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
if (!cnt) {
- msgConfirm("No CDROM devices found! Please check that your system's\n"
- "configuration is correct and that the CDROM drive is of a supported\n"
- "type. For more information, consult the hardware guide\n"
- "in the Doc menu.");
+ if (self) /* Interactive? */
+ msgConfirm("No CDROM devices found! Please check that your system's\n"
+ "configuration is correct and that the CDROM drive is of a supported\n"
+ "type. For more information, consult the hardware guide\n"
+ "in the Doc menu.");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
@@ -105,7 +106,7 @@ mediaSetCDROM(dialogMenuItem *self)
}
else
mediaDevice = devs[0];
- return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE | DITEM_RECREATE;
+ return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE) | DITEM_RESTORE | DITEM_RECREATE;
}
static int
OpenPOWER on IntegriCloud