1995-10-19 16:15:43 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-10-19 16:15:43 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
|
|
|
* point in the file.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
1997-09-08 11:09:11 +00:00
|
|
|
static int installUpgradeNonInteractive(dialogMenuItem *self);
|
|
|
|
|
1995-10-19 16:15:43 +00:00
|
|
|
typedef struct _hitList {
|
|
|
|
enum { JUST_COPY, CALL_HANDLER } action ;
|
|
|
|
char *name;
|
|
|
|
Boolean optional;
|
|
|
|
void (*handler)(struct _hitList *self);
|
|
|
|
} HitList;
|
|
|
|
|
|
|
|
/* These are the only meaningful files I know about */
|
|
|
|
static HitList etc_files [] = {
|
|
|
|
{ JUST_COPY, "Xaccel.ini", TRUE, NULL },
|
2002-06-10 04:47:26 +00:00
|
|
|
{ JUST_COPY, "X11", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "adduser.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "aliases", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "aliases.db", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "amd.map", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "auth.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "crontab", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "csh.cshrc", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "csh.login", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "csh.logout", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "cvsupfile", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "devfs.conf", TRUE, NULL },
|
2001-08-31 20:10:01 +00:00
|
|
|
{ JUST_COPY, "dhclient.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "disktab", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "dumpdates", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "exports", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "fbtab", TRUE, NULL },
|
1997-01-15 13:39:50 +00:00
|
|
|
{ JUST_COPY, "fstab", FALSE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "ftpusers", TRUE, NULL },
|
1997-04-02 12:07:39 +00:00
|
|
|
{ JUST_COPY, "gettytab", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "gnats", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "group", FALSE, NULL },
|
|
|
|
{ JUST_COPY, "hosts", TRUE, NULL },
|
2001-08-31 20:10:01 +00:00
|
|
|
{ JUST_COPY, "hosts.allow", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "hosts.equiv", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "hosts.lpd", TRUE, NULL },
|
1997-01-15 13:39:50 +00:00
|
|
|
{ JUST_COPY, "inetd.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "localtime", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "login.access", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "login.conf", TRUE, NULL },
|
2001-02-21 07:47:31 +00:00
|
|
|
{ JUST_COPY, "mail", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "mail.rc", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "mac.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "make.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "manpath.config", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "master.passwd", FALSE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "mergemaster.rc", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "motd", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "namedb", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "networks", TRUE, NULL },
|
1998-05-24 02:49:54 +00:00
|
|
|
{ JUST_COPY, "newsyslog.conf", TRUE, NULL },
|
2001-12-27 01:57:18 +00:00
|
|
|
{ JUST_COPY, "nsmb.conf", TRUE, NULL },
|
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be
looked up using flat files, NIS, or Hesiod.
= Hesiod has been added to libc (see hesiod(3)).
= A library routine for parsing nsswitch.conf and invoking callback
functions as specified has been added to libc (see nsdispatch(3)).
= The following C library functions have been modified to use nsdispatch:
. getgrent, getgrnam, getgrgid
. getpwent, getpwnam, getpwuid
. getusershell
. getaddrinfo
. gethostbyname, gethostbyname2, gethostbyaddr
. getnetbyname, getnetbyaddr
. getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr
= host.conf has been removed from src/etc. rc.network has been modified
to warn that host.conf is no longer used at boot time. In addition, if
there is a host.conf but no nsswitch.conf, the latter is created at boot
time from the former.
Obtained from: NetBSD
2000-09-06 18:16:48 +00:00
|
|
|
{ JUST_COPY, "nsswitch.conf", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "ntp.conf", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "pam.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "passwd", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "periodic", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "pf.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "portsnap.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "ppp", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "printcap", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "profile", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "protocols", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "pwd.db", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "rc.local", TRUE, NULL },
|
1999-03-19 08:22:31 +00:00
|
|
|
{ JUST_COPY, "rc.firewall", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "rc.conf.local", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "remote", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "resolv.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "rmt", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "sendmail.cf", TRUE, NULL },
|
1999-02-13 05:18:06 +00:00
|
|
|
{ JUST_COPY, "sendmail.cw", TRUE, NULL },
|
1997-01-15 13:39:50 +00:00
|
|
|
{ JUST_COPY, "services", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "shells", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "skeykeys", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "snmpd.config", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "spwd.db", TRUE, NULL },
|
2006-05-31 19:16:34 +00:00
|
|
|
{ JUST_COPY, "src.conf", TRUE, NULL },
|
2001-03-24 05:40:43 +00:00
|
|
|
{ JUST_COPY, "ssh", TRUE, NULL },
|
2005-12-01 21:39:43 +00:00
|
|
|
{ JUST_COPY, "sysctl.conf", TRUE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
{ JUST_COPY, "syslog.conf", TRUE, NULL },
|
|
|
|
{ JUST_COPY, "ttys", TRUE, NULL },
|
2006-02-28 21:49:33 +00:00
|
|
|
{ 0, NULL, FALSE, NULL },
|
1995-10-19 16:15:43 +00:00
|
|
|
};
|
|
|
|
|
2006-02-28 21:49:33 +00:00
|
|
|
static void
|
1995-10-19 16:15:43 +00:00
|
|
|
traverseHitlist(HitList *h)
|
|
|
|
{
|
1997-01-15 15:32:04 +00:00
|
|
|
system("rm -rf /etc/upgrade");
|
|
|
|
Mkdir("/etc/upgrade");
|
1995-10-19 16:15:43 +00:00
|
|
|
while (h->name) {
|
|
|
|
if (!file_readable(h->name)) {
|
1996-04-23 01:29:35 +00:00
|
|
|
if (!h->optional)
|
1995-10-19 16:15:43 +00:00
|
|
|
msgConfirm("Unable to find an old /etc/%s file! That is decidedly non-standard and\n"
|
1997-01-15 11:48:37 +00:00
|
|
|
"your upgraded system may function a little strangely as a result.", h->name);
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (h->action == JUST_COPY) {
|
1997-01-15 13:39:50 +00:00
|
|
|
/* Move the just-loaded copy aside */
|
1997-01-15 15:32:04 +00:00
|
|
|
vsystem("mv /etc/%s /etc/upgrade/%s", h->name, h->name);
|
1995-10-19 16:15:43 +00:00
|
|
|
|
|
|
|
/* Copy the old one into its place */
|
|
|
|
msgNotify("Resurrecting %s..", h->name);
|
|
|
|
/* Do this with tar so that symlinks and such are preserved */
|
1996-04-23 01:29:35 +00:00
|
|
|
if (vsystem("tar cf - %s | tar xpf - -C /etc", h->name))
|
1995-10-19 16:15:43 +00:00
|
|
|
msgConfirm("Unable to resurrect your old /etc/%s! Hmmmm.", h->name);
|
|
|
|
}
|
|
|
|
else /* call handler */
|
|
|
|
h->handler(h);
|
|
|
|
}
|
|
|
|
++h;
|
|
|
|
}
|
|
|
|
}
|
1996-07-05 08:36:02 +00:00
|
|
|
|
1995-10-19 16:15:43 +00:00
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installUpgrade(dialogMenuItem *self)
|
1995-10-19 16:15:43 +00:00
|
|
|
{
|
1997-10-12 16:21:21 +00:00
|
|
|
char saved_etc[FILENAME_MAX];
|
1995-10-19 16:15:43 +00:00
|
|
|
Boolean extractingBin = TRUE;
|
|
|
|
|
1997-09-08 11:09:11 +00:00
|
|
|
if (variable_get(VAR_NONINTERACTIVE))
|
|
|
|
return installUpgradeNonInteractive(self);
|
|
|
|
|
1999-02-05 22:15:52 +00:00
|
|
|
variable_set2(SYSTEM_STATE, "upgrade", 0);
|
2000-02-26 12:43:01 +00:00
|
|
|
dialog_clear();
|
1995-10-24 02:18:23 +00:00
|
|
|
|
2001-09-04 21:06:48 +00:00
|
|
|
if (msgYesNo("Before beginning a binary upgrade, please review the upgrade instructions,\n"
|
|
|
|
"which are located in the \"Install\" document under the main documentation\n"
|
|
|
|
"menu. Given that you have read these instructions and understand the risks\n"
|
|
|
|
"and precautions involved, are you sure that you want to proceed with\n"
|
|
|
|
"this upgrade?") != 0)
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-10-24 02:18:23 +00:00
|
|
|
|
1995-10-19 16:15:43 +00:00
|
|
|
if (!Dists) {
|
1997-10-12 16:21:21 +00:00
|
|
|
msgConfirm("First, you must select some distribution components. The upgrade procedure\n"
|
|
|
|
"will only upgrade the distributions you select in the next set of menus.");
|
1997-01-15 06:30:50 +00:00
|
|
|
if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists)
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
2002-04-23 22:16:41 +00:00
|
|
|
else if (!(Dists & DIST_BASE)) { /* No base selected? Not much of an upgrade.. */
|
|
|
|
if (msgYesNo("You didn't select the base distribution as one of the distributons to load.\n"
|
1996-12-15 18:14:37 +00:00
|
|
|
"This one is pretty vital to a successful upgrade. Are you SURE you don't\n"
|
2002-04-23 22:16:41 +00:00
|
|
|
"want to select the base distribution? Chose No to bring up the Distributions\n"
|
1997-10-12 16:21:21 +00:00
|
|
|
"menu again.") != 0) {
|
1996-07-14 01:54:39 +00:00
|
|
|
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Still?! OK! They must know what they're doing.. */
|
2002-04-23 22:16:41 +00:00
|
|
|
if (!(Dists & DIST_BASE))
|
1995-10-19 16:15:43 +00:00
|
|
|
extractingBin = FALSE;
|
|
|
|
|
1996-07-14 01:54:39 +00:00
|
|
|
if (RunningAsInit) {
|
|
|
|
Device **devs;
|
|
|
|
int i, cnt;
|
|
|
|
char *cp;
|
1995-10-19 16:15:43 +00:00
|
|
|
|
1996-07-14 01:54:39 +00:00
|
|
|
cp = variable_get(VAR_DISK);
|
|
|
|
devs = deviceFind(cp, DEVICE_TYPE_DISK);
|
|
|
|
cnt = deviceCount(devs);
|
|
|
|
if (!cnt) {
|
|
|
|
msgConfirm("No disks found! Please verify that your disk controller is being\n"
|
|
|
|
"properly probed at boot time. See the Hardware Guide on the\n"
|
|
|
|
"Documentation menu for clues on diagnosing this type of problem.");
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE;
|
1996-07-14 01:54:39 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-03-21 02:08:52 +00:00
|
|
|
/* Enable all the drives before we start */
|
1996-07-14 01:54:39 +00:00
|
|
|
for (i = 0; i < cnt; i++)
|
|
|
|
devs[i]->enabled = TRUE;
|
|
|
|
}
|
1995-10-19 16:15:43 +00:00
|
|
|
|
1996-07-14 01:54:39 +00:00
|
|
|
msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n"
|
1997-01-15 13:39:50 +00:00
|
|
|
"you will be expected to Mount any partitions you're interested in\n"
|
1996-07-14 01:54:39 +00:00
|
|
|
"upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n"
|
|
|
|
"unless you're absolutely sure you know what you're doing! In this\n"
|
|
|
|
"instance, you'll be using the label editor as little more than a fancy\n"
|
1997-01-15 13:39:50 +00:00
|
|
|
"screen-oriented partition mounting tool.\n\n"
|
1996-07-14 01:54:39 +00:00
|
|
|
"Once you're done in the label editor, press Q to return here for the next\n"
|
|
|
|
"step.");
|
|
|
|
|
|
|
|
if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) {
|
1996-12-15 18:14:37 +00:00
|
|
|
msgConfirm("The disk label editor returned an error status. Upgrade operation\n"
|
1996-07-14 01:54:39 +00:00
|
|
|
"aborted.");
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE;
|
1996-07-14 01:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't write out MBR info */
|
1999-02-05 22:15:52 +00:00
|
|
|
variable_set2(DISK_PARTITIONED, "written", 0);
|
1996-07-14 01:54:39 +00:00
|
|
|
if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
|
|
|
|
msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
|
|
|
|
"aborted.");
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE;
|
1996-07-14 01:54:39 +00:00
|
|
|
}
|
1995-10-19 16:15:43 +00:00
|
|
|
|
1997-01-29 01:23:05 +00:00
|
|
|
msgNotify("Updating /stand on root filesystem");
|
|
|
|
(void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
|
|
|
|
|
1997-01-15 07:28:25 +00:00
|
|
|
if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) {
|
|
|
|
msgConfirm("Unable to chroot to /mnt - something is wrong with the\n"
|
|
|
|
"root partition or the way it's mounted if this doesn't work.");
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE;
|
1997-01-15 07:28:25 +00:00
|
|
|
}
|
|
|
|
chdir("/");
|
1998-03-23 08:36:27 +00:00
|
|
|
installEnvironment();
|
1997-01-15 07:28:25 +00:00
|
|
|
systemCreateHoloshell();
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
1995-11-06 08:28:12 +00:00
|
|
|
|
1997-10-12 16:21:21 +00:00
|
|
|
saved_etc[0] = '\0';
|
1999-04-07 03:06:44 +00:00
|
|
|
|
|
|
|
/* Don't allow sources to be upgraded unless if we have src already */
|
|
|
|
if (directory_exists("/usr/src/") && (Dists & DIST_SRC)) {
|
|
|
|
Dists &= ~DIST_SRC;
|
2000-11-14 21:21:53 +00:00
|
|
|
SrcDists = 0;
|
1999-04-07 03:06:44 +00:00
|
|
|
msgConfirm("Warning: /usr/src exists and sources were selected as upgrade\n"
|
|
|
|
"targets. Unfortunately, this is not the way to upgrade your\n"
|
|
|
|
"sources - please use CTM or CVSup or some other method which\n"
|
|
|
|
"handles ``deletion events'', unlike this particular feature.\n\n"
|
|
|
|
"Your existing /usr/src will not be affected by this upgrade.\n");
|
|
|
|
}
|
|
|
|
|
1995-10-19 16:15:43 +00:00
|
|
|
if (extractingBin) {
|
1997-10-12 16:21:21 +00:00
|
|
|
while (!*saved_etc) {
|
2002-04-01 21:35:24 +00:00
|
|
|
char *cp = msgGetInput("/var/tmp/etc", "Under which directory do you wish to save your current /etc?");
|
1997-10-12 16:21:21 +00:00
|
|
|
|
|
|
|
if (!cp || !*cp || Mkdir(cp)) {
|
1995-10-19 16:15:43 +00:00
|
|
|
if (msgYesNo("Directory was not specified, was invalid or user selected Cancel.\n\n"
|
|
|
|
"Doing an upgrade without first backing up your /etc directory is a very\n"
|
1996-10-09 09:53:41 +00:00
|
|
|
"bad idea! Do you want to go back and specify the save directory again?") != 0)
|
1995-10-19 16:15:43 +00:00
|
|
|
break;
|
|
|
|
}
|
1997-10-12 16:21:21 +00:00
|
|
|
else {
|
|
|
|
SAFE_STRCPY(saved_etc, cp);
|
|
|
|
}
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
|
|
|
|
1997-10-12 16:21:21 +00:00
|
|
|
if (saved_etc[0]) {
|
1995-10-19 16:15:43 +00:00
|
|
|
msgNotify("Preserving /etc directory..");
|
1997-10-01 01:30:35 +00:00
|
|
|
if (vsystem("tar -cBpf - -C /etc . | tar --unlink -xBpf - -C %s", saved_etc))
|
1996-07-05 08:36:02 +00:00
|
|
|
if (msgYesNo("Unable to backup your /etc into %s.\n"
|
1996-12-08 12:27:58 +00:00
|
|
|
"Do you want to continue anyway?", saved_etc) != 0)
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1999-05-11 08:00:06 +00:00
|
|
|
msgNotify("Preserving /root directory..");
|
|
|
|
vsystem("tar -cBpf - -C / root | tar --unlink -xBpf - -C %s", saved_etc);
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
1997-10-29 07:47:06 +00:00
|
|
|
|
|
|
|
msgNotify("chflags'ing old binaries - please wait.");
|
2006-11-11 10:38:10 +00:00
|
|
|
(void)vsystem("chflags -R noschg /bin /sbin /lib /libexec /usr/bin /usr/sbin /usr/lib /usr/libexec /var/empty /boot/kernel*");
|
1997-10-29 07:47:06 +00:00
|
|
|
|
2006-05-31 19:15:20 +00:00
|
|
|
if (directory_exists("/boot/kernel")) {
|
|
|
|
msgNotify("Moving old kernel to /boot/kernel.prev");
|
|
|
|
if (system("mv /boot/kernel /boot/kernel.prev")) {
|
1995-10-19 16:15:43 +00:00
|
|
|
if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n"
|
1995-10-24 02:18:23 +00:00
|
|
|
"treat this as a big problem and abort the upgrade? Due to the\n"
|
|
|
|
"way that this upgrade process works, you will have to reboot\n"
|
1996-05-16 11:47:46 +00:00
|
|
|
"and start over from the beginning. Select Yes to reboot now"))
|
|
|
|
systemShutdown(1);
|
1995-10-22 17:39:29 +00:00
|
|
|
}
|
1998-03-21 02:08:52 +00:00
|
|
|
else
|
2006-05-31 19:15:20 +00:00
|
|
|
msgConfirm("NOTICE: Your old kernel is in /boot/kernel.prev should this\n"
|
|
|
|
"upgrade fail for any reason and you need to boot your old\n"
|
|
|
|
"kernel.");
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
|
|
|
}
|
1995-10-24 02:18:23 +00:00
|
|
|
|
1997-10-01 01:30:35 +00:00
|
|
|
media:
|
1997-10-12 16:21:21 +00:00
|
|
|
/* We do this very late, but we unfortunately need to back up /etc first */
|
1997-10-01 01:30:35 +00:00
|
|
|
if (!mediaVerify())
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-10-01 01:30:35 +00:00
|
|
|
|
2001-07-02 00:18:04 +00:00
|
|
|
if (!DEVICE_INIT(mediaDevice)) {
|
1997-10-01 01:30:35 +00:00
|
|
|
if (!msgYesNo("Couldn't initialize the media. Would you like\n"
|
|
|
|
"to adjust your media selection and try again?")) {
|
|
|
|
mediaDevice = NULL;
|
|
|
|
goto media;
|
|
|
|
}
|
|
|
|
else
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_FAILURE | DITEM_REDRAW | DITEM_RESTORE;
|
1997-10-01 01:30:35 +00:00
|
|
|
}
|
|
|
|
|
1995-10-19 16:15:43 +00:00
|
|
|
msgNotify("Beginning extraction of distributions..");
|
1996-04-28 03:27:26 +00:00
|
|
|
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
|
2002-04-23 22:16:41 +00:00
|
|
|
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
|
1997-01-15 06:30:50 +00:00
|
|
|
"should be considered a failure and started from the beginning, sorry!\n"
|
|
|
|
"The system will reboot now.");
|
|
|
|
dialog_clear();
|
|
|
|
systemShutdown(1);
|
|
|
|
}
|
1997-01-15 13:39:50 +00:00
|
|
|
else if (Dists) {
|
2002-04-23 22:16:41 +00:00
|
|
|
if (!extractingBin || !(Dists & DIST_BASE)) {
|
1997-01-15 13:39:50 +00:00
|
|
|
msgNotify("The extraction process seems to have had some problems, but we got most\n"
|
1997-01-15 06:30:50 +00:00
|
|
|
"of the essentials. We'll treat this as a warning since it may have been\n"
|
|
|
|
"only non-essential distributions which failed to load.");
|
|
|
|
}
|
|
|
|
else {
|
2002-04-23 22:16:41 +00:00
|
|
|
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
|
1995-10-24 02:18:23 +00:00
|
|
|
"should be considered a failure and started from the beginning, sorry!\n"
|
|
|
|
"The system will reboot now.");
|
1996-04-23 01:29:35 +00:00
|
|
|
dialog_clear();
|
1996-05-16 11:47:46 +00:00
|
|
|
systemShutdown(1);
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-15 02:22:47 +00:00
|
|
|
if (extractingBin)
|
|
|
|
vsystem("disklabel -B `awk '$2~/\\/$/ {print substr($1, 6, 3)}' /etc/fstab`");
|
1997-01-15 15:32:04 +00:00
|
|
|
msgNotify("First stage of upgrade completed successfully!\n\n"
|
1995-11-03 12:02:45 +00:00
|
|
|
"Next comes stage 2, where we attempt to resurrect your /etc\n"
|
|
|
|
"directory!");
|
|
|
|
|
1996-07-05 08:36:02 +00:00
|
|
|
if (saved_etc && chdir(saved_etc)) {
|
1995-10-19 16:15:43 +00:00
|
|
|
msgConfirm("Unable to go to your saved /etc directory in %s?! Argh!\n"
|
|
|
|
"Something went seriously wrong! It's quite possible that\n"
|
|
|
|
"your former /etc is toast. I hope you didn't have any\n"
|
1997-01-15 11:48:37 +00:00
|
|
|
"important customizations you wanted to keep in there.. :(", saved_etc);
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
1995-10-24 02:18:23 +00:00
|
|
|
else {
|
|
|
|
/* Now try to resurrect the /etc files */
|
|
|
|
traverseHitlist(etc_files);
|
1999-05-11 08:00:06 +00:00
|
|
|
/* Resurrect the root dotfiles */
|
|
|
|
vsystem("tar -cBpf - root | tar -xBpf - -C / && rm -rf root");
|
1995-10-24 02:18:23 +00:00
|
|
|
}
|
1995-10-19 16:15:43 +00:00
|
|
|
|
1998-03-24 09:51:58 +00:00
|
|
|
msgConfirm("Upgrade completed! All of your old /etc files have been restored.\n"
|
|
|
|
"For your reference, the new /etc files are in /etc/upgrade/ in case\n"
|
|
|
|
"you wish to upgrade these files by hand (though that should not be\n"
|
|
|
|
"strictly necessary). If your root partition is specified in /etc/fstab\n"
|
|
|
|
"using the old \"compatibility\" slice, you may also wish to update it to\n"
|
|
|
|
"use a fully qualified slice name in order to avoid warnings on startup.\n\n"
|
|
|
|
"When you're ready to reboot into the new system, simply exit the installation.");
|
2000-02-26 12:43:01 +00:00
|
|
|
return DITEM_SUCCESS | DITEM_REDRAW | DITEM_RESTORE;
|
1995-10-19 16:15:43 +00:00
|
|
|
}
|
1997-09-08 11:09:11 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
installUpgradeNonInteractive(dialogMenuItem *self)
|
|
|
|
{
|
|
|
|
char *saved_etc;
|
|
|
|
Boolean extractingBin = TRUE;
|
|
|
|
|
1999-02-05 22:15:52 +00:00
|
|
|
variable_set2(SYSTEM_STATE, "upgrade", 0);
|
1997-09-08 11:09:11 +00:00
|
|
|
|
|
|
|
/* Make sure at least BIN is selected */
|
2002-04-23 22:16:41 +00:00
|
|
|
Dists |= DIST_BASE;
|
1997-09-08 11:09:11 +00:00
|
|
|
|
|
|
|
if (RunningAsInit) {
|
|
|
|
Device **devs;
|
|
|
|
int i, cnt;
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
cp = variable_get(VAR_DISK);
|
|
|
|
devs = deviceFind(cp, DEVICE_TYPE_DISK);
|
|
|
|
cnt = deviceCount(devs);
|
|
|
|
if (!cnt) {
|
|
|
|
msgConfirm("No disks found! Please verify that your disk controller is being\n"
|
|
|
|
"properly probed at boot time. See the Hardware Guide on the\n"
|
|
|
|
"Documentation menu for clues on diagnosing this type of problem.");
|
|
|
|
return DITEM_FAILURE;
|
|
|
|
}
|
|
|
|
else {
|
2006-11-07 23:54:14 +00:00
|
|
|
/* Enable all the drives before we start */
|
1997-09-08 11:09:11 +00:00
|
|
|
for (i = 0; i < cnt; i++)
|
|
|
|
devs[i]->enabled = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n"
|
|
|
|
"you will be expected to Mount any partitions you're interested in\n"
|
|
|
|
"upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n"
|
|
|
|
"unless you're absolutely sure you know what you're doing! In this\n"
|
|
|
|
"instance, you'll be using the label editor as little more than a fancy\n"
|
|
|
|
"screen-oriented partition mounting tool.\n\n"
|
|
|
|
"Once you're done in the label editor, press Q to return here for the next\n"
|
|
|
|
"step.");
|
|
|
|
|
|
|
|
if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) {
|
|
|
|
msgConfirm("The disk label editor returned an error status. Upgrade operation\n"
|
|
|
|
"aborted.");
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't write out MBR info */
|
1999-02-05 22:15:52 +00:00
|
|
|
variable_set2(DISK_PARTITIONED, "written", 0);
|
1997-09-08 11:09:11 +00:00
|
|
|
if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
|
|
|
|
msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
|
|
|
|
"aborted.");
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (extractingBin) {
|
|
|
|
msgNotify("chflags'ing old binaries - please wait.");
|
|
|
|
(void)vsystem("chflags -R noschg /mnt/");
|
|
|
|
}
|
|
|
|
msgNotify("Updating /stand on root filesystem");
|
|
|
|
(void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
|
|
|
|
|
|
|
|
if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) {
|
|
|
|
msgConfirm("Unable to chroot to /mnt - something is wrong with the\n"
|
|
|
|
"root partition or the way it's mounted if this doesn't work.");
|
|
|
|
variable_unset(DISK_PARTITIONED);
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
chdir("/");
|
|
|
|
systemCreateHoloshell();
|
|
|
|
}
|
|
|
|
|
2001-07-02 00:18:04 +00:00
|
|
|
if (!mediaVerify() || !DEVICE_INIT(mediaDevice)) {
|
1997-09-08 11:09:11 +00:00
|
|
|
msgNotify("Upgrade: Couldn't initialize media.");
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
|
2002-04-01 21:35:24 +00:00
|
|
|
saved_etc = "/var/tmp/etc";
|
1997-09-08 11:09:11 +00:00
|
|
|
Mkdir(saved_etc);
|
|
|
|
msgNotify("Preserving /etc directory..");
|
|
|
|
if (vsystem("tar -cpBf - -C /etc . | tar -xpBf - -C %s", saved_etc)) {
|
|
|
|
msgNotify("Unable to backup your /etc into %s.", saved_etc);
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (file_readable("/kernel")) {
|
|
|
|
msgNotify("Moving old kernel to /kernel.prev");
|
1997-09-09 09:19:30 +00:00
|
|
|
if (!system("chflags noschg /kernel && mv /kernel /kernel.prev")) {
|
|
|
|
/* Give us a working kernel in case we crash and reboot */
|
|
|
|
system("cp /kernel.prev /kernel");
|
|
|
|
}
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
msgNotify("Beginning extraction of distributions..");
|
|
|
|
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
|
2002-04-23 22:16:41 +00:00
|
|
|
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
|
1997-09-08 11:09:11 +00:00
|
|
|
"should be considered a failure and started from the beginning, sorry!\n"
|
|
|
|
"The system will reboot now.");
|
|
|
|
dialog_clear();
|
|
|
|
systemShutdown(1);
|
|
|
|
}
|
|
|
|
else if (Dists) {
|
2002-04-23 22:16:41 +00:00
|
|
|
if (!(Dists & DIST_BASE)) {
|
1997-09-08 11:09:11 +00:00
|
|
|
msgNotify("The extraction process seems to have had some problems, but we got most\n"
|
|
|
|
"of the essentials. We'll treat this as a warning since it may have been\n"
|
|
|
|
"only non-essential distributions which failed to upgrade.");
|
|
|
|
}
|
|
|
|
else {
|
2002-04-23 22:16:41 +00:00
|
|
|
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
|
1997-09-08 11:09:11 +00:00
|
|
|
"should be considered a failure and started from the beginning, sorry!\n"
|
|
|
|
"The system will reboot now.");
|
|
|
|
dialog_clear();
|
|
|
|
systemShutdown(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msgNotify("First stage of upgrade completed successfully.");
|
|
|
|
if (vsystem("tar -cpBf - -C %s . | tar --unlink -xpBf - -C /etc", saved_etc)) {
|
|
|
|
msgNotify("Unable to resurrect your old /etc!");
|
1999-12-14 04:25:29 +00:00
|
|
|
return DITEM_FAILURE;
|
1997-09-08 11:09:11 +00:00
|
|
|
}
|
|
|
|
return DITEM_SUCCESS | DITEM_REDRAW;
|
|
|
|
}
|