2008-02-04 04:54:55 +03:00
|
|
|
/* $NetBSD: util.c,v 1.151 2008/02/04 01:54:56 riz Exp $ */
|
1997-09-27 03:02:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997 Piermont Information Systems Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Philip A. Nelson for Piermont Information Systems Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1999-06-20 10:08:13 +04:00
|
|
|
* This product includes software developed for the NetBSD Project by
|
1997-09-27 03:02:53 +04:00
|
|
|
* Piermont Information Systems Inc.
|
|
|
|
* 4. The name of Piermont Information Systems Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* util.c -- routines that don't really fit anywhere else... */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1997-11-02 11:20:40 +03:00
|
|
|
#include <stdarg.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
#include <unistd.h>
|
1997-10-18 01:10:39 +04:00
|
|
|
#include <sys/types.h>
|
1997-10-07 08:01:29 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysctl.h>
|
1997-10-18 01:10:39 +04:00
|
|
|
#include <sys/stat.h>
|
1997-09-27 04:09:22 +04:00
|
|
|
#include <curses.h>
|
1999-04-14 00:17:47 +04:00
|
|
|
#include <errno.h>
|
2003-07-07 16:30:19 +04:00
|
|
|
#include <dirent.h>
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
#include <util.h>
|
1997-09-27 03:02:53 +04:00
|
|
|
#include "defs.h"
|
1997-10-18 01:10:39 +04:00
|
|
|
#include "md.h"
|
1997-09-27 03:02:53 +04:00
|
|
|
#include "msg_defs.h"
|
|
|
|
#include "menu_defs.h"
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
#ifndef MD_SETS_SELECTED
|
|
|
|
#define MD_SETS_SELECTED SET_KERNEL_1, SET_SYSTEM, SET_X11, SET_MD
|
|
|
|
#endif
|
2006-09-04 06:20:40 +04:00
|
|
|
#ifndef MD_SETS_SELECTED_MINIMAL
|
|
|
|
#define MD_SETS_SELECTED_MINIMAL SET_KERNEL_1, SET_CORE
|
|
|
|
#endif
|
2006-01-13 01:02:44 +03:00
|
|
|
#ifndef MD_SETS_VALID
|
|
|
|
#define MD_SETS_VALID SET_KERNEL, SET_SYSTEM, SET_X11, SET_MD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char *msg_yes, *msg_no, *msg_all, *msg_some, *msg_none;
|
|
|
|
static const char *msg_cur_distsets_row;
|
|
|
|
static int select_menu_width;
|
|
|
|
|
|
|
|
static uint8_t set_status[SET_GROUP_END];
|
|
|
|
#define SET_VALID 0x01
|
|
|
|
#define SET_SELECTED 0x02
|
|
|
|
#define SET_SKIPPED 0x04
|
|
|
|
#define SET_INSTALLED 0x08
|
|
|
|
|
|
|
|
struct tarstats {
|
|
|
|
int nselected;
|
|
|
|
int nfound;
|
|
|
|
int nnotfound;
|
|
|
|
int nerror;
|
|
|
|
int nsuccess;
|
|
|
|
int nskipped;
|
|
|
|
} tarstats;
|
|
|
|
|
2003-06-12 01:35:35 +04:00
|
|
|
distinfo dist_list[] = {
|
|
|
|
#ifdef SET_KERNEL_1_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_1_NAME, SET_KERNEL_1, MSG_set_kernel_1, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_2_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_2_NAME, SET_KERNEL_2, MSG_set_kernel_2, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_3_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_3_NAME, SET_KERNEL_3, MSG_set_kernel_3, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_4_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_4_NAME, SET_KERNEL_4, MSG_set_kernel_4, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_5_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_5_NAME, SET_KERNEL_5, MSG_set_kernel_5, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_6_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_6_NAME, SET_KERNEL_6, MSG_set_kernel_6, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_7_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_7_NAME, SET_KERNEL_7, MSG_set_kernel_7, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_KERNEL_8_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_KERNEL_8_NAME, SET_KERNEL_8, MSG_set_kernel_8, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
2006-01-13 01:02:44 +03:00
|
|
|
|
2006-10-23 23:45:56 +04:00
|
|
|
{"base", SET_BASE, MSG_set_base, NULL},
|
|
|
|
{"etc", SET_ETC, MSG_set_system, NULL},
|
|
|
|
{"comp", SET_COMPILER, MSG_set_compiler, NULL},
|
|
|
|
{"games", SET_GAMES, MSG_set_games, NULL},
|
|
|
|
{"man", SET_MAN_PAGES, MSG_set_man_pages, NULL},
|
|
|
|
{"misc", SET_MISC, MSG_set_misc, NULL},
|
2007-11-12 18:07:33 +03:00
|
|
|
{"tests", SET_TESTS, MSG_set_tests, NULL},
|
2006-10-23 23:45:56 +04:00
|
|
|
{"text", SET_TEXT_TOOLS, MSG_set_text_tools, NULL},
|
|
|
|
|
|
|
|
{NULL, SET_GROUP, MSG_set_X11, NULL},
|
|
|
|
{"xbase", SET_X11_BASE, MSG_set_X11_base, NULL},
|
|
|
|
{"xcomp", SET_X11_PROG, MSG_set_X11_prog, NULL},
|
|
|
|
{"xetc", SET_X11_ETC, MSG_set_X11_etc, NULL},
|
|
|
|
{"xfont", SET_X11_FONTS, MSG_set_X11_fonts, NULL},
|
|
|
|
{"xserver", SET_X11_SERVERS, MSG_set_X11_servers, NULL},
|
|
|
|
{NULL, SET_GROUP_END, NULL, NULL},
|
2006-01-13 01:02:44 +03:00
|
|
|
|
2003-06-12 01:35:35 +04:00
|
|
|
#ifdef SET_MD_1_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_MD_1_NAME, SET_MD_1, MSG_set_md_1, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_MD_2_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_MD_2_NAME, SET_MD_2, MSG_set_md_2, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_MD_3_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_MD_3_NAME, SET_MD_3, MSG_set_md_3, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SET_MD_4_NAME
|
2006-10-23 23:45:56 +04:00
|
|
|
{SET_MD_4_NAME, SET_MD_4, MSG_set_md_4, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
#endif
|
2006-01-13 01:02:44 +03:00
|
|
|
|
2006-10-23 23:45:56 +04:00
|
|
|
{NULL, SET_LAST, NULL, NULL},
|
2003-06-12 01:35:35 +04:00
|
|
|
};
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
|
|
|
* local prototypes
|
|
|
|
*/
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-07-18 13:49:18 +04:00
|
|
|
static int check_for(unsigned int mode, const char *pathname);
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2006-01-15 23:41:00 +03:00
|
|
|
void
|
2006-09-04 06:20:40 +04:00
|
|
|
init_set_status(int minimal)
|
2006-01-13 01:02:44 +03:00
|
|
|
{
|
2006-10-23 23:45:56 +04:00
|
|
|
static const uint8_t sets_valid[] = {MD_SETS_VALID};
|
|
|
|
static const uint8_t sets_selected_full[] = {MD_SETS_SELECTED};
|
|
|
|
static const uint8_t sets_selected_minimal[] = {MD_SETS_SELECTED_MINIMAL};
|
|
|
|
static const uint8_t *sets_selected;
|
2006-11-24 03:53:47 +03:00
|
|
|
int nelem_selected;
|
2006-01-13 01:02:44 +03:00
|
|
|
unsigned int i, len;
|
|
|
|
const char *longest;
|
|
|
|
|
2006-11-24 03:53:47 +03:00
|
|
|
if (minimal) {
|
2006-09-04 06:20:40 +04:00
|
|
|
sets_selected = sets_selected_minimal;
|
2006-11-24 03:53:47 +03:00
|
|
|
nelem_selected = nelem(sets_selected_minimal);
|
|
|
|
} else {
|
2006-09-04 06:20:40 +04:00
|
|
|
sets_selected = sets_selected_full;
|
2006-11-24 03:53:47 +03:00
|
|
|
nelem_selected = nelem(sets_selected_full);
|
|
|
|
}
|
2006-09-04 06:20:40 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
for (i = 0; i < nelem(sets_valid); i++)
|
|
|
|
set_status[sets_valid[i]] = SET_VALID;
|
2006-11-24 03:53:47 +03:00
|
|
|
for (i = 0; i < nelem_selected; i++)
|
2006-01-13 01:02:44 +03:00
|
|
|
set_status[sets_selected[i]] |= SET_SELECTED;
|
|
|
|
|
|
|
|
set_status[SET_GROUP] = SET_VALID;
|
|
|
|
|
|
|
|
/* Lookup some strings we need lots of times */
|
|
|
|
msg_yes = msg_string(MSG_Yes);
|
|
|
|
msg_no = msg_string(MSG_No);
|
|
|
|
msg_all = msg_string(MSG_All);
|
|
|
|
msg_some = msg_string(MSG_Some);
|
|
|
|
msg_none = msg_string(MSG_None);
|
|
|
|
msg_cur_distsets_row = msg_string(MSG_cur_distsets_row);
|
|
|
|
|
|
|
|
/* Find longest and use it to determine width of selection menu */
|
|
|
|
len = strlen(msg_no); longest = msg_no;
|
|
|
|
i = strlen(msg_yes); if (i > len) {len = i; longest = msg_yes; }
|
|
|
|
i = strlen(msg_all); if (i > len) {len = i; longest = msg_all; }
|
|
|
|
i = strlen(msg_some); if (i > len) {len = i; longest = msg_some; }
|
|
|
|
i = strlen(msg_none); if (i > len) {len = i; longest = msg_none; }
|
|
|
|
select_menu_width = snprintf(NULL, 0, msg_cur_distsets_row, "",longest);
|
2008-01-28 05:47:12 +03:00
|
|
|
|
|
|
|
/* Give the md code a chance to choose the right kernel, etc. */
|
|
|
|
md_init_set_status(minimal);
|
2006-01-13 01:02:44 +03:00
|
|
|
}
|
2003-06-12 01:35:35 +04:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
dir_exists_p(const char *path)
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
2003-06-11 15:00:39 +04:00
|
|
|
|
2000-09-26 17:26:02 +04:00
|
|
|
return file_mode_match(path, S_IFDIR);
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
file_exists_p(const char *path)
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
2003-06-11 15:00:39 +04:00
|
|
|
|
2000-09-26 17:26:02 +04:00
|
|
|
return file_mode_match(path, S_IFREG);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
file_mode_match(const char *path, unsigned int mode)
|
2000-09-26 17:26:02 +04:00
|
|
|
{
|
|
|
|
struct stat st;
|
1998-06-20 17:05:48 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return (stat(path, &st) == 0 && (st.st_mode & S_IFMT) == mode);
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 14:55:03 +04:00
|
|
|
uint
|
2003-06-11 15:00:39 +04:00
|
|
|
get_ramsize(void)
|
1997-10-07 08:01:29 +04:00
|
|
|
{
|
2004-07-17 14:55:03 +04:00
|
|
|
uint64_t ramsize;
|
|
|
|
size_t len = sizeof ramsize;
|
|
|
|
int mib[2] = {CTL_HW, HW_PHYSMEM64};
|
1997-10-07 08:01:29 +04:00
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
sysctl(mib, 2, &ramsize, &len, NULL, 0);
|
1997-10-07 08:01:29 +04:00
|
|
|
|
|
|
|
/* Find out how many Megs ... round up. */
|
2004-07-17 14:55:03 +04:00
|
|
|
return (ramsize + MEG - 1) / MEG;
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
2003-06-11 15:00:39 +04:00
|
|
|
run_makedev(void)
|
1997-10-01 09:04:24 +04:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
char *owd;
|
|
|
|
|
2004-08-17 01:04:08 +04:00
|
|
|
msg_display_add("\n\n");
|
2004-08-14 20:06:36 +04:00
|
|
|
msg_display_add(MSG_makedev);
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
owd = getcwd(NULL, 0);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/* make /dev, in case the user didn't extract it. */
|
|
|
|
make_target_dir("/dev");
|
1997-11-02 11:20:40 +03:00
|
|
|
target_chdir_or_die("/dev");
|
2003-11-30 17:36:43 +03:00
|
|
|
run_program(0, "/bin/sh MAKEDEV all");
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
chdir(owd);
|
|
|
|
free(owd);
|
1997-10-18 01:10:39 +04:00
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
static int
|
|
|
|
floppy_fetch(const char *set_name)
|
|
|
|
{
|
|
|
|
char post[4];
|
2006-02-26 13:25:52 +03:00
|
|
|
msg errmsg;
|
2006-01-13 01:02:44 +03:00
|
|
|
int menu;
|
|
|
|
int status;
|
2006-02-26 13:25:52 +03:00
|
|
|
const char *write_mode = ">";
|
2006-01-13 01:02:44 +03:00
|
|
|
|
|
|
|
strcpy(post, "aa");
|
|
|
|
|
2006-02-26 13:25:52 +03:00
|
|
|
errmsg = "";
|
2006-01-13 01:02:44 +03:00
|
|
|
menu = MENU_fdok;
|
|
|
|
for (;;) {
|
|
|
|
umount_mnt2();
|
2006-02-26 13:25:52 +03:00
|
|
|
msg_display(errmsg);
|
|
|
|
msg_display_add(MSG_fdmount, set_name, post);
|
2006-01-13 01:02:44 +03:00
|
|
|
process_menu(menu, &status);
|
|
|
|
if (status != SET_CONTINUE)
|
|
|
|
return status;
|
|
|
|
menu = MENU_fdremount;
|
2006-02-26 13:25:52 +03:00
|
|
|
errmsg = MSG_fdremount;
|
2006-01-13 01:02:44 +03:00
|
|
|
if (run_program(0, "/sbin/mount -r -t %s %s /mnt2",
|
2006-02-26 13:25:52 +03:00
|
|
|
fd_type, fd_dev))
|
2006-01-13 01:02:44 +03:00
|
|
|
continue;
|
|
|
|
mnt2_mounted = 1;
|
2006-02-26 13:25:52 +03:00
|
|
|
errmsg = MSG_fdnotfound;
|
2006-01-13 01:02:44 +03:00
|
|
|
|
|
|
|
/* Display this because it might take a while.... */
|
|
|
|
if (run_program(RUN_DISPLAY,
|
|
|
|
"sh -c '/bin/cat /mnt2/%s.%s %s %s/%s/%s%s'",
|
2006-02-26 13:25:52 +03:00
|
|
|
set_name, post, write_mode,
|
2006-01-13 01:02:44 +03:00
|
|
|
target_prefix(), xfer_dir, set_name, dist_postfix))
|
|
|
|
/* XXX: a read error will give a corrupt file! */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* We got that file, advance to next fragment */
|
|
|
|
if (post[1] < 'z')
|
|
|
|
post[1]++;
|
|
|
|
else
|
|
|
|
post[1] = 'a', post[0]++;
|
2006-02-26 13:25:52 +03:00
|
|
|
write_mode = ">>";
|
|
|
|
errmsg = "";
|
2006-01-13 01:02:44 +03:00
|
|
|
menu = MENU_fdok;
|
|
|
|
}
|
|
|
|
}
|
1997-10-18 01:10:39 +04:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
|
|
|
* Load files from floppy. Requires a /mnt2 directory for mounting them.
|
|
|
|
*/
|
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
get_via_floppy(void)
|
1997-10-18 01:10:39 +04:00
|
|
|
{
|
|
|
|
|
2006-02-25 23:21:00 +03:00
|
|
|
process_menu(MENU_floppysource, NULL);
|
1997-10-29 04:06:42 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
fetch_fn = floppy_fetch;
|
2006-02-25 23:21:00 +03:00
|
|
|
|
|
|
|
/* Set ext_dir for absolute path. */
|
|
|
|
snprintf(ext_dir, sizeof ext_dir, "%s/%s", target_prefix(), xfer_dir);
|
1997-10-18 01:10:39 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return SET_OK;
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
1997-10-20 10:13:25 +04:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
|
|
|
* Get from a CDROM distribution.
|
|
|
|
*/
|
1997-10-20 10:13:25 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
get_via_cdrom(void)
|
1997-10-20 10:13:25 +04:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1998-05-15 19:12:29 +04:00
|
|
|
/* Get CD-rom device name and path within CD-rom */
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_cdromsource, NULL);
|
1998-05-15 19:12:29 +04:00
|
|
|
|
1997-10-20 10:13:25 +04:00
|
|
|
/* Mount it */
|
2006-01-13 01:02:44 +03:00
|
|
|
if (run_program(0, "/sbin/mount -rt cd9660 /dev/%s /mnt2",
|
|
|
|
cdrom_dev) != 0)
|
|
|
|
return SET_RETRY;
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
mnt2_mounted = 1;
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2004-06-06 01:18:59 +04:00
|
|
|
snprintf(ext_dir, sizeof ext_dir, "%s/%s", "/mnt2", set_dir);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return SET_OK;
|
1997-10-20 10:13:25 +04:00
|
|
|
}
|
1997-10-29 04:06:42 +03:00
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get from a pathname inside an unmounted local filesystem
|
|
|
|
* (e.g., where sets were preloaded onto a local DOS partition)
|
|
|
|
*/
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
get_via_localfs(void)
|
1997-11-06 01:45:53 +03:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-11-06 01:45:53 +03:00
|
|
|
/* Get device, filesystem, and filepath */
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu (MENU_localfssource, NULL);
|
1997-11-06 01:45:53 +03:00
|
|
|
|
|
|
|
/* Mount it */
|
2003-11-30 17:36:43 +03:00
|
|
|
if (run_program(0, "/sbin/mount -rt %s /dev/%s /mnt2",
|
2006-01-13 01:02:44 +03:00
|
|
|
localfs_fs, localfs_dev))
|
|
|
|
return SET_RETRY;
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
mnt2_mounted = 1;
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2004-06-06 01:18:59 +04:00
|
|
|
snprintf(ext_dir, sizeof ext_dir, "%s/%s/%s",
|
|
|
|
"/mnt2", localfs_dir, set_dir);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return SET_OK;
|
1997-11-06 01:45:53 +03:00
|
|
|
}
|
1997-10-29 04:06:42 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
|
|
|
* Get from an already-mounted pathname.
|
|
|
|
*/
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-06-16 23:42:13 +04:00
|
|
|
int
|
|
|
|
get_via_localdir(void)
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
|
|
|
|
2004-06-06 01:18:59 +04:00
|
|
|
/* Get filepath */
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_localdirsource, NULL);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2004-06-06 01:18:59 +04:00
|
|
|
/*
|
|
|
|
* We have to have an absolute path ('cos pax runs in a
|
|
|
|
* different directory), make it so.
|
|
|
|
*/
|
|
|
|
snprintf(ext_dir, sizeof ext_dir, "/%s/%s", localfs_dir, set_dir);
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return SET_OK;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
|
|
|
* Support for custom distribution fetches / unpacks.
|
|
|
|
*/
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
unsigned int
|
|
|
|
set_X11_selected(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = SET_X11_FIRST; ++i < SET_X11_LAST;)
|
|
|
|
if (set_status[i] & SET_SELECTED)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
get_kernel_set(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = SET_KERNEL_FIRST; ++i < SET_KERNEL_LAST;)
|
|
|
|
if (set_status[i] & SET_SELECTED)
|
|
|
|
return i;
|
|
|
|
return SET_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_kernel_set(unsigned int kernel_set)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* only one kernel set is allowed */
|
|
|
|
for (i = SET_KERNEL_FIRST; ++i < SET_KERNEL_LAST;)
|
|
|
|
set_status[i] &= ~SET_SELECTED;
|
|
|
|
set_status[kernel_set] |= SET_SELECTED;
|
|
|
|
}
|
2003-06-12 01:35:35 +04:00
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_toggle(menudesc *menu, void *arg)
|
2003-06-12 01:35:35 +04:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
distinfo **distp = arg;
|
|
|
|
int set = distp[menu->cursel]->set;
|
|
|
|
|
|
|
|
if (set > SET_KERNEL_FIRST && set < SET_KERNEL_LAST &&
|
|
|
|
!(set_status[set] & SET_SELECTED))
|
|
|
|
set_kernel_set(set);
|
|
|
|
else
|
|
|
|
set_status[set] ^= SET_SELECTED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set_all_none(menudesc *menu, void *arg, int set, int clr)
|
|
|
|
{
|
|
|
|
distinfo **distp = arg;
|
|
|
|
distinfo *dist = *distp;
|
|
|
|
int nested;
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
for (nested = 0; dist->set != SET_GROUP_END || nested--; dist++) {
|
|
|
|
if (dist->set == SET_GROUP) {
|
|
|
|
nested++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
set_status[dist->set] = (set_status[dist->set] & ~clr) | set;
|
|
|
|
}
|
2003-06-12 01:35:35 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_all(menudesc *menu, void *arg)
|
1997-10-29 04:06:42 +03:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
return set_all_none(menu, arg, SET_SELECTED, 0);
|
1997-10-29 04:06:42 +03:00
|
|
|
}
|
|
|
|
|
2003-06-12 01:35:35 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_none(menudesc *menu, void *arg)
|
2003-06-12 01:35:35 +04:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
return set_all_none(menu, arg, 0, SET_SELECTED);
|
2003-06-12 01:35:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-13 01:02:44 +03:00
|
|
|
set_label(menudesc *menu, int opt, void *arg)
|
1997-10-29 04:06:42 +03:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
distinfo **distp = arg;
|
|
|
|
distinfo *dist = distp[opt];
|
2003-06-12 01:35:35 +04:00
|
|
|
const char *selected;
|
2006-01-13 01:02:44 +03:00
|
|
|
const char *desc;
|
|
|
|
int nested;
|
|
|
|
|
|
|
|
desc = dist->desc;
|
|
|
|
|
|
|
|
if (dist->set != SET_GROUP)
|
|
|
|
selected = set_status[dist->set] & SET_SELECTED ? msg_yes : msg_no;
|
|
|
|
else {
|
|
|
|
/* sub menu - display None/Some/All */
|
|
|
|
nested = 0;
|
|
|
|
selected = "unknown";
|
|
|
|
while ((++dist)->set != SET_GROUP_END || nested--) {
|
|
|
|
if (dist->set == SET_GROUP) {
|
|
|
|
nested++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!(set_status[dist->set] & SET_VALID))
|
|
|
|
continue;
|
|
|
|
if (set_status[dist->set] & SET_SELECTED) {
|
|
|
|
if (selected == msg_none) {
|
|
|
|
selected = msg_some;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
selected = msg_all;
|
|
|
|
} else {
|
|
|
|
if (selected == msg_all) {
|
|
|
|
selected = msg_some;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
selected = msg_none;
|
|
|
|
}
|
|
|
|
}
|
2003-06-12 01:35:35 +04:00
|
|
|
}
|
1997-10-29 04:06:42 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
wprintw(menu->mw, msg_cur_distsets_row, msg_string(desc), selected);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int set_sublist(menudesc *menu, void *arg);
|
|
|
|
|
|
|
|
static int
|
|
|
|
initialise_set_menu(distinfo *dist, menu_ent *me, distinfo **de, int all_none)
|
|
|
|
{
|
|
|
|
int set;
|
|
|
|
int sets;
|
|
|
|
int nested;
|
|
|
|
|
|
|
|
for (sets = 0; ; dist++) {
|
|
|
|
set = dist->set;
|
|
|
|
if (set == SET_LAST || set == SET_GROUP_END)
|
2003-06-12 01:35:35 +04:00
|
|
|
break;
|
2006-01-13 01:02:44 +03:00
|
|
|
if (!(set_status[set] & SET_VALID))
|
2003-06-12 01:35:35 +04:00
|
|
|
continue;
|
2006-01-13 01:02:44 +03:00
|
|
|
*de = dist;
|
|
|
|
me->opt_menu = OPT_NOMENU;
|
|
|
|
me->opt_flags = 0;
|
|
|
|
me->opt_name = NULL;
|
|
|
|
if (set != SET_GROUP)
|
|
|
|
me->opt_action = set_toggle;
|
|
|
|
else {
|
|
|
|
/* Collapse sublist */
|
|
|
|
nested = 0;
|
|
|
|
while ((++dist)->set != SET_GROUP_END || nested--) {
|
|
|
|
if (dist->set == SET_GROUP)
|
|
|
|
nested++;
|
|
|
|
}
|
|
|
|
me->opt_action = set_sublist;
|
2003-06-12 01:35:35 +04:00
|
|
|
}
|
2006-01-13 01:02:44 +03:00
|
|
|
sets++;
|
|
|
|
de++;
|
|
|
|
me++;
|
2003-06-12 01:35:35 +04:00
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
if (all_none) {
|
|
|
|
me->opt_menu = OPT_NOMENU;
|
|
|
|
me->opt_flags = 0;
|
|
|
|
me->opt_name = MSG_select_all;
|
|
|
|
me->opt_action = set_all;
|
|
|
|
me++;
|
|
|
|
me->opt_menu = OPT_NOMENU;
|
|
|
|
me->opt_flags = 0;
|
|
|
|
me->opt_name = MSG_select_none;
|
|
|
|
me->opt_action = set_none;
|
|
|
|
sets += 2;
|
|
|
|
}
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
return sets;
|
2003-06-12 01:35:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_sublist(menudesc *menu, void *arg)
|
2003-06-12 01:35:35 +04:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
distinfo *de[SET_LAST];
|
|
|
|
menu_ent me[SET_LAST];
|
|
|
|
distinfo **dist = arg;
|
2003-06-12 01:35:35 +04:00
|
|
|
int menu_no;
|
2006-01-13 01:02:44 +03:00
|
|
|
int sets;
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
sets = initialise_set_menu(dist[menu->cursel] + 1, me, de, 1);
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
menu_no = new_menu(NULL, me, sets, 20, 10, 0, select_menu_width,
|
|
|
|
MC_SUBMENU | MC_SCROLL | MC_DFLTEXIT,
|
|
|
|
NULL, set_label, NULL, NULL,
|
|
|
|
MSG_install_selected_sets);
|
2003-06-12 01:35:35 +04:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
process_menu(menu_no, de);
|
2003-06-12 01:35:35 +04:00
|
|
|
free_menu(menu_no);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
customise_sets(void)
|
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
distinfo *de[SET_LAST];
|
|
|
|
menu_ent me[SET_LAST];
|
2003-06-12 01:35:35 +04:00
|
|
|
int sets;
|
|
|
|
int menu_no;
|
|
|
|
|
2005-10-22 13:31:50 +04:00
|
|
|
msg_display(MSG_cur_distsets);
|
|
|
|
msg_table_add(MSG_cur_distsets_header);
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
sets = initialise_set_menu(dist_list, me, de, 0);
|
|
|
|
|
|
|
|
menu_no = new_menu(NULL, me, sets, 0, 5, 0, select_menu_width,
|
|
|
|
MC_SCROLL | MC_NOBOX | MC_DFLTEXIT | MC_NOCLEAR,
|
|
|
|
NULL, set_label, NULL, NULL,
|
|
|
|
MSG_install_selected_sets);
|
|
|
|
|
|
|
|
process_menu(menu_no, de);
|
2003-06-12 01:35:35 +04:00
|
|
|
free_menu(menu_no);
|
1997-10-29 04:06:42 +03:00
|
|
|
}
|
1997-11-02 11:20:40 +03:00
|
|
|
|
2004-07-17 01:35:44 +04:00
|
|
|
static int
|
2004-06-06 01:18:59 +04:00
|
|
|
ask_verbose_dist(msg setup_done)
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
2004-07-17 01:35:44 +04:00
|
|
|
int verbose = 0;
|
1998-06-20 17:05:48 +04:00
|
|
|
|
2004-06-06 01:18:59 +04:00
|
|
|
wclear(stdscr);
|
|
|
|
wrefresh(stdscr);
|
|
|
|
if (setup_done != NULL)
|
|
|
|
msg_display(setup_done);
|
|
|
|
msg_display_add(MSG_verboseextract);
|
|
|
|
process_menu(MENU_extract, &verbose);
|
|
|
|
wclear(stdscr);
|
|
|
|
wrefresh(stdscr);
|
2004-07-17 01:35:44 +04:00
|
|
|
|
|
|
|
return verbose;
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
|
2006-02-25 23:21:00 +03:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
static int
|
2006-02-25 23:21:00 +03:00
|
|
|
extract_file(distinfo *dist, int update, int verbose)
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
2006-02-25 23:21:00 +03:00
|
|
|
char path[STRSIZE];
|
1997-11-04 04:39:03 +03:00
|
|
|
char *owd;
|
2006-01-13 01:02:44 +03:00
|
|
|
int rval;
|
2006-02-25 23:21:00 +03:00
|
|
|
|
|
|
|
/* 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);
|
1997-11-04 04:39:03 +03:00
|
|
|
|
2003-07-18 13:49:18 +04:00
|
|
|
owd = getcwd(NULL, 0);
|
1997-11-04 04:39:03 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
/* Do we need to fetch the file now? */
|
|
|
|
if (fetch_fn != NULL) {
|
|
|
|
rval = fetch_fn(dist->name);
|
|
|
|
if (rval != SET_OK)
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
/* check tarfile exists */
|
|
|
|
if (!file_exists_p(path)) {
|
|
|
|
tarstats.nnotfound++;
|
1999-06-22 06:43:09 +04:00
|
|
|
|
|
|
|
msg_display(MSG_notarfile, path);
|
2006-01-13 01:02:44 +03:00
|
|
|
process_menu(MENU_ok, NULL);
|
|
|
|
return SET_RETRY;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
tarstats.nfound++;
|
1997-11-05 10:28:20 +03:00
|
|
|
/* cd to the target root. */
|
2006-01-13 01:02:44 +03:00
|
|
|
if (update && dist->set == SET_ETC) {
|
2004-04-19 01:34:56 +04:00
|
|
|
make_target_dir("/.sysinst");
|
|
|
|
target_chdir_or_die("/.sysinst");
|
|
|
|
} else
|
|
|
|
target_chdir_or_die("/");
|
1997-11-04 04:39:03 +03:00
|
|
|
|
2004-11-12 01:39:03 +03:00
|
|
|
/* now extract set files into "./". */
|
2004-06-06 01:18:59 +04:00
|
|
|
if (verbose == 0)
|
2006-01-13 01:02:44 +03:00
|
|
|
rval = run_program(RUN_DISPLAY | RUN_PROGRESS,
|
2004-11-12 01:39:03 +03:00
|
|
|
"progress -zf %s tar --chroot -xhepf -", path);
|
2004-06-06 01:18:59 +04:00
|
|
|
else if (verbose == 1)
|
2006-01-13 01:02:44 +03:00
|
|
|
rval = run_program(RUN_DISPLAY,
|
2004-11-12 01:39:03 +03:00
|
|
|
"tar --chroot -zxhepf %s", path);
|
2004-07-17 01:35:44 +04:00
|
|
|
else
|
2006-01-13 01:02:44 +03:00
|
|
|
rval = run_program(RUN_DISPLAY | RUN_PROGRESS,
|
2004-11-12 01:39:03 +03:00
|
|
|
"tar --chroot -zxhvepf %s", path);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
chdir(owd);
|
|
|
|
free(owd);
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
/* Check rval for errors and give warning. */
|
|
|
|
if (rval != 0) {
|
1997-12-05 17:00:59 +03:00
|
|
|
tarstats.nerror++;
|
1999-06-22 06:43:09 +04:00
|
|
|
msg_display(MSG_tarerror, path);
|
2006-01-13 01:02:44 +03:00
|
|
|
process_menu(MENU_ok, NULL);
|
|
|
|
return SET_RETRY;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
1999-06-22 06:43:09 +04:00
|
|
|
|
2006-02-25 23:21:00 +03:00
|
|
|
if (fetch_fn != NULL && clean_xfer_dir) {
|
|
|
|
run_program(0, "rm %s", path);
|
|
|
|
/* Plausibly we should unlink an empty xfer_dir as well */
|
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
if (update && dist->set == SET_ETC) {
|
2007-10-22 00:21:01 +04:00
|
|
|
int oldsendmail;
|
|
|
|
oldsendmail = run_program(RUN_DISPLAY | RUN_CHROOT |
|
|
|
|
RUN_ERROR_OK | RUN_PROGRESS,
|
|
|
|
"/usr/sbin/postinstall -s /.sysinst -d / check mailerconf");
|
|
|
|
if (oldsendmail == 1) {
|
|
|
|
msg_display(MSG_oldsendmail);
|
|
|
|
process_menu(MENU_yesno, NULL);
|
|
|
|
if (yesno) {
|
|
|
|
run_program(RUN_DISPLAY | RUN_CHROOT,
|
|
|
|
"/usr/sbin/postinstall -s /.sysinst -d / fix mailerconf");
|
|
|
|
}
|
|
|
|
}
|
2004-04-19 01:34:56 +04:00
|
|
|
run_program(RUN_DISPLAY | RUN_CHROOT,
|
2005-04-19 03:36:03 +04:00
|
|
|
"/usr/sbin/postinstall -s /.sysinst -d / fix");
|
2004-04-19 01:34:56 +04:00
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
set_status[dist->set] |= SET_INSTALLED;
|
2003-10-20 00:17:31 +04:00
|
|
|
tarstats.nsuccess++;
|
2006-01-13 01:02:44 +03:00
|
|
|
return SET_OK;
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
static void
|
|
|
|
skip_set(distinfo *dist, int skip_type)
|
|
|
|
{
|
|
|
|
int nested;
|
|
|
|
int set;
|
|
|
|
|
|
|
|
nested = 0;
|
|
|
|
while ((++dist)->set != SET_GROUP_END || nested--) {
|
|
|
|
set = dist->set;
|
|
|
|
if (set == SET_GROUP) {
|
|
|
|
nested++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (set == SET_LAST)
|
|
|
|
break;
|
|
|
|
if (set_status[set] == (SET_SELECTED | SET_VALID))
|
|
|
|
set_status[set] |= SET_SKIPPED;
|
|
|
|
tarstats.nskipped++;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
|
1997-11-02 12:41:57 +03:00
|
|
|
/*
|
1998-06-20 17:05:48 +04:00
|
|
|
* Get and unpack the distribution.
|
2003-10-20 00:17:31 +04:00
|
|
|
* Show success_msg if installation completes.
|
|
|
|
* Otherwise show failure_msg and wait for the user to ack it before continuing.
|
1997-11-02 12:41:57 +03:00
|
|
|
* success_msg and failure_msg must both be 0-adic messages.
|
|
|
|
*/
|
1999-06-22 10:57:00 +04:00
|
|
|
int
|
2004-06-06 01:18:59 +04:00
|
|
|
get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_msg)
|
1997-11-02 12:41:57 +03:00
|
|
|
{
|
2006-01-13 01:02:44 +03:00
|
|
|
distinfo *dist;
|
|
|
|
int status;
|
2004-07-17 01:35:44 +04:00
|
|
|
int verbose;
|
2006-01-13 01:02:44 +03:00
|
|
|
int set;
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1997-11-13 06:06:44 +03:00
|
|
|
/* Ensure mountpoint for distribution files exists in current root. */
|
2003-10-20 00:17:31 +04:00
|
|
|
(void)mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH);
|
1999-01-21 11:02:17 +03:00
|
|
|
if (scripting)
|
2006-01-13 01:02:44 +03:00
|
|
|
(void)fprintf(script, "mkdir -m 755 /mnt2\n");
|
|
|
|
|
|
|
|
/* reset failure/success counters */
|
|
|
|
memset(&tarstats, 0, sizeof(tarstats));
|
1997-11-13 06:06:44 +03:00
|
|
|
|
1998-02-09 09:55:27 +03:00
|
|
|
/* Find out which files to "get" if we get files. */
|
|
|
|
|
1999-04-14 00:17:47 +04:00
|
|
|
/* ask user whether to do normal or verbose extraction */
|
2004-07-17 01:35:44 +04:00
|
|
|
verbose = ask_verbose_dist(setupdone_msg);
|
1999-04-14 00:17:47 +04:00
|
|
|
|
2006-01-15 23:41:00 +03:00
|
|
|
/* Accurately count selected sets */
|
|
|
|
for (dist = dist_list; (set = dist->set) != SET_LAST; dist++) {
|
|
|
|
if ((set_status[set] & (SET_VALID | SET_SELECTED))
|
|
|
|
== (SET_VALID | SET_SELECTED))
|
|
|
|
tarstats.nselected++;
|
|
|
|
}
|
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
status = SET_RETRY;
|
2006-01-15 23:41:00 +03:00
|
|
|
for (dist = dist_list; ; dist++) {
|
2006-01-13 01:02:44 +03:00
|
|
|
set = dist->set;
|
|
|
|
if (set == SET_LAST)
|
|
|
|
break;
|
|
|
|
if (dist->name == NULL)
|
|
|
|
continue;
|
|
|
|
if (set_status[set] != (SET_VALID | SET_SELECTED))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (status != SET_OK) {
|
|
|
|
/* This might force a redraw.... */
|
|
|
|
clearok(curscr, 1);
|
|
|
|
touchwin(stdscr);
|
|
|
|
wrefresh(stdscr);
|
|
|
|
/* Sort out the location of the set files */
|
|
|
|
do {
|
2006-01-15 23:41:00 +03:00
|
|
|
umount_mnt2();
|
|
|
|
msg_display(MSG_distmedium, tarstats.nselected,
|
|
|
|
tarstats.nsuccess + tarstats.nskipped,
|
|
|
|
dist->name);
|
2006-01-13 01:02:44 +03:00
|
|
|
fetch_fn = NULL;
|
|
|
|
process_menu(MENU_distmedium, &status);
|
|
|
|
} while (status == SET_RETRY);
|
|
|
|
|
|
|
|
if (status == SET_SKIP) {
|
|
|
|
set_status[set] |= SET_SKIPPED;
|
|
|
|
tarstats.nskipped++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (status == SET_SKIP_GROUP) {
|
|
|
|
skip_set(dist, status);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (status != SET_OK) {
|
|
|
|
msg_display(failure_msg);
|
|
|
|
process_menu(MENU_ok, NULL);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-25 23:21:00 +03:00
|
|
|
/* Try to extract this set */
|
|
|
|
status = extract_file(dist, update, verbose);
|
2006-01-15 23:41:00 +03:00
|
|
|
if (status == SET_RETRY)
|
|
|
|
dist--;
|
2006-01-13 01:02:44 +03:00
|
|
|
}
|
1997-11-02 12:41:57 +03:00
|
|
|
|
2006-01-13 01:02:44 +03:00
|
|
|
if (tarstats.nerror == 0 && tarstats.nsuccess == tarstats.nselected) {
|
|
|
|
msg_display(MSG_endtarok);
|
|
|
|
/* Give user a chance to see the success message */
|
|
|
|
sleep(1);
|
|
|
|
} else {
|
|
|
|
/* We encountered errors. Let the user know. */
|
|
|
|
msg_display(MSG_endtar,
|
|
|
|
tarstats.nselected, tarstats.nnotfound, tarstats.nskipped,
|
|
|
|
tarstats.nfound, tarstats.nsuccess, tarstats.nerror);
|
2003-10-20 00:17:31 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
2006-01-13 01:02:44 +03:00
|
|
|
msg_clear();
|
2003-10-20 00:17:31 +04:00
|
|
|
}
|
1997-11-02 12:41:57 +03:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
/* Configure the system */
|
2006-01-13 01:02:44 +03:00
|
|
|
if (set_status[SET_BASE] & SET_INSTALLED)
|
2003-10-20 00:17:31 +04:00
|
|
|
run_makedev();
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2004-06-12 23:18:24 +04:00
|
|
|
/* Save keybard type */
|
|
|
|
save_kb_encoding();
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
/* Other configuration. */
|
|
|
|
mnt_net_config();
|
2006-01-13 01:02:44 +03:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
/* Mounted dist dir? */
|
|
|
|
umount_mnt2();
|
|
|
|
|
|
|
|
/* Install/Upgrade complete ... reboot or exit to script */
|
|
|
|
msg_display(success_msg);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
2003-10-20 00:17:31 +04:00
|
|
|
return 0;
|
1997-11-02 12:41:57 +03:00
|
|
|
}
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
void
|
|
|
|
umount_mnt2(void)
|
|
|
|
{
|
|
|
|
if (!mnt2_mounted)
|
|
|
|
return;
|
2003-11-30 17:36:43 +03:00
|
|
|
run_program(RUN_SILENT, "/sbin/umount /mnt2");
|
2003-10-20 00:17:31 +04:00
|
|
|
mnt2_mounted = 0;
|
|
|
|
}
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
|
|
|
* Do a quick sanity check that the target can reboot.
|
|
|
|
* return 1 if everything OK, 0 if there is a problem.
|
|
|
|
* Uses a table of files we expect to find after a base install/upgrade.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* test flag and pathname to check for after unpacking. */
|
2000-09-26 17:26:02 +04:00
|
|
|
struct check_table { unsigned int mode; const char *path;} checks[] = {
|
|
|
|
{ S_IFREG, "/netbsd" },
|
|
|
|
{ S_IFDIR, "/etc" },
|
|
|
|
{ S_IFREG, "/etc/fstab" },
|
|
|
|
{ S_IFREG, "/sbin/init" },
|
|
|
|
{ S_IFREG, "/bin/sh" },
|
|
|
|
{ S_IFREG, "/etc/rc" },
|
|
|
|
{ S_IFREG, "/etc/rc.subr" },
|
|
|
|
{ S_IFREG, "/etc/rc.conf" },
|
|
|
|
{ S_IFDIR, "/dev" },
|
|
|
|
{ S_IFCHR, "/dev/console" },
|
1997-11-05 10:28:20 +03:00
|
|
|
/* XXX check for rootdev in target /dev? */
|
2000-09-26 17:26:02 +04:00
|
|
|
{ S_IFREG, "/etc/fstab" },
|
|
|
|
{ S_IFREG, "/sbin/fsck" },
|
|
|
|
{ S_IFREG, "/sbin/fsck_ffs" },
|
|
|
|
{ S_IFREG, "/sbin/mount" },
|
|
|
|
{ S_IFREG, "/sbin/mount_ffs" },
|
|
|
|
{ S_IFREG, "/sbin/mount_nfs" },
|
1997-11-13 06:06:44 +03:00
|
|
|
#if defined(DEBUG) || defined(DEBUG_CHECK)
|
2000-09-26 17:26:02 +04:00
|
|
|
{ S_IFREG, "/foo/bar" }, /* bad entry to exercise warning */
|
1997-11-05 10:28:20 +03:00
|
|
|
#endif
|
|
|
|
{ 0, 0 }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check target for a single file.
|
|
|
|
*/
|
1998-06-20 17:05:48 +04:00
|
|
|
static int
|
2003-06-11 15:00:39 +04:00
|
|
|
check_for(unsigned int mode, const char *pathname)
|
1997-11-05 10:28:20 +03:00
|
|
|
{
|
1997-11-06 12:02:36 +03:00
|
|
|
int found;
|
1997-11-05 10:28:20 +03:00
|
|
|
|
2000-09-26 17:26:02 +04:00
|
|
|
found = (target_test(mode, pathname) == 0);
|
1997-11-06 12:02:36 +03:00
|
|
|
if (found == 0)
|
1997-11-05 10:28:20 +03:00
|
|
|
msg_display(MSG_rootmissing, pathname);
|
1997-11-06 12:02:36 +03:00
|
|
|
return found;
|
1997-11-05 10:28:20 +03:00
|
|
|
}
|
|
|
|
|
1998-02-07 12:32:32 +03:00
|
|
|
/*
|
|
|
|
* Check that all the files in check_table are present in the
|
|
|
|
* target root. Warn if not found.
|
|
|
|
*/
|
1997-11-05 10:28:20 +03:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
sanity_check(void)
|
1997-11-05 10:28:20 +03:00
|
|
|
{
|
|
|
|
int target_ok = 1;
|
|
|
|
struct check_table *p;
|
|
|
|
|
|
|
|
for (p = checks; p->path; p++) {
|
2000-09-26 17:26:02 +04:00
|
|
|
target_ok = target_ok && check_for(p->mode, p->path);
|
1997-11-05 10:28:20 +03:00
|
|
|
}
|
|
|
|
if (target_ok)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Uh, oh. Something's missing. */
|
|
|
|
msg_display(MSG_badroot);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_ok, NULL);
|
1997-11-05 10:28:20 +03:00
|
|
|
return 1;
|
|
|
|
}
|
1999-01-21 11:02:17 +03:00
|
|
|
|
2000-08-15 05:08:00 +04:00
|
|
|
/*
|
|
|
|
* Some globals to pass things back from callbacks
|
|
|
|
*/
|
|
|
|
static char zoneinfo_dir[STRSIZE];
|
2003-07-07 16:30:19 +04:00
|
|
|
static int zonerootlen;
|
|
|
|
static char *tz_selected; /* timezonename (relative to share/zoneinfo */
|
2003-05-09 16:45:01 +04:00
|
|
|
static const char *tz_default; /* UTC, or whatever /etc/localtime points to */
|
2000-08-15 05:08:00 +04:00
|
|
|
static char tz_env[STRSIZE];
|
2003-07-07 16:30:19 +04:00
|
|
|
static int save_cursel, save_topline;
|
2000-08-15 05:08:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback from timezone menu
|
|
|
|
*/
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_tz_select(menudesc *m, void *arg)
|
2000-08-15 05:08:00 +04:00
|
|
|
{
|
|
|
|
time_t t;
|
2003-07-07 16:30:19 +04:00
|
|
|
char *new;
|
2000-08-15 05:08:00 +04:00
|
|
|
|
2003-07-29 16:08:32 +04:00
|
|
|
if (m && strcmp(tz_selected, m->opts[m->cursel].opt_name) != 0) {
|
2004-07-17 15:28:16 +04:00
|
|
|
/* Change the displayed timezone */
|
2003-07-07 16:30:19 +04:00
|
|
|
new = strdup(m->opts[m->cursel].opt_name);
|
|
|
|
if (new == NULL)
|
|
|
|
return 0;
|
|
|
|
free(tz_selected);
|
|
|
|
tz_selected = new;
|
2003-07-29 16:08:32 +04:00
|
|
|
snprintf(tz_env, sizeof tz_env, "%.*s%s",
|
|
|
|
zonerootlen, zoneinfo_dir, tz_selected);
|
|
|
|
setenv("TZ", tz_env, 1);
|
2003-07-07 16:30:19 +04:00
|
|
|
}
|
2004-07-17 15:28:16 +04:00
|
|
|
if (m)
|
|
|
|
/* Warp curser to 'Exit' line on menu */
|
|
|
|
m->cursel = -1;
|
|
|
|
|
|
|
|
/* Update displayed time */
|
2000-08-15 05:08:00 +04:00
|
|
|
t = time(NULL);
|
|
|
|
msg_display(MSG_choose_timezone,
|
|
|
|
tz_default, tz_selected, ctime(&t), localtime(&t)->tm_zone);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_tz_back(menudesc *m, void *arg)
|
2003-07-07 16:30:19 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
zoneinfo_dir[zonerootlen] = 0;
|
|
|
|
m->cursel = save_cursel;
|
|
|
|
m->topline = save_topline;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
set_tz_dir(menudesc *m, void *arg)
|
2003-07-07 16:30:19 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
strlcpy(zoneinfo_dir + zonerootlen, m->opts[m->cursel].opt_name,
|
|
|
|
sizeof zoneinfo_dir - zonerootlen);
|
|
|
|
save_cursel = m->cursel;
|
|
|
|
save_topline = m->topline;
|
|
|
|
m->cursel = 0;
|
|
|
|
m->topline = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-08-15 05:08:00 +04:00
|
|
|
/*
|
|
|
|
* Alarm-handler to update example-display
|
|
|
|
*/
|
|
|
|
static void
|
2003-01-10 23:00:27 +03:00
|
|
|
/*ARGSUSED*/
|
2000-08-15 05:08:00 +04:00
|
|
|
timezone_sig(int sig)
|
|
|
|
{
|
2003-06-11 15:00:39 +04:00
|
|
|
|
2003-07-27 11:45:08 +04:00
|
|
|
set_tz_select(NULL, NULL);
|
2002-10-05 06:41:54 +04:00
|
|
|
alarm(60);
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
static int
|
|
|
|
tz_sort(const void *a, const void *b)
|
|
|
|
{
|
2003-07-25 12:26:21 +04:00
|
|
|
return strcmp(((const menu_ent *)a)->opt_name, ((const menu_ent *)b)->opt_name);
|
2003-07-07 16:30:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tzm_set_names(menudesc *m, void *arg)
|
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dp;
|
|
|
|
static int nfiles;
|
|
|
|
static int maxfiles = 32;
|
|
|
|
static menu_ent *tz_menu;
|
|
|
|
static char **tz_names;
|
|
|
|
void *p;
|
|
|
|
int maxfname;
|
|
|
|
char *fp;
|
|
|
|
struct stat sb;
|
|
|
|
|
|
|
|
if (tz_menu == NULL)
|
|
|
|
tz_menu = malloc(maxfiles * sizeof *tz_menu);
|
|
|
|
if (tz_names == NULL)
|
|
|
|
tz_names = malloc(maxfiles * sizeof *tz_names);
|
|
|
|
if (tz_menu == NULL || tz_names == NULL)
|
|
|
|
return; /* error - skip timezone setting */
|
|
|
|
while (nfiles > 0)
|
|
|
|
free(tz_names[--nfiles]);
|
|
|
|
|
|
|
|
dir = opendir(zoneinfo_dir);
|
|
|
|
fp = strchr(zoneinfo_dir, 0);
|
|
|
|
if (fp != zoneinfo_dir + zonerootlen) {
|
|
|
|
tz_names[0] = 0;
|
2003-07-08 15:58:57 +04:00
|
|
|
tz_menu[0].opt_name = msg_string(MSG_tz_back);
|
2003-07-07 16:30:19 +04:00
|
|
|
tz_menu[0].opt_menu = OPT_NOMENU;
|
|
|
|
tz_menu[0].opt_flags = 0;
|
|
|
|
tz_menu[0].opt_action = set_tz_back;
|
|
|
|
nfiles = 1;
|
|
|
|
}
|
|
|
|
maxfname = zoneinfo_dir + sizeof zoneinfo_dir - fp - 1;
|
|
|
|
if (dir != NULL) {
|
|
|
|
while ((dp = readdir(dir)) != NULL) {
|
|
|
|
if (dp->d_namlen > maxfname || dp->d_name[0] == '.')
|
|
|
|
continue;
|
|
|
|
strlcpy(fp, dp->d_name, maxfname);
|
|
|
|
if (stat(zoneinfo_dir, &sb) == -1)
|
|
|
|
continue;
|
|
|
|
if (nfiles >= maxfiles) {
|
|
|
|
p = realloc(tz_menu, 2 * maxfiles * sizeof *tz_menu);
|
|
|
|
if (p == NULL)
|
|
|
|
break;
|
|
|
|
tz_menu = p;
|
|
|
|
p = realloc(tz_names, 2 * maxfiles * sizeof *tz_names);
|
|
|
|
if (p == NULL)
|
|
|
|
break;
|
|
|
|
tz_names = p;
|
|
|
|
maxfiles *= 2;
|
|
|
|
}
|
|
|
|
if (S_ISREG(sb.st_mode))
|
|
|
|
tz_menu[nfiles].opt_action = set_tz_select;
|
|
|
|
else if (S_ISDIR(sb.st_mode)) {
|
|
|
|
tz_menu[nfiles].opt_action = set_tz_dir;
|
2003-08-06 17:56:58 +04:00
|
|
|
strlcat(fp, "/",
|
|
|
|
sizeof(zoneinfo_dir) - (fp - zoneinfo_dir));
|
2003-07-07 16:30:19 +04:00
|
|
|
} else
|
|
|
|
continue;
|
|
|
|
tz_names[nfiles] = strdup(zoneinfo_dir + zonerootlen);
|
|
|
|
tz_menu[nfiles].opt_name = tz_names[nfiles];
|
|
|
|
tz_menu[nfiles].opt_menu = OPT_NOMENU;
|
|
|
|
tz_menu[nfiles].opt_flags = 0;
|
|
|
|
nfiles++;
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
*fp = 0;
|
|
|
|
|
|
|
|
m->opts = tz_menu;
|
|
|
|
m->numopts = nfiles;
|
|
|
|
qsort(tz_menu, nfiles, sizeof *tz_menu, tz_sort);
|
|
|
|
}
|
|
|
|
|
2000-08-15 05:08:00 +04:00
|
|
|
/*
|
|
|
|
* Choose from the files in usr/share/zoneinfo and set etc/localtime
|
|
|
|
*/
|
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
set_timezone(void)
|
2000-08-15 05:08:00 +04:00
|
|
|
{
|
|
|
|
char localtime_link[STRSIZE];
|
|
|
|
char localtime_target[STRSIZE];
|
|
|
|
int rc;
|
|
|
|
time_t t;
|
|
|
|
int menu_no;
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"),
|
|
|
|
sizeof zoneinfo_dir - 1);
|
|
|
|
zonerootlen = strlen(zoneinfo_dir);
|
2003-05-16 23:34:00 +04:00
|
|
|
strlcpy(localtime_link, target_expand("/etc/localtime"),
|
|
|
|
sizeof localtime_link);
|
2000-08-15 05:08:00 +04:00
|
|
|
|
|
|
|
/* Add sanity check that /mnt/usr/share/zoneinfo contains
|
2003-07-07 16:30:19 +04:00
|
|
|
* something useful
|
|
|
|
*/
|
2000-08-15 05:08:00 +04:00
|
|
|
|
|
|
|
rc = readlink(localtime_link, localtime_target,
|
2002-10-20 00:33:17 +04:00
|
|
|
sizeof(localtime_target) - 1);
|
2000-08-15 05:08:00 +04:00
|
|
|
if (rc < 0) {
|
2000-08-31 05:10:43 +04:00
|
|
|
/* error, default to UTC */
|
|
|
|
tz_default = "UTC";
|
|
|
|
} else {
|
|
|
|
localtime_target[rc] = '\0';
|
2003-05-16 23:34:00 +04:00
|
|
|
tz_default = strchr(strstr(localtime_target, "zoneinfo"), '/') + 1;
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
tz_selected = strdup(tz_default);
|
|
|
|
snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected);
|
2000-08-15 05:08:00 +04:00
|
|
|
setenv("TZ", tz_env, 1);
|
|
|
|
t = time(NULL);
|
|
|
|
msg_display(MSG_choose_timezone,
|
|
|
|
tz_default, tz_selected, ctime(&t), localtime(&t)->tm_zone);
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
signal(SIGALRM, timezone_sig);
|
|
|
|
alarm(60);
|
2000-08-15 05:08:00 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
menu_no = new_menu(NULL, NULL, 14, 23, 9,
|
2003-10-20 00:17:31 +04:00
|
|
|
12, 32, MC_ALWAYS_SCROLL | MC_NOSHORTCUT,
|
2003-07-07 16:30:19 +04:00
|
|
|
tzm_set_names, NULL, NULL,
|
2003-06-04 23:09:50 +04:00
|
|
|
"\nPlease consult the install documents.", NULL);
|
2003-05-16 23:34:00 +04:00
|
|
|
if (menu_no < 0)
|
|
|
|
goto done; /* error - skip timezone setting */
|
2003-07-07 16:30:19 +04:00
|
|
|
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(menu_no, NULL);
|
2000-08-15 05:08:00 +04:00
|
|
|
|
|
|
|
free_menu(menu_no);
|
|
|
|
|
|
|
|
signal(SIGALRM, SIG_IGN);
|
|
|
|
|
|
|
|
snprintf(localtime_target, sizeof(localtime_target),
|
|
|
|
"/usr/share/zoneinfo/%s", tz_selected);
|
|
|
|
unlink(localtime_link);
|
|
|
|
symlink(localtime_target, localtime_link);
|
|
|
|
|
2003-05-16 23:34:00 +04:00
|
|
|
done:
|
2000-08-15 05:08:00 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2000-10-12 03:47:55 +04:00
|
|
|
|
2002-04-04 18:26:43 +04:00
|
|
|
int
|
|
|
|
set_crypt_type(void)
|
|
|
|
{
|
|
|
|
FILE *pwc;
|
|
|
|
char *fn;
|
|
|
|
|
|
|
|
msg_display(MSG_choose_crypt);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_crypttype, NULL);
|
2002-04-04 18:26:43 +04:00
|
|
|
fn = strdup(target_expand("/etc/passwd.conf"));
|
2003-01-12 01:32:43 +03:00
|
|
|
if (fn == NULL)
|
|
|
|
return -1;
|
2002-04-04 18:26:43 +04:00
|
|
|
|
2002-05-24 12:07:48 +04:00
|
|
|
switch (yesno) {
|
2002-06-02 18:12:54 +04:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1: /* DES */
|
|
|
|
rename(fn, target_expand("/etc/passwd.conf.pre-sysinst"));
|
|
|
|
pwc = fopen(fn, "w");
|
|
|
|
fprintf(pwc,
|
|
|
|
"default:\n"
|
2002-06-05 14:00:43 +04:00
|
|
|
" localcipher = old\n"
|
|
|
|
" ypcipher = old\n");
|
2002-06-02 18:12:54 +04:00
|
|
|
fclose(pwc);
|
|
|
|
break;
|
|
|
|
case 2: /* MD5 */
|
|
|
|
rename(fn, target_expand("/etc/passwd.conf.pre-sysinst"));
|
2002-04-04 18:26:43 +04:00
|
|
|
pwc = fopen(fn, "w");
|
|
|
|
fprintf(pwc,
|
|
|
|
"default:\n"
|
|
|
|
" localcipher = md5\n"
|
|
|
|
" ypcipher = md5\n");
|
|
|
|
fclose(pwc);
|
2002-05-24 12:07:48 +04:00
|
|
|
break;
|
2002-06-02 18:12:54 +04:00
|
|
|
case 3: /* blowfish 2^7 */
|
|
|
|
rename(fn, target_expand("/etc/passwd.conf.pre-sysinst"));
|
2002-05-24 12:07:48 +04:00
|
|
|
pwc = fopen(fn, "w");
|
|
|
|
fprintf(pwc,
|
|
|
|
"default:\n"
|
|
|
|
" localcipher = blowfish,7\n"
|
|
|
|
" ypcipher = blowfish,7\n");
|
|
|
|
fclose(pwc);
|
|
|
|
break;
|
2008-02-04 04:54:55 +03:00
|
|
|
case 4: /* sha1 */
|
|
|
|
rename(fn, target_expand("/etc/passwd.conf.pre-sysinst"));
|
|
|
|
pwc = fopen(fn, "w");
|
|
|
|
fprintf(pwc,
|
|
|
|
"default:\n"
|
|
|
|
" localcipher = sha1\n"
|
|
|
|
" ypcipher = sha1\n");
|
|
|
|
fclose(pwc);
|
|
|
|
break;
|
2002-04-04 18:26:43 +04:00
|
|
|
}
|
|
|
|
|
2002-04-05 04:12:14 +04:00
|
|
|
free(fn);
|
2002-04-04 18:26:43 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-10-12 03:47:55 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
set_root_password(void)
|
2000-10-12 03:47:55 +04:00
|
|
|
{
|
2003-06-11 15:00:39 +04:00
|
|
|
|
2000-10-12 03:47:55 +04:00
|
|
|
msg_display(MSG_rootpw);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_yesno, NULL);
|
2000-10-12 03:47:55 +04:00
|
|
|
if (yesno)
|
2004-08-17 21:12:26 +04:00
|
|
|
run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT,
|
|
|
|
"passwd -l root");
|
2000-10-12 03:47:55 +04:00
|
|
|
return 0;
|
|
|
|
}
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
|
2002-07-29 07:05:16 +04:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
set_root_shell(void)
|
2002-07-29 07:05:16 +04:00
|
|
|
{
|
2005-02-20 23:54:52 +03:00
|
|
|
const char *shellpath;
|
2003-06-11 15:00:39 +04:00
|
|
|
|
2002-07-29 07:05:16 +04:00
|
|
|
msg_display(MSG_rootsh);
|
2005-02-20 23:54:52 +03:00
|
|
|
process_menu(MENU_rootsh, &shellpath);
|
2004-08-17 21:12:26 +04:00
|
|
|
run_program(RUN_DISPLAY | RUN_CHROOT, "chpass -s %s root", shellpath);
|
2002-07-29 07:05:16 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
void
|
|
|
|
scripting_vfprintf(FILE *f, const char *fmt, va_list ap)
|
|
|
|
{
|
2003-06-11 15:00:39 +04:00
|
|
|
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
if (f)
|
|
|
|
(void)vfprintf(f, fmt, ap);
|
|
|
|
if (scripting)
|
|
|
|
(void)vfprintf(script, fmt, ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
scripting_fprintf(FILE *f, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
scripting_vfprintf(f, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_rc_conf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
f = target_fopen("/etc/rc.conf", "a");
|
|
|
|
if (f != 0) {
|
|
|
|
scripting_fprintf(NULL, "cat <<EOF >>%s/etc/rc.conf\n",
|
|
|
|
target_prefix());
|
|
|
|
scripting_vfprintf(f, fmt, ap);
|
|
|
|
fclose(f);
|
|
|
|
scripting_fprintf(NULL, "EOF\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
void
|
|
|
|
enable_rc_conf(void)
|
|
|
|
{
|
2006-09-04 03:54:02 +04:00
|
|
|
run_program(RUN_CHROOT,
|
|
|
|
"sed -an -e 's/^rc_configured=NO/rc_configured=YES/;"
|
|
|
|
"H;$!d;g;w /etc/rc.conf' /etc/rc.conf");
|
2003-10-20 00:17:31 +04:00
|
|
|
}
|
|
|
|
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
int
|
2003-06-11 15:00:39 +04:00
|
|
|
check_lfs_progs(void)
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
{
|
|
|
|
|
2006-01-17 00:47:55 +03:00
|
|
|
return (access("/sbin/fsck_lfs", X_OK) == 0 &&
|
extend sysinst disk handling, some general clean ups, better /etc support
and some sparc64 fixes. details:
- new scripting_{,v}fprintf() that also write to the script log (if open).
- support of creation of LFS filesystems
- standard installs now allow one to choose which file systems to create,
out of the list of /usr, /var, /home, MFS /tmp, and swap. a / is always
created, but the rest all optional. [*]
- new disklabel method: use existing. this requires one to fill in the
mount points (and having at least a "/" is enforced).
- preservation of existing filesystems (at install) is supported.
- rewrote most of make_fstab(): the entire thing is generated from the
bsdlabel now, rather than hard coding / to 'a' and swap to 'b'. create
MFS /tmp if requested.
- if IPv6 support isn't present, don't display any ipv6 messages.
- better rc.conf support
- sparc & sparc64 default to "cylinders" now.
- choosing "standard" instead of "standard with X" de-selects the X pkgs
by default.
- sparc64: don't install bootblocks until we have a complete system, avoids
booting with no /dev/console.
- sparc64: bump STDNEEDMB, it is way low.
[*] i have added default values for DEFVARSIZE & DEFUSRSIZE (this is used
only if /usr and /home are selected) to each port, based on STDNEEDMB. as
such, my guesses might be wrong so port maintainers should look at these.
2001-01-14 05:38:13 +03:00
|
|
|
access("/sbin/mount_lfs", X_OK) == 0 &&
|
|
|
|
access("/sbin/newfs_lfs", X_OK) == 0);
|
|
|
|
}
|