Make the FTP installation codepath a lot more defensive. Trap

bogus path and FTP I/O errors much earlier, offer retry possibilities
at steps along the way so you don't have to resume from the very beginning
again on a hard error.
This commit is contained in:
jkh 1997-01-15 06:30:50 +00:00
parent ec943e8ff2
commit c99adcceb9
9 changed files with 154 additions and 62 deletions

View File

@ -567,16 +567,10 @@ distExtractAll(dialogMenuItem *self)
int retries = 0;
char buf[512];
/* First try to initialize the state of things */
if (!Dists) {
msgConfirm("You haven't selected any distributions to extract.");
return DITEM_FAILURE;
}
if (!mediaVerify())
/* paranoia */
if (!Dists || !mediaVerify() || !mediaDevice->init(mediaDevice))
return DITEM_FAILURE;
if (!mediaDevice->init(mediaDevice))
return DITEM_FAILURE;
dialog_clear_norefresh();
msgNotify("Attempting to install all selected distributions..");
/* Try for 3 times around the loop, then give up. */
@ -592,7 +586,7 @@ distExtractAll(dialogMenuItem *self)
msgConfirm("Couldn't extract the following distributions. This may\n"
"be because they were not available on the installation\n"
"media you've chosen:\n\n\t%s", buf);
return DITEM_FAILURE | DITEM_RESTORE;
return DITEM_SUCCESS | DITEM_RESTORE;
}
return DITEM_SUCCESS;
}

View File

@ -102,7 +102,10 @@ mediaInitFTP(Device *dev)
ftpBinary(OpenConn);
if (dir && *dir != '\0') {
if ((i = ftpChdir(OpenConn, dir)) != 0) {
msgDebug("Attempt to chdir to distribution in %s returns error code %d\n", dir, i);
if (i == 550)
msgConfirm("No such directory %s, please check your path and try again.", dir);
else
msgConfirm("FTP chdir to directory %s returned FTP error status %d\n", dir, i);
goto punt;
}
}

View File

@ -502,7 +502,7 @@ installNovice(dialogMenuItem *self)
break;
}
if (!mediaDevice && !dmenuOpenSimple(&MenuMedia, FALSE))
if (!mediaDevice && (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice))
return DITEM_FAILURE | DITEM_RECREATE;
if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) {
@ -664,8 +664,31 @@ installCommit(dialogMenuItem *self)
char *str;
Boolean need_bin = FALSE;
if (!mediaVerify())
return DITEM_FAILURE;
if (!Dists) {
if (!msgYesNo("No distributions are selected for installation! Do you\n"
"want to do this now?")) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists)
return DITEM_FAILURE | DITEM_RECREATE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice && !msgYesNo("You need to select a media type first. Do you want\n"
"to do this now?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice->init(mediaDevice)) {
if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
"adjust your media configuration?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
str = variable_get(SYSTEM_STATE);
if (isDebug())
@ -682,9 +705,10 @@ installCommit(dialogMenuItem *self)
if (Dists & DIST_BIN)
need_bin = TRUE;
i = distExtractAll(self);
if (DITEM_STATUS(i) != DITEM_FAILURE || !need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
if (DITEM_STATUS(i) == DITEM_SUCCESS) {
if (!need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
}
variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install");
return i | DITEM_RECREATE;
}

View File

@ -198,18 +198,16 @@ installUpgrade(dialogMenuItem *self)
msgConfirm("You haven't specified any distributions yet. The upgrade procedure will\n"
"only upgrade those portions of the system for which a distribution has\n"
"been selected. In the next screen, we'll go to the Distributions menu\n"
"to select those portions of 2.1 you wish to install on top of your 2.0.5\n"
"system.");
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
"to select those portions of the new system you wish to install on top of\n"
"the old.");
if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists)
return DITEM_FAILURE | DITEM_RECREATE;
dialog_clear_norefresh();
}
/* No bin selected? Not much of an upgrade.. */
if (!(Dists & DIST_BIN)) {
else if (!(Dists & DIST_BIN)) { /* No bin selected? Not much of an upgrade.. */
if (msgYesNo("You didn't select the bin distribution as one of the distributons to load.\n"
"This one is pretty vital to a successful upgrade. Are you SURE you don't\n"
"want to select the bin distribution? Chose _No_ to bring up the Distributions\n"
"want to select the bin distribution? Chose No to bring up the Distributions\n"
"menu.") != 0) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
return DITEM_FAILURE | DITEM_RECREATE;
@ -221,12 +219,18 @@ installUpgrade(dialogMenuItem *self)
if (!(Dists & DIST_BIN))
extractingBin = FALSE;
if (!mediaDevice) {
if (!mediaVerify()) {
msgConfirm("Now you must specify an installation medium for the upgrade.");
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RECREATE;
}
if (!mediaDevice->init(mediaDevice)) {
msgConfirm("Couldn't initialize the media; upgrade aborted. Please\n"
"fix whatever the problem is and try again.");
return DITEM_FAILURE | DITEM_REDRAW;
}
if (RunningAsInit) {
Device **devs;
int i, cnt;
@ -316,16 +320,25 @@ installUpgrade(dialogMenuItem *self)
msgNotify("Beginning extraction of distributions..");
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
if (extractingBin && (Dists & DIST_BIN)) {
msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
else {
if (extractingBin && !(Dists & DIST_BIN)) {
msgConfirm("The extraction process seems to have had some problems, but we got most\n"
"of the essentials. We'll treat this as a warning since it may have been\n"
"only non-essential distributions which failed to load.");
}
else {
msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
msgConfirm("The extraction process seems to have had some problems, but we got most\n"
"of the essentials. We'll treat this as a warning since it may have been\n"
"only non-essential distributions which failed to load.");
}
if (extractingBin) {

View File

@ -502,7 +502,7 @@ installNovice(dialogMenuItem *self)
break;
}
if (!mediaDevice && !dmenuOpenSimple(&MenuMedia, FALSE))
if (!mediaDevice && (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice))
return DITEM_FAILURE | DITEM_RECREATE;
if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) {
@ -664,8 +664,31 @@ installCommit(dialogMenuItem *self)
char *str;
Boolean need_bin = FALSE;
if (!mediaVerify())
return DITEM_FAILURE;
if (!Dists) {
if (!msgYesNo("No distributions are selected for installation! Do you\n"
"want to do this now?")) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists)
return DITEM_FAILURE | DITEM_RECREATE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice && !msgYesNo("You need to select a media type first. Do you want\n"
"to do this now?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice->init(mediaDevice)) {
if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
"adjust your media configuration?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
str = variable_get(SYSTEM_STATE);
if (isDebug())
@ -682,9 +705,10 @@ installCommit(dialogMenuItem *self)
if (Dists & DIST_BIN)
need_bin = TRUE;
i = distExtractAll(self);
if (DITEM_STATUS(i) != DITEM_FAILURE || !need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
if (DITEM_STATUS(i) == DITEM_SUCCESS) {
if (!need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
}
variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install");
return i | DITEM_RECREATE;
}

View File

@ -567,16 +567,10 @@ distExtractAll(dialogMenuItem *self)
int retries = 0;
char buf[512];
/* First try to initialize the state of things */
if (!Dists) {
msgConfirm("You haven't selected any distributions to extract.");
return DITEM_FAILURE;
}
if (!mediaVerify())
/* paranoia */
if (!Dists || !mediaVerify() || !mediaDevice->init(mediaDevice))
return DITEM_FAILURE;
if (!mediaDevice->init(mediaDevice))
return DITEM_FAILURE;
dialog_clear_norefresh();
msgNotify("Attempting to install all selected distributions..");
/* Try for 3 times around the loop, then give up. */
@ -592,7 +586,7 @@ distExtractAll(dialogMenuItem *self)
msgConfirm("Couldn't extract the following distributions. This may\n"
"be because they were not available on the installation\n"
"media you've chosen:\n\n\t%s", buf);
return DITEM_FAILURE | DITEM_RESTORE;
return DITEM_SUCCESS | DITEM_RESTORE;
}
return DITEM_SUCCESS;
}

View File

@ -102,7 +102,10 @@ mediaInitFTP(Device *dev)
ftpBinary(OpenConn);
if (dir && *dir != '\0') {
if ((i = ftpChdir(OpenConn, dir)) != 0) {
msgDebug("Attempt to chdir to distribution in %s returns error code %d\n", dir, i);
if (i == 550)
msgConfirm("No such directory %s, please check your path and try again.", dir);
else
msgConfirm("FTP chdir to directory %s returned FTP error status %d\n", dir, i);
goto punt;
}
}

View File

@ -502,7 +502,7 @@ installNovice(dialogMenuItem *self)
break;
}
if (!mediaDevice && !dmenuOpenSimple(&MenuMedia, FALSE))
if (!mediaDevice && (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice))
return DITEM_FAILURE | DITEM_RECREATE;
if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) {
@ -664,8 +664,31 @@ installCommit(dialogMenuItem *self)
char *str;
Boolean need_bin = FALSE;
if (!mediaVerify())
return DITEM_FAILURE;
if (!Dists) {
if (!msgYesNo("No distributions are selected for installation! Do you\n"
"want to do this now?")) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists)
return DITEM_FAILURE | DITEM_RECREATE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice && !msgYesNo("You need to select a media type first. Do you want\n"
"to do this now?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
if (!mediaDevice->init(mediaDevice)) {
if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
"adjust your media configuration?")) {
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RESTORE;
}
else
return DITEM_FAILURE | DITEM_RESTORE;
}
str = variable_get(SYSTEM_STATE);
if (isDebug())
@ -682,9 +705,10 @@ installCommit(dialogMenuItem *self)
if (Dists & DIST_BIN)
need_bin = TRUE;
i = distExtractAll(self);
if (DITEM_STATUS(i) != DITEM_FAILURE || !need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
if (DITEM_STATUS(i) == DITEM_SUCCESS) {
if (!need_bin || !(Dists & DIST_BIN))
i = installFixup(self);
}
variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install");
return i | DITEM_RECREATE;
}

View File

@ -198,18 +198,16 @@ installUpgrade(dialogMenuItem *self)
msgConfirm("You haven't specified any distributions yet. The upgrade procedure will\n"
"only upgrade those portions of the system for which a distribution has\n"
"been selected. In the next screen, we'll go to the Distributions menu\n"
"to select those portions of 2.1 you wish to install on top of your 2.0.5\n"
"system.");
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
"to select those portions of the new system you wish to install on top of\n"
"the old.");
if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists)
return DITEM_FAILURE | DITEM_RECREATE;
dialog_clear_norefresh();
}
/* No bin selected? Not much of an upgrade.. */
if (!(Dists & DIST_BIN)) {
else if (!(Dists & DIST_BIN)) { /* No bin selected? Not much of an upgrade.. */
if (msgYesNo("You didn't select the bin distribution as one of the distributons to load.\n"
"This one is pretty vital to a successful upgrade. Are you SURE you don't\n"
"want to select the bin distribution? Chose _No_ to bring up the Distributions\n"
"want to select the bin distribution? Chose No to bring up the Distributions\n"
"menu.") != 0) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
return DITEM_FAILURE | DITEM_RECREATE;
@ -221,12 +219,18 @@ installUpgrade(dialogMenuItem *self)
if (!(Dists & DIST_BIN))
extractingBin = FALSE;
if (!mediaDevice) {
if (!mediaVerify()) {
msgConfirm("Now you must specify an installation medium for the upgrade.");
if (!dmenuOpenSimple(&MenuMedia, FALSE) || !mediaDevice)
return DITEM_FAILURE | DITEM_RECREATE;
}
if (!mediaDevice->init(mediaDevice)) {
msgConfirm("Couldn't initialize the media; upgrade aborted. Please\n"
"fix whatever the problem is and try again.");
return DITEM_FAILURE | DITEM_REDRAW;
}
if (RunningAsInit) {
Device **devs;
int i, cnt;
@ -316,16 +320,25 @@ installUpgrade(dialogMenuItem *self)
msgNotify("Beginning extraction of distributions..");
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
if (extractingBin && (Dists & DIST_BIN)) {
msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
else {
if (extractingBin && !(Dists & DIST_BIN)) {
msgConfirm("The extraction process seems to have had some problems, but we got most\n"
"of the essentials. We'll treat this as a warning since it may have been\n"
"only non-essential distributions which failed to load.");
}
else {
msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
msgConfirm("The extraction process seems to have had some problems, but we got most\n"
"of the essentials. We'll treat this as a warning since it may have been\n"
"only non-essential distributions which failed to load.");
}
if (extractingBin) {