Use a menu for 'install from floppy' questions.

Ask whether the user wants to delete the fetched files (ftp and floppy) after
install.  Delete after sucessful install of each file.
Kill bufferred tty input in a couple of places when typeahead will be wrong.
Code added to run.c to do a 'cd' in the child, unused (so far).
This commit is contained in:
dsl 2006-02-25 20:21:00 +00:00
parent 286c74606d
commit ac97411677
12 changed files with 155 additions and 180 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.126 2006/02/25 13:29:34 dsl Exp $ */
/* $NetBSD: defs.h,v 1.127 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -244,7 +244,6 @@ const char *doessf;
/* Relative file name for storing a distribution. */
char xfer_dir[STRSIZE];
int clean_xfer_dir;
/* Absolute path name where the distribution should be extracted from. */
#if !defined(SYSINST_FTP_HOST)
#define SYSINST_FTP_HOST "ftp.NetBSD.org"
@ -274,6 +273,7 @@ char nfs_host[STRSIZE];
char nfs_dir[STRSIZE];
char cdrom_dev[SSTRSIZE];
char fd_dev[SSTRSIZE];
char localfs_dev[SSTRSIZE];
char localfs_fs[SSTRSIZE];
@ -374,7 +374,6 @@ int get_via_floppy(void);
int get_via_cdrom(void);
int get_via_localfs(void);
int get_via_localdir(void);
void get_xfer_dir(const char *);
void show_cur_distsets(void);
void make_ramdisk_dir(const char *);
void set_kernel_set(unsigned int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.93 2006/01/15 20:33:05 dsl Exp $ */
/* $NetBSD: disks.c,v 1.94 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -155,6 +155,8 @@ find_disks(const char *doingwhat)
/* need a redraw here, kernel messages hose everything */
touchwin(stdscr);
refresh();
/* Kill typeahead, it won't be what the user had in mind */
fpurge(stdin);
if (numdisks == 0) {
/* No disks found! */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.49 2006/01/12 22:02:44 dsl Exp $ */
/* $NetBSD: main.c,v 1.50 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -95,6 +95,7 @@ static const struct f_arg fflagopts[] = {
{"nfs host", "", nfs_host, sizeof nfs_host},
{"nfs dir", "/bsd/release", nfs_dir, sizeof nfs_dir},
{"cd dev", "cd0a", cdrom_dev, sizeof cdrom_dev},
{"fd dev", "/dev/fd0a", fd_dev, sizeof fd_dev},
{"local dev", "", localfs_dev, sizeof localfs_dev},
{"local fs", "ffs", localfs_fs, sizeof localfs_fs},
{"local dir", "release", localfs_dir, sizeof localfs_dir},

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.mi,v 1.25 2006/02/23 21:44:56 dsl Exp $ */
/* $NetBSD: menus.mi,v 1.26 2006/02/25 20:21:00 dsl Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -58,7 +58,13 @@
static void
src_legend(menudesc *menu, const char *legend, const char *text)
{
wprintw(menu->mw, "%-25s %.50s", MSG_XLAT(legend), text);
wprintw(menu->mw, "%-25s %.50s", MSG_XLAT(legend), MSG_XLAT(text));
}
static void
src_prompt(const char *prompt, char *buf, size_t size)
{
msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
}
}
@ -235,34 +241,28 @@ menu distset, title MSG_Select_your_distribution;
menu ftpsource, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_Get_Distribution;
display action { msg_display(MSG_ftpsource, arg); };
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Host), ftp.host);},
action { msg_prompt_win(MSG_Host, -1, 12, 0, 0,
ftp.host, ftp.host, sizeof ftp.host); };
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Base_dir), ftp.dir);},
action { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
ftp.dir, ftp.dir, sizeof ftp.dir); };
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Set_dir), set_dir);},
action { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
set_dir, set_dir, sizeof set_dir); };
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_User), ftp.user);},
action { msg_prompt_win(MSG_User, -1, 12, 0, 0,
ftp.user, ftp.user, sizeof ftp.user);
option {src_legend(menu, MSG_Host, ftp.host);},
action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
option {src_legend(menu, MSG_Base_dir, ftp.dir);},
action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
option {src_legend(menu, MSG_Set_dir, set_dir);},
action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
option {src_legend(menu, MSG_User, ftp.user);},
action { src_prompt(MSG_User, ftp.user, sizeof ftp.user);
ftp.pass[0] = 0;
};
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Password),
option {src_legend(menu, MSG_Password,
strcmp(ftp.user, "ftp") == 0 || ftp.pass[0] == 0
? ftp.pass : msg_string(MSG_hidden));},
action { if (strcmp(ftp.user, "ftp") == 0)
msg_prompt_win(MSG_email, -1, 12, 0, 0,
ftp.pass, ftp.pass, sizeof ftp.pass);
src_prompt(MSG_email, ftp.pass, sizeof ftp.pass);
else {
msg_prompt_noecho(MSG_Password, "",
ftp.pass, sizeof ftp.pass);
}
};
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Proxy), ftp.proxy);},
action { msg_prompt_win(MSG_Proxy, -1, 12, 0, 0,
ftp.proxy, ftp.proxy, sizeof ftp.proxy);
option {src_legend(menu, MSG_Proxy, ftp.proxy);},
action { src_prompt(MSG_Proxy, ftp.proxy, sizeof ftp.proxy);
if (strcmp(ftp.proxy, "") == 0) {
unsetenv("ftp_proxy");
unsetenv("http_proxy");
@ -271,22 +271,22 @@ menu ftpsource, y=-4, x=0, w=70, no box, no clear,
setenv("http_proxy", ftp.proxy, 1);
}
};
option {wprintw(menu->mw, "%25s %s", MSG_XLAT(MSG_Xfer_dir), xfer_dir);},
action { msg_prompt_win(MSG_Xfer_dir, -1, 12, 0, 0,
xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
clean_xfer_dir = yesno; };
menu nfssource, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_Continue;
display action { msg_display(MSG_nfssource); };
option {src_legend(menu, MSG_Host, nfs_host);},
action { msg_prompt_win(MSG_Host, -1, 12, 0, 0,
nfs_host, nfs_host, sizeof nfs_host); };
action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
option {src_legend(menu, MSG_Base_dir, nfs_dir);},
action { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
nfs_dir, nfs_dir, sizeof nfs_dir); };
action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
option {src_legend(menu, MSG_Set_dir, set_dir);},
action { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
set_dir, set_dir, sizeof set_dir); };
action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
menu fdremount, title MSG_What_do_you_want_to_do;
option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
@ -304,38 +304,42 @@ menu crypttype, title MSG_Password_cipher, y=16;
option MSG_Blowfish_2_7_round, exit, action { yesno = 3; };
option MSG_do_not_change, exit, action { yesno = 0; };
menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_floppysource); };
option {src_legend(menu, MSG_Device, fd_dev);},
action { src_prompt(MSG_dev, fd_dev, sizeof fd_dev); };
/* XXX: ask for fsytype */
option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
clean_xfer_dir = yesno; };
menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_cdromsource); };
option {src_legend(menu, MSG_Device, cdrom_dev);},
action { msg_prompt_win(MSG_dev, -1, 12, 0, 0,
cdrom_dev, cdrom_dev, sizeof cdrom_dev); };
action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
option {src_legend(menu, MSG_Set_dir, set_dir);},
action { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
set_dir, set_dir, sizeof set_dir); };
action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_localfssource); };
option {src_legend(menu, MSG_Device, localfs_dev);},
action { msg_prompt_win(MSG_dev, -1, 12, 0, 0,
localfs_dev, localfs_dev, sizeof localfs_dev);};
action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
option {src_legend(menu, MSG_File_system, localfs_fs);},
action { msg_prompt_win(MSG_filesys, -1, 12, 0, 0,
localfs_fs, localfs_fs, sizeof localfs_fs); };
action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
option {src_legend(menu, MSG_Base_dir, localfs_dir);},
action { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
localfs_dir, localfs_dir, sizeof localfs_dir);};
action { src_prompt(MSG_Base_dir, localfs_dir, sizeof localfs_dir);};
option {src_legend(menu, MSG_Set_dir, set_dir);},
action { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
set_dir, set_dir, sizeof set_dir); };
action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_localdir); };
option {src_legend(menu, MSG_Base_dir, localfs_dir);},
action { msg_prompt_win(MSG_Base_dir, -1, 12, 0, 0,
localfs_dir, localfs_dir, 60); };
action { src_prompt(MSG_Base_dir, localfs_dir, 60); };
option {src_legend(menu, MSG_Set_dir, set_dir);},
action { msg_prompt_win(MSG_Set_dir, -1, 12, 0, 0,
set_dir, set_dir, 60); };
action { src_prompt(MSG_Set_dir, set_dir, 60); };
menu namesrv6, title MSG_Select_IPv6_DNS_server;
option "ns9.iij.ad.jp", exit, action

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.de,v 1.29 2006/02/24 22:13:16 dsl Exp $ */
/* $NetBSD: msg.mi.de,v 1.30 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -461,6 +461,12 @@ finden ist.
}
message floppysource /* XXX translate */
{Enter the floppy device to be used and transfer directory on the target
filesystem. The set files must be in the root directory of the floppies.
}
message cdromsource
{Geben Sie das CD-Laufwerk und das entsprechende Verzeichnis
an, in dem die Distribution zu finden ist.
@ -595,13 +601,8 @@ message realdir
{Konnte nicht in das Verzeichnis %s: %s wechseln. Installation abgebrochen.
}
message xferdir
{Welches Verzeichnis möchten Sie für %s nutzen?}
message delete_xfer_files
{Wollen Sie die NetBSD Pakete von %s löschen?
(Sie können diese auch dazu beibehalten ein weiteres System zu installieren
oder zu erneuern.)}
message delete_xfer_file /* XXX translate */
{Delete after install}
message verboseextract
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.en,v 1.143 2006/02/24 22:13:16 dsl Exp $ */
/* $NetBSD: msg.mi.en,v 1.144 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -447,6 +447,12 @@ must be nfs mountable.
}
message floppysource
{Enter the floppy device to be used and transfer directory on the target
filesystem. The set files must be in the root directory of the floppies.
}
message cdromsource
{Enter the CDROM device to be used and directory on the CDROM where
the distribution is located.
@ -574,12 +580,8 @@ message realdir
{Could not change to directory %s: %s. Install aborted.
}
message xferdir
{What directory shall I use for %s? }
message delete_xfer_files
{Do you want to delete the NetBSD sets from %s?
(You can keep them to install/upgrade a second system.)}
message delete_xfer_file
{Delete after install}
message verboseextract
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.es,v 1.13 2006/02/24 22:13:16 dsl Exp $ */
/* $NetBSD: msg.mi.es,v 1.14 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -455,6 +455,11 @@ debe ser montable por nfs.
}
message floppysource /* XXX translate */
{Enter the floppy device to be used and transfer directory on the target
filesystem. The set files must be in the root directory of the floppies.
}
message cdromsource
{Introduzca el dispositivo de CDROM a usar y el directorio del CDROM
donde se encuentre la distribución.
@ -584,12 +589,8 @@ message realdir
interrumpida.
}
message xferdir
{¿Qué directorio debería usar para %s? }
message delete_xfer_files
{¿Quiere borrar los conjuntos de NetBSD de %s?
(Puede dejarlos para instalar/actualizar un segundo sistema.)}
message delete_xfer_file /* XXX translate */
{Delete after install}
message verboseextract
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.fr,v 1.92 2006/02/24 22:13:16 dsl Exp $ */
/* $NetBSD: msg.mi.fr,v 1.93 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -451,6 +451,12 @@ composants est relatif au r
}
message floppysource /* XXX translate */
{Enter the floppy device to be used and transfer directory on the target
filesystem. The set files must be in the root directory of the floppies.
}
message cdromsource
{Donnez le nom de périphérique du CD-Rom à utiliser ainsi que
le répertoire qui contient les composants.
@ -589,12 +595,8 @@ message realdir
L'installation a échoué.
}
message xferdir
{Quel répertoire dois je utiliser pour %s ?}
message delete_xfer_files
{Voulez-vous supprimer les fichiers de distribution de NetBSD de %s ?
Vous pouvez les conserver pour installer ou mettre a jour d'autre systèmes.}
message delete_xfer_file /* XXX translate */
{Delete after install}
message verboseextract
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.pl,v 1.53 2006/02/24 22:13:16 dsl Exp $ */
/* $NetBSD: msg.mi.pl,v 1.54 2006/02/25 20:21:00 dsl Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
@ -437,6 +437,12 @@ dostepny via nfs.
}
message floppysource /* XXX translate */
{Enter the floppy device to be used and transfer directory on the target
filesystem. The set files must be in the root directory of the floppies.
}
message cdromsource
{Podaj urzadzenie CDROM oraz katalog na CDROMie, w ktorym znajduje sie
dystrybucja.
@ -567,12 +573,8 @@ message realdir
{Nie moglem przejsc do katalogu %s: %s. Instalacja przerwana.
}
message xferdir
{Jakiego katalogu powinienem uzyc dla %s? }
message delete_xfer_files
{Czy chcesz usunac pakiety NetBSD z %s?
(Mozesz je zachowac aby zainstalowac/zaktualizowac kolejny system.)}
message delete_xfer_file /* XXX translate */
{Delete after install}
message verboseextract
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: net.c,v 1.108 2006/01/15 20:34:20 dsl Exp $ */
/* $NetBSD: net.c,v 1.109 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -956,7 +956,6 @@ get_via_ftp(const char *xfer_type)
/* We'll fetch each file just before installing it */
fetch_fn = ftp_fetch;
ftp.xfer_type = xfer_type;
clean_xfer_dir = 1;
snprintf(ext_dir, sizeof ext_dir, "%s/%s", target_prefix(),
xfer_dir + (*xfer_dir == '/'));
@ -983,7 +982,6 @@ get_via_nfs(void)
snprintf(ext_dir, sizeof ext_dir, "/mnt2/%s", set_dir);
/* return location, don't clean... */
clean_xfer_dir = 0;
return SET_OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: run.c,v 1.60 2006/01/12 22:02:44 dsl Exp $ */
/* $NetBSD: run.c,v 1.61 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -446,6 +446,10 @@ launch_subwin(WINDOW **actionwin, char **args, struct winsize *win, int flags,
fprintf(script, "%s\n", scmd);
fclose(script);
}
if (strcmp(args[0], "cd") == 0 && strcmp(args[2], "&&") == 0) {
target_chdir_or_die(args[1]);
args += 3;
}
if (flags & RUN_XFER_DIR)
target_chdir_or_die(xfer_dir);
/*
@ -470,6 +474,12 @@ launch_subwin(WINDOW **actionwin, char **args, struct winsize *win, int flags,
ttysig_ignore = 0;
break;
}
/*
* Now loop transferring program output to screen, and keyboard
* input to the program.
*/
FD_ZERO(&active_fd_set);
FD_SET(master, &active_fd_set);
FD_SET(STDIN_FILENO, &active_fd_set);
@ -482,16 +492,20 @@ launch_subwin(WINDOW **actionwin, char **args, struct winsize *win, int flags,
errx(1, mmsg);
}
read_fd_set = active_fd_set;
tmo.tv_sec = 1;
tmo.tv_sec = 2;
tmo.tv_usec = 0;
if (select(FD_SETSIZE, &read_fd_set, NULL, NULL, &tmo) < 0) {
if (errno == EINTR)
goto loop;
warn("select");
if (logging)
(void)fprintf(logfp,
"select failure: %s\n", strerror(errno));
++selectfailed;
i = select(FD_SETSIZE, &read_fd_set, NULL, NULL, &tmo);
if (i == 0 && *actionwin == NULL)
*actionwin = show_cmd(scmd, win);
if (i < 0) {
if (errno != EINTR) {
warn("select");
if (logging)
(void)fprintf(logfp,
"select failure: %s\n",
strerror(errno));
selectfailed = 1;
}
} else for (i = 0; i < FD_SETSIZE; ++i) {
if (!FD_ISSET(i, &read_fd_set))
continue;
@ -532,7 +546,6 @@ launch_subwin(WINDOW **actionwin, char **args, struct winsize *win, int flags,
waddstr(*actionwin, cp);
wrefresh(*actionwin);
}
loop:
pid = wait4(child, &status, WNOHANG, 0);
if (pid == child && (WIFEXITED(status) || WIFSIGNALED(status)))
break;
@ -587,6 +600,7 @@ run_program(int flags, const char *cmd, ...)
va_start(ap, cmd);
vasprintf(&scmd, cmd, ap);
va_end(ap);
if (scmd == NULL)
err(1, "vasprintf(&scmd, \"%s\", ...)", cmd);
@ -615,6 +629,7 @@ run_program(int flags, const char *cmd, ...)
win.ws_row -= 4;
ret = launch_subwin(&actionwin, args, &win, flags, scmd, &errstr);
fpurge(stdin);
/* If the command failed, show command name */
if (actionwin == NULL && ret != 0 && !(flags & RUN_ERROR_OK))
@ -658,7 +673,6 @@ run_program(int flags, const char *cmd, ...)
}
}
va_end(ap);
/* restore tty setting we saved earlier */
reset_prog_mode();

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.141 2006/01/16 21:47:56 dsl Exp $ */
/* $NetBSD: util.c,v 1.142 2006/02/25 20:21:00 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -71,8 +71,6 @@ static uint8_t set_status[SET_GROUP_END];
#define SET_SKIPPED 0x04
#define SET_INSTALLED 0x08
static char fddev[STRSIZE];
struct tarstats {
int nselected;
int nfound;
@ -253,7 +251,7 @@ floppy_fetch(const char *set_name)
menu = MENU_fdremount;
prompt = MSG_fdremount;
if (run_program(0, "/sbin/mount -r -t %s %s /mnt2",
fdtype, fddev))
fdtype, fd_dev))
continue;
mnt2_mounted = 1;
prompt = MSG_fdnotfound;
@ -284,12 +282,12 @@ int
get_via_floppy(void)
{
(void)strlcpy(fddev, "/dev/fd0a", sizeof fddev);
get_xfer_dir("unloading from floppy");
process_menu(MENU_floppysource, NULL);
msg_prompt_add(MSG_fddev, fddev, fddev, sizeof fddev);
fetch_fn = floppy_fetch;
clean_xfer_dir = 1;
/* Set ext_dir for absolute path. */
snprintf(ext_dir, sizeof ext_dir, "%s/%s", target_prefix(), xfer_dir);
return SET_OK;
}
@ -313,8 +311,6 @@ get_via_cdrom(void)
snprintf(ext_dir, sizeof ext_dir, "%s/%s", "/mnt2", set_dir);
/* return location, don't clean... */
clean_xfer_dir = 0;
return SET_OK;
}
@ -340,8 +336,6 @@ get_via_localfs(void)
snprintf(ext_dir, sizeof ext_dir, "%s/%s/%s",
"/mnt2", localfs_dir, set_dir);
/* return location, don't clean... */
clean_xfer_dir = 0;
return SET_OK;
}
@ -362,27 +356,10 @@ get_via_localdir(void)
*/
snprintf(ext_dir, sizeof ext_dir, "/%s/%s", localfs_dir, set_dir);
/* return location, don't clean... */
clean_xfer_dir = 0;
return SET_OK;
}
void
get_xfer_dir(const char *forwhat)
{
/* ask user for the mountpoint. */
msg_prompt(MSG_xferdir, xfer_dir, xfer_dir,
sizeof xfer_dir, forwhat);
clean_xfer_dir = 1;
/* Set ext_dir for absolute path. */
snprintf(ext_dir, sizeof ext_dir, "%s/%s", target_prefix(), xfer_dir);
}
/*
* Support for custom distribution fetches / unpacks.
*/
@ -618,11 +595,25 @@ ask_verbose_dist(msg setup_done)
return verbose;
}
/*
* Extract_file **REQUIRES** an absolute path in ext_dir. Any code
* that sets up xfer_dir for use by extract_file needs to put in the
* full path name to the directory.
*/
static int
extract_file(distinfo *dist, int update, int verbose, char *path)
extract_file(distinfo *dist, int update, int verbose)
{
char path[STRSIZE];
char *owd;
int rval;
/* If we might need to tidy up, ensure directory exists */
if (fetch_fn != NULL)
make_target_dir(xfer_dir);
(void)snprintf(path, sizeof path, "%s/%s%s",
ext_dir, dist->name, dist_postfix);
owd = getcwd(NULL, 0);
@ -672,6 +663,11 @@ extract_file(distinfo *dist, int update, int verbose, char *path)
return SET_RETRY;
}
if (fetch_fn != NULL && clean_xfer_dir) {
run_program(0, "rm %s", path);
/* Plausibly we should unlink an empty xfer_dir as well */
}
if (update && dist->set == SET_ETC) {
run_program(RUN_DISPLAY | RUN_CHROOT,
"/usr/sbin/postinstall -s /.sysinst -d / fix");
@ -682,32 +678,6 @@ extract_file(distinfo *dist, int update, int verbose, char *path)
return SET_OK;
}
/*
* Extract_dist **REQUIRES** an absolute path in ext_dir. Any code
* that sets up xfer_dir for use by extract_dist needs to put in the
* full path name to the directory.
*/
static int
extract_dist(distinfo *dist, int update, int verbose)
{
char fname[STRSIZE];
int set;
/* If we might need to tidy up, ensure directory exists */
if (fetch_fn != NULL && clean_xfer_dir)
make_target_dir(xfer_dir);
set = dist->set;
(void)snprintf(fname, sizeof fname, "%s/%s%s",
ext_dir, dist->name, dist_postfix);
/* if extraction failed and user aborted, punt. */
return extract_file(dist, update, verbose, fname);
}
static void
skip_set(distinfo *dist, int skip_type)
{
@ -804,8 +774,8 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_
}
}
/* Extract the distribution, retry from top on errors. */
status = extract_dist(dist, update, verbose);
/* Try to extract this set */
status = extract_file(dist, update, verbose);
if (status == SET_RETRY)
dist--;
}
@ -833,27 +803,6 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_
/* Other configuration. */
mnt_net_config();
#if 0
/* Clean up dist dir (use absolute path name) */
if (clean_xfer_dir) {
msg_display(MSG_delete_xfer_files, xfer_dir);
process_menu(MENU_yesno, deconst(MSG_Delete));
if (yesno) {
for (dist = dist_list; dist->desc != NULL; dist++) {
if (dist->name == NULL)
/* menu entry for a group of sets */
continue;
run_program(0, "/bin/rm -f %s/%s/%s%s",
target_prefix(), xfer_dir,
dist->name, dist_postfix);
}
/* chroot 'cos no rmdir in install fs */
run_program(RUN_CHROOT | RUN_SILENT | RUN_ERROR_OK,
"/bin/rmdir %s", xfer_dir);
}
}
#endif
/* Mounted dist dir? */
umount_mnt2();