2003-01-10 23:00:27 +03:00
|
|
|
/* $NetBSD: util.c,v 1.78 2003/01/10 20:00:28 christos 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>
|
2000-08-15 05:08:00 +04:00
|
|
|
#include <fts.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"
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/*
|
|
|
|
* local prototypes
|
|
|
|
*/
|
1998-06-20 17:05:48 +04:00
|
|
|
struct tarstats {
|
1997-12-05 17:00:59 +03:00
|
|
|
int nselected;
|
|
|
|
int nfound;
|
|
|
|
int nnotfound;
|
|
|
|
int nerror;
|
|
|
|
int nsuccess;
|
1999-06-22 06:43:09 +04:00
|
|
|
int nskipped;
|
1997-12-05 17:00:59 +03:00
|
|
|
} tarstats;
|
|
|
|
|
2000-12-22 13:12:12 +03:00
|
|
|
int extract_file (char *path);
|
|
|
|
int extract_dist (void);
|
|
|
|
int cleanup_dist (const char *path);
|
|
|
|
int distribution_sets_exist_p (const char *path);
|
|
|
|
static int check_for (unsigned int mode, const char *pathname);
|
1997-10-07 08:01:29 +04:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
|
|
|
dir_exists_p(path)
|
|
|
|
const char *path;
|
1997-12-05 17:00:59 +03: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
|
|
|
|
file_exists_p(path)
|
|
|
|
const char *path;
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
2000-09-26 17:26:02 +04:00
|
|
|
return file_mode_match(path, S_IFREG);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
file_mode_match(path, mode)
|
|
|
|
const char *path;
|
|
|
|
unsigned int mode;
|
|
|
|
{
|
|
|
|
struct stat st;
|
1998-06-20 17:05:48 +04:00
|
|
|
|
2000-09-26 17:26:02 +04:00
|
|
|
return (stat(path, &st) == 0 && (st.st_mode & mode) != 0);
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
|
|
|
distribution_sets_exist_p(path)
|
|
|
|
const char *path;
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
|
|
|
char buf[STRSIZE];
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
snprintf(buf, STRSIZE, "%s/%s", path, "etc.tgz");
|
|
|
|
result = result && file_exists_p(buf);
|
|
|
|
|
2000-12-31 16:08:05 +03:00
|
|
|
snprintf(buf, STRSIZE, "%s/%s", path, "base.tgz");
|
|
|
|
result = result && file_exists_p(buf);
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
|
|
|
get_ramsize()
|
1997-10-07 08:01:29 +04:00
|
|
|
{
|
2003-01-10 23:00:27 +03:00
|
|
|
size_t len = sizeof(ramsize);
|
1997-10-07 08:01:29 +04:00
|
|
|
int mib[2] = {CTL_HW, HW_PHYSMEM};
|
|
|
|
|
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. */
|
2003-01-10 23:00:27 +03:00
|
|
|
rammb = (unsigned int)((ramsize + MEG - 1) / MEG);
|
1997-10-07 08:01:29 +04:00
|
|
|
}
|
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
static int asked = 0;
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
2000-03-15 01:42:48 +03:00
|
|
|
ask_sizemult(cylsize)
|
|
|
|
int cylsize;
|
1997-09-27 03:02:53 +04:00
|
|
|
{
|
2000-03-15 01:42:48 +03:00
|
|
|
current_cylsize = cylsize; /* XXX */
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1997-09-27 03:02:53 +04:00
|
|
|
if (!asked) {
|
2000-03-15 01:42:48 +03:00
|
|
|
msg_display(MSG_sizechoice);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_sizechoice);
|
1997-09-27 03:02:53 +04:00
|
|
|
}
|
|
|
|
asked = 1;
|
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
2000-03-15 01:42:48 +03:00
|
|
|
reask_sizemult(cylsize)
|
|
|
|
int cylsize;
|
1997-11-01 02:00:32 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1997-11-01 02:00:32 +03:00
|
|
|
asked = 0;
|
2000-03-15 01:42:48 +03:00
|
|
|
ask_sizemult(cylsize);
|
1997-11-01 02:00:32 +03:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
|
|
|
run_makedev()
|
1997-10-01 09:04:24 +04:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
char *owd;
|
|
|
|
|
1999-04-15 16:25:54 +04:00
|
|
|
wclear(stdscr);
|
|
|
|
wrefresh(stdscr);
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_makedev);
|
1997-10-18 01:10:39 +04:00
|
|
|
sleep (1);
|
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");
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/bin/sh MAKEDEV all");
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
chdir(owd);
|
|
|
|
free(owd);
|
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
|
|
|
|
get_via_floppy()
|
1997-10-18 01:10:39 +04:00
|
|
|
{
|
|
|
|
char distname[STRSIZE];
|
|
|
|
char fddev[STRSIZE] = "/dev/fd0a";
|
|
|
|
char fname[STRSIZE];
|
2003-01-10 23:00:27 +03:00
|
|
|
char full_name[STRSIZE];
|
1999-03-08 22:42:30 +03:00
|
|
|
char catcmd[STRSIZE];
|
1997-10-29 04:06:42 +03:00
|
|
|
distinfo *list;
|
1997-10-18 01:10:39 +04:00
|
|
|
char post[4];
|
|
|
|
int mounted = 0;
|
1997-10-30 03:03:32 +03:00
|
|
|
int first;
|
1997-10-18 01:10:39 +04:00
|
|
|
struct stat sb;
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
cd_dist_dir("unloading from floppy");
|
1997-10-29 04:06:42 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_prompt_add(MSG_fddev, fddev, fddev, STRSIZE);
|
1997-10-18 01:10:39 +04:00
|
|
|
|
|
|
|
list = dist_list;
|
1997-10-29 04:06:42 +03:00
|
|
|
while (list->name) {
|
1998-06-20 17:05:48 +04:00
|
|
|
strcpy(post, ".aa");
|
|
|
|
snprintf(distname, STRSIZE, "%s%s", list->name, dist_postfix);
|
1997-10-30 03:03:32 +03:00
|
|
|
while (list->getit && strcmp(&post[1],list->fdlast) <= 0) {
|
1998-06-20 17:05:48 +04:00
|
|
|
snprintf(fname, STRSIZE, "%s%s", list->name, post);
|
2003-01-10 23:00:27 +03:00
|
|
|
snprintf(full_name, STRSIZE, "/mnt2/%s", fname);
|
1997-10-30 03:03:32 +03:00
|
|
|
first = 1;
|
2003-01-10 23:00:27 +03:00
|
|
|
while (!mounted || stat(full_name, &sb)) {
|
1997-10-30 03:03:32 +03:00
|
|
|
if (mounted)
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/sbin/umount /mnt2");
|
1997-10-30 03:03:32 +03:00
|
|
|
if (first)
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_fdmount, fname);
|
1997-10-30 03:03:32 +03:00
|
|
|
else
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_fdnotfound, fname);
|
|
|
|
process_menu(MENU_fdok);
|
1997-10-30 03:03:32 +03:00
|
|
|
if (!yesno)
|
|
|
|
return 0;
|
2000-10-12 03:47:55 +04:00
|
|
|
while (run_prog(0, NULL,
|
1999-04-09 14:24:38 +04:00
|
|
|
"/sbin/mount -r -t %s %s /mnt2",
|
1998-06-20 17:05:48 +04:00
|
|
|
fdtype, fddev)) {
|
|
|
|
msg_display(MSG_fdremount, fname);
|
|
|
|
process_menu(MENU_fdremount);
|
1997-10-18 01:10:39 +04:00
|
|
|
if (!yesno)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mounted = 1;
|
1997-10-30 03:03:32 +03:00
|
|
|
first = 0;
|
1997-10-18 01:10:39 +04:00
|
|
|
}
|
1999-03-08 22:42:30 +03:00
|
|
|
sprintf(catcmd, "/bin/cat %s >> %s",
|
2003-01-10 23:00:27 +03:00
|
|
|
full_name, distname);
|
1999-03-08 22:42:30 +03:00
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
(void)fprintf(logfp, "%s\n", catcmd);
|
1999-03-08 22:42:30 +03:00
|
|
|
if (scripting)
|
|
|
|
(void)fprintf(script, "%s\n", catcmd);
|
|
|
|
do_system(catcmd);
|
1997-10-30 03:03:32 +03:00
|
|
|
if (post[2] < 'z')
|
|
|
|
post[2]++;
|
1997-10-18 01:10:39 +04:00
|
|
|
else
|
1998-06-20 17:05:48 +04:00
|
|
|
post[2] = 'a', post[1]++;
|
1997-10-18 01:10:39 +04:00
|
|
|
}
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/sbin/umount /mnt2");
|
1997-10-18 01:10:39 +04:00
|
|
|
mounted = 0;
|
|
|
|
list++;
|
|
|
|
}
|
|
|
|
#ifndef DEBUG
|
1997-11-02 11:20:40 +03:00
|
|
|
chdir("/"); /* back to current real root */
|
1997-10-18 01:10:39 +04:00
|
|
|
#endif
|
|
|
|
return 1;
|
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
|
1998-06-20 17:05:48 +04:00
|
|
|
get_via_cdrom()
|
1997-10-20 10:13:25 +04:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
char tmpdir[STRSIZE];
|
|
|
|
|
1998-05-15 19:12:29 +04:00
|
|
|
/* Get CD-rom device name and path within CD-rom */
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_cdromsource);
|
1998-05-15 19:12:29 +04:00
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
again:
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/sbin/umount /mnt2");
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-10-20 10:13:25 +04:00
|
|
|
/* Mount it */
|
2000-10-12 03:47:55 +04:00
|
|
|
if (run_prog(0, NULL,
|
1999-04-09 14:24:38 +04:00
|
|
|
"/sbin/mount -rt cd9660 /dev/%sa /mnt2", cdrom_dev)) {
|
1997-12-05 17:00:59 +03:00
|
|
|
msg_display(MSG_badsetdir, cdrom_dev);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_cdrombadmount);
|
1997-10-20 10:13:25 +04:00
|
|
|
if (!yesno)
|
|
|
|
return 0;
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!ignorerror)
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(tmpdir, STRSIZE, "%s/%s", "/mnt2", cdrom_dir);
|
|
|
|
|
|
|
|
/* Verify distribution files exist. */
|
|
|
|
if (distribution_sets_exist_p(tmpdir) == 0) {
|
|
|
|
msg_display(MSG_badsetdir, tmpdir);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_cdrombadmount);
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!yesno)
|
|
|
|
return (0);
|
|
|
|
if (!ignorerror)
|
|
|
|
goto again;
|
1997-10-20 10:13:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return location, don't clean... */
|
1997-12-05 17:00:59 +03:00
|
|
|
strncpy(ext_dir, tmpdir, STRSIZE);
|
1997-10-20 10:13:25 +04:00
|
|
|
clean_dist_dir = 0;
|
|
|
|
mnt2_mounted = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
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
|
|
|
|
get_via_localfs()
|
1997-11-06 01:45:53 +03:00
|
|
|
{
|
1997-12-05 17:00:59 +03:00
|
|
|
char tmpdir[STRSIZE];
|
|
|
|
|
1997-11-06 01:45:53 +03:00
|
|
|
/* Get device, filesystem, and filepath */
|
|
|
|
process_menu (MENU_localfssource);
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
again:
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/sbin/umount /mnt2");
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-11-06 01:45:53 +03:00
|
|
|
/* Mount it */
|
2000-10-12 03:47:55 +04:00
|
|
|
if (run_prog(0, NULL, "/sbin/mount -rt %s /dev/%s /mnt2",
|
1999-04-09 14:24:38 +04:00
|
|
|
localfs_fs, localfs_dev)) {
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_localfsbadmount, localfs_dir, localfs_dev);
|
|
|
|
process_menu(MENU_localfsbadmount);
|
1997-11-06 01:45:53 +03:00
|
|
|
if (!yesno)
|
|
|
|
return 0;
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!ignorerror)
|
1998-06-20 17:05:48 +04:00
|
|
|
goto again;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(tmpdir, STRSIZE, "%s/%s", "/mnt2", localfs_dir);
|
|
|
|
|
|
|
|
/* Verify distribution files exist. */
|
|
|
|
if (distribution_sets_exist_p(tmpdir) == 0) {
|
|
|
|
msg_display(MSG_badsetdir, tmpdir);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_localfsbadmount);
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!yesno)
|
|
|
|
return 0;
|
|
|
|
if (!ignorerror)
|
|
|
|
goto again;
|
1997-11-06 01:45:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return location, don't clean... */
|
1997-12-05 17:00:59 +03:00
|
|
|
strncpy(ext_dir, tmpdir, STRSIZE);
|
1997-11-06 01:45:53 +03:00
|
|
|
clean_dist_dir = 0;
|
|
|
|
mnt2_mounted = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
int get_via_localdir(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Get device, filesystem, and filepath */
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_localdirsource);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
again:
|
|
|
|
/* Complain if not a directory */
|
|
|
|
if (dir_exists_p(localfs_dir) == 0) {
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_badlocalsetdir, localfs_dir);
|
|
|
|
process_menu(MENU_localdirbad);
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!yesno)
|
|
|
|
return (0);
|
|
|
|
if (!ignorerror)
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify distribution files exist. */
|
|
|
|
if (distribution_sets_exist_p(localfs_dir) == 0) {
|
|
|
|
msg_display(MSG_badsetdir, localfs_dir);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_localdirbad);
|
1997-12-05 17:00:59 +03:00
|
|
|
if (!yesno)
|
|
|
|
return (0);
|
|
|
|
if (!ignorerror)
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return location, don't clean... */
|
1998-06-20 17:05:48 +04:00
|
|
|
strncpy(ext_dir, localfs_dir, STRSIZE);
|
1997-12-05 17:00:59 +03:00
|
|
|
clean_dist_dir = 0;
|
|
|
|
mnt2_mounted = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
|
|
|
cd_dist_dir(forwhat)
|
|
|
|
char *forwhat;
|
1997-10-29 04:06:42 +03:00
|
|
|
{
|
1997-11-11 03:43:31 +03:00
|
|
|
char *cwd;
|
|
|
|
|
1997-11-02 11:20:40 +03:00
|
|
|
/* ask user for the mountpoint. */
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_prompt(MSG_distdir, dist_dir, dist_dir, STRSIZE, forwhat);
|
1997-11-02 11:20:40 +03:00
|
|
|
|
|
|
|
/* make sure the directory exists. */
|
|
|
|
make_target_dir(dist_dir);
|
|
|
|
|
1997-10-29 04:06:42 +03:00
|
|
|
clean_dist_dir = 1;
|
1997-11-02 11:20:40 +03:00
|
|
|
target_chdir_or_die(dist_dir);
|
1997-11-11 03:43:31 +03:00
|
|
|
|
|
|
|
/* Set ext_dir for absolute path. */
|
1998-06-20 17:05:48 +04:00
|
|
|
cwd = getcwd(NULL,0);
|
|
|
|
strncpy(ext_dir, cwd, STRSIZE);
|
1997-11-11 03:43:31 +03:00
|
|
|
free (cwd);
|
1997-10-29 04:06:42 +03:00
|
|
|
}
|
|
|
|
|
1997-11-02 11:20:40 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
|
|
|
* Support for custom distribution fetches / unpacks.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
toggle_getit(num)
|
|
|
|
int num;
|
1997-10-29 04:06:42 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1997-10-29 04:06:42 +03:00
|
|
|
dist_list[num].getit ^= 1;
|
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
void
|
|
|
|
show_cur_distsets()
|
1997-10-29 04:06:42 +03:00
|
|
|
{
|
|
|
|
distinfo *list;
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_cur_distsets);
|
1999-07-05 02:31:37 +04:00
|
|
|
msg_table_add(MSG_cur_distsets_header);
|
1997-10-29 04:06:42 +03:00
|
|
|
list = dist_list;
|
|
|
|
while (list->name) {
|
1999-07-05 02:31:37 +04:00
|
|
|
msg_table_add(MSG_cur_distsets_row, list->desc,
|
1998-06-20 17:05:48 +04:00
|
|
|
list->getit ? msg_string(MSG_yes) : msg_string(MSG_no));
|
1997-10-29 04:06:42 +03:00
|
|
|
list++;
|
|
|
|
}
|
|
|
|
}
|
1997-11-02 11:20:40 +03:00
|
|
|
|
1997-11-04 04:39:03 +03:00
|
|
|
/* Do we want a verbose extract? */
|
|
|
|
static int verbose = -1;
|
|
|
|
|
|
|
|
void
|
1998-06-20 17:05:48 +04:00
|
|
|
ask_verbose_dist()
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
1998-06-20 17:05:48 +04:00
|
|
|
|
1997-11-04 04:39:03 +03:00
|
|
|
if (verbose < 0) {
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_verboseextract);
|
|
|
|
process_menu(MENU_noyes);
|
1997-11-04 04:39:03 +03:00
|
|
|
verbose = yesno;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
wclear(stdscr);
|
|
|
|
wrefresh(stdscr);
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-22 06:43:09 +04:00
|
|
|
int
|
1998-06-20 17:05:48 +04:00
|
|
|
extract_file(path)
|
|
|
|
char *path;
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
|
|
|
char *owd;
|
1999-06-22 06:43:09 +04:00
|
|
|
int tarexit, rv;
|
1997-11-04 04:39:03 +03:00
|
|
|
|
|
|
|
owd = getcwd (NULL,0);
|
|
|
|
|
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);
|
|
|
|
process_menu(MENU_noyes);
|
|
|
|
return (yesno == 0);
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
tarstats.nfound++;
|
1997-11-05 10:28:20 +03:00
|
|
|
/* cd to the target root. */
|
1997-11-04 04:39:03 +03:00
|
|
|
target_chdir_or_die("/");
|
|
|
|
|
1997-11-05 10:28:20 +03:00
|
|
|
/* now extract set files files into "./". */
|
2000-10-12 03:47:55 +04:00
|
|
|
tarexit = run_prog(RUN_DISPLAY, NULL,
|
2002-12-22 15:07:34 +03:00
|
|
|
"pax -zr%spe -O -f %s", verbose ? "v" : "", path);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-11-06 02:32:44 +03:00
|
|
|
/* Check tarexit for errors and give warning. */
|
1997-12-05 17:00:59 +03:00
|
|
|
if (tarexit) {
|
|
|
|
tarstats.nerror++;
|
1999-06-22 06:43:09 +04:00
|
|
|
|
|
|
|
msg_display(MSG_tarerror, path);
|
|
|
|
process_menu(MENU_noyes);
|
|
|
|
rv = (yesno == 0);
|
1997-12-05 17:00:59 +03:00
|
|
|
} else {
|
|
|
|
tarstats.nsuccess++;
|
1999-06-22 06:43:09 +04:00
|
|
|
rv = 0;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
chdir(owd);
|
|
|
|
free(owd);
|
1999-06-22 06:43:09 +04:00
|
|
|
|
|
|
|
return (rv);
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
|
1997-11-11 03:43:31 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/*
|
1999-04-14 00:17:47 +04:00
|
|
|
* Extract_dist **REQUIRES** an absolute path in ext_dir. Any code
|
1997-11-11 03:43:31 +03:00
|
|
|
* that sets up dist_dir for use by extract_dist needs to put in the
|
|
|
|
* full path name to the directory.
|
|
|
|
*/
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
int
|
1998-06-20 17:05:48 +04:00
|
|
|
extract_dist()
|
1997-11-04 04:39:03 +03:00
|
|
|
{
|
|
|
|
char distname[STRSIZE];
|
|
|
|
char fname[STRSIZE];
|
|
|
|
distinfo *list;
|
1999-06-22 06:43:09 +04:00
|
|
|
int punt;
|
1997-11-04 04:39:03 +03:00
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
/* reset failure/success counters */
|
1998-08-10 06:23:45 +04:00
|
|
|
memset(&tarstats, 0, sizeof(tarstats));
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
/*endwin();*/
|
1999-06-22 06:43:09 +04:00
|
|
|
for (punt = 0, list = dist_list; list->name != NULL; list++) {
|
1997-11-05 10:48:52 +03:00
|
|
|
if (list->getit) {
|
1997-12-05 17:00:59 +03:00
|
|
|
tarstats.nselected++;
|
1999-06-22 06:43:09 +04:00
|
|
|
if (punt) {
|
|
|
|
tarstats.nskipped++;
|
|
|
|
continue;
|
|
|
|
}
|
1999-04-14 00:17:47 +04:00
|
|
|
if (cleanup_dist(list->name) == 0) {
|
|
|
|
msg_display(MSG_cleanup_warn);
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
}
|
1998-06-20 17:05:48 +04:00
|
|
|
(void)snprintf(distname, STRSIZE, "%s%s", list->name,
|
|
|
|
dist_postfix);
|
|
|
|
(void)snprintf(fname, STRSIZE, "%s/%s", ext_dir,
|
|
|
|
distname);
|
1999-06-22 06:43:09 +04:00
|
|
|
|
|
|
|
/* if extraction failed and user aborted, punt. */
|
|
|
|
punt = extract_file(fname);
|
1997-11-05 10:48:52 +03:00
|
|
|
}
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2001-01-07 16:07:57 +03:00
|
|
|
wrefresh(curscr);
|
2000-12-22 00:42:00 +03:00
|
|
|
wmove(stdscr, 0, 0);
|
1999-06-22 04:57:06 +04:00
|
|
|
wclear(stdscr);
|
1997-11-06 02:32:44 +03:00
|
|
|
wrefresh(stdscr);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
if (tarstats.nerror == 0 && tarstats.nsuccess == tarstats.nselected) {
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(MSG_endtarok);
|
|
|
|
process_menu(MENU_ok);
|
1997-12-05 17:00:59 +03:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
/* We encountered errors. Let the user know. */
|
|
|
|
msg_display(MSG_endtar,
|
1999-06-22 06:43:09 +04:00
|
|
|
tarstats.nselected, tarstats.nnotfound, tarstats.nskipped,
|
1997-12-05 17:00:59 +03:00
|
|
|
tarstats.nfound, tarstats.nsuccess, tarstats.nerror);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_ok);
|
1997-12-05 17:00:59 +03:00
|
|
|
return 1;
|
|
|
|
}
|
1997-11-04 04:39:03 +03:00
|
|
|
}
|
|
|
|
|
1999-04-14 00:17:47 +04:00
|
|
|
/*
|
|
|
|
* Do pre-extract cleanup for set 'name':
|
|
|
|
* open a file named '/dist/<name>_obsolete file', which contain a list of
|
|
|
|
* files to kill from the target. For each file, test if it is present on
|
|
|
|
* the target. Then display the list of files which will be removed,
|
|
|
|
* ask user for confirmation, and process.
|
2000-12-31 16:08:05 +03:00
|
|
|
* Non-empty directories will be renamed to <directory.old>.
|
1999-04-14 00:17:47 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* definition for a list of files. */
|
|
|
|
struct filelist {
|
|
|
|
struct filelist *next;
|
|
|
|
char name[MAXPATHLEN];
|
|
|
|
mode_t type;
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
cleanup_dist(name)
|
|
|
|
const char *name;
|
|
|
|
{
|
|
|
|
char file_path[MAXPATHLEN];
|
|
|
|
char file_name[MAXPATHLEN];
|
|
|
|
FILE *list_file;
|
|
|
|
struct filelist *head = NULL;
|
|
|
|
struct filelist *current;
|
|
|
|
int saved_errno;
|
|
|
|
struct stat st;
|
|
|
|
int retval = 1;
|
|
|
|
int needok = 0;
|
|
|
|
|
|
|
|
snprintf(file_path, MAXPATHLEN, "/dist/%s_obsolete", name);
|
|
|
|
list_file = fopen(file_path, "r");
|
|
|
|
if (list_file == NULL) {
|
|
|
|
saved_errno = errno;
|
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "Open of %s failed: %s\n", file_path,
|
1999-04-14 00:17:47 +04:00
|
|
|
strerror(saved_errno));
|
|
|
|
if (saved_errno == ENOENT)
|
|
|
|
return 1;
|
|
|
|
msg_display_add(MSG_openfail, name, strerror(saved_errno));
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
while (fgets(file_name, MAXPATHLEN, list_file)) {
|
|
|
|
/* ignore lines that don't begin with '/' */
|
|
|
|
if (file_name[0] != '/')
|
|
|
|
continue;
|
|
|
|
/* Remove trailing \n if any */
|
|
|
|
if (file_name[strlen(file_name)-1] == '\n')
|
|
|
|
file_name[strlen(file_name)-1] = '\0';
|
|
|
|
snprintf(file_path, MAXPATHLEN, "%s%s", target_prefix(),
|
|
|
|
file_name);
|
|
|
|
if (lstat(file_path, &st) != 0) {
|
|
|
|
saved_errno = errno;
|
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "stat() of %s failed: %s\n",
|
1999-04-14 00:17:47 +04:00
|
|
|
file_path, strerror(saved_errno));
|
|
|
|
if (saved_errno == ENOENT)
|
|
|
|
continue;
|
|
|
|
msg_display_add(MSG_statfail, file_path,
|
|
|
|
strerror(saved_errno));
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (head == NULL) {
|
|
|
|
head = current = malloc(sizeof(struct filelist));
|
|
|
|
if (head == NULL) {
|
|
|
|
fprintf(stderr, "out of memory\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
current->next = malloc(sizeof(struct filelist));
|
2002-06-30 00:04:56 +04:00
|
|
|
if (current->next == NULL) {
|
1999-04-14 00:17:47 +04:00
|
|
|
fprintf(stderr, "out of memory\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
current->next = NULL;
|
|
|
|
snprintf(current->name, MAXPATHLEN, "%s", file_path);
|
|
|
|
current->type = st.st_mode & S_IFMT;
|
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "Adding file %s, type %d to list of "
|
1999-04-14 00:17:47 +04:00
|
|
|
"obsolete file\n", current->name, current->type);
|
|
|
|
}
|
2000-12-31 16:08:05 +03:00
|
|
|
fclose(list_file);
|
1999-04-14 00:17:47 +04:00
|
|
|
if (head == NULL)
|
1999-04-14 16:47:27 +04:00
|
|
|
return 1;
|
1999-04-14 00:17:47 +04:00
|
|
|
#if 0
|
|
|
|
/* XXX doesn't work, too many files printed ! */
|
|
|
|
msg_display(MSG_deleting_files);
|
|
|
|
for (current = head; current != NULL; current = current->next) {
|
1999-07-05 02:33:54 +04:00
|
|
|
if (current->type != S_IFDIR) {
|
|
|
|
/* XXX msg_printf_add going/gone away */
|
1999-04-14 00:17:47 +04:00
|
|
|
msg_printf_add("%s ", current->name);
|
1999-07-05 02:33:54 +04:00
|
|
|
}
|
1999-04-14 00:17:47 +04:00
|
|
|
}
|
|
|
|
msg_display_add(MSG_deleting_dirs);
|
|
|
|
for (current = head; current != NULL; current = current->next) {
|
1999-07-05 02:33:54 +04:00
|
|
|
if (current->type == S_IFDIR) {
|
|
|
|
/* XXX msg_printf_add going/gone away */
|
1999-04-14 00:17:47 +04:00
|
|
|
msg_printf_add("%s ", current->name);
|
1999-07-05 02:33:54 +04:00
|
|
|
}
|
1999-04-14 00:17:47 +04:00
|
|
|
}
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
#endif
|
|
|
|
/* first remove files */
|
|
|
|
for (current = head; current != NULL; current = current->next) {
|
|
|
|
if (current->type == S_IFDIR)
|
|
|
|
continue;
|
|
|
|
if (scripting)
|
|
|
|
(void)fprintf(script, "rm %s\n", current->name);
|
|
|
|
if (unlink(current->name) != 0) {
|
|
|
|
saved_errno = errno;
|
2000-06-18 17:40:41 +04:00
|
|
|
if (saved_errno == ENOENT)
|
|
|
|
continue; /* don't worry about
|
|
|
|
non-existing files */
|
1999-04-14 00:17:47 +04:00
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "rm %s failed: %s\n",
|
1999-04-14 00:17:47 +04:00
|
|
|
current->name, strerror(saved_errno));
|
|
|
|
msg_display_add(MSG_unlink_fail, current->name,
|
|
|
|
strerror(saved_errno));
|
|
|
|
retval = 0;
|
|
|
|
needok = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/* now dirs */
|
|
|
|
for (current = head; current != NULL; current = current->next) {
|
|
|
|
if (current->type != S_IFDIR)
|
|
|
|
continue;
|
|
|
|
if (rmdir(current->name) == 0) {
|
|
|
|
if (scripting)
|
|
|
|
(void)fprintf(script, "rmdir %s\n",
|
|
|
|
current->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
saved_errno = errno;
|
|
|
|
if (saved_errno == ENOTEMPTY) {
|
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "dir %s not empty, "
|
1999-04-14 00:17:47 +04:00
|
|
|
"trying to rename to %s.old\n",
|
|
|
|
current->name, current->name);
|
|
|
|
snprintf(file_path, MAXPATHLEN,
|
|
|
|
"%s.old", current->name);
|
|
|
|
if (scripting)
|
|
|
|
(void)fprintf(script, "mv %s %s\n",
|
|
|
|
current->name, file_path);
|
|
|
|
needok = 1;
|
|
|
|
if (rename(current->name, file_path) != 0) {
|
|
|
|
saved_errno = errno;
|
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "mv %s %s failed: %s\n",
|
1999-04-14 00:17:47 +04:00
|
|
|
current->name, file_path,
|
|
|
|
strerror(saved_errno));
|
|
|
|
msg_display_add(MSG_rename_fail, current->name,
|
|
|
|
file_path, strerror(errno));
|
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
msg_display_add(MSG_renamed_dir, current->name,
|
|
|
|
file_path);
|
|
|
|
} else { /* rmdir error */
|
2000-10-11 15:10:46 +04:00
|
|
|
/*
|
|
|
|
* Don't worry about non-existing directories.
|
|
|
|
*/
|
|
|
|
if (saved_errno == ENOENT)
|
|
|
|
continue;
|
1999-04-14 00:17:47 +04:00
|
|
|
if (logging)
|
2002-12-05 04:17:15 +03:00
|
|
|
fprintf(logfp, "rm %s failed: %s\n",
|
1999-04-14 00:17:47 +04:00
|
|
|
current->name, strerror(saved_errno));
|
|
|
|
msg_display_add(MSG_unlink_fail, current->name,
|
|
|
|
strerror(saved_errno));
|
|
|
|
retval = 0;
|
|
|
|
needok = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (needok)
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
1997-11-02 12:41:57 +03:00
|
|
|
/*
|
1998-06-20 17:05:48 +04:00
|
|
|
* Get and unpack the distribution.
|
|
|
|
* 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
|
1998-06-20 17:05:48 +04:00
|
|
|
get_and_unpack_sets(success_msg, failure_msg)
|
1999-07-05 01:32:48 +04:00
|
|
|
msg success_msg;
|
|
|
|
msg failure_msg;
|
1997-11-02 12:41:57 +03:00
|
|
|
{
|
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. */
|
1999-01-21 11:02:17 +03:00
|
|
|
(void) mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH);
|
|
|
|
if (scripting)
|
|
|
|
(void)fprintf(script, "mkdir /mnt2\nchmod 755 /mnt2\n");
|
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
|
|
|
wclear(stdscr);
|
|
|
|
wrefresh(stdscr);
|
1998-06-20 17:05:48 +04:00
|
|
|
process_menu(MENU_distset);
|
1998-02-09 09:55:27 +03:00
|
|
|
|
1999-04-14 00:17:47 +04:00
|
|
|
/* ask user whether to do normal or verbose extraction */
|
|
|
|
ask_verbose_dist();
|
|
|
|
|
1997-11-02 12:41:57 +03:00
|
|
|
/* Get the distribution files */
|
1999-06-22 22:47:07 +04:00
|
|
|
do {
|
|
|
|
got_dist = 0;
|
|
|
|
process_menu(MENU_distmedium);
|
|
|
|
} while (got_dist == -1);
|
1998-02-09 09:55:27 +03:00
|
|
|
|
1997-11-02 12:41:57 +03:00
|
|
|
if (nodist)
|
1999-06-22 10:57:00 +04:00
|
|
|
return 1;
|
1997-11-02 12:41:57 +03:00
|
|
|
|
|
|
|
if (got_dist) {
|
1997-12-05 17:00:59 +03:00
|
|
|
|
|
|
|
/* Extract the distribution, abort on errors. */
|
1999-06-22 10:57:00 +04:00
|
|
|
if (extract_dist())
|
|
|
|
return 1;
|
1997-11-02 12:41:57 +03:00
|
|
|
|
|
|
|
/* Configure the system */
|
1998-06-20 17:05:48 +04:00
|
|
|
run_makedev();
|
1997-11-02 12:41:57 +03:00
|
|
|
|
|
|
|
/* Other configuration. */
|
|
|
|
mnt_net_config();
|
|
|
|
|
1997-11-11 03:43:31 +03:00
|
|
|
/* Clean up dist dir (use absolute path name) */
|
1997-11-02 12:41:57 +03:00
|
|
|
if (clean_dist_dir)
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/bin/rm -rf %s", ext_dir);
|
1997-11-02 12:41:57 +03:00
|
|
|
|
|
|
|
/* Mounted dist dir? */
|
|
|
|
if (mnt2_mounted)
|
2000-10-12 03:47:55 +04:00
|
|
|
run_prog(0, NULL, "/sbin/umount /mnt2");
|
1997-11-05 10:28:20 +03:00
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
/* Install/Upgrade complete ... reboot or exit to script */
|
|
|
|
msg_display(success_msg);
|
|
|
|
process_menu(MENU_ok);
|
1999-06-22 10:57:00 +04:00
|
|
|
return 0;
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
msg_display(failure_msg);
|
|
|
|
process_menu(MENU_ok);
|
1999-06-22 10:57:00 +04:00
|
|
|
return 1;
|
1997-11-02 12:41:57 +03:00
|
|
|
}
|
1997-11-05 10:28:20 +03:00
|
|
|
|
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
|
2000-09-26 17:26:02 +04:00
|
|
|
check_for(mode, pathname)
|
|
|
|
unsigned int mode;
|
1998-06-20 17:05:48 +04:00
|
|
|
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
|
|
|
|
sanity_check()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
process_menu(MENU_ok);
|
|
|
|
return 1;
|
|
|
|
}
|
1999-01-21 11:02:17 +03:00
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
#ifdef notdef
|
1999-01-21 11:02:17 +03:00
|
|
|
/* set reverse to 1 to default to no */
|
|
|
|
int askyesno(int reverse)
|
|
|
|
{
|
|
|
|
WINDOW *yesnowin;
|
|
|
|
int c, found;
|
|
|
|
|
1999-04-18 08:09:27 +04:00
|
|
|
yesnowin = subwin(stdscr, 5, 20, getmaxy(stdscr)/2 - 2, getmaxx(stdscr)/2 - 10);
|
1999-06-20 08:17:57 +04:00
|
|
|
if (yesnowin == NULL) {
|
|
|
|
fprintf(stderr, "sysinst: failed to allocate yes/no box\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
1999-01-21 11:02:17 +03:00
|
|
|
box(yesnowin, '*', '*');
|
|
|
|
wmove(yesnowin, 2,2);
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
waddstr(yesnowin, "Yes or No: [N]");
|
|
|
|
else
|
|
|
|
waddstr(yesnowin, "Yes or No: [Y]");
|
|
|
|
|
|
|
|
wrefresh(yesnowin);
|
2003-01-10 23:00:27 +03:00
|
|
|
while ((c = getchar()) != 0) {
|
1999-01-21 11:02:17 +03:00
|
|
|
if (c == 'y' || c == 'Y') {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
} else if (c == 'n' || c == 'N' ) {
|
|
|
|
found = 0;
|
|
|
|
break;
|
|
|
|
} else if (c == '\n' || c == '\r') {
|
|
|
|
if (reverse)
|
|
|
|
found = 0;
|
|
|
|
else
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wclear(yesnowin);
|
|
|
|
wrefresh(yesnowin);
|
|
|
|
delwin(yesnowin);
|
|
|
|
refresh();
|
|
|
|
return(found);
|
|
|
|
}
|
2003-01-10 23:00:27 +03:00
|
|
|
#endif
|
2000-08-15 05:08:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some globals to pass things back from callbacks
|
|
|
|
*/
|
|
|
|
static char zoneinfo_dir[STRSIZE];
|
|
|
|
static char *tz_selected; /* timezonename (relative to share/zoneinfo */
|
|
|
|
static char *tz_default; /* UTC, or whatever /etc/localtime points to */
|
|
|
|
static char tz_env[STRSIZE];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback from timezone menu
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
set_timezone_select(menudesc *m)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
if (m)
|
|
|
|
tz_selected = m->opts[m->cursel].opt_name;
|
|
|
|
snprintf(tz_env, sizeof(tz_env), "%s/%s",
|
|
|
|
zoneinfo_dir, tz_selected);
|
|
|
|
setenv("TZ", tz_env, 1);
|
|
|
|
t = time(NULL);
|
|
|
|
msg_display(MSG_choose_timezone,
|
|
|
|
tz_default, tz_selected, ctime(&t), localtime(&t)->tm_zone);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
set_timezone_select(NULL);
|
2002-10-05 06:41:54 +04:00
|
|
|
alarm(60);
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Choose from the files in usr/share/zoneinfo and set etc/localtime
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
set_timezone()
|
|
|
|
{
|
|
|
|
char localtime_link[STRSIZE];
|
|
|
|
char localtime_target[STRSIZE];
|
|
|
|
int rc;
|
|
|
|
time_t t;
|
|
|
|
FTS *tree;
|
|
|
|
FTSENT *entry;
|
|
|
|
char *argv[2];
|
|
|
|
int skip;
|
|
|
|
struct stat sb;
|
|
|
|
int nfiles, n;
|
|
|
|
int menu_no;
|
|
|
|
menu_ent *tz_menu;
|
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
signal(SIGALRM, timezone_sig);
|
2000-08-15 05:08:00 +04:00
|
|
|
alarm(1);
|
|
|
|
|
|
|
|
strncpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo"), STRSIZE);
|
|
|
|
strncpy(localtime_link, target_expand("/etc/localtime"), STRSIZE);
|
|
|
|
|
|
|
|
/* Add sanity check that /mnt/usr/share/zoneinfo contains
|
|
|
|
* something useful */
|
|
|
|
|
|
|
|
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';
|
|
|
|
tz_default = strchr(strstr(localtime_target, "zoneinfo"), '/')+1;
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
tz_selected=tz_default;
|
|
|
|
snprintf(tz_env, sizeof(tz_env), "%s/%s",
|
|
|
|
zoneinfo_dir, tz_selected);
|
|
|
|
setenv("TZ", tz_env, 1);
|
|
|
|
t = time(NULL);
|
|
|
|
msg_display(MSG_choose_timezone,
|
|
|
|
tz_default, tz_selected, ctime(&t), localtime(&t)->tm_zone);
|
|
|
|
|
|
|
|
skip = strlen(zoneinfo_dir);
|
|
|
|
argv[0] = zoneinfo_dir;
|
|
|
|
argv[1] = NULL;
|
|
|
|
if (!(tree = fts_open(argv, FTS_LOGICAL, NULL))) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
for (nfiles = 0; (entry = fts_read(tree)) != NULL;) {
|
|
|
|
stat(entry->fts_accpath, &sb);
|
|
|
|
if (S_ISREG(sb.st_mode))
|
|
|
|
nfiles++;
|
|
|
|
}
|
|
|
|
if (errno) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
(void)fts_close(tree);
|
|
|
|
|
|
|
|
tz_menu = malloc(nfiles * sizeof(struct menu_ent));
|
|
|
|
if (tz_menu == NULL) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(tree = fts_open(argv, FTS_LOGICAL, NULL))) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +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
|
|
|
n = 0;
|
2003-01-10 23:00:27 +03:00
|
|
|
for (; (entry = fts_read(tree)) != NULL; ) {
|
2000-08-15 05:08:00 +04:00
|
|
|
stat(entry->fts_accpath, &sb);
|
|
|
|
if (S_ISREG(sb.st_mode)) {
|
|
|
|
tz_menu[n].opt_name = strdup(entry->fts_accpath+skip+1);
|
2003-01-10 23:00:27 +03:00
|
|
|
if (tz_menu[n].opt_name == NULL)
|
|
|
|
tz_menu[n].opt_name = "*";
|
2000-08-15 05:08:00 +04:00
|
|
|
tz_menu[n].opt_menu = OPT_NOMENU;
|
|
|
|
tz_menu[n].opt_flags = 0;
|
|
|
|
tz_menu[n].opt_action = set_timezone_select;
|
|
|
|
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errno) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
(void)fts_close(tree);
|
|
|
|
|
|
|
|
menu_no = new_menu(NULL, tz_menu, nfiles, 23, 9,
|
|
|
|
12, 32, MC_SCROLL|MC_NOSHORTCUT, NULL, NULL,
|
|
|
|
"\nPlease consult the install documents.");
|
|
|
|
if (menu_no < 0) {
|
2000-08-31 05:10:43 +04:00
|
|
|
return 1; /* error - skip timezone setting */
|
2000-08-15 05:08:00 +04:00
|
|
|
}
|
|
|
|
process_menu(menu_no);
|
|
|
|
|
|
|
|
free_menu(menu_no);
|
|
|
|
for(n=0; n < nfiles; n++)
|
|
|
|
free(tz_menu[n].opt_name);
|
|
|
|
free(tz_menu);
|
|
|
|
|
|
|
|
signal(SIGALRM, SIG_IGN);
|
|
|
|
|
|
|
|
snprintf(localtime_target, sizeof(localtime_target),
|
|
|
|
"/usr/share/zoneinfo/%s", tz_selected);
|
|
|
|
unlink(localtime_link);
|
|
|
|
symlink(localtime_target, localtime_link);
|
|
|
|
|
|
|
|
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);
|
|
|
|
process_menu(MENU_crypttype);
|
|
|
|
fn = strdup(target_expand("/etc/passwd.conf"));
|
|
|
|
|
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;
|
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
|
|
|
|
set_root_password()
|
|
|
|
{
|
|
|
|
msg_display(MSG_rootpw);
|
|
|
|
process_menu(MENU_yesno);
|
|
|
|
if (yesno)
|
|
|
|
run_prog(RUN_DISPLAY|RUN_CHROOT, NULL, "passwd -l root");
|
|
|
|
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
|
|
|
|
set_root_shell()
|
|
|
|
{
|
|
|
|
msg_display(MSG_rootsh);
|
|
|
|
process_menu(MENU_rootsh);
|
|
|
|
run_prog(RUN_DISPLAY|RUN_CHROOT, NULL, "chpass -s %s root", shellpath);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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-01-10 23:00:27 +03:00
|
|
|
#ifdef notdef
|
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
|
|
|
/*
|
|
|
|
* check that there is at least a / somewhere.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
check_partitions()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < getmaxpartitions(); i++)
|
|
|
|
if (PI_ISBSDFS(&bsdlabel[i]) &&
|
|
|
|
fsmount[i][0] == '/' && fsmount[i][1] == '\0')
|
|
|
|
return 1;
|
|
|
|
msg_display(MSG_no_root_fs);
|
|
|
|
getchar();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_sizemultname_cyl()
|
|
|
|
{
|
|
|
|
|
|
|
|
sizemult = dlcylsize;
|
|
|
|
multname = msg_string(MSG_cylname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_sizemultname_meg()
|
|
|
|
{
|
|
|
|
|
|
|
|
sizemult = MEG / sectorsize;
|
|
|
|
multname = msg_string(MSG_megname);
|
|
|
|
}
|
2003-01-10 23:00:27 +03:00
|
|
|
#endif
|
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
|
|
|
|
check_lfs_progs()
|
|
|
|
{
|
|
|
|
|
|
|
|
return (access("/sbin/dump_lfs", X_OK) == 0 &&
|
|
|
|
access("/sbin/fsck_lfs", X_OK) == 0 &&
|
|
|
|
access("/sbin/mount_lfs", X_OK) == 0 &&
|
|
|
|
access("/sbin/newfs_lfs", X_OK) == 0);
|
|
|
|
}
|