diff options
Diffstat (limited to 'release/sysinstall/dist.c')
-rw-r--r-- | release/sysinstall/dist.c | 248 |
1 files changed, 157 insertions, 91 deletions
diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c index 539fc61..d01c84f 100644 --- a/release/sysinstall/dist.c +++ b/release/sysinstall/dist.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dist.c,v 1.36.2.1 1995/07/21 10:53:48 rgrimes Exp $ + * $Id: dist.c,v 1.37 1995/09/18 16:52:24 peter Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -80,7 +80,7 @@ static Distribution DistTable[] = { { "compat20", "/", &Dists, DIST_COMPAT20, NULL }, { "commerce", "/usr/local", &Dists, DIST_COMMERCIAL, NULL }, { "xperimnt", "/usr/local", &Dists, DIST_EXPERIMENTAL, NULL }, -{ "XF86311", "/usr", &Dists, DIST_XF86, XF86DistTable }, +{ "XF86312", "/usr", &Dists, DIST_XF86, XF86DistTable }, { NULL }, }; @@ -110,23 +110,27 @@ static Distribution SrcDistTable[] = { { "ssys", "/usr/src", &SrcDists, DIST_SRC_SYS, NULL }, { "subin", "/usr/src", &SrcDists, DIST_SRC_UBIN, NULL }, { "susbin", "/usr/src", &SrcDists, DIST_SRC_USBIN, NULL }, +{ "ssmailcf", "/usr/src", &SrcDists, DIST_SRC_SMAILCF, NULL }, { NULL }, }; /* The XFree86 distribution */ static Distribution XF86DistTable[] = { -{ "X311bin", "/usr", &XF86Dists, DIST_XF86_BIN, NULL }, -{ "X311lib", "/usr", &XF86Dists, DIST_XF86_LIB, NULL }, -{ "X311doc", "/usr", &XF86Dists, DIST_XF86_DOC, NULL }, -{ "XF86311", "/usr", &XF86Dists, DIST_XF86_FONTS, XF86FontDistTable }, -{ "X311man", "/usr", &XF86Dists, DIST_XF86_MAN, NULL }, -{ "X311prog", "/usr", &XF86Dists, DIST_XF86_PROG, NULL }, -{ "X311link", "/usr", &XF86Dists, DIST_XF86_LINK, NULL }, -{ "X311pex", "/usr", &XF86Dists, DIST_XF86_PEX, NULL }, -{ "X311lbx", "/usr", &XF86Dists, DIST_XF86_LBX, NULL }, -{ "X311xicf", "/usr", &XF86Dists, DIST_XF86_XINIT, NULL }, -{ "X311xdcf", "/usr", &XF86Dists, DIST_XF86_XDMCF, NULL }, -{ "XF86311", "/usr", &XF86Dists, DIST_XF86_SERVER, XF86ServerDistTable }, +{ "X312bin", "/usr", &XF86Dists, DIST_XF86_BIN, NULL }, +{ "X312lib", "/usr", &XF86Dists, DIST_XF86_LIB, NULL }, +{ "X312doc", "/usr", &XF86Dists, DIST_XF86_DOC, NULL }, +{ "X312etc", "/usr", &XF86Dists, DIST_XF86_ETC, NULL }, +{ "XF86312", "/usr", &XF86Dists, DIST_XF86_FONTS, XF86FontDistTable }, +{ "X312man", "/usr", &XF86Dists, DIST_XF86_MAN, NULL }, +{ "X312ctrb", "/usr", &XF86Dists, DIST_XF86_CTRB, NULL }, +{ "X312prog", "/usr", &XF86Dists, DIST_XF86_PROG, NULL }, +{ "X312link", "/usr", &XF86Dists, DIST_XF86_LINK, NULL }, +{ "X312pex", "/usr", &XF86Dists, DIST_XF86_PEX, NULL }, +{ "X312lbx", "/usr", &XF86Dists, DIST_XF86_LBX, NULL }, +{ "X312ubin", "/usr", &XF86Dists, DIST_XF86_UBIN, NULL }, +{ "X312xicf", "/usr", &XF86Dists, DIST_XF86_XINIT, NULL }, +{ "X312xdcf", "/usr", &XF86Dists, DIST_XF86_XDMCF, NULL }, +{ "XF86312", "/usr", &XF86Dists, DIST_XF86_SERVER, XF86ServerDistTable }, { "XF86-xc", "/usr/X11R6/src", &XF86Dists, DIST_XF86_SRC, NULL }, { "XF86-co", "/usr/X11R6/src", &XF86Dists, DIST_XF86_SRC, NULL }, { NULL }, @@ -134,28 +138,29 @@ static Distribution XF86DistTable[] = { /* The XFree86 server distribution */ static Distribution XF86ServerDistTable[] = { -{ "X3118514", "/usr", &XF86ServerDists, DIST_XF86_SERVER_8514, NULL }, -{ "X311AGX", "/usr", &XF86ServerDists, DIST_XF86_SERVER_AGX, NULL }, -{ "X311Ma8", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH8, NULL }, -{ "X311Ma32", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH32,NULL }, -{ "X311Ma64", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH64,NULL }, -{ "X311Mono", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MONO, NULL }, -{ "X311P9K", "/usr", &XF86ServerDists, DIST_XF86_SERVER_P9000, NULL }, -{ "X311S3", "/usr", &XF86ServerDists, DIST_XF86_SERVER_S3, NULL }, -{ "X311SVGA", "/usr", &XF86ServerDists, DIST_XF86_SERVER_SVGA, NULL }, -{ "X311VG16", "/usr", &XF86ServerDists, DIST_XF86_SERVER_VGA16, NULL }, -{ "X311W32", "/usr", &XF86ServerDists, DIST_XF86_SERVER_W32, NULL }, -{ "X311nest", "/usr", &XF86ServerDists, DIST_XF86_SERVER_NEST, NULL }, +{ "X3128514", "/usr", &XF86ServerDists, DIST_XF86_SERVER_8514, NULL }, +{ "X312AGX", "/usr", &XF86ServerDists, DIST_XF86_SERVER_AGX, NULL }, +{ "X312Ma8", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH8, NULL }, +{ "X312Ma32", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH32,NULL }, +{ "X312Ma64", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MACH64,NULL }, +{ "X312Mono", "/usr", &XF86ServerDists, DIST_XF86_SERVER_MONO, NULL }, +{ "X312P9K", "/usr", &XF86ServerDists, DIST_XF86_SERVER_P9000, NULL }, +{ "X312S3", "/usr", &XF86ServerDists, DIST_XF86_SERVER_S3, NULL }, +{ "X312SVGA", "/usr", &XF86ServerDists, DIST_XF86_SERVER_SVGA, NULL }, +{ "X312VG16", "/usr", &XF86ServerDists, DIST_XF86_SERVER_VGA16, NULL }, +{ "X312W32", "/usr", &XF86ServerDists, DIST_XF86_SERVER_W32, NULL }, +{ "X312nest", "/usr", &XF86ServerDists, DIST_XF86_SERVER_NEST, NULL }, { NULL }, }; /* The XFree86 font distribution */ static Distribution XF86FontDistTable[] = { -{ "X311fnts", "/usr", &XF86FontDists, DIST_XF86_FONTS_MISC, NULL }, -{ "X311f100", "/usr", &XF86FontDists, DIST_XF86_FONTS_100, NULL }, -{ "X311fscl", "/usr", &XF86FontDists, DIST_XF86_FONTS_SCALE, NULL }, -{ "X311fnon", "/usr", &XF86FontDists, DIST_XF86_FONTS_NON, NULL }, -{ "X311fsrv", "/usr", &XF86FontDists, DIST_XF86_FONTS_SERVER, NULL }, +{ "X312fnts", "/usr", &XF86FontDists, DIST_XF86_FONTS_MISC, NULL }, +{ "X312f100", "/usr", &XF86FontDists, DIST_XF86_FONTS_100, NULL }, +{ "X312fcyr", "/usr", &XF86FontDists, DIST_XF86_FONTS_CYR, NULL }, +{ "X312fscl", "/usr", &XF86FontDists, DIST_XF86_FONTS_SCALE, NULL }, +{ "X312fnon", "/usr", &XF86FontDists, DIST_XF86_FONTS_NON, NULL }, +{ "X312fsrv", "/usr", &XF86FontDists, DIST_XF86_FONTS_SERVER, NULL }, { NULL }, }; @@ -167,7 +172,7 @@ distReset(char *str) XF86Dists = 0; XF86ServerDists = 0; XF86FontDists = 0; - return 0; + return RET_SUCCESS; } int @@ -176,7 +181,7 @@ distSetDeveloper(char *str) distReset(NULL); Dists = _DIST_DEVELOPER; SrcDists = DIST_SRC_ALL; - return 0; + return RET_SUCCESS; } int @@ -189,7 +194,7 @@ distSetXDeveloper(char *str) XF86ServerDists = DIST_XF86_SERVER_SVGA; XF86FontDists = DIST_XF86_FONTS_MISC; distSetXF86(NULL); - return 0; + return RET_SUCCESS; } int @@ -198,7 +203,7 @@ distSetKernDeveloper(char *str) distReset(NULL); Dists = _DIST_DEVELOPER; SrcDists = DIST_SRC_SYS; - return 0; + return RET_SUCCESS; } int @@ -206,7 +211,7 @@ distSetUser(char *str) { distReset(NULL); Dists = _DIST_USER; - return 0; + return RET_SUCCESS; } int @@ -218,7 +223,7 @@ distSetXUser(char *str) XF86ServerDists = DIST_XF86_SERVER_SVGA; XF86FontDists = DIST_XF86_FONTS_MISC; distSetXF86(NULL); - return 0; + return RET_SUCCESS; } int @@ -226,7 +231,7 @@ distSetMinimum(char *str) { distReset(NULL); Dists = DIST_BIN; - return 0; + return RET_SUCCESS; } int @@ -237,16 +242,33 @@ distSetEverything(char *str) XF86Dists = DIST_XF86_ALL; XF86ServerDists = DIST_XF86_SERVER_ALL; XF86FontDists = DIST_XF86_FONTS_ALL; - return 0; + return RET_SUCCESS; +} + +int +distSetCustom(char *str) +{ + /* These *ALL* have to be set at once. It's for power users only! :) */ + if (sscanf(str, "%d %d %d %d %d %d", + &Dists, &DESDists, &SrcDists, &XF86Dists, &XF86ServerDists, &XF86FontDists) != 6) { + dialog_clear(); + msgConfirm("Warning: A `%s' set was configured which did not set all\n" + "distributions explicitly. Some distributions will default to\n" + "unselected as a result.", str); + } + return RET_SUCCESS; } int distSetDES(char *str) { dmenuOpenSimple(&MenuDESDistributions); - if (DESDists) + if (DESDists) { + if (DESDists & DIST_DES_KERBEROS) + DESDists |= DIST_DES_DES; Dists |= DIST_DES; - return 0; + } + return RET_SUCCESS; } int @@ -255,7 +277,7 @@ distSetSrc(char *str) dmenuOpenSimple(&MenuSrcDistributions); if (SrcDists) Dists |= DIST_SRC; - return 0; + return RET_SUCCESS; } int @@ -271,7 +293,7 @@ distSetXF86(char *str) if (isDebug()) msgDebug("SetXF86 Masks: Server: %0x, Fonts: %0x, XDists: %0x, Dists: %0x\n", XF86ServerDists, XF86FontDists, XF86Dists, Dists); - return 0; + return RET_SUCCESS; } static Boolean @@ -312,43 +334,46 @@ distExtract(char *parent, Distribution *me) snprintf(buf, 512, "%s/%s.tgz", path, dist); if (isDebug()) msgDebug("Trying to get large piece: %s\n", buf); - /* Set it as an "exploratory get" so that we don't loop unnecessarily on it */ - mediaDevice->flags |= OPT_EXPLORATORY_GET; - fd = (*mediaDevice->get)(mediaDevice, buf, NULL); - mediaDevice->flags &= ~OPT_EXPLORATORY_GET; + fd = mediaDevice->get(mediaDevice, buf, TRUE); if (fd >= 0) { msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); status = mediaExtractDist(me[i].my_dir, fd); - (*mediaDevice->close)(mediaDevice, fd); + mediaDevice->close(mediaDevice, fd); goto done; } - else if (fd == -2) /* Hard error, can't continue */ - return FALSE; + else if (fd == -2) { /* Hard error, can't continue */ + mediaDevice->shutdown(mediaDevice); + status = FALSE; + goto done; + } + + /* + * If we couldn't get it as one file then we need to get multiple pieces; locate and parse an + * info file telling us how many we need for this distribution. + */ + dist_attr = NULL; + numchunks = 0; - /* If we couldn't get it as one file then we need to get multiple pieces; get info file telling us how many */ snprintf(buf, sizeof buf, "/stand/info/%s/%s.inf", path, dist); - if (!access(buf, R_OK)) { + if (file_readable(buf)) { if (isDebug()) - msgDebug("Parsing attributes file for %s\n", dist); + msgDebug("Parsing attributes file for distribution %s\n", dist); dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); - if (attr_parse(&dist_attr, buf) == 0) { - msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); - return FALSE; + if (attr_parse_file(dist_attr, buf) == RET_FAIL) { + dialog_clear(); + msgConfirm("Cannot load information file for %s distribution!\n" + "Please verify that your media is valid and try again.", dist); } - - if (isDebug()) - msgDebug("Looking for attribute `pieces'\n"); - tmp = attr_match(dist_attr, "pieces"); - if (tmp) - numchunks = strtol(tmp, 0, 0); - else - numchunks = 0; - } - else { - if (isDebug()) - msgDebug("Couldn't open attributes file: %s\n", buf); - numchunks = 0; + else { + if (isDebug()) + msgDebug("Looking for attribute `pieces'\n"); + tmp = attr_match(dist_attr, "pieces"); + if (tmp) + numchunks = strtol(tmp, 0, 0); + } + safe_free(dist_attr); } + if (!numchunks) continue; @@ -364,8 +389,8 @@ distExtract(char *parent, Distribution *me) snprintf(buf, 512, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); if (isDebug()) - msgDebug("trying for piece %d of %d: %s\n", chunk, numchunks, buf); - fd = (*mediaDevice->get)(mediaDevice, buf, dist_attr); + msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks, buf); + fd = mediaDevice->get(mediaDevice, buf, FALSE); if (fd < 0) { dialog_clear(); msgConfirm("failed to retreive piece file %s!\nAborting the transfer", buf); @@ -373,18 +398,17 @@ distExtract(char *parent, Distribution *me) } snprintf(prompt, 80, "Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); dialog_gauge("Progress", prompt, 8, 15, 6, 50, (int)((float)(chunk + 1) / numchunks * 100)); + move(0, 0); /* Get cursor out of the way - it makes gauges look strange */ while ((n = read(fd, buf, sizeof buf)) > 0) { retval = write(fd2, buf, n); if (retval != n) { - if (mediaDevice->close) - (*mediaDevice->close)(mediaDevice, fd); - else - close(fd); + mediaDevice->close(mediaDevice, fd); + dialog_clear(); msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, n); goto punt; } } - (*mediaDevice->close)(mediaDevice, fd); + mediaDevice->close(mediaDevice, fd); } close(fd2); status = mediaExtractDistEnd(zpid, cpid); @@ -397,15 +421,23 @@ distExtract(char *parent, Distribution *me) done: if (!status) { - if (OptFlags & OPT_NO_CONFIRM) + if (variable_get(VAR_NO_CONFIRM)) status = TRUE; else { if (me[i].my_dist) { - msgConfirm("Unable to transfer all components of the %s distribution.\nIf this is a CDROM install, it may be because export restrictions prohibit\nDES code from being shipped from the U.S. Try to get this code from a\nlocal FTP site instead!"); + dialog_clear(); + msgConfirm("Unable to transfer all components of the %s distribution.\n" + "If this is a CDROM install, it may be because export restrictions prohibit\n" + "DES code from being shipped from the U.S. Try to get this code from a\n" + "local FTP site instead!", me[i].my_name); status = TRUE; } - else - status = msgYesNo("Unable to transfer the %s distribution from %s.\nDo you want to try to retrieve it again?", me[i].my_name, mediaDevice->name); + else { + dialog_clear(); + status = msgYesNo("Unable to transfer the %s distribution from %s.\n" + "Do you want to try to retrieve it again?", + me[i].my_name, mediaDevice->name); + } } } /* Extract was successful, remove ourselves from further consideration */ @@ -415,24 +447,58 @@ distExtract(char *parent, Distribution *me) return status; } +static void +printSelected(char *buf, int selected, Distribution *me) +{ + int i; + static int col = 0; + + /* Loop through to see if we're in our parent's plans */ + for (i = 0; me[i].my_name; i++) { + + /* If our bit isn't set, go to the next */ + if (!(me[i].my_bit & selected)) + continue; + + /* This is shorthand for "dist currently disabled" */ + if (!me[i].my_dir) + continue; + + col += strlen(me[i].my_name); + if (col > 50) { + col = 0; + strcat(buf, "\n"); + } + sprintf(&buf[strlen(buf)], " %s", me[i].my_name); + /* Recurse if have a sub-distribution */ + if (me[i].my_dist) + printSelected(buf, *(me[i].my_mask), me[i].my_dist); + } +} + int -distExtractAll(char *unused) +distExtractAll(char *ptr) { int retries = 0; + char buf[512]; /* First try to initialize the state of things */ - if (!(*mediaDevice->init)(mediaDevice)) - return 0; - + if (!mediaDevice->init(mediaDevice)) + return RET_FAIL; + if (!Dists && ptr) { + msgConfirm("You haven't selected any distributions to extract."); + return RET_FAIL; + } /* Try for 3 times around the loop, then give up. */ while (Dists && ++retries < 3) distExtract(NULL, DistTable); - /* Anything left? */ - if (Dists) - msgConfirm("Couldn't extract all of the distributions. This may\nbe because the specified distributions are not available from the\ninstallation media you've chosen (residue: %0x)", Dists); - - /* Close up shop and go home */ - (*mediaDevice->shutdown)(mediaDevice); - return 0; + if (Dists) { + printSelected(buf, Dists, DistTable); + dialog_clear(); + msgConfirm("Couldn't extract all of the distributions. This may\n" + "be because the following distributions are not available on the\n" + "installation media you've chosen:\n\n\t%s", buf); + } + return RET_SUCCESS; } |