Farewall, sysinstall! You served us well for many years, but 10.0 is one

digit beyond your time.

Various sysinstall dependencies (e.g. libftpio, libdisk, libodialog, etc.)
will be cleaned up in coming days. Some will take longer than others due to
a few other consumers (tzsetup and sade).
This commit is contained in:
Nathan Whitehorn 2011-10-03 15:13:09 +00:00
parent 8d79dfca55
commit e59e2d8ec7
112 changed files with 5 additions and 26264 deletions

View File

@ -123,8 +123,6 @@ usr.sbin/zic edwin Heads-up appreciated, since this code is
maintained by a third party source.
lib/libc/stdtime edwin Heads-up appreciated, since parts of this code
is maintained by a third party source.
sysinstall randi Please contact about any major changes so that
they can be co-ordinated.
sbin/routed bms Pre-commit review; notify vendor at rhyolite.com
Following are the entries from the Makefiles, and a few other sources.

View File

@ -1106,7 +1106,6 @@ build-tools:
${_aicasm} \
usr.bin/awk \
lib/libmagic \
usr.sbin/sysinstall \
usr.bin/mkesdb_static \
usr.bin/mkcsmapper_static
${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \

View File

@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
# 20110930: sysinstall removed
OLD_FILES+=usr/sbin/sysinstall usr/share/man/man8/sysinstall.8.gz
# 20110915: rename congestion control manpages
OLD_FILES+=usr/share/man/man4/cc.4.gz
OLD_FILES+=usr/share/man/man9/cc.9.gz

View File

@ -22,6 +22,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
machines to maximize performance. (To disable malloc debugging, run
ln -s aj /etc/malloc.conf.)
20110930:
sysinstall has been removed
20110923:
The stable/9 branch created in subversion. This corresponds to the
RELENG_9 branch in CVS.

View File

@ -1,89 +0,0 @@
# $FreeBSD$
#
# List of (dependent) ports that are minimally required to be
# checked out from CVS in order to get ${DOCPORTS} built and
# installed. It should follow the dependency list in
# ports/textproc/docproj/Makefile as much as feasible.
#
# Note that these names are /not/ CVS module names but path
# names, so the required part of the ports infrastructure will
# be cvs co'ed accordingly.
#
# This list of ports should be checked with the output of :
# make all-depends-list | sed -e 's|^/usr/||' | sed -e 's|$| \\|'
#
# Get __FreeBSD_version
.if !defined(OSVERSION)
OSVERSION!= /sbin/sysctl -n kern.osreldate
.endif
MINIMALDOCPORTS= \
ports/Mk \
ports/Templates \
ports/Tools
MINIMALDOCPORTS+= \
ports/archivers/unzip \
ports/converters/libiconv \
ports/devel/autoconf267 \
ports/devel/autoconf-wrapper \
ports/devel/gettext \
ports/devel/gmake \
ports/devel/libtool22 \
ports/devel/m4 \
ports/devel/pkg-config \
ports/graphics/gd \
ports/graphics/jbigkit \
ports/graphics/jpeg \
ports/graphics/netpbm \
ports/graphics/png \
ports/graphics/scr2png \
ports/graphics/tiff \
ports/misc/help2man \
ports/print/freetype2 \
ports/print/ghostscript8 \
ports/print/ghostscript8-nox11 \
ports/print/gsfonts \
ports/textproc/docbook-410 \
ports/textproc/docbook-xml \
ports/textproc/docbook-xsl \
ports/textproc/docproj \
ports/textproc/dsssl-docbook-modular \
ports/textproc/expat2 \
ports/textproc/fixrtf \
ports/textproc/html \
ports/textproc/html2text \
ports/textproc/iso8879 \
ports/textproc/libxml2 \
ports/textproc/libxslt \
ports/textproc/linuxdoc \
ports/textproc/scr2txt \
ports/textproc/sdocbook-xml \
ports/textproc/xhtml \
ports/textproc/xmlcatmgr \
ports/textproc/xmlcharent \
ports/www/links1 \
ports/www/tidy
.if ${MACHINE_ARCH} != "i386"
MINIMALDOCPORTS+= ports/textproc/openjade \
ports/textproc/opensp
.else
MINIMALDOCPORTS+= ports/textproc/jade
.endif
.if ${OSVERSION} < 500000
MINIMALDOCPORTS+= \
ports/converters/p5-MIME-Base64 \
ports/devel/p5-File-Spec \
ports/devel/p5-File-Temp \
ports/devel/p5-Test-Harness \
ports/devel/p5-Test-Simple \
ports/security/p5-Digest \
ports/security/p5-Digest-MD5 \
ports/textproc/p5-PodParser
.else
MINIMALDOCPORTS+= \
ports/lang/perl5.10
.endif

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs ifconfig
progs mount_nfs
progs newfs
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
progs usbconfig
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lsbuf -lufs -ldevinfo
libs -lbsdxml -larchive -lcrypto -lbz2 -llzma -lusb -ljail

View File

@ -1,42 +0,0 @@
:
# $FreeBSD$
export BLOCKSIZE=K
export PS1="Fixit# "
export EDITOR="/mnt2/rescue/vi"
export PAGER="/mnt2/usr/bin/more"
export SCSI_MODES="/mnt2/usr/share/misc/scsi_modes"
# the root MFS doesn't have /dev/nrsa0, pick a better default for mt(1)
export TAPE=/mnt2/dev/nrsa0
# make geom(8) utilities find their modules
export GEOM_LIBRARY_PATH="/mnt2/lib/geom:/lib/geom"
alias ls="ls -F"
alias ll="ls -l"
alias m="more -e"
echo '+---------------------------------------------------------------+'
echo '| You are now running from FreeBSD "fixit" media. |'
echo '| ------------------------------------------------------------- |'
echo "| When you're finished with this shell, please type exit. |"
echo '| The fixit media is mounted as /mnt2. |'
echo '| |'
echo '| You might want to symlink /mnt/etc/*pwd.db and /mnt/etc/group |'
echo '| to /etc after mounting a root filesystem from your disk. |'
echo '| tar(1) will not restore all permissions correctly otherwise! |'
echo '| |'
echo '| In order to load kernel modules you might want to add the |'
echo '| fixit media to the kern.module_path sysctl variable so that |'
echo '| the kernel knows where to find them. |'
echo '| |'
echo '| Note: you can use the arrow keys to browse through the |'
echo '| command history of this shell. |'
echo '+---------------------------------------------------------------+'
echo
echo 'Good Luck!'
echo
# Make the arrow keys work; everybody will love this.
set -o emacs 2>/dev/null
cd /

View File

@ -1,108 +0,0 @@
#
# Network services, Internet style
#
# Stripped-down version.
#
# $FreeBSD$
#
# WELL KNOWN PORT NUMBERS
#
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users #Active Users
systat 11/udp users #Active Users
daytime 13/tcp
daytime 13/udp
chargen 19/tcp ttytst source #Character Generator
chargen 19/udp ttytst source #Character Generator
ftp-data 20/tcp #File Transfer [Default Data]
ftp-data 20/udp #File Transfer [Default Data]
ftp 21/tcp #File Transfer [Control]
ftp 21/udp #File Transfer [Control]
ssh 22/tcp #Secure Shell Login
ssh 22/udp #Secure Shell Login
telnet 23/tcp
telnet 23/udp
# 24/tcp any private mail system
# 24/udp any private mail system
smtp 25/tcp mail #Simple Mail Transfer
smtp 25/udp mail #Simple Mail Transfer
time 37/tcp timserver
time 37/udp timserver
domain 53/tcp #Domain Name Server
domain 53/udp #Domain Name Server
bootps 67/tcp dhcps #Bootstrap Protocol Server
bootps 67/udp dhcps #Bootstrap Protocol Server
bootpc 68/tcp dhcpc #Bootstrap Protocol Client
bootpc 68/udp dhcpc #Bootstrap Protocol Client
tftp 69/tcp #Trivial File Transfer
tftp 69/udp #Trivial File Transfer
gopher 70/tcp
gopher 70/udp
finger 79/tcp
finger 79/udp
http 80/tcp www www-http #World Wide Web HTTP
http 80/udp www www-http #World Wide Web HTTP
sunrpc 111/tcp rpcbind #SUN Remote Procedure Call
sunrpc 111/udp rpcbind #SUN Remote Procedure Call
auth 113/tcp ident tap #Authentication Service
auth 113/udp ident tap #Authentication Service
nntp 119/tcp usenet #Network News Transfer Protocol
nntp 119/udp usenet #Network News Transfer Protocol
rmt 411/tcp #Remote MT Protocol
rmt 411/udp #Remote MT Protocol
https 443/tcp
https 443/udp
#
# Berkeley-specific services
#
exec 512/tcp #remote process execution;
# authentication performed using
# passwords and UNIX loppgin names
biff 512/udp comsat #used by mail system to notify users
# of new mail received; currently
# receives messages only from
# processes on the same machine
login 513/tcp #remote login a la telnet;
# automatic authentication performed
# based on priviledged port numbers
# and distributed data bases which
# identify "authentication domains"
who 513/udp whod #maintains data bases showing who's
# logged in to machines on a local
# net and the load average of the
# machine
cmd 514/tcp shell #like exec, but automatic
# authentication is performed as for
# login server
syslog 514/udp
printer 515/tcp spooler
printer 515/udp spooler
talk 517/tcp #like tenex link, but across
# machine - unfortunately, doesn't
# use link protocol (this is actually
# just a rendezvous port from which a
# tcp connection is established)
talk 517/udp #like tenex link, but across
# machine - unfortunately, doesn't
# use link protocol (this is actually
# just a rendezvous port from which a
# tcp connection is established)
ntalk 518/tcp
ntalk 518/udp
utime 519/tcp unixtime
utime 519/udp unixtime
efs 520/tcp #extended file name server
router 520/udp route routed #local routing process (on site);
# uses variant of Xerox NS routing
# information protocol
uucp 540/tcp uucpd
uucp 540/udp uucpd
uucp-rlogin 541/tcp
uucp-rlogin 541/udp
klogin 543/tcp # Kerberos (v4/v5)
klogin 543/udp # Kerberos (v4/v5)
kshell 544/tcp krcmd # Kerberos (v4/v5)
kshell 544/udp krcmd # Kerberos (v4/v5)

View File

@ -1,44 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs ifconfig
progs mount_nfs
progs newfs
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
progs usbconfig
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lsbuf -lufs -ldevinfo
libs -lbsdxml -larchive -lcrypto -lbz2 -llzma -lusb -ljail

View File

@ -1,49 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH
srcdirs /usr/src/bin
progs cat
progs chmod
progs cp
progs dd
progs df
progs echo
progs ed
progs expr
progs kill
progs ln
progs ls
progs mkdir
progs mv
progs rm
progs rmdir
progs sleep
progs sync
srcdirs /usr/src/sbin
progs bsdlabel
progs clri
progs dmesg
progs fdisk
progs mknod
progs mount
progs mount_cd9660
progs mount_msdosfs
progs reboot
progs restore
progs swapon
progs umount
ln bsdlabel disklabel
ln restore rrestore
srcdirs /usr/src/usr.bin
progs ftp
progs telnet
srcdirs /usr/src/usr.sbin
progs chown
progs chroot
ln chown chgrp
libs -ledit -lgeom -lbsdxml -lsbuf -lkiconv -lkvm -lncurses -lutil

View File

@ -1,49 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs geom
progs ifconfig
progs mount_msdosfs
progs mount_nfs
progs newfs
progs newfs_msdos
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
ln geom glabel
ln geom gpart
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
progs usbconfig
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lkiconv -lsbuf -lufs -ldevinfo
libs -lgeom -lbsdxml -larchive -lcrypto -lbz2 -llzma -lusb -ljail

View File

@ -1,43 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs ifconfig
progs mount_nfs
progs newfs
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lsbuf -lufs -lbsdxml
libs -larchive -lcrypto -lbz2 -llzma -ljail

View File

@ -1,43 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH
srcdirs /usr/src/bin
progs cat
progs chmod
progs cp
progs dd
progs df
progs echo
progs ed
progs expr
progs kill
progs ln
progs ls
progs mkdir
progs mv
progs rm
progs rmdir
progs sleep
progs sync
srcdirs /usr/src/sbin
progs bsdlabel
progs clri
progs dmesg
progs fdisk
progs mount
progs mount_cd9660
progs mount_msdosfs
progs reboot
progs swapon
progs umount
ln bsdlabel disklabel
special fdisk srcdir /usr/src/sbin/fdisk_pc98
srcdirs /usr/src/usr.sbin
progs chown
ln chown chgrp
libs -lgeom -lbsdxml -lsbuf -lkiconv -lkvm -lncurses -lutil

View File

@ -1,47 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH
srcdirs /usr/src/bin
progs cat
progs chmod
progs cp
progs dd
progs df
progs echo
progs ed
progs expr
progs kill
progs ln
progs ls
progs mkdir
progs mv
progs rm
progs rmdir
progs sleep
progs sync
srcdirs /usr/src/sbin
progs bsdlabel
progs clri
progs dmesg
progs fdisk
progs mount
progs mount_cd9660
progs mount_msdosfs
progs reboot
progs swapon
progs umount
ln bsdlabel disklabel
special fdisk srcdir /usr/src/sbin/fdisk_pc98
srcdirs /usr/src/usr.bin
progs ftp
progs telnet
srcdirs /usr/src/usr.sbin
progs chown
ln chown chgrp
libs -ledit -lgeom -lbsdxml -lsbuf -lkiconv -lkvm -lncurses -lutil

View File

@ -1,49 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs geom
progs ifconfig
progs mount_msdosfs
progs mount_nfs
progs newfs
progs newfs_msdos
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
ln geom glabel
ln geom gpart
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
progs usbconfig
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lkiconv -lsbuf -lufs
libs -lgeom -lbsdxml -larchive -lcrypto -lbz2 -llzma -lusb -ljail

View File

@ -1,16 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
echo "You are about to extract the base distribution into ${DESTDIR:-/} - are you SURE"
echo -n "you want to do this over your installed system (y/n)? "
read ans
if [ "$ans" = "y" ]; then
cat base.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
fi

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat catpages.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Move all the catpages out to their own dist, using the base dist as a
# starting point. This must precede the manpages dist script.
if [ -d ${RD}/trees/base/usr/share/man ]; then
( cd ${RD}/trees/base/usr/share/man;
find cat* whatis | cpio -dumpl ${RD}/trees/catpages/usr/share/man > /dev/null 2>&1) &&
rm -rf ${RD}/trees/base/usr/share/man/cat*;
fi

View File

@ -1,192 +0,0 @@
#!/usr/bin/perl
# -----------------------------------------------------------------
# FreeBSD Release Checking Utility - Package Index Check
#
# This program checks the packages/INDEX file to verify that
# the index is in the correct format and that every package
# needed by a release is included on the CD.
#
# Copyright(c) 2000 BSDi
# Murray Stokely
# -----------------------------------------------------------------
# 08 Apr 2000
#
# $FreeBSD$
#
use Getopt::Long;
#
# Display the usage instructions
#
sub printHelp {
print<<end;
usage : checkindex -s <sysinstall src dir> <INDEX>
This program checks the packages INDEX file to verify that the
index is correct and that every package needed by sysinstall is
included in the index.
Options
-help Display usage instructions
-s <src dir> Specify the sysinstall source directory. Use
this so to make sure every package referenced
in the code is in your INDEX
-newindex Generate a new index consisting of only those
packages that actually exist in pkgdir/All
-depends <pkg> Lists all packages in the index that depend
on <pkg>.
end
}
##
## Attempts to find the value of a variable in C code by backtracking
## up the source looking for a previous declaration.
##
## This is a bit overkill for the purpose of this script,
## stick with grepping for likely packages for now.
sub findAssignment($$) {
## This code deals with the small (5%) number of matches
## in which package_add refers to a variable rather than
## a inline string, so we have to find the value of that
## variable so that we can push it onto the list
# my($fileName,$code) = split(/:/,$match);
# open(FILE,$fileName) || die "Could not open $fileName : $!\n";
# my(@lines) = <FILE>;
# my($cnt) = 1;
# my($lineMatch) = 0;
# chomp(@lines);
# foreach $line (@lines) {
# $lineMatch = $cnt if ($line eq $code);
# $cnt++;
# }
# $code =~ /package_add\((\S+)\)/;
# my($varName) = $1;
# print STDERR "$lineMatch of $fileName is wierd\n";
# print STDERR "Trying to find '$varName'\n";
# while ($cnt > 0) {
# $cnt--;
# }
}
##
## Returns a list of all the packages referenced in the sysinstall source
## code
##
sub getPackages($) {
my($srcDir) = $_[0];
my(@matches) = `grep package_add $opt_s/*.c`;
my(@packages);
foreach $match (@matches) {
chomp $match;
next if ($match =~ m|$opt_s/package.c|);
if ($match =~ /package_add\(\"(\S+)\"\)/) {
push(@packages,$1);
} elsif ($match =~ /package_add\(char/) {
# function definition or prototype
next;
} else {
# package_add(variable or DEFINE)
my(@varMatches) = `grep variable_set2 $opt_s/*.c`;
chomp @varMatches;
foreach $varMatch (@varMatches) {
if ($varMatch =~ /variable_set2\(\S+_PACKAGE,\s+\"(\S+)\"/) {
push(@packages,$1);
}
}
}
}
@packages;
}
&GetOptions("help","s=s","newindex","depends=s");
if ($opt_help) {
&printHelp;
} else{
my ($indexName) = $ARGV[0];
my ($mistakes) = 0;
my ($counter) = 0;
print STDERR "Packages Referenced :\n---------------------\n";
open(INDEX,$indexName) || die "Could not open $indexName : $!";
@index = <INDEX>;
close(INDEX);
## Check to ensure that every file in the index exists physically.
print STDERR "Check to ensure that every file in the index exists physically\n";
foreach $line (@index) {
chomp $line;
($file,$pathto,$prefix,$comment,$descr,$maint,$cats,$junk,$rdeps,$junk) = split(/\|/,$line,10);
$DEPENDS{$file} = $rdeps if (-e "All/$file.tgz");
}
if ($opt_newindex) {
foreach $pkg (keys %DEPENDS) {
$new = quotemeta $pkg;
@lines = grep(/^$new\|/,@index);
chomp $lines;
($#lines == 0) || die "Multiple lines for '$pkg' in index!";
printf "%s\n",$lines[0];
}
} elsif ($opt_depends) {
foreach $key (keys %DEPENDS) {
foreach $dependency (split ' ',$DEPENDS{$key}) {
if ($opt_depends eq $dependency) {
print "$opt_depends is needed by $key\n";
$counter++;
}
}
}
print "$opt_depends is not needed by any packages in the index!\n"
unless ($counter);
} else {
## Check to ensure that all the dependencies are there.
print "Check to make sure that every dependency of every file exists\n",
"in the Index and physically.\n";
foreach $file (keys %DEPENDS) {
# print "Checking $file\n";
foreach $depend (split(' ',$DEPENDS{$file})) {
unless (-e "All/$depend.tgz") {
# instead of a hash counter, make it a hash of arrays
# where the arrays are the files depended on.
push @{ $MISSING{$depend} }, $file;
$mistakes++;
}
}
}
## This makes sure that the index file contains everything
## that sysinstall uses.
if ($opt_s) {
@packages = getPackages($opt_s);
foreach $pkg (@packages) {
unless (grep(/^$pkg/,@index)) {
push @{ $MISSING{$pkg} }, "sysinstall";
$mistakes++;
}
}
}
## If there were mistakes, print out the missing packages.
if ($mistakes) {
print "--------------------------------------------------------\n",
" Packages Missing : \n",
"--------------------------------------------------------\n";
foreach $pkg (keys %MISSING) {
@files = @{ $MISSING{$pkg} };
print "$pkg (@files)\n";
}
} else {
print "Everything looks good!\n";
}
}
}

View File

@ -1,20 +0,0 @@
#! /bin/sh
#
# $FreeBSD$
usage()
{
echo "$*" >&2
echo "This script must be run from the top level package directory" >&2
exit 1
}
[ $# -ge 1 ] && usage "usage: chkINDEX"
[ -f INDEX ] || usage "INDEX file not found"
echo Checking for missing files
sed 's,^\([^|]*\)|.*,All/\1.tbz,' INDEX | xargs ls -l >/dev/null
echo Checking for missing dependents
awk -F'|' '{print $9}' INDEX | sed 's/ /\
/g' | sort -u | sed -e /^$/d -e 's/\(.*\)/All\/\1.tbz/' | xargs ls -l >/dev/null

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
echo "Extracting commerce tarball into ${DESTDIR}/usr/local"
tar --unlink -xpzf commerce.tgz -C ${DESTDIR}/usr/local
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat dict.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,18 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Move the dict stuff out to its own dist
if [ -d ${RD}/trees/base/usr/share/dict ]; then
tar -cf - -C ${RD}/trees/base/usr/share/dict . |
tar -xpf - -C ${RD}/trees/dict/usr/share/dict &&
rm -rf ${RD}/trees/base/usr/share/dict;
fi
for i in birthtoken flowers; do
if [ -f ${RD}/trees/base/usr/share/misc/$i ]; then
mv ${RD}/trees/base/usr/share/misc/$i \
${RD}/trees/dict/usr/share/misc;
fi;
done

View File

@ -1,122 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
set -ex
export BLOCKSIZE=512
DISKLABEL=$1; shift
MACHINE=${1:+"-m $1"}; shift
FSIMG=$1; shift
RD=$1 ; shift
MNT=$1 ; shift
FSSIZE=$1 ; shift
FSPROTO=$1 ; shift
FSINODE=$1 ; shift
FSLABEL=$1 ; shift
#
# If we've been told to, compute the required file system size
# and average inode size automatically.
#
if [ ${FSSIZE} -eq 0 -a ${FSLABEL} = "auto" ]; then
roundup() echo $((($1+$2-1)-($1+$2-1)%$2))
nf=$(find ${FSPROTO} |wc -l)
sk=$(du -sk ${FSPROTO} |cut -f1)
FSINODE=$(roundup $(($sk*1024/$nf)) ${FSINODE})
FSSIZE=$(roundup $(($sk*12/10)) 1024)
fi
dofs_vn () {
if [ "x$VNDEVICE" = "x" ] ; then
VNDEVICE=vn0
fi
u=`expr $VNDEVICE : 'vn\([0-9]*\)' || true`
VNDEVICE=vnn$u
rm -f /dev/*vnn*
mknod /dev/rvnn${u} c 43 `expr 65538 + $u '*' 8`
mknod /dev/rvnn${u}c c 43 `expr 2 + $u '*' 8`
mknod /dev/vnn${u} b 15 `expr 65538 + $u '*' 8`
mknod /dev/vnn${u}c b 15 `expr 2 + $u '*' 8`
umount /dev/${VNDEVICE} 2>/dev/null || true
umount ${MNT} 2>/dev/null || true
vnconfig -u /dev/r${VNDEVICE} 2>/dev/null || true
vnconfig -s labels -c /dev/r${VNDEVICE} ${FSIMG}
trap "umount ${MNT}; vnconfig -u /dev/r${VNDEVICE}; rm -f /dev/*vnn*" EXIT
disklabel -w ${BOOT} ${VNDEVICE} ${FSLABEL}
newfs -i ${FSINODE} -o space -m 0 /dev/r${VNDEVICE}c
mount /dev/${VNDEVICE}c ${MNT}
}
dofs_md () {
if [ "x${MDDEVICE}" != "x" ] ; then
umount /dev/${MDDEVICE} 2>/dev/null || true
umount ${MNT} 2>/dev/null || true
mdconfig -d -u ${MDDEVICE} 2>/dev/null || true
fi
MDDEVICE=`mdconfig -a -t vnode -f ${FSIMG}`
if [ ! -c /dev/${MDDEVICE} ] ; then
echo "No /dev/$MDDEVICE" 1>&2
exit 1
fi
trap "umount ${MNT}; mdconfig -d -u ${MDDEVICE}" EXIT
if [ "x${DISKLABEL}" != "x" ] ; then
${DISKLABEL} ${MACHINE} -w ${BOOT} ${MDDEVICE} ${FSLABEL}
fi
newfs -O1 -b 4096 -f 512 -i ${FSINODE} -o space -m 0 /dev/${MDDEVICE}
mount /dev/${MDDEVICE} ${MNT}
}
rm -f ${FSIMG}
dd of=${FSIMG} if=/dev/zero count=${FSSIZE} bs=1k 2>/dev/null
#
# We don't have any bootblocks on ia64. Note that -B implies -r,
# so we have to specifically specify -r when we don't have -B.
# bsdlabel fails otherwise.
#
case `uname -r` in
4.*)
if [ -f "${RD}/trees/base/boot/boot1" ]; then
BOOT="-B -b ${RD}/trees/base/boot/boot1"
if [ -f "${RD}/trees/base/boot/boot2" ]; then
BOOT="${BOOT} -s ${RD}/trees/base/boot/boot2"
fi
else
BOOT="-r"
fi
dofs_vn
;;
*)
if [ -f "${RD}/trees/base/boot/boot" ]; then
BOOT="-B -b ${RD}/trees/base/boot/boot"
else
BOOT="-r"
fi
dofs_md
;;
esac
if [ -d ${FSPROTO} ]; then
(set -e && cd ${FSPROTO} && find . -print | cpio -dump ${MNT})
else
cp -p ${FSPROTO} ${MNT}
fi
df -ki ${MNT}
set `df -ki ${MNT} | tail -1`
echo "*** File system is ${FSSIZE} K, $4 left"
echo "*** ${FSINODE} bytes/inode, $7 left"

View File

@ -1,15 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
echo "You are about to extract the doc distribution into ${DESTDIR:-/} - are you SURE"
echo -n "you want to do this over your installed system (y/n)? "
read ans
if [ "$ans" = "y" ]; then
cat doc.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
fi

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Create the doc dist.
if [ -d ${RD}/trees/base/usr/share/doc ]; then
( cd ${RD}/trees/base/usr/share/doc;
find . | cpio -dumpl ${RD}/trees/doc/usr/share/doc ) &&
rm -rf ${RD}/trees/base/usr/share/doc
fi

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat games.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat info.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Move the info files out to their own dist
if [ -d ${RD}/trees/base/usr/share/info ]; then
tar -cf - -C ${RD}/trees/base/usr/share/info . |
tar -xpf - -C ${RD}/trees/info/usr/share/info &&
rm -rf ${RD}/trees/base/usr/share/info;
fi

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $ANA: info.sh,v 1.3 1996/06/04 16:25:30 wollman Exp $
# $FreeBSD$
#
ls $1.[a-z][a-z] | wc | awk '{ print "Pieces = ",$1 }'
for FILE in $1.[a-z][a-z]; do
PIECE=`echo $FILE | cut -d . -f 2`
echo -n "cksum.$PIECE = "
cksum $FILE | awk ' { print $1,$2 } '
done

View File

@ -1,43 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
if [ $# -lt 1 ]; then
echo "You must specify which kernel to extract."
exit 1
fi
CONFIG=$1
BOOT=${DESTDIR}/boot
KERNEL=$BOOT/$CONFIG
if [ -d $KERNEL ]; then
echo "You are about to extract the $CONFIG kernel distribution into $KERNEL - are you SURE"
echo -n "you want to do this over your installed system (y/n)? "
read ans
else
# new installation; do not prompt
ans=y
fi
if [ "$ans" = "y" ]; then
if [ -d $KERNEL ]; then
sav=$KERNEL.sav
if [ -d $sav ]; then
# XXX remove stuff w/o a prompt
echo "Removing existing $sav"
rm -rf $sav
fi
echo "Saving existing $KERNEL as $sav"
mv $KERNEL $sav
fi
# translate per Makefile:doTARBALL XXX are we sure to have tr?
tn=`echo ${CONFIG} | tr 'A-Z' 'a-z'`
cat $tn.?? | tar --unlink -xpzf - -C $BOOT
else
echo "Installation of $CONFIG kernel distribution not done."
fi

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat lib32.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat manpages.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Move all the manpages out to their own dist, using the base dist as a
# starting point.
if [ -d ${RD}/trees/base/usr/share/man ]; then
( cd ${RD}/trees/base/usr/share/man;
find . | cpio -dumpl ${RD}/trees/manpages/usr/share/man > /dev/null 2>&1) &&
rm -rf ${RD}/trees/base/usr/share/man;
fi

View File

@ -1,33 +0,0 @@
#! /bin/sh
#
# $FreeBSD$
usage()
{
echo "$*" >&2
echo "This script must be run from the top level package directory" >&2
exit 1
}
[ $# -ge 1 ] && usage "usage: mkpkghier"
[ -f INDEX ] || usage "INDEX file not found"
[ -d All ] || usage "All directory not found"
old=$(ls | egrep -v "^INDEX$|^All$|^Latest$")
[ -n "$old" ] && { echo Removing old hierarchy; rm -fr $old; }
echo Creating new hierarchy
awk -F'|' '{ print $1 " " $7; }' INDEX | while read pkg dirs
do
[ -f All/$pkg.tbz ] || {
echo "All/$pkg.tbz: Non-existent" >&2
continue
}
for dir in $dirs
do
mkdir -p $dir
[ -e $dir/$pkg.tbz ] && continue
ln -s ../All/$pkg.tbz $dir/$pkg.tbz
done
done

View File

@ -1,57 +0,0 @@
#! /bin/sh
# ex:ts=8
# Copyright (c) 2003 David E. O'Brien
# 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.
# 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 THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
#
# $FreeBSD$
# Creates an INDEX file suitable for an ISO distribution image from a master
# INDEX file. The generated INDEX file contains only the packages in the
# supplied directory.
case $# in
3) PKG_EXT="tbz" ;;
4) PKG_EXT=$4 ;;
*)
echo `basename $0` "<master index file> <output index file> <pkg dir> [pkg ext]"
exit 1
;;
esac
PKG_LIST=$(basename `ls $3/*.${PKG_EXT}` | sed -e "s/\.${PKG_EXT}$//")
REGEX=$(echo ${PKG_LIST} | sed \
-e 's/ /|/g' \
-e 's/\./\\\./g' \
-e 's/\+/\\\+/g' \
-e 's/\^/\\\^/g')
egrep "^(${REGEX})" $1 > $2
if [ $(echo ${PKG_LIST} | wc -w) != $(wc -l < $2) ]; then
echo "ERROR: some packages not found in $1"
exit 1
else
exit 0
fi

View File

@ -1,187 +0,0 @@
#!/usr/local/bin/python
#
# This script generates a master INDEX file for the CD images built by the
# FreeBSD release engineers. Each disc is given a list of desired packages.
# Dependencies of these packages are placed on either the same disc or an
# earlier disc. The resulting master INDEX file is then written out.
#
# Usage: package-split.py <INDEX> <master INDEX>
#
# $FreeBSD$
import os
import sys
try:
arch = os.environ["PKG_ARCH"]
except:
arch = os.uname()[4]
print "Using arch %s" % (arch)
if 'PKG_VERBOSE' in os.environ:
verbose = 1
else:
verbose = 0
if 'PKG_DVD' in os.environ:
doing_dvd = 1
else:
doing_dvd = 0
# List of packages for disc1.
def disc1_packages():
pkgs = ['misc/freebsd-doc-bn',
'misc/freebsd-doc-da',
'misc/freebsd-doc-de',
'misc/freebsd-doc-el',
'misc/freebsd-doc-en',
'misc/freebsd-doc-es',
'misc/freebsd-doc-fr',
'misc/freebsd-doc-hu',
'misc/freebsd-doc-it',
'misc/freebsd-doc-ja',
'misc/freebsd-doc-mn',
'misc/freebsd-doc-nl',
'misc/freebsd-doc-pl',
'misc/freebsd-doc-pt',
'misc/freebsd-doc-ru',
'misc/freebsd-doc-sr',
'misc/freebsd-doc-tr',
'misc/freebsd-doc-zh_cn',
'misc/freebsd-doc-zh_tw']
if doing_dvd:
pkgs.extend(['archivers/unzip',
'astro/xearth',
'devel/gmake',
'devel/imake',
'editors/emacs',
'editors/vim-lite',
'emulators/linux_base-f10',
'emulators/mtools',
'graphics/png',
'graphics/xv',
'irc/xchat',
'lang/perl5.8',
'mail/alpine',
'mail/exim',
'mail/fetchmail',
'mail/mutt',
'mail/popd',
'mail/postfix',
'mail/xfmail',
'net/cvsup-without-gui',
'net/rsync',
'net/samba3',
'news/slrn',
'news/tin',
'ports-mgmt/p5-FreeBSD-Portindex',
'ports-mgmt/portaudit',
'ports-mgmt/portmaster',
'ports-mgmt/portupgrade',
'print/a2ps-letter',
'print/apsfilter',
'print/ghostscript7-nox11',
'print/psutils-letter',
'print/gv',
'shells/bash',
'shells/pdksh',
'shells/zsh',
'security/sudo',
'sysutils/screen',
'www/links',
'www/lynx',
'x11/gnome2',
'x11/kde4',
'x11/rxvt',
'x11/xorg',
'x11-wm/afterstep',
'x11-wm/fvwm2',
'x11-wm/windowmaker'])
return pkgs
# The list of desired packages
def desired_packages():
disc1 = disc1_packages()
return [disc1]
# Suck the entire INDEX file into a two different dictionaries. The first
# dictionary maps port names (origins) to package names. The second
# dictionary maps a package name to a list of its dependent packages.
PACKAGE_COL=0
ORIGIN_COL=1
DEPENDS_COL=8
def load_index(index):
deps = {}
pkgs = {}
line_num = 1
for line in index:
fields = line.split('|')
name = fields[PACKAGE_COL]
if name in deps:
sys.stderr.write('%d: Duplicate package %s\n' % (line_num, name))
sys.exit(1)
origin = fields[ORIGIN_COL].replace('/usr/ports/', '', 1)
if origin in pkgs:
sys.stderr.write('%d: Duplicate port %s\n' % (line_num, origin))
sys.exit(1)
deps[name] = fields[DEPENDS_COL].split()
pkgs[origin] = name
line_num = line_num + 1
return (deps, pkgs)
# Layout the packages on the various CD images. Here's how it works. We walk
# each disc in the list of discs. Within each disc we walk the list of ports.
# For each port, we add the package name to a dictionary with the value being
# the current disc number. We also add all of the dependent packages. If
# a package is already in the dictionary when we go to add it, we just leave
# the dictionary as it is. This means that each package ends up on the first
# disc that either lists it or contains it as a dependency.
def layout_discs(discs, pkgs, deps):
disc_num = 1
layout = {}
for disc in discs:
for port in disc:
if port not in pkgs:
sys.stderr.write('Disc %d: Unable to find package for %s\n' %
(disc_num, port))
continue
pkg = pkgs[port]
pkg_list = [pkg] + deps[pkg]
for pkg in pkg_list:
if pkg not in layout:
if verbose:
print "--> Adding %s to Disc %d" % (pkg, disc_num)
layout[pkg] = disc_num
disc_num = disc_num + 1
return layout
# Generate a master INDEX file based on the generated layout. The way this
# works is that for each INDEX line, we check to see if the package is in the
# layout. If it is, we put that INDEX line into the master INDEX and append
# a new field with the disc number to the line.
def generate_index(index, layout, master_index):
for line in index:
pkg = line.split('|')[PACKAGE_COL]
if pkg in layout:
new_line = '%s|%d\n' % (line.splitlines()[0], layout[pkg])
master_index.write(new_line)
# Verify the command line arguments
if len(sys.argv) != 3:
sys.stderr.write('Invalid number of arguments\n')
sys.stderr.write('Usage: package-split.py <source INDEX> <master INDEX>\n')
sys.exit(1)
print "Loading %s..." % (sys.argv[1])
index = file(sys.argv[1])
(deps, pkgs) = load_index(index)
discs = desired_packages()
layout = layout_discs(discs, pkgs, deps)
index.seek(0)
print "Generating %s..." % (sys.argv[2])
master_index = file(sys.argv[2], 'w')
generate_index(index, layout, master_index)
index.close()
master_index.close()

View File

@ -1,58 +0,0 @@
#!/bin/sh
#
# This script generates the disk layout for the CD images built by the FreeBSD
# release engineers as dictated by a specified master INDEX file. Each disc
# contains the master INDEX, it's assigned list of packages, and the
# appropriate tree of category symlinks.
#
# Usage: package-trees.sh <copy method> <INDEX> <package tree> <destination>
#
# $FreeBSD$
# Verify the command line
if [ $# -ne 4 ]; then
echo "Invalid number of arguments"
echo "Usage: package-trees.sh <copy method> <INDEX> <tree> <destination>"
exit 1
fi
COPY=$1 ; shift
INDEX=$1 ; shift
TREE=$1 ; shift
DESTDIR=$1 ; shift
# First, determine the highest disc number.
high_disc=`cut -d '|' -f 14 ${INDEX} | sort -n | tail -1`
echo "Generating trees for ${high_disc} discs"
# Second, initialize the trees for each disc
for disc in `jot $high_disc`; do
rm -rf ${DESTDIR}/disc${disc}/packages
mkdir -p ${DESTDIR}/disc${disc}/packages/All
cp ${INDEX} ${DESTDIR}/disc${disc}/packages/INDEX
done
# Third, run through the INDEX copying each package to its appropriate CD and
# making the appropriate category symlinks
while read line; do
disc=`echo $line | cut -d '|' -f 14`
package=`echo $line | cut -d '|' -f 1`
categories=`echo $line | cut -d '|' -f 7`
discdir=${DESTDIR}/disc${disc}
if [ -n "$PKG_VERBOSE" ]; then
echo "--> Copying $package to Disc $disc"
fi
${COPY} ${TREE}/All/${package}.tbz ${discdir}/packages/All
for cat in ${categories}; do
catdir=${discdir}/packages/${cat}
mkdir -p ${catdir}
ln -s ../All/${package}.tbz ${catdir}
done
done < ${INDEX}
# Fourth, output du info for the relative size of the trees.
discs=""
for disc in `jot $high_disc`; do
discs="${discs} disc${disc}"
done
(cd ${DESTDIR}; du -sh ${discs})

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
echo "Extracting ports tarball into ${DESTDIR}/usr"
tar --unlink -xpzf ports.tgz -C ${DESTDIR}/usr
exit 0

View File

@ -1,11 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
cat proflibs.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
exit 0

View File

@ -1,9 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Move the profiled libraries out to their own dist
for i in ${RD}/trees/base/usr/lib/*_p.a; do
mv $i ${RD}/trees/proflibs/usr/lib
done

View File

@ -1,39 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
# Bail if things fail and be verbose about what we are doing
set -ex
# Arguments are as follows: file destdir chunksize description
FILE=$1; shift
DEST=$1; shift
CHUNK_SIZE=$1; shift
DESCR=$1; shift
# Make sure we can read the file.
[ -r ${FILE} ]
# Create clean working area to stick file chunks and list in
rm -rf ${DEST} || true
mkdir -p ${DEST}
# Split the file into pieces
prefix=`basename $FILE`
dd if=${FILE} bs=16k iseek=1 | split -b ${CHUNK_SIZE}k - ${DEST}/${prefix}.
# Create a special file for the first 16k that gets stuck on the boot
# floppy
files=`ls ${DEST}/${prefix}.*`
first=`echo "${files}" | head -1`
bootchunk="${DEST}/${prefix}.boot"
dd if=${FILE} of=${bootchunk} bs=16k count=1
# Create the split index file
echo `basename ${bootchunk}` "\"Boot floppy\"" > ${DEST}/${prefix}.split
i=1
for file in ${files}; do
echo `basename ${file}` "\"${DESCR} floppy ${i}\"" >> ${DEST}/${prefix}.split
i=$(($i + 1))
done

View File

@ -1,34 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
if [ $# -lt 1 ]; then
echo "You must specify which components of src to extract"
echo "possible subcomponents are:"
echo
echo "base bin cddl contrib crypto etc games gnu include krb5"
echo "lib libexec release rescue sbin secure share sys tools ubin"
echo "usbin"
echo
echo "You may also specify all to extract all subcomponents."
exit 1
fi
if [ "$1" = "all" ]; then
dists="base bin cddl contrib crypto etc games gnu include krb5 lib libexec release rescue sbin secure share sys tools ubin usbin"
else
dists="$*"
fi
echo "Extracting sources into ${DESTDIR}/usr/src..."
for i in $dists; do
echo " Extracting source component: $i"
cat s${i}.?? | tar --unlink -xpzf - -C ${DESTDIR}/usr/src
done
echo "Done extracting sources."
exit 0

View File

@ -1,119 +0,0 @@
#!/bin/sh -p
#
# Simple replacement for tar(1), using cpio(1).
#
# Copyright (c) 1996 Joerg Wunsch
# 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.
# 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 THE DEVELOPERS ``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 THE DEVELOPERS 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.
#
# $FreeBSD$
#
#
# For use on the fixit floppy. External programs required:
# cpio(1), find(1), test(1)
#
archive=${TAPE:-/dev/rsa0}
blocksize="20"
device=""
mode="none"
verbose=""
usage()
{
echo "usage: tar -{c|t|x} [-v] [-b blocksize] [-f archive] [files...]" 1>&2
exit 64 # EX_USAGE
}
#
# Prepend a hyphen to the first arg if necessary, so the traditional form
# ``tar xvf /dev/foobar'' will work, too. More kludgy legacy forms are not
# supported however.
#
if [ $# -lt 1 ] ; then
usage
fi
case "$1" in
-*) break
;;
*) tmp="$1"
shift
set -- -$tmp "$@"
;;
esac
while getopts "ctxvb:f:" option
do
case $option in
[ctx])
if [ $mode = "none" ] ; then
mode=$option
else
usage
fi
;;
v)
verbose="-v"
;;
b)
blocksize="${OPTARG}"
;;
f)
archive="${OPTARG## }"
;;
*)
usage
;;
esac
done
shift $(($OPTIND - 1))
if [ "X${archive}" != "X-" ] ; then
device="-F ${archive}"
# else: use stdin or stdout, which is the default for cpio
fi
case $mode in
none)
usage
;;
t)
exec cpio -it $verbose $device --block-size="$blocksize" "$@"
;;
x)
exec cpio -idmu $verbose $device --block-size="$blocksize" "$@"
;;
c)
if [ $# -eq 0 ] ; then
# use current dir -- slightly bogus
set -- "."
fi
find "$@" -print |\
cpio -o -H ustar $verbose $device --block-size="$blocksize"
exit $?
;;
esac

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# $FreeBSD$
#
if [ "`id -u`" != "0" ]; then
echo "Sorry, this must be done as root."
exit 1
fi
echo "Extracting xperimnt tarball into ${DESTDIR}/usr/local"
tar --unlink -xpzf xperimnt.tgz -C ${DESTDIR}/usr/local
exit 0

View File

@ -1,47 +0,0 @@
# $FreeBSD$
buildopts -DRELEASE_CRUNCH -Dlint
srcdirs /usr/src/bin
progs hostname
progs pwd
progs rm
progs sh
progs test
ln sh -sh
ln test [
srcdirs /usr/src/sbin
progs camcontrol
progs dhclient
progs fsck_ffs
progs geom
progs ifconfig
progs mount_nfs
progs newfs
progs route
progs rtsol
progs tunefs
ln fsck_ffs fsck_4.2bsd
ln fsck_ffs fsck_ufs
ln geom glabel
ln geom gpart
srcdirs /usr/src/usr.bin
progs cpio
progs find
progs minigzip
progs sed
ln minigzip gzip
ln minigzip gunzip
ln minigzip zcat
srcdirs /usr/src/usr.sbin
progs arp
progs ppp
progs sysinstall
progs usbconfig
libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph
libs -lodialog -lncurses -ldisk -lcam -lsbuf -lufs -lgeom -lbsdxml
libs -larchive -lcrypto -lbz2 -llzma -lusb -ljail

View File

@ -290,8 +290,6 @@ SUBDIR+= praliases
SUBDIR+= sendmail
.endif
SUBDIR+= sysinstall
.if ${MK_TOOLCHAIN} != "no"
SUBDIR+= config
SUBDIR+= crunch

View File

@ -1,126 +0,0 @@
# $FreeBSD$
.if ${MACHINE_CPUARCH} != "ia64"
_wizard= wizard.c
.endif
PROG= sysinstall
MAN= sysinstall.8
SRCS= anonFTP.c cdrom.c command.c config.c devices.c dhcp.c \
disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \
ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \
label.c main.c makedevs.c media.c menus.c misc.c modules.c \
mouse.c msg.c network.c nfs.c options.c package.c \
system.c tcpip.c termcap.c ttys.c ufs.c usb.c user.c \
variable.c ${_wizard} keymap.h countries.h
CFLAGS+= -DUSE_GZIP=1
.if ${MACHINE} == "pc98"
CFLAGS+= -DPC98
.endif
CFLAGS+= -I${.CURDIR}/../../gnu/lib/libodialog -I.
WARNS?= 2
DPADD= ${LIBODIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
LDADD= -lodialog -lncurses -lutil -ldisk -lftpio
CLEANFILES= makedevs.c rtermcap
CLEANFILES+= keymap.tmp keymap.h countries.tmp countries.h
.if exists(${.CURDIR}/../../share/termcap/termcap.src)
RTERMCAP= TERMCAP=${.CURDIR}/../../share/termcap/termcap.src ./rtermcap
.else
RTERMCAP= ./rtermcap
.endif
makedevs.c: Makefile rtermcap
echo '#include <sys/types.h>' > makedevs.c
${RTERMCAP} ansi | \
file2c 'const char termcap_ansi[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25w | \
file2c 'const char termcap_cons25w[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25 | \
file2c 'const char termcap_cons25[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25-m | \
file2c 'const char termcap_cons25_m[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25r | \
file2c 'const char termcap_cons25r[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25r-m | \
file2c 'const char termcap_cons25r_m[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25l1 | \
file2c 'const char termcap_cons25l1[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} cons25l1-m | \
file2c 'const char termcap_cons25l1_m[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} vt100 | \
file2c 'const char termcap_vt100[] = {' ',0};' \
>> makedevs.c
${RTERMCAP} xterm | \
file2c 'const char termcap_xterm[] = {' ',0};' \
>> makedevs.c
build-tools: rtermcap
rtermcap: rtermcap.c
${CC} -o ${.TARGET} ${.ALLSRC} -ltermcap
.if ${MACHINE} == "pc98"
KEYMAPS= jp.pc98 jp.pc98.iso
.else
KEYMAPS= be.iso bg.bds.ctrlcaps bg.phonetic.ctrlcaps br275.iso \
ce.iso2 cs.latin2.qwertz danish.iso el.iso07 \
estonian.cp850 estonian.iso estonian.iso15 finnish.iso fr.iso \
german.iso gr.elot.acc gr.us101.acc hr.iso hu.iso2.101keys \
it.iso icelandic.iso jp.106 latinamerican latinamerican.iso.acc \
norwegian.iso pl_PL.ISO8859-2 \
pt.iso ru.koi8-r si.iso sk.iso2 spanish.iso spanish.iso.acc swedish.iso \
swissfrench.iso \
swissgerman.iso ua.koi8-u ua.koi8-u.shift.alt uk.iso us.dvorak \
us.iso us.pc-ctrl us.unix
.endif
keymap.h:
rm -f keymap.tmp
for map in ${KEYMAPS} ; do \
KEYMAP_PATH=${.CURDIR}/../../share/syscons/keymaps \
kbdcontrol -L $$map | \
sed -e '/^static accentmap_t/,$$d' >> keymap.tmp ; \
done
echo "static struct keymapInfo keymapInfos[] = {" >> keymap.tmp
for map in ${KEYMAPS} ; do \
echo -n ' { "'$$map'", ' >> keymap.tmp ; \
echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \
done
( echo " { NULL, NULL }"; echo "};" ; echo "" ) >> keymap.tmp
mv keymap.tmp keymap.h
countries.h: ${.CURDIR}/../../share/misc/iso3166
rm -f countries.tmp
awk 'BEGIN { \
FS = "\t"; \
num = 1; \
print "DMenu MenuCountry = {"; \
print " DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,"; \
print " \"Country Selection\","; \
print " \"Please choose a country, region, or group.\\n\""; \
print " \"Select an item using [SPACE] or [ENTER].\","; \
printf " NULL,\n NULL,\n { "; \
} \
/^[[:space:]]*#/ {next;} \
{if (num > 1) {printf " ";} \
print "{ \"" num "\", \"" $$4 "\"" \
", dmenuVarCheck, dmenuSetCountryVariable" \
", NULL, VAR_COUNTRY \"=" tolower($$1) "\" },"; \
++num;} \
END {print " { NULL } }\n};\n";}' < ${.ALLSRC} > countries.tmp
mv countries.tmp ${.TARGET}
.include <bsd.prog.mk>

View File

@ -1,328 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
* Coranth Gryphon. All rights reserved.
* Copyright (c) 1996
* Jordan K. 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 THE AUTHORS ``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 THE AUTHORS OR THEIR 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/param.h>
#include <pwd.h>
#include <grp.h>
/* This doesn't change until FTP itself changes */
#define FTP_NAME "ftp"
#define MOTD_FILE "ftpmotd"
/* These change if we want to use different defaults */
#define FTP_UID 14
#define FTP_GID 14
#define FTP_GROUP "ftp"
#define FTP_UPLOAD "incoming"
#define FTP_COMMENT "Anonymous FTP Admin"
#define FTP_HOMEDIR "/var/ftp"
#define ANONFTP_HELPFILE "anonftp"
/* Set up the structure to hold configuration information */
/* Note that this is only what we could fit onto the one screen */
typedef struct
{
char homedir[64]; /* Home Dir for Anon FTP */
char group[32]; /* Group */
char uid[8]; /* UID */
char comment[64]; /* PWD Comment */
char upload[32]; /* Upload Dir */
} FTPConf;
static FTPConf tconf;
#define ANONFTP_HOMEDIR_LEN 64
#define ANONFTP_COMMENT_LEN 64
#define ANONFTP_UPLOAD_LEN 32
#define ANONFTP_GROUP_LEN 32
#define ANONFTP_UID_LEN 8
static int okbutton, cancelbutton;
/* What the screen size is meant to be */
#define ANONFTP_DIALOG_Y 0
#define ANONFTP_DIALOG_X 8
#define ANONFTP_DIALOG_WIDTH COLS - 16
#define ANONFTP_DIALOG_HEIGHT LINES - 2
static Layout layout[] = {
#define LAYOUT_UID 0
{ 2, 3, 8, ANONFTP_UID_LEN - 1,
"UID:", "What user ID to assign to FTP Admin",
tconf.uid, STRINGOBJ, NULL },
#define LAYOUT_GROUP 1
{ 2, 15, 15, ANONFTP_GROUP_LEN - 1,
"Group:", "Group name that ftp process belongs to",
tconf.group, STRINGOBJ, NULL },
#define LAYOUT_COMMENT 2
{ 2, 35, 24, ANONFTP_COMMENT_LEN - 1,
"Comment:", "Password file comment for FTP Admin",
tconf.comment, STRINGOBJ, NULL },
#define LAYOUT_HOMEDIR 3
{ 9, 10, 43, ANONFTP_HOMEDIR_LEN - 1,
"FTP Root Directory:",
"The top directory to chroot to when doing anonymous ftp",
tconf.homedir, STRINGOBJ, NULL },
#define LAYOUT_UPLOAD 4
{ 14, 20, 22, ANONFTP_UPLOAD_LEN - 1,
"Upload Subdirectory:", "Designated sub-directory that holds uploads (leave empty for none)",
tconf.upload, STRINGOBJ, NULL },
#define LAYOUT_OKBUTTON 5
{ 19, 15, 0, 0,
"OK", "Select this if you are happy with these settings",
&okbutton, BUTTONOBJ, NULL },
#define LAYOUT_CANCELBUTTON 6
{ 19, 35, 0, 0,
"CANCEL", "Select this if you wish to cancel this screen",
&cancelbutton, BUTTONOBJ, NULL },
LAYOUT_END,
};
static int
createFtpUser(void)
{
struct passwd *tpw;
struct group *tgrp;
char pwline[256];
char *tptr;
int gid;
FILE *fptr;
if ((gid = atoi(tconf.group)) <= 0) {
if (!(tgrp = getgrnam(tconf.group))) {
/* group does not exist, create it by name */
tptr = msgGetInput("14", "What group ID to use for group %s ?", tconf.group);
if (tptr && *tptr && ((gid = atoi(tptr)) > 0)) {
if ((fptr = fopen(_PATH_GROUP,"a"))) {
fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
fclose(fptr);
}
}
else
gid = FTP_GID;
}
else
gid = tgrp->gr_gid;
}
else if (!getgrgid(gid)) {
/* group does not exist, create it by number */
tptr = msgGetInput("ftp", "What group name to use for gid %d ?", gid);
if (tptr && *tptr) {
SAFE_STRCPY(tconf.group, tptr);
if ((tgrp = getgrnam(tconf.group))) {
gid = tgrp->gr_gid;
}
else if ((fptr = fopen(_PATH_GROUP,"a"))) {
fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
fclose(fptr);
}
}
}
if ((tpw = getpwnam(FTP_NAME))) {
if (tpw->pw_uid != FTP_UID)
msgConfirm("FTP user already exists with a different uid.");
return DITEM_SUCCESS; /* succeeds if already exists */
}
sprintf(pwline, "%s:*:%s:%d::0:0:%s:%s:/nonexistent\n", FTP_NAME, tconf.uid, gid, tconf.comment, tconf.homedir);
fptr = fopen(_PATH_MASTERPASSWD,"a");
if (! fptr) {
msgConfirm("Could not open master password file.");
return DITEM_FAILURE;
}
fprintf(fptr, "%s", pwline);
fclose(fptr);
msgNotify("Remaking password file: %s", _PATH_MASTERPASSWD);
vsystem("pwd_mkdb -p %s", _PATH_MASTERPASSWD);
return DITEM_SUCCESS | DITEM_RESTORE;
}
/* This is it - how to get the setup values */
static int
anonftpOpenDialog(void)
{
WINDOW *ds_win;
ComposeObj *obj = NULL;
int n = 0, cancel = FALSE;
int max;
char title[80];
WINDOW *w = savescr();
/* We need a curses window */
if (!(ds_win = openLayoutDialog(ANONFTP_HELPFILE, " Anonymous FTP Configuration ",
ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, ANONFTP_DIALOG_WIDTH, ANONFTP_DIALOG_HEIGHT))) {
beep();
msgConfirm("Cannot open anonymous ftp dialog window!!");
restorescr(w);
return DITEM_FAILURE;
}
/* Draw a sub-box for the path configuration */
draw_box(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 8,
ANONFTP_DIALOG_HEIGHT - 11, ANONFTP_DIALOG_WIDTH - 17,
dialog_attr, border_attr);
wattrset(ds_win, dialog_attr);
sprintf(title, " Path Configuration ");
mvwaddstr(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 22, title);
/** Initialize the config Data Structure **/
bzero(&tconf, sizeof(tconf));
SAFE_STRCPY(tconf.group, FTP_GROUP);
SAFE_STRCPY(tconf.upload, FTP_UPLOAD);
SAFE_STRCPY(tconf.comment, FTP_COMMENT);
SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
sprintf(tconf.uid, "%d", FTP_UID);
/* Some more initialisation before we go into the main input loop */
obj = initLayoutDialog(ds_win, layout, ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, &max);
cancelbutton = okbutton = 0;
while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel));
/* Clear this crap off the screen */
delwin(ds_win);
use_helpfile(NULL);
restorescr(w);
if (cancel)
return DITEM_FAILURE;
return DITEM_SUCCESS;
}
int
configAnonFTP(dialogMenuItem *self __unused)
{
int i;
if (msgYesNo("Anonymous FTP permits un-authenticated users to connect to the system\n"
"FTP server, if FTP service is enabled. Anonymous users are\n"
"restricted to a specific subset of the file system, and the default\n"
"configuration provides a drop-box incoming directory to which uploads\n"
"are permitted. You must separately enable both inetd(8), and enable\n"
"ftpd(8) in inetd.conf(5) for FTP services to be available. If you\n"
"did not do so earlier, you will have the opportunity to enable inetd(8)\n"
"again later.\n\n"
"If you want the server to be read-only you should leave the upload\n"
"directory option empty and add the -r command-line option to ftpd(8)\n"
"in inetd.conf(5)\n\n"
"Do you wish to continue configuring anonymous FTP?")) {
return DITEM_FAILURE;
}
/* Be optimistic */
i = DITEM_SUCCESS;
i = anonftpOpenDialog();
if (DITEM_STATUS(i) != DITEM_SUCCESS) {
msgConfirm("Configuration of Anonymous FTP cancelled per user request.");
return i;
}
/*** Use defaults for any invalid values ***/
if (atoi(tconf.uid) <= 0)
sprintf(tconf.uid, "%d", FTP_UID);
if (!tconf.group[0])
SAFE_STRCPY(tconf.group, FTP_GROUP);
/*** If the user did not specify a directory, use default ***/
if (tconf.homedir[strlen(tconf.homedir) - 1] == '/')
tconf.homedir[strlen(tconf.homedir) - 1] = '\0';
if (!tconf.homedir[0])
SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
/*** If HomeDir does not exist, create it ***/
if (!directory_exists(tconf.homedir))
vsystem("mkdir -p %s", tconf.homedir);
if (directory_exists(tconf.homedir)) {
msgNotify("Configuring %s for use by anon FTP.", tconf.homedir);
vsystem("chmod 555 %s && chown root:%s %s", tconf.homedir, tconf.group, tconf.homedir);
vsystem("mkdir %s/etc && chmod 555 %s/etc", tconf.homedir, tconf.homedir);
vsystem("mkdir -p %s/pub", tconf.homedir);
if (tconf.upload[0]) {
vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload);
vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload);
}
if (DITEM_STATUS(createFtpUser()) == DITEM_SUCCESS) {
msgNotify("Copying password information for anon FTP.");
vsystem("awk -F: '{if ((substr($1, 1, 1) != \"+\") && (substr($1, 1, 1) != \"-\") && ($3 < 10 || $1 == \"ftp\")) print $0}' /etc/master.passwd > %s/etc/master.passwd", tconf.homedir);
vsystem("/usr/sbin/pwd_mkdb -d %s/etc %s/etc/master.passwd && chmod 444 %s/etc/pwd.db", tconf.homedir, tconf.homedir, tconf.homedir);
vsystem("rm -f %s/etc/master.passwd %s/etc/spwd.db", tconf.homedir, tconf.homedir);
vsystem("awk -F: '!/^#/ {if ((substr($1, 1, 1) != \"+\") && (substr($1, 1, 1) != \"-\") && ($3 < 100)) printf \"%%s:*:%%s:\\n\", $1, $3}' /etc/group > %s/etc/group && chmod 444 %s/etc/group", tconf.homedir, tconf.homedir);
vsystem("chown -R root:%s %s/pub", tconf.group, tconf.homedir);
}
else {
msgConfirm("Unable to create FTP user! Anonymous FTP setup failed.");
i = DITEM_FAILURE;
}
if (!msgYesNo("Create a welcome message file for anonymous FTP users?")) {
char cmd[256];
vsystem("echo Your welcome message here. > %s/etc/%s", tconf.homedir, MOTD_FILE);
sprintf(cmd, "%s %s/etc/%s", variable_get(VAR_EDITOR), tconf.homedir, MOTD_FILE);
if (!systemExecute(cmd))
i = DITEM_SUCCESS;
else
i = DITEM_FAILURE;
}
}
else {
msgConfirm("Invalid Directory: %s\n"
"Anonymous FTP will not be set up.", tconf.homedir);
i = DITEM_FAILURE;
}
if (DITEM_STATUS(i) == DITEM_SUCCESS)
variable_set2("anon_ftp", "YES", 0);
return i | DITEM_RESTORE;
}

View File

@ -1,244 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
* Copyright (c) 1995
* Gary J Palmer. 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.
*
*/
/* These routines deal with getting things off of CDROM media */
#include "sysinstall.h"
#include <sys/stat.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/cdio.h>
#include <unistd.h>
#include <grp.h>
#include <fcntl.h>
#include <libutil.h>
#define CD9660
#include <sys/mount.h>
#include <isofs/cd9660/cd9660_mount.h>
#undef CD9660
static Boolean cdromMounted;
static Boolean previouslyMounted; /* Was the disc already mounted? */
static char mountpoint[MAXPATHLEN] = "/dist";
int CDROMInitQuiet;
static void mediaEjectCDROM(Device *dev);
static properties
read_props(char *name)
{
int fd;
properties n;
fd = open(name, O_RDONLY);
if (fd == -1)
return NULL;
n = properties_read(fd);
close(fd);
return n;
}
Boolean
mediaInitCDROM(Device *dev)
{
struct iso_args args;
properties cd_attr = NULL;
char *cp = NULL;
Boolean readInfo = TRUE;
static Boolean bogusCDOK = FALSE;
int err;
if (cdromMounted)
return TRUE;
Mkdir(mountpoint);
bzero(&args, sizeof(args));
args.fspec = dev->devname;
args.flags = 0;
err = mount("cd9660", mountpoint, MNT_RDONLY, (caddr_t) &args);
/* If disc inserted too recently first access generates EIO, try again */
if (err == -1 && errno == EIO)
err = mount("cd9660", mountpoint, MNT_RDONLY, (caddr_t) &args);
if (err == -1) {
if (errno == EINVAL) {
msgConfirm("The disc in your drive looks more like an Audio disc than a FreeBSD release.");
return FALSE;
}
if (errno == EBUSY) {
/* Perhaps the CDROM drive is already mounted as /cdrom */
if (file_readable("/cdrom/cdrom.inf")) {
previouslyMounted = TRUE;
strlcpy(mountpoint, "/cdrom", 7);
errno = 0;
}
}
if (errno) {
if (!CDROMInitQuiet)
msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname,
mountpoint, strerror(errno), errno);
return FALSE;
}
}
cdromMounted = TRUE;
if (!file_readable(string_concat(mountpoint, "/cdrom.inf")) && !bogusCDOK) {
if (msgYesNo("Warning: The disc currently in the drive is either not a FreeBSD\n"
"disc or it is an older (pre 2.1.5) FreeBSD CD which does not\n"
"have a version number on it. Do you wish to use this disc anyway?") != 0) {
if (!previouslyMounted)
unmount(mountpoint, MNT_FORCE);
cdromMounted = FALSE;
return FALSE;
}
else {
readInfo = FALSE;
bogusCDOK = TRUE;
}
}
if (readInfo) {
if (!(cd_attr = read_props(string_concat(mountpoint, "/cdrom.inf")))
|| !(cp = property_find(cd_attr, "CD_VERSION"))) {
msgConfirm("Unable to find a %s/cdrom.inf file.\n"
"Either this is not a FreeBSD disc, there is a problem with\n"
"the CDROM driver or something is wrong with your hardware.\n"
"Please fix this problem (check the console logs on VTY2) and\n"
"try again.", mountpoint);
}
else {
if (variable_cmp(VAR_RELNAME, cp) &&
variable_cmp(VAR_RELNAME, "any") &&
strcmp(cp, "any") &&
!bogusCDOK) {
msgConfirm("Warning: The version of the FreeBSD disc currently in the drive\n"
"(%s) does not match the version of the boot floppy\n"
"(%s).\n\n"
"If this is intentional, to avoid this message in the future\n"
"please visit the Options editor to set the boot floppy version\n"
"string to match that of the disc before selecting it as your\n"
"installation media.", cp, variable_get(VAR_RELNAME));
if (msgYesNo("Would you like to try and use this disc anyway?") != 0) {
if (!previouslyMounted)
unmount(mountpoint, MNT_FORCE);
cdromMounted = FALSE;
properties_free(cd_attr);
return FALSE;
}
else
bogusCDOK = TRUE;
}
if ((cp = property_find(cd_attr, "CD_MACHINE_ARCH")) != NULL) {
if (strcmp(cp, "any") &&
#if defined(PC98)
strcmp(cp, "pc98")) {
#elif defined(__sparc64__)
strcmp(cp, "sparc64")) {
#else
strcmp(cp, "x86")) {
#endif
msgConfirm("Fatal: The FreeBSD install CD/DVD currently in the drive\n"
"is for the %s architecture, not the machine you're using.\n\n"
"Please use the correct installation CD/DVD for your machine type.", cp);
if (!previouslyMounted)
unmount(mountpoint, MNT_FORCE);
cdromMounted = FALSE;
properties_free(cd_attr);
return FALSE;
}
}
if ((cp = property_find(cd_attr, "CD_VOLUME")) != NULL) {
dev->volume = atoi(cp);
/* XXX - Sanity check the volume here? */
msgDebug("CD Volume %d initialized!\n", dev->volume);
} else {
dev->volume = 0;
}
}
}
if (cd_attr)
properties_free(cd_attr);
return TRUE;
}
FILE *
mediaGetCDROM(Device *dev, char *file, Boolean probe)
{
return mediaGenericGet(mountpoint, file);
}
void
mediaShutdownCDROM(Device *dev)
{
if (!cdromMounted)
return;
if (previouslyMounted) {
cdromMounted = FALSE;
return;
}
if (unmount(mountpoint, MNT_FORCE) != 0)
msgConfirm("Could not unmount the CDROM/DVD from %s: %s", mountpoint, strerror(errno));
else
cdromMounted = FALSE;
mediaEjectCDROM(dev);
}
static void
mediaEjectCDROM(Device *dev)
{
int fd = -1;
msgDebug("Ejecting CDROM/DVD at %s", dev->devname);
fd = open(dev->devname, O_RDONLY);
if (fd < 0)
msgDebug("Could not eject the CDROM/DVD from %s: %s", dev->devname, strerror(errno));
else {
ioctl(fd, CDIOCALLOW);
ioctl(fd, CDIOCEJECT);
close(fd);
}
}

View File

@ -1,184 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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"
#define MAX_NUM_COMMANDS 10
typedef struct {
char key[FILENAME_MAX];
struct {
enum { CMD_SHELL, CMD_FUNCTION } type;
void *ptr, *data;
} cmds[MAX_NUM_COMMANDS];
int ncmds;
} Command;
#define MAX_CMDS 200
static Command *commandStack[MAX_CMDS];
int numCommands;
/* Nuke the command stack */
void
command_clear(void)
{
int i, j;
for (i = 0; i < numCommands; i++)
for (j = 0; j < commandStack[i]->ncmds; j++)
if (commandStack[i]->cmds[j].type == CMD_SHELL)
free(commandStack[i]->cmds[j].ptr);
free(commandStack[i]);
numCommands = 0;
}
static void
addit(char *key, int type, void *cmd, void *data)
{
int i;
/* First, look for the key already present and add a command to it if found */
for (i = 0; i < numCommands; i++) {
if (!strcmp(commandStack[i]->key, key)) {
if (commandStack[i]->ncmds == MAX_NUM_COMMANDS)
msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key);
commandStack[i]->cmds[commandStack[i]->ncmds].type = type;
commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd;
commandStack[i]->cmds[commandStack[i]->ncmds].data = data;
++(commandStack[i]->ncmds);
return;
}
}
if (numCommands == MAX_CMDS)
msgFatal("More than %d commands accumulated??", MAX_CMDS);
/* If we fell to here, it's a new key */
commandStack[numCommands] = safe_malloc(sizeof(Command));
strcpy(commandStack[numCommands]->key, key);
commandStack[numCommands]->ncmds = 1;
commandStack[numCommands]->cmds[0].type = type;
commandStack[numCommands]->cmds[0].ptr = cmd;
commandStack[numCommands]->cmds[0].data = data;
++numCommands;
}
/* Add a shell command under a given key */
void
command_shell_add(char *key, char *fmt, ...)
{
va_list args;
char *cmd;
cmd = (char *)safe_malloc(256);
va_start(args, fmt);
vsnprintf(cmd, 256, fmt, args);
va_end(args);
addit(key, CMD_SHELL, cmd, NULL);
}
/* Add a shell command under a given key */
void
command_func_add(char *key, commandFunc func, void *data)
{
addit(key, CMD_FUNCTION, func, data);
}
static int
sort_compare(Command *p1, Command *p2)
{
if (!p1 && !p2)
return 0;
else if (!p1 && p2) /* NULL has a "greater" value for commands */
return 1;
else if (p1 && !p2)
return -1;
else
return strcmp(p1->key, p2->key);
}
void
command_sort(void)
{
int i, j;
commandStack[numCommands] = NULL;
/* Just do a crude bubble sort since the list is small */
for (i = 0; i < numCommands; i++) {
for (j = 0; j < numCommands; j++) {
if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) {
Command *tmp = commandStack[j];
commandStack[j] = commandStack[j + 1];
commandStack[j + 1] = tmp;
}
}
}
}
/* Run all accumulated commands in sorted order */
void
command_execute(void)
{
int i, j, ret;
commandFunc func;
for (i = 0; i < numCommands; i++) {
for (j = 0; j < commandStack[i]->ncmds; j++) {
/* If it's a shell command, run system on it */
if (commandStack[i]->cmds[j].type == CMD_SHELL) {
msgNotify("Doing %s", (char *)commandStack[i]->cmds[j].ptr);
ret = vsystem("%s", (char *)commandStack[i]->cmds[j].ptr);
if (isDebug())
msgDebug("Command `%s' returns status %d\n",
(char *)commandStack[i]->cmds[j].ptr, ret);
}
else {
/* It's a function pointer - call it with the key and
the data */
func = (commandFunc)commandStack[i]->cmds[j].ptr;
if (isDebug())
msgDebug("%p: Execute(%s, %s)\n",
func, commandStack[i]->key,
(char *)commandStack[i]->cmds[j].data);
ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data);
if (isDebug())
msgDebug("Function @ %p returns status %d\n",
commandStack[i]->cmds[j].ptr, ret);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,590 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/fcntl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <libdisk.h>
static Device *Devices[DEV_MAX];
static int numDevs;
#define DEVICE_ENTRY(type, name, descr, max) { type, name, descr, max }
#define CDROM(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_CDROM, name, descr, max)
#define DISK(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_DISK, name, descr, max)
#define FLOPPY(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_FLOPPY, name, descr, max)
#define NETWORK(name, descr) \
DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, 0)
#define SERIAL(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, max)
#define USB(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_USB, name, descr, max)
static struct _devname {
DeviceType type;
char *name;
char *description;
int max;
} device_names[] = {
CDROM("cd%d", "SCSI CDROM drive", 4),
CDROM("mcd%d", "Mitsumi (old model) CDROM drive", 4),
CDROM("scd%d", "Sony CDROM drive - CDU31/33A type", 4),
CDROM("acd%d", "ATAPI/IDE CDROM", 4),
DISK("da%d", "SCSI disk device", 16),
DISK("ad%d", "ATA/IDE disk device", 16),
DISK("ada%d", "SATA disk device", 16),
DISK("ar%d", "ATA/IDE RAID device", 16),
DISK("afd%d", "ATAPI/IDE floppy device", 4),
DISK("mlxd%d", "Mylex RAID disk", 4),
DISK("amrd%d", "AMI MegaRAID drive", 4),
DISK("idad%d", "Compaq RAID array", 4),
DISK("twed%d", "3ware ATA RAID array", 4),
DISK("aacd%d", "Adaptec FSA RAID array", 4),
DISK("ipsd%d", "IBM ServeRAID RAID array", 4),
DISK("mfid%d", "LSI MegaRAID SAS array", 4),
FLOPPY("fd%d", "floppy drive unit A", 4),
SERIAL("cuau%d", "%s on device %s (COM%d)", 16),
USB("da%da", "USB Mass Storage Device", 16),
NETWORK("ae", "Attansic/Atheros L2 Fast Ethernet"),
NETWORK("age", "Attansic/Atheros L1 Gigabit Ethernet"),
NETWORK("alc", "Atheros AR8131/AR8132 PCIe Ethernet"),
NETWORK("ale", "Atheros AR8121/AR8113/AR8114 PCIe Ethernet"),
NETWORK("an", "Aironet 4500/4800 802.11 wireless adapter"),
NETWORK("ath", "Atheros IEEE 802.11 wireless adapter"),
NETWORK("aue", "ADMtek USB Ethernet adapter"),
NETWORK("axe", "ASIX Electronics USB Ethernet adapter"),
NETWORK("bce", "Broadcom NetXtreme II Gigabit Ethernet card"),
NETWORK("bfe", "Broadcom BCM440x PCI Ethernet card"),
NETWORK("bge", "Broadcom BCM570x PCI Gigabit Ethernet card"),
NETWORK("bm", "Apple BMAC Built-in Ethernet"),
NETWORK("bwn", "Broadcom BCM43xx IEEE 802.11 wireless adapter"),
NETWORK("bxe", "Broadcom NetXtreme II 10Gb Ethernet card"),
NETWORK("cas", "Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet"),
NETWORK("cue", "CATC USB Ethernet adapter"),
NETWORK("cxgb", "Chelsio T3 10Gb Ethernet card"),
NETWORK("cxgbe", "Chelsio T4 10Gb Ethernet card"),
NETWORK("fpa", "DEC DEFPA PCI FDDI card"),
NETWORK("sr", "SDL T1/E1 sync serial PCI card"),
NETWORK("cc3i", "SDL HSSI sync serial PCI card"),
NETWORK("en", "Efficient Networks ATM PCI card"),
NETWORK("dc", "DEC/Intel 21143 (and clones) PCI Fast Ethernet card"),
NETWORK("de", "DEC DE435 PCI NIC or other DC21040-AA based card"),
NETWORK("fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card"),
NETWORK("ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA"),
NETWORK("ep", "3Com 3C509 Ethernet card/3C589 PCMCIA"),
NETWORK("em", "Intel(R) PRO/1000 Ethernet card"),
NETWORK("et", "Agere ET1310 based PCI Express Gigabit Ethernet card"),
NETWORK("ex", "Intel EtherExpress Pro/10 Ethernet card"),
NETWORK("fe", "Fujitsu MB86960A/MB86965A Ethernet card"),
NETWORK("gem", "Apple GMAC or Sun ERI/GEM Ethernet adapter"),
NETWORK("hme", "Sun HME (Happy Meal Ethernet) Ethernet adapter"),
NETWORK("ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210"),
NETWORK("igb", "Intel(R) PRO/1000 PCI Express Gigabit Ethernet card"),
NETWORK("ipw", "Intel PRO/Wireless 2100 IEEE 802.11 adapter"),
NETWORK("iwi", "Intel PRO/Wireless 2200BG/2225BG/2915ABG adapter"),
NETWORK("iwn", "Intel Wireless WiFi Link 4965AGN IEEE 802.11n adapter"),
NETWORK("ixgb", "Intel(R) PRO/10Gb Ethernet card"),
NETWORK("ixgbe", "Intel(R) PRO/10Gb Ethernet card"),
NETWORK("jme", "JMicron JMC250 Gigabit/JMC260 Fast Ethernet"),
NETWORK("kue", "Kawasaki LSI USB Ethernet adapter"),
NETWORK("le", "AMD Am7900 LANCE or Am79C9xx PCnet Ethernet adapter"),
NETWORK("lge", "Level 1 LXT1001 Gigabit Ethernet card"),
NETWORK("malo", "Marvell Libertas 88W8335 802.11 wireless adapter"),
NETWORK("msk", "Marvell/SysKonnect Yukon II Gigabit Ethernet"),
NETWORK("mxge", "Myricom Myri10GE 10Gb Ethernet card"),
NETWORK("nfe", "NVIDIA nForce MCP Ethernet"),
NETWORK("nge", "NatSemi PCI Gigabit Ethernet card"),
NETWORK("nve", "NVIDIA nForce MCP Ethernet"),
NETWORK("nxge", "Neterion Xframe 10GbE Server/Storage adapter"),
NETWORK("pcn", "AMD Am79c79x PCI Ethernet card"),
NETWORK("ral", "Ralink Technology IEEE 802.11 wireless adapter"),
NETWORK("ray", "Raytheon Raylink 802.11 wireless adapter"),
NETWORK("re", "RealTek 8139C+/8169/8169S/8110S PCI Ethernet card"),
NETWORK("rl", "RealTek 8129/8139 PCI Ethernet card"),
NETWORK("rue", "RealTek USB Ethernet card"),
NETWORK("rum", "Ralink Technology USB IEEE 802.11 wireless adapter"),
NETWORK("sf", "Adaptec AIC-6915 PCI Ethernet card"),
NETWORK("sge", "Silicon Integrated Systems SiS190/191 Ethernet"),
NETWORK("sis", "SiS 900/SiS 7016 PCI Ethernet card"),
#ifdef PC98
NETWORK("snc", "SONIC Ethernet card"),
#endif
NETWORK("sn", "SMC/Megahertz Ethernet card"),
NETWORK("ste", "Sundance ST201 PCI Ethernet card"),
NETWORK("stge", "Sundance/Tamarack TC9021 Gigabit Ethernet"),
NETWORK("sk", "SysKonnect PCI Gigabit Ethernet card"),
NETWORK("tx", "SMC 9432TX Ethernet card"),
NETWORK("txp", "3Com 3cR990 Ethernet card"),
NETWORK("ti", "Alteon Networks PCI Gigabit Ethernet card"),
NETWORK("tl", "Texas Instruments ThunderLAN PCI Ethernet card"),
NETWORK("uath", "Atheros AR5005UG and AR5005UX USB wireless adapter"),
NETWORK("upgt", "Conexant/Intersil PrismGT USB wireless adapter"),
NETWORK("ural", "Ralink Technology RT2500USB 802.11 wireless adapter"),
NETWORK("urtw", "Realtek 8187L USB wireless adapter"),
NETWORK("vge", "VIA VT612x PCI Gigabit Ethernet card"),
NETWORK("vr", "VIA VT3043/VT86C100A Rhine PCI Ethernet card"),
NETWORK("vte", "DM&P Vortex86 RDC R6040 Fast Ethernet"),
NETWORK("vlan", "IEEE 802.1Q VLAN network interface"),
NETWORK("vx", "3COM 3c590 / 3c595 Ethernet card"),
NETWORK("wb", "Winbond W89C840F PCI Ethernet card"),
NETWORK("wi", "Lucent WaveLAN/IEEE 802.11 wireless adapter"),
NETWORK("wpi", "Intel 3945ABG IEEE 802.11 wireless adapter"),
NETWORK("xe", "Xircom/Intel EtherExpress Pro100/16 Ethernet card"),
NETWORK("xl", "3COM 3c90x / 3c90xB PCI Ethernet card"),
NETWORK("zyd", "ZyDAS ZD1211/ZD1211B USB 802.11 wireless adapter"),
NETWORK("fwe", "FireWire Ethernet emulation"),
NETWORK("fwip", "IP over FireWire"),
NETWORK("plip", "Parallel Port IP (PLIP) peer connection"),
NETWORK("lo", "Loop-back (local) network interface"),
NETWORK("disc", "Software discard network interface"),
{ 0, NULL, NULL, 0 }
};
Device *
new_device(char *name)
{
Device *dev;
dev = safe_malloc(sizeof(Device));
bzero(dev, sizeof(Device));
if (name)
SAFE_STRCPY(dev->name, name);
return dev;
}
/* Stubs for unimplemented strategy routines */
Boolean
dummyInit(Device *dev)
{
return TRUE;
}
FILE *
dummyGet(Device *dev, char *dist, Boolean probe)
{
return NULL;
}
void
dummyShutdown(Device *dev)
{
return;
}
static int
deviceTry(struct _devname dev, char *try, int i)
{
int fd;
char unit[80];
snprintf(unit, sizeof unit, dev.name, i);
snprintf(try, FILENAME_MAX, "/dev/%s", unit);
if (isDebug())
msgDebug("deviceTry: attempting to open %s\n", try);
fd = open(try, O_RDONLY);
if (fd >= 0) {
if (isDebug())
msgDebug("deviceTry: open of %s succeeded on first try.\n", try);
} else {
if (isDebug())
msgDebug("deviceTry: open of %s failed.\n", try);
}
return fd;
}
/* Register a new device in the devices array */
Device *
deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
void (*shutdown)(Device *), void *private)
{
Device *newdev = NULL;
if (numDevs == DEV_MAX)
msgFatal("Too many devices found!");
else {
newdev = new_device(name);
newdev->description = desc;
newdev->devname = devname;
newdev->type = type;
newdev->enabled = enabled;
newdev->init = init ? init : dummyInit;
newdev->get = get ? get : dummyGet;
newdev->shutdown = shutdown ? shutdown : dummyShutdown;
newdev->private = private;
Devices[numDevs] = newdev;
Devices[++numDevs] = NULL;
}
return newdev;
}
/* Reset the registered device chain */
void
deviceReset(void)
{
int i;
for (i = 0; i < numDevs; i++) {
DEVICE_SHUTDOWN(Devices[i]);
/* XXX this potentially leaks Devices[i]->private if it's being
* used to point to something dynamic, but you're not supposed
* to call this routine at such times that some open instance
* has its private ptr pointing somewhere anyway. XXX
*/
free(Devices[i]);
}
Devices[numDevs = 0] = NULL;
}
/* Get all device information for devices we have attached */
void
deviceGetAll(void)
{
int i, j, fd, s;
struct ifconf ifc;
struct ifreq *ifptr, *end;
int ifflags;
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
char **names;
msgNotify("Probing devices, please wait (this can take a while)...");
/* First go for the network interfaces. Stolen shamelessly from ifconfig! */
memset(&ifc, 0, sizeof(ifc));
memset(buffer, 0, INTERFACE_MAX * sizeof(struct ifreq));
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto skipif; /* Jump over network iface probing */
if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0)
goto skipif; /* Jump over network iface probing */
close(s);
ifflags = ifc.ifc_req->ifr_flags;
end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) {
char *descr;
/* If it's not a link entry, forget it */
if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK)
goto loopend;
/* Eliminate network devices that don't make sense */
if (!strncmp(ifptr->ifr_name, "lo", 2))
goto loopend;
/* Try and find its description */
for (i = 0, descr = NULL; device_names[i].name; i++) {
int len = strlen(device_names[i].name);
if (!ifptr->ifr_name || !ifptr->ifr_name[0])
continue;
else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
descr = device_names[i].description;
break;
}
}
if (!descr)
descr = "<unknown network interface type>";
deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
if (isDebug())
msgDebug("Found a network device named %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
continue;
loopend:
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
close(s);
}
skipif:
/* Next, try to find all the types of devices one might need
* during the second stage of the installation.
*/
for (i = 0; device_names[i].name; i++) {
for (j = 0; j < device_names[i].max; j++) {
char try[FILENAME_MAX];
switch(device_names[i].type) {
case DEVICE_TYPE_CDROM:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
char n[BUFSIZ];
if (fd >= 0) close(fd);
snprintf(n, sizeof n, device_names[i].name, j);
deviceRegister(n, device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
mediaShutdownCDROM, NULL);
if (isDebug())
msgDebug("Found a CDROM device for %s\n", try);
}
break;
case DEVICE_TYPE_DISK:
/* nothing to do */
break;
case DEVICE_TYPE_FLOPPY:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0) {
char n[BUFSIZ];
close(fd);
snprintf(n, sizeof n, device_names[i].name, j);
deviceRegister(n, device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
mediaShutdownFloppy, NULL);
if (isDebug())
msgDebug("Found a floppy device for %s\n", try);
}
break;
case DEVICE_TYPE_USB:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0) {
char n[BUFSIZ];
close(fd);
snprintf(n, sizeof(n), device_names[i].name, j);
deviceRegister(n, device_names[i].description,
strdup(try), DEVICE_TYPE_USB, TRUE, mediaInitUSB,
mediaGetUSB, mediaShutdownUSB, NULL);
if (isDebug())
msgDebug("Found a USB disk for %s\n", try);
}
break;
default:
break;
}
}
}
/* Finally, go get the disks and look for partitions to register */
if ((names = Disk_Names()) != NULL) {
int i;
for (i = 0; names[i]; i++) {
Chunk *c1;
Disk *d;
/* Ignore memory disks */
if (!strncmp(names[i], "md", 2))
continue;
/*
* XXX
* Due to unknown reasons, Disk_Names() returns SCSI CDROM as a
* valid disk. This is main reason why sysinstall presents SCSI
* CDROM to available disks in Fdisk/Label menu. In addition,
* adding a blank SCSI CDROM to the menu generates floating point
* exception in sparc64. Disk_Names() just extracts sysctl
* "kern.disks". Why GEOM treats SCSI CDROM as a disk is beyond
* me and that should be investigated.
* For temporary workaround, ignore SCSI CDROM device.
*/
if (!strncmp(names[i], "cd", 2))
continue;
d = Open_Disk(names[i]);
if (!d) {
msgDebug("Unable to open disk %s\n", names[i]);
continue;
}
deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
dummyInit, dummyGet, dummyShutdown, d);
if (isDebug())
msgDebug("Found a disk device named %s\n", names[i]);
/* Look for existing DOS partitions to register as "DOS media devices"
* XXX: libdisks handling of extended partitions is too
* simplistic - it does not handle them containing (for
* example) UFS partitions
*/
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == fat || c1->type == efi || c1->type == extended) {
Device *dev;
char devname[80];
/* Got one! */
snprintf(devname, sizeof devname, "/dev/%s", c1->name);
dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
dev->private = c1;
if (isDebug())
msgDebug("Found a DOS partition %s\n", c1->name);
} else if (c1->type == freebsd) {
Device *dev;
char devname[80];
Chunk *c2;
for (c2 = c1->part; c2; c2 = c2->next) {
if (c2->type != part || c2->subtype != 7)
continue;
/* Got one! */
snprintf(devname, sizeof devname, "/dev/%s", c1->name);
dev = deviceRegister(c2->name, c2->name, strdup(devname), DEVICE_TYPE_UFS, TRUE,
mediaInitUFS, mediaGetUFS, mediaShutdownUFS, NULL);
dev->private = c2;
if (isDebug())
msgDebug("Found a UFS sub-partition %s\n", c2->name);
}
}
}
}
free(names);
}
dialog_clear_norefresh();
}
/* Rescan all devices, after closing previous set - convenience function */
void
deviceRescan(void)
{
deviceReset();
deviceGetAll();
}
/*
* Find all devices that match the criteria, allowing "wildcarding" as well
* by allowing NULL or ANY values to match all. The array returned is static
* and may be used until the next invocation of deviceFind().
*/
Device **
deviceFind(char *name, DeviceType class)
{
static Device *found[DEV_MAX];
int i, j;
j = 0;
for (i = 0; i < numDevs; i++) {
if ((!name || !strcmp(Devices[i]->name, name))
&& (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
found[j++] = Devices[i];
}
found[j] = NULL;
return j ? found : NULL;
}
Device **
deviceFindDescr(char *name, char *desc, DeviceType class)
{
static Device *found[DEV_MAX];
int i, j;
j = 0;
for (i = 0; i < numDevs; i++) {
if ((!name || !strcmp(Devices[i]->name, name)) &&
(!desc || !strcmp(Devices[i]->description, desc)) &&
(class == DEVICE_TYPE_ANY || class == Devices[i]->type))
found[j++] = Devices[i];
}
found[j] = NULL;
return j ? found : NULL;
}
int
deviceCount(Device **devs)
{
int i;
if (!devs)
return 0;
for (i = 0; devs[i]; i++);
return i;
}
/*
* Create a menu listing all the devices of a certain type in the system.
* The passed-in menu is expected to be a "prototype" from which the new
* menu is cloned.
*/
DMenu *
deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d))
{
Device **devs;
int numdevs;
DMenu *tmp = NULL;
int i, j;
devs = deviceFind(NULL, type);
numdevs = deviceCount(devs);
if (!numdevs)
return NULL;
tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1)));
bcopy(menu, tmp, sizeof(DMenu));
for (i = 0; devs[i]; i++) {
tmp->items[i].prompt = devs[i]->name;
for (j = 0; j < numDevs; j++) {
if (devs[i] == Devices[j]) {
tmp->items[i].title = Devices[j]->description;
break;
}
}
if (j == numDevs)
tmp->items[i].title = "<unknown device type>";
tmp->items[i].fire = hook;
tmp->items[i].checked = check;
}
tmp->items[i].title = NULL;
return tmp;
}

View File

@ -1,158 +0,0 @@
/*
* $FreeBSD$
*
* Copyright (c) 1999
* C. Stone. 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 C. STONE ``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 C STONE OR HIS BODILY PARASITES 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 BY THE VOICES IN YOUR HEAD BEFOREHAND.
*
*/
#include "sysinstall.h"
#include <ctype.h>
int
dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver,
char *ipaddr, char *gateway, char *netmask)
{
char tempbuf[1024];
char optbuf[1024], *optname = NULL;
char *tptr;
int endedflag = 0;
int leaseflag = 0;
FILE *fp;
enum { P_NOSTMT, P_NOSTMT1, P_STMT, P_STMTLINE } state;
if ((fp = fopen(file, "r")) == NULL) {
msgDebug("error opening file %s: %s\n", file, strerror(errno));
return -1;
}
state = P_NOSTMT;
while (fscanf(fp, "%1023s", tempbuf) > 0) {
switch (state) {
case P_NOSTMT:
state = P_NOSTMT1;
if (!strncasecmp(tempbuf, "lease", 5)) {
if (!leaseflag)
leaseflag = 1;
else {
fclose(fp);
return 0;
}
}
break;
case P_NOSTMT1:
if (tempbuf[0] != '{') {
msgWarn("dhcpParseLeases: '{' expected");
fclose(fp);
return -1;
}
state = P_STMT;
break;
case P_STMT:
if (!strncasecmp("option", tempbuf, 6))
continue;
if (tempbuf[0] == '}') {
state = P_NOSTMT;
leaseflag = 0;
continue;
}
if (!leaseflag)
break;
if (tempbuf[0] == ';') { /* play it safe */
state = P_STMT;
continue;
}
if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
*tptr = '\0';
endedflag = 1;
}
if (!isalnum(tempbuf[0])) {
msgWarn("dhcpParseLeases: bad option");
fclose(fp);
return -1;
}
if (optname)
free(optname);
optname = strdup(tempbuf);
if (endedflag) {
state = P_STMT;
endedflag = 0;
continue;
}
state = P_STMTLINE;
break;
case P_STMTLINE:
if (tempbuf[0] == ';') {
state = P_STMT;
continue;
}
if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
*tptr = '\0';
endedflag = 1;
}
if (tempbuf[0] == '"') {
if (sscanf(tempbuf, "\"%[^\" ]\"", optbuf) < 1) {
msgWarn("dhcpParseLeases: bad option value");
fclose(fp);
return -1;
}
}
else
strcpy(optbuf, tempbuf);
if (!strcasecmp("host-name", optname)) {
strcpy(hostname, optbuf);
} else if (!strcasecmp("domain-name", optname)) {
strcpy(domain, optbuf);
} else if (!strcasecmp("fixed-address", optname)) {
strcpy(ipaddr, optbuf);
} else if (!strcasecmp("routers", optname)) {
if((tptr = (char *)strchr(optbuf, ',')))
*tptr = '\0';
strcpy(gateway, optbuf);
} else if (!strcasecmp("subnet-mask", optname)) {
strcpy(netmask, optbuf);
} else if (!strcasecmp("domain-name-servers", optname)) {
/* <jkh> ...one value per property */
if((tptr = (char *)strchr(optbuf, ',')))
*tptr = '\0';
strcpy(nameserver, optbuf);
}
if (endedflag) {
state = P_STMT;
endedflag = 0;
continue;
}
break;
}
}
fclose(fp);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,653 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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 <ctype.h>
#include <errno.h>
#include <sys/signal.h>
#include <sys/fcntl.h>
#include "list.h"
static int dispatch_shutdown(dialogMenuItem *unused);
static int dispatch_systemExecute(dialogMenuItem *unused);
static int dispatch_msgConfirm(dialogMenuItem *unused);
static int dispatch_mediaOpen(dialogMenuItem *unused);
static int dispatch_mediaClose(dialogMenuItem *unused);
static int cfgModuleFire(dialogMenuItem *self);
static struct _word {
char *name;
int (*handler)(dialogMenuItem *self);
} resWords[] = {
{ "configAnonFTP", configAnonFTP },
{ "configRouter", configRouter },
{ "configInetd", configInetd },
{ "configNFSServer", configNFSServer },
{ "configNTP", configNTP },
{ "configPCNFSD", configPCNFSD },
{ "configPackages", configPackages },
{ "configUsers", configUsers },
#ifdef WITH_SLICES
{ "diskPartitionEditor", diskPartitionEditor },
#endif
{ "diskPartitionWrite", diskPartitionWrite },
{ "diskLabelEditor", diskLabelEditor },
{ "diskLabelCommit", diskLabelCommit },
{ "distReset", distReset },
{ "distSetCustom", distSetCustom },
{ "distUnsetCustom", distUnsetCustom },
{ "distSetDeveloper", distSetDeveloper },
{ "distSetKernDeveloper", distSetKernDeveloper },
{ "distSetUser", distSetUser },
{ "distSetMinimum", distSetMinimum },
{ "distSetEverything", distSetEverything },
{ "distSetSrc", distSetSrc },
{ "distExtractAll", distExtractAll },
{ "docBrowser", docBrowser },
{ "docShowDocument", docShowDocument },
{ "installCommit", installCommit },
{ "installExpress", installExpress },
{ "installStandard", installStandard },
{ "installUpgrade", installUpgrade },
{ "installFixupBase", installFixupBase },
{ "installFixitHoloShell", installFixitHoloShell },
{ "installFixitCDROM", installFixitCDROM },
{ "installFixitUSB", installFixitUSB },
{ "installFixitFloppy", installFixitFloppy },
{ "installFilesystems", installFilesystems },
{ "installVarDefaults", installVarDefaults },
{ "loadConfig", dispatch_load_file },
{ "loadFloppyConfig", dispatch_load_floppy },
{ "loadCDROMConfig", dispatch_load_cdrom },
{ "mediaOpen", dispatch_mediaOpen },
{ "mediaClose", dispatch_mediaClose },
{ "mediaSetCDROM", mediaSetCDROM },
{ "mediaSetFloppy", mediaSetFloppy },
{ "mediaSetUSB", mediaSetUSB },
{ "mediaSetDOS", mediaSetDOS },
{ "mediaSetFTP", mediaSetFTP },
{ "mediaSetFTPActive", mediaSetFTPActive },
{ "mediaSetFTPPassive", mediaSetFTPPassive },
{ "mediaSetHTTP", mediaSetHTTP },
{ "mediaSetUFS", mediaSetUFS },
{ "mediaSetNFS", mediaSetNFS },
{ "mediaSetFTPUserPass", mediaSetFTPUserPass },
{ "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity },
{ "mediaGetType", mediaGetType },
{ "msgConfirm", dispatch_msgConfirm },
{ "optionsEditor", optionsEditor },
{ "packageAdd", packageAdd },
{ "addGroup", userAddGroup },
{ "addUser", userAddUser },
{ "shutdown", dispatch_shutdown },
{ "system", dispatch_systemExecute },
{ "dumpVariables", dump_variables },
{ "tcpMenuSelect", tcpMenuSelect },
{ NULL, NULL },
};
/*
* Helper routines for buffering data.
*
* We read an entire configuration into memory before executing it
* so that we are truely standalone and can do things like nuke the
* file or disk we're working on.
*/
typedef struct command_buffer_ {
qelement queue;
char * string;
} command_buffer;
static void
dispatch_free_command(command_buffer *item)
{
if (item != NULL) {
REMQUE(item);
free(item->string);
item->string = NULL;
}
free(item);
}
static void
dispatch_free_all(qelement *head)
{
command_buffer *item;
while (!EMPTYQUE(*head)) {
item = (command_buffer *) head->q_forw;
dispatch_free_command(item);
}
}
static command_buffer *
dispatch_add_command(qelement *head, char *string)
{
command_buffer *new = NULL;
new = malloc(sizeof(command_buffer));
if (new != NULL) {
new->string = strdup(string);
/*
* We failed to copy `string'; clean up the allocated
* resources.
*/
if (new->string == NULL) {
free(new);
new = NULL;
} else {
INSQUEUE(new, head->q_back);
}
}
return new;
}
/*
* Command processing
*/
/* Just convenience */
static int
dispatch_shutdown(dialogMenuItem *unused)
{
systemShutdown(0);
return DITEM_FAILURE;
}
static int
dispatch_systemExecute(dialogMenuItem *unused)
{
char *cmd = variable_get(VAR_COMMAND);
if (cmd)
return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS;
else
msgDebug("_systemExecute: No command passed in `command' variable.\n");
return DITEM_FAILURE;
}
static int
dispatch_msgConfirm(dialogMenuItem *unused)
{
char *msg = variable_get(VAR_COMMAND);
if (msg) {
msgConfirm("%s", msg);
return DITEM_SUCCESS;
}
msgDebug("_msgConfirm: No message passed in `command' variable.\n");
return DITEM_FAILURE;
}
static int
dispatch_mediaOpen(dialogMenuItem *unused)
{
return mediaOpen();
}
static int
dispatch_mediaClose(dialogMenuItem *unused)
{
mediaClose();
return DITEM_SUCCESS;
}
static int
call_possible_resword(char *name, dialogMenuItem *value, int *status)
{
int i, rval;
rval = 0;
for (i = 0; resWords[i].name; i++) {
if (!strcmp(name, resWords[i].name)) {
*status = resWords[i].handler(value);
rval = 1;
break;
}
}
return rval;
}
/* For a given string, call it or spit out an undefined command diagnostic */
int
dispatchCommand(char *str)
{
int i;
char *cp;
if (!str || !*str) {
msgConfirm("Null or zero-length string passed to dispatchCommand");
return DITEM_FAILURE;
}
/* Fixup DOS abuse */
if ((cp = index(str, '\r')) != NULL)
*cp = '\0';
/* If it's got a `=' sign in there, assume it's a variable setting */
if (index(str, '=')) {
if (isDebug())
msgDebug("dispatch: setting variable `%s'\n", str);
variable_set(str, 0);
i = DITEM_SUCCESS;
}
else {
/* A command might be a pathname if it's encoded in argv[0], which
we also support */
if ((cp = rindex(str, '/')) != NULL)
str = cp + 1;
if (isDebug())
msgDebug("dispatch: calling resword `%s'\n", str);
if (!call_possible_resword(str, NULL, &i)) {
msgNotify("Warning: No such command ``%s''", str);
i = DITEM_FAILURE;
}
/*
* Allow a user to prefix a command with "noError" to cause
* us to ignore any errors for that one command.
*/
if (i != DITEM_SUCCESS && variable_get(VAR_NO_ERROR))
i = DITEM_SUCCESS;
variable_unset(VAR_NO_ERROR);
}
return i;
}
/*
* File processing
*/
static qelement *
dispatch_load_fp(FILE *fp)
{
qelement *head;
char buf[BUFSIZ], *cp;
head = malloc(sizeof(qelement));
if (!head)
return NULL;
INITQUE(*head);
while (fgets(buf, sizeof buf, fp)) {
/* Fix up DOS abuse */
if ((cp = index(buf, '\r')) != NULL)
*cp = '\0';
/* If it's got a new line, trim it */
if ((cp = index(buf, '\n')) != NULL)
*cp = '\0';
if (*buf == '\0' || *buf == '#')
continue;
if (!dispatch_add_command(head, buf))
return NULL;
}
return head;
}
static int
dispatch_execute(qelement *head)
{
int result = DITEM_SUCCESS;
command_buffer *item;
char *old_interactive;
if (!head)
return result | DITEM_FAILURE;
old_interactive = variable_get(VAR_NONINTERACTIVE);
if (old_interactive)
old_interactive = strdup(old_interactive); /* save copy */
/* Hint to others that we're running from a script, should they care */
variable_set2(VAR_NONINTERACTIVE, "yes", 0);
while (!EMPTYQUE(*head)) {
item = (command_buffer *) head->q_forw;
if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) {
msgConfirm("Command `%s' failed - rest of script aborted.\n",
item->string);
result |= DITEM_FAILURE;
break;
}
dispatch_free_command(item);
}
dispatch_free_all(head);
if (!old_interactive)
variable_unset(VAR_NONINTERACTIVE);
else {
variable_set2(VAR_NONINTERACTIVE, old_interactive, 0);
free(old_interactive);
}
return result;
}
int
dispatch_load_file_int(int quiet)
{
FILE *fp;
char *cp;
int i;
qelement *list;
static const char *names[] = {
"install.cfg",
"/stand/install.cfg",
"/tmp/install.cfg",
NULL
};
fp = NULL;
cp = variable_get(VAR_CONFIG_FILE);
if (!cp) {
for (i = 0; names[i]; i++)
if ((fp = fopen(names[i], "r")) != NULL)
break;
} else
fp = fopen(cp, "r");
if (!fp) {
if (!quiet)
msgConfirm("Unable to open %s: %s", cp, strerror(errno));
return DITEM_FAILURE;
}
list = dispatch_load_fp(fp);
fclose(fp);
return dispatch_execute(list);
}
int
dispatch_load_file(dialogMenuItem *self)
{
return dispatch_load_file_int(FALSE);
}
int
dispatch_load_floppy(dialogMenuItem *self)
{
int what = DITEM_SUCCESS;
extern char *distWanted;
char *cp;
FILE *fp;
qelement *list;
mediaClose();
cp = variable_get_value(VAR_INSTALL_CFG,
"Specify the name of a configuration file", 0);
if (!cp || !*cp) {
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
return what;
}
distWanted = cp;
/* Try to open the floppy drive */
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
msgConfirm("Unable to set media device to floppy.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
if (!DEVICE_INIT(mediaDevice)) {
msgConfirm("Unable to mount floppy filesystem.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
fp = DEVICE_GET(mediaDevice, cp, TRUE);
if (fp) {
list = dispatch_load_fp(fp);
fclose(fp);
mediaClose();
what |= dispatch_execute(list);
}
else {
if (!variable_get(VAR_NO_ERROR))
msgConfirm("Configuration file '%s' not found.", cp);
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
mediaClose();
}
return what;
}
int
dispatch_load_cdrom(dialogMenuItem *self)
{
int what = DITEM_SUCCESS;
extern char *distWanted;
char *cp;
FILE *fp;
qelement *list;
mediaClose();
cp = variable_get_value(VAR_INSTALL_CFG,
"Specify the name of a configuration file\n"
"residing on the CDROM.", 0);
if (!cp || !*cp) {
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
return what;
}
distWanted = cp;
/* Try to open the floppy drive */
if (DITEM_STATUS(mediaSetCDROM(NULL)) == DITEM_FAILURE) {
msgConfirm("Unable to set media device to CDROM.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
if (!DEVICE_INIT(mediaDevice)) {
msgConfirm("Unable to CDROM filesystem.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
fp = DEVICE_GET(mediaDevice, cp, TRUE);
if (fp) {
list = dispatch_load_fp(fp);
fclose(fp);
mediaClose();
what |= dispatch_execute(list);
}
else {
if (!variable_get(VAR_NO_ERROR))
msgConfirm("Configuration file '%s' not found.", cp);
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
mediaClose();
}
return what;
}
/*
* Create a menu based on available disk devices
*/
int
dispatch_load_menu(dialogMenuItem *self)
{
DMenu *menu;
Device **devlist;
char *err;
int what, i, j, msize, count;
DeviceType dtypes[] = {DEVICE_TYPE_FLOPPY, DEVICE_TYPE_CDROM,
DEVICE_TYPE_DOS, DEVICE_TYPE_UFS, DEVICE_TYPE_USB};
fprintf(stderr, "dispatch_load_menu called\n");
msize = sizeof(DMenu) + (sizeof(dialogMenuItem) * 2);
count = 0;
err = NULL;
what = DITEM_SUCCESS;
if ((menu = malloc(msize)) == NULL) {
err = "Failed to allocate memory for menu";
goto errout;
}
bcopy(&MenuConfig, menu, sizeof(DMenu));
bzero(&menu->items[count], sizeof(menu->items[0]));
menu->items[count].prompt = strdup("X Exit");
menu->items[count].title = strdup("Exit this menu (returning to previous)");
menu->items[count].fire = dmenuExit;
count++;
for (i = 0; i < sizeof(dtypes) / sizeof(dtypes[0]); i++) {
if ((devlist = deviceFind(NULL, dtypes[i])) == NULL) {
fprintf(stderr, "No devices found for type %d\n", dtypes[i]);
continue;
}
for (j = 0; devlist[j] != NULL; j++) {
fprintf(stderr, "device type %d device name %s\n", dtypes[i], devlist[j]->name);
msize += sizeof(dialogMenuItem);
if ((menu = realloc(menu, msize)) == NULL) {
err = "Failed to allocate memory for menu item";
goto errout;
}
bzero(&menu->items[count], sizeof(menu->items[0]));
menu->items[count].fire = cfgModuleFire;
menu->items[count].prompt = strdup(devlist[j]->name);
menu->items[count].title = strdup(devlist[j]->description);
/* XXX: dialog(3) sucks */
menu->items[count].aux = (long)devlist[j];
count++;
}
}
menu->items[count].prompt = NULL;
menu->items[count].title = NULL;
dmenuOpenSimple(menu, FALSE);
errout:
for (i = 0; i < count; i++) {
free(menu->items[i].prompt);
free(menu->items[i].title);
}
free(menu);
if (err != NULL) {
what |= DITEM_FAILURE;
if (!variable_get(VAR_NO_ERROR))
msgConfirm(err);
}
return (what);
}
static int
cfgModuleFire(dialogMenuItem *self) {
Device *d;
FILE *fp;
int what = DITEM_SUCCESS;
extern char *distWanted;
qelement *list;
char *cp;
d = (Device *)self->aux;
msgDebug("cfgModuleFire: User selected %s (%s)\n", self->prompt, d->devname);
mediaClose();
cp = variable_get_value(VAR_INSTALL_CFG,
"Specify the name of a configuration file", 0);
if (!cp || !*cp) {
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
return what;
}
distWanted = cp;
mediaDevice = d;
if (!DEVICE_INIT(mediaDevice)) {
msgConfirm("Unable to mount filesystem.");
what |= DITEM_FAILURE;
mediaClose();
return what;
}
msgDebug("getting fp for %s\n", cp);
fp = DEVICE_GET(mediaDevice, cp, TRUE);
if (fp) {
msgDebug("opened OK, processing..\n");
list = dispatch_load_fp(fp);
fclose(fp);
mediaClose();
what |= dispatch_execute(list);
} else {
if (!variable_get(VAR_NO_ERROR))
msgConfirm("Configuration file '%s' not found.", cp);
variable_unset(VAR_INSTALL_CFG);
what |= DITEM_FAILURE;
mediaClose();
}
return(what);
}

View File

@ -1,922 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/param.h>
#include <sys/mount.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <ctype.h>
#include <signal.h>
#include <libutil.h>
unsigned int Dists;
unsigned int DocDists;
unsigned int SrcDists;
unsigned int KernelDists;
enum _disttype { DT_TARBALL, DT_SUBDIST, DT_PACKAGE };
typedef struct _dist {
char *my_name;
unsigned int *my_mask;
unsigned int my_bit;
enum _disttype my_type;
union {
char *my_string; /* DT_TARBALL & DT_PACKAGE */
struct _dist *my_dist; /* DT_SUBDIST */
} my_data;
} Distribution;
static Distribution DocDistTable[];
static Distribution KernelDistTable[];
static Distribution SrcDistTable[];
#define DTE_TARBALL(name, mask, flag, directory) \
{ name, mask, DIST_ ## flag, DT_TARBALL, { directory } }
#define DTE_PACKAGE(name, mask, flag, package) \
{ name, mask, DIST_ ## flag, DT_PACKAGE, { package } }
#define DTE_SUBDIST(name, mask, flag, subdist) \
{ name, mask, DIST_ ## flag, DT_SUBDIST, { .my_dist = subdist } }
#define DTE_END { NULL, NULL, 0, 0, { NULL } }
#define BASE_DIST (&DistTable[0])
/* The top-level distribution categories */
static Distribution DistTable[] = {
DTE_TARBALL("base", &Dists, BASE, "/"),
DTE_SUBDIST("kernels", &Dists, KERNEL, KernelDistTable),
DTE_TARBALL("doc", &Dists, DOCUSERLAND, "/"),
DTE_SUBDIST("docproj", &Dists, DOC, DocDistTable),
DTE_TARBALL("games", &Dists, GAMES, "/"),
DTE_TARBALL("manpages", &Dists, MANPAGES, "/"),
DTE_TARBALL("catpages", &Dists, CATPAGES, "/"),
DTE_TARBALL("proflibs", &Dists, PROFLIBS, "/"),
DTE_TARBALL("dict", &Dists, DICT, "/"),
DTE_TARBALL("info", &Dists, INFO, "/"),
#if defined(__amd64__) || defined(__powerpc64__)
DTE_TARBALL("lib32", &Dists, LIB32, "/"),
#endif
DTE_SUBDIST("src", &Dists, SRC, SrcDistTable),
DTE_TARBALL("ports", &Dists, PORTS, "/usr"),
DTE_TARBALL("local", &Dists, LOCAL, "/"),
DTE_END,
};
/* The kernel distributions */
static Distribution KernelDistTable[] = {
DTE_TARBALL(GENERIC_KERNEL_NAME, &KernelDists, KERNEL_GENERIC, "/boot"),
DTE_END,
};
/* The /usr/src distribution */
static Distribution SrcDistTable[] = {
DTE_TARBALL("sbase", &SrcDists, SRC_BASE, "/usr/src"),
DTE_TARBALL("scddl", &SrcDists, SRC_CDDL, "/usr/src"),
DTE_TARBALL("scontrib", &SrcDists, SRC_CONTRIB, "/usr/src"),
DTE_TARBALL("scrypto", &SrcDists, SRC_SCRYPTO, "/usr/src"),
DTE_TARBALL("sgnu", &SrcDists, SRC_GNU, "/usr/src"),
DTE_TARBALL("setc", &SrcDists, SRC_ETC, "/usr/src"),
DTE_TARBALL("sgames", &SrcDists, SRC_GAMES, "/usr/src"),
DTE_TARBALL("sinclude", &SrcDists, SRC_INCLUDE, "/usr/src"),
DTE_TARBALL("skrb5", &SrcDists, SRC_SKERBEROS5, "/usr/src"),
DTE_TARBALL("slib", &SrcDists, SRC_LIB, "/usr/src"),
DTE_TARBALL("slibexec", &SrcDists, SRC_LIBEXEC, "/usr/src"),
DTE_TARBALL("srelease", &SrcDists, SRC_RELEASE, "/usr/src"),
DTE_TARBALL("sbin", &SrcDists, SRC_BIN, "/usr/src"),
DTE_TARBALL("ssecure", &SrcDists, SRC_SSECURE, "/usr/src"),
DTE_TARBALL("ssbin", &SrcDists, SRC_SBIN, "/usr/src"),
DTE_TARBALL("sshare", &SrcDists, SRC_SHARE, "/usr/src"),
DTE_TARBALL("ssys", &SrcDists, SRC_SYS, "/usr/src"),
DTE_TARBALL("subin", &SrcDists, SRC_UBIN, "/usr/src"),
DTE_TARBALL("susbin", &SrcDists, SRC_USBIN, "/usr/src"),
DTE_TARBALL("stools", &SrcDists, SRC_TOOLS, "/usr/src"),
DTE_TARBALL("srescue", &SrcDists, SRC_RESCUE, "/usr/src"),
DTE_END,
};
/* The Documentation distribution */
static Distribution DocDistTable[] = {
DTE_PACKAGE("Bengali Documentation", &DocDists, DOC_BN, "bn-freebsd-doc"),
DTE_PACKAGE("Danish Documentation", &DocDists, DOC_DA, "da-freebsd-doc"),
DTE_PACKAGE("German Documentation", &DocDists, DOC_DE, "de-freebsd-doc"),
DTE_PACKAGE("Greek Documentation", &DocDists, DOC_EL, "el-freebsd-doc"),
DTE_PACKAGE("English Documentation", &DocDists, DOC_EN, "en-freebsd-doc"),
DTE_PACKAGE("Spanish Documentation", &DocDists, DOC_ES, "es-freebsd-doc"),
DTE_PACKAGE("French Documentation", &DocDists, DOC_FR, "fr-freebsd-doc"),
DTE_PACKAGE("Hungarian Documentation", &DocDists, DOC_HU, "hu-freebsd-doc"),
DTE_PACKAGE("Italian Documentation", &DocDists, DOC_IT, "it-freebsd-doc"),
DTE_PACKAGE("Japanese Documentation", &DocDists, DOC_JA, "ja-freebsd-doc"),
DTE_PACKAGE("Mongolian Documentation", &DocDists, DOC_MN, "mn-freebsd-doc"),
DTE_PACKAGE("Dutch Documentation", &DocDists, DOC_NL, "nl-freebsd-doc"),
DTE_PACKAGE("Polish Documentation", &DocDists, DOC_PL, "pl-freebsd-doc"),
DTE_PACKAGE("Portuguese Documentation", &DocDists, DOC_PT, "pt-freebsd-doc"),
DTE_PACKAGE("Russian Documentation", &DocDists, DOC_RU, "ru-freebsd-doc"),
DTE_PACKAGE("Serbian Documentation", &DocDists, DOC_SR, "sr-freebsd-doc"),
DTE_PACKAGE("Turkish Documentation", &DocDists, DOC_TR, "tr-freebsd-doc"),
DTE_PACKAGE("Simplified Chinese Documentation", &DocDists, DOC_ZH_CN, "zh_cn-freebsd-doc"),
DTE_PACKAGE("Traditional Chinese Documentation", &DocDists, DOC_ZH_TW, "zh_tw-freebsd-doc"),
DTE_END,
};
static int distMaybeSetPorts(dialogMenuItem *self);
static void
distVerifyFlags(void)
{
if (SrcDists)
Dists |= DIST_SRC;
if (KernelDists)
Dists |= DIST_KERNEL;
if (DocDists)
Dists |= DIST_DOC;
if (isDebug())
msgDebug("Dist Masks: Dists: %0x, Srcs: %0x Kernels: %0x Docs: %0x\n", Dists,
SrcDists, KernelDists, DocDists);
}
int
distReset(dialogMenuItem *self)
{
Dists = 0;
DocDists = 0;
SrcDists = 0;
KernelDists = 0;
return DITEM_SUCCESS | DITEM_REDRAW;
}
int
distConfig(dialogMenuItem *self)
{
char *cp;
distReset(NULL);
if ((cp = variable_get(VAR_DIST_MAIN)) != NULL)
Dists = atoi(cp);
if ((cp = variable_get(VAR_DIST_DOC)) != NULL)
DocDists = atoi(cp);
if ((cp = variable_get(VAR_DIST_SRC)) != NULL)
SrcDists = atoi(cp);
if ((cp = variable_get(VAR_DIST_KERNEL)) != NULL)
KernelDists = atoi(cp);
distVerifyFlags();
return DITEM_SUCCESS | DITEM_REDRAW;
}
int
selectKernel(void)
{
return DIST_KERNEL_GENERIC;
}
int
distSetDeveloper(dialogMenuItem *self)
{
int i;
distReset(NULL);
Dists = _DIST_DEVELOPER;
SrcDists = DIST_SRC_ALL;
KernelDists = selectKernel();
i = distSetDoc(self);
i |= distMaybeSetPorts(self);
distVerifyFlags();
return i;
}
int
distSetKernDeveloper(dialogMenuItem *self)
{
int i;
distReset(NULL);
Dists = _DIST_DEVELOPER;
SrcDists = DIST_SRC_SYS | DIST_SRC_BASE;
KernelDists = selectKernel();
i = distSetDoc(self);
i |= distMaybeSetPorts(self);
distVerifyFlags();
return i;
}
int
distSetUser(dialogMenuItem *self)
{
int i;
distReset(NULL);
Dists = _DIST_USER;
KernelDists = selectKernel();
i = distSetDoc(self);
i |= distMaybeSetPorts(self);
distVerifyFlags();
return i;
}
int
distSetMinimum(dialogMenuItem *self)
{
distReset(NULL);
Dists = DIST_BASE | DIST_KERNEL;
KernelDists = selectKernel();
distVerifyFlags();
return DITEM_SUCCESS | DITEM_REDRAW;
}
int
distSetEverything(dialogMenuItem *self)
{
int i;
Dists = DIST_ALL;
SrcDists = DIST_SRC_ALL;
KernelDists = DIST_KERNEL_ALL;
DocDists = DIST_DOC_ALL;
i = distMaybeSetPorts(self);
distVerifyFlags();
return i | DITEM_REDRAW;
}
static int
distMaybeSetPorts(dialogMenuItem *self)
{
dialog_clear_norefresh();
if (!msgYesNo("Would you like to install the FreeBSD ports collection?\n\n"
"This will give you ready access to over 19,000 ported software packages,\n"
"at a cost of around 445MB of disk space when \"clean\" and possibly\n"
"much more than that when a lot of the distribution tarballs are loaded\n"
"(unless you have the extra discs available from a FreeBSD CD/DVD distribution\n"
"and can mount them on /cdrom, in which case this is far less of a problem).\n\n"
"The ports collection is a very valuable resource and well worth having\n"
"on your /usr partition, so it is advisable to say Yes to this option.\n\n"
"For more information on the ports collection & the latest ports, visit:\n"
" http://www.freebsd.org/ports\n"))
Dists |= DIST_PORTS;
else
Dists &= ~DIST_PORTS;
return DITEM_SUCCESS | DITEM_RESTORE;
}
static Boolean
distSetByName(Distribution *dist, char *name)
{
int i, status = FALSE;
/* Loop through current set */
for (i = 0; dist[i].my_name; i++) {
switch (dist[i].my_type) {
case DT_TARBALL:
case DT_PACKAGE:
if (!strcmp(dist[i].my_name, name)) {
*(dist[i].my_mask) |= dist[i].my_bit;
status = TRUE;
}
break;
case DT_SUBDIST:
if (distSetByName(dist[i].my_data.my_dist, name)) {
status = TRUE;
}
break;
}
}
distVerifyFlags();
return status;
}
static Boolean
distUnsetByName(Distribution *dist, char *name)
{
int i, status = FALSE;
/* Loop through current set */
for (i = 0; dist[i].my_name; i++) {
switch (dist[i].my_type) {
case DT_TARBALL:
case DT_PACKAGE:
if (!strcmp(dist[i].my_name, name)) {
*(dist[i].my_mask) &= ~(dist[i].my_bit);
status = TRUE;
}
break;
case DT_SUBDIST:
if (distUnsetByName(dist[i].my_data.my_dist, name)) {
status = TRUE;
}
break;
}
}
return status;
}
/* Just for the dispatch stuff */
int
distSetCustom(dialogMenuItem *self)
{
char *cp, *cp2, *tmp;
if (!(tmp = variable_get(VAR_DISTS))) {
msgDebug("distSetCustom() called without %s variable set.\n", VAR_DISTS);
return DITEM_FAILURE;
}
cp = alloca(strlen(tmp) + 1);
if (!cp)
msgFatal("Couldn't alloca() %d bytes!\n", (int)(strlen(tmp) + 1));
strcpy(cp, tmp);
while (cp) {
if ((cp2 = index(cp, ' ')) != NULL)
*(cp2++) = '\0';
if (!distSetByName(DistTable, cp))
msgDebug("distSetCustom: Warning, no such release \"%s\"\n", cp);
cp = cp2;
}
distVerifyFlags();
return DITEM_SUCCESS;
}
/* Just for the dispatch stuff */
int
distUnsetCustom(dialogMenuItem *self)
{
char *cp, *cp2, *tmp;
if (!(tmp = variable_get(VAR_DISTS))) {
msgDebug("distUnsetCustom() called without %s variable set.\n", VAR_DISTS);
return DITEM_FAILURE;
}
cp = alloca(strlen(tmp) + 1);
if (!cp)
msgFatal("Couldn't alloca() %d bytes!\n", (int)(strlen(tmp) + 1));
strcpy(cp, tmp);
while (cp) {
if ((cp2 = index(cp, ' ')) != NULL)
*(cp2++) = '\0';
if (!distUnsetByName(DistTable, cp))
msgDebug("distUnsetCustom: Warning, no such release \"%s\"\n", cp);
cp = cp2;
}
return DITEM_SUCCESS;
}
int
distSetSrc(dialogMenuItem *self)
{
int i;
dialog_clear_norefresh();
if (!dmenuOpenSimple(&MenuSrcDistributions, FALSE))
i = DITEM_FAILURE;
else
i = DITEM_SUCCESS;
distVerifyFlags();
return i | DITEM_RESTORE;
}
int
distSetKernel(dialogMenuItem *self)
{
int i;
dialog_clear_norefresh();
if (!dmenuOpenSimple(&MenuKernelDistributions, FALSE))
i = DITEM_FAILURE;
else
i = DITEM_SUCCESS;
distVerifyFlags();
return i | DITEM_RESTORE;
}
static Boolean got_intr = FALSE;
/* timeout handler */
static void
handle_intr(int sig)
{
msgDebug("User generated interrupt.\n");
got_intr = TRUE;
}
static int
check_for_interrupt(void)
{
if (got_intr) {
got_intr = FALSE;
return TRUE;
}
return FALSE;
}
/*
* translate distribution filename to lower case
* as doTARBALL does in release/Makefile
*/
static void
translateDist(char trdist[PATH_MAX], const char *dist)
{
int j;
/*
* translate distribution filename to lower case
* as doTARBALL does in release/Makefile
*/
for (j = 0; j < PATH_MAX-1 && dist[j] != '\0'; j++)
trdist[j] = tolower(dist[j]);
trdist[j] = '\0';
}
/*
* Try to get distribution as multiple pieces, locating and parsing an
* info file which tells us how many we need for this distribution.
*/
static Boolean
distExtractTarball(char *path, char *dist, char *my_dir, int is_base)
{
char *buf = NULL, trdist[PATH_MAX], fname[PATH_MAX];
struct timeval start, stop;
int j, status, total, intr;
int cpid, zpid, fd2, chunk, numchunks;
properties dist_attr = NULL;
const char *tmp;
FILE *fp;
translateDist(trdist, dist);
if (isDebug())
msgDebug("%s: path \"%s\" dist \"%s\" trdist \"%s\" "
"my_dir \"%s\" %sis_base\n",
__func__, path, dist, trdist, my_dir, is_base ? "" : "!");
status = TRUE;
numchunks = 0;
snprintf(fname, sizeof (fname), "%s/%s.inf", path, trdist);
getinfo:
fp = DEVICE_GET(mediaDevice, fname, TRUE);
intr = check_for_interrupt();
if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
if (isDebug())
msgDebug("%s: fname %s fp: %p, intr: %d mediaDevice: %p\n",
__func__, fname, fp, intr, mediaDevice);
/* Hard error, can't continue */
if (!msgYesNo("Unable to open %s: %s.\nReinitialize media?",
fname, !intr ? "I/O error." : "User interrupt.")) {
DEVICE_SHUTDOWN(mediaDevice);
if (!DEVICE_INIT(mediaDevice))
return (FALSE);
goto getinfo;
} else
return (FALSE);
} else if (fp == NULL) {
/* No attributes file, so try as a single file. */
snprintf(fname, sizeof(fname), "%s/%s.%s", path, trdist,
USE_GZIP ? "tgz" : "tbz");
if (isDebug())
msgDebug("%s: fp is NULL (1) fname: %s\n", __func__, fname);
/*
* Passing TRUE as 3rd parm to get routine makes this a "probing"
* get, for which errors are not considered too significant.
*/
getsingle:
fp = DEVICE_GET(mediaDevice, fname, TRUE);
intr = check_for_interrupt();
if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
if (isDebug())
msgDebug("%s: fname %s fp: %p, intr: %d mediaDevice: %p\n",
__func__, fname, fp, intr, mediaDevice);
/* Hard error, can't continue */
msgConfirm("Unable to open %s: %s", fname,
!intr ? "I/O error" : "User interrupt");
DEVICE_SHUTDOWN(mediaDevice);
if (!DEVICE_INIT(mediaDevice))
return (FALSE);
goto getsingle;
} else if (fp != NULL) {
char *dir = root_bias(my_dir);
dialog_clear_norefresh();
msgNotify("Extracting %s into %s directory...", dist, dir);
status = mediaExtractDist(dir, dist, fp);
fclose(fp);
return (status);
} else {
if (isDebug())
msgDebug("%s: fp is NULL (2) fname %s\n", __func__, fname);
return (FALSE);
}
}
if (isDebug())
msgDebug("Parsing attributes file for distribution %s\n", dist);
dist_attr = properties_read(fileno(fp));
intr = check_for_interrupt();
if (intr || !dist_attr) {
if (isDebug())
msgDebug("%s: intr %d dist_attr %p\n", __func__, intr, dist_attr);
msgConfirm("Cannot parse information file for the %s distribution: %s\n"
"Please verify that your media is valid and try again.",
dist, !intr ? "I/O error" : "User interrupt");
} else {
tmp = property_find(dist_attr, "Pieces");
if (tmp)
numchunks = strtol(tmp, 0, 0);
}
fclose(fp);
if (!numchunks) {
if (isDebug())
msgDebug("%s: numchunks is zero\n", __func__);
return (TRUE);
}
if (isDebug())
msgDebug("Attempting to extract distribution from %u chunks.\n",
numchunks);
total = 0;
(void)gettimeofday(&start, (struct timezone *)NULL);
/* We have one or more chunks, initialize unpackers... */
mediaExtractDistBegin(root_bias(my_dir), &fd2, &zpid, &cpid);
/* And go for all the chunks */
dialog_clear_norefresh();
for (chunk = 0; chunk < numchunks; chunk++) {
int n, retval, last_msg, chunksize, realsize;
char prompt[80];
last_msg = 0;
getchunk:
snprintf(fname, sizeof(fname), "cksum.%c%c", (chunk / 26) + 'a',
(chunk % 26) + 'a');
tmp = property_find(dist_attr, fname);
chunksize = 0;
if (tmp) {
tmp = index(tmp, ' ');
chunksize = strtol(tmp, 0, 0);
}
snprintf(fname, sizeof(fname), "%s/%s.%c%c", path, trdist, (chunk / 26) + 'a',
(chunk % 26) + 'a');
if (isDebug())
msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks,
fname);
fp = DEVICE_GET(mediaDevice, fname, FALSE);
intr = check_for_interrupt();
/* XXX: this can't work if we get an I/O error */
if (fp <= (FILE *)NULL || intr) {
if (fp == NULL)
msgConfirm("Failed to find %s on this media. Reinitializing media.", fname);
else
msgConfirm("Failed to retrieve piece file %s.\n"
"%s: Reinitializing media.",
fname, !intr ? "I/O error" : "User interrupt");
DEVICE_SHUTDOWN(mediaDevice);
if (!DEVICE_INIT(mediaDevice))
goto punt;
else
goto getchunk;
}
snprintf(prompt, sizeof(prompt), "Extracting %s into %s directory...",
dist, root_bias(my_dir));
dialog_gauge("Progress", prompt, 8, 15, 6, 50,
(chunk + 1) * 100 / numchunks);
buf = safe_realloc(buf, chunksize);
realsize = 0;
while (1) {
int seconds;
n = fread(buf + realsize, 1, BUFSIZ, fp);
if (check_for_interrupt()) {
msgConfirm("Media read error: User interrupt.");
fclose(fp);
goto punt;
} else if (n <= 0)
break;
total += n;
realsize += n;
/* Print statistics about how we're doing */
(void) gettimeofday(&stop, (struct timezone *)0);
stop.tv_sec = stop.tv_sec - start.tv_sec;
stop.tv_usec = stop.tv_usec - start.tv_usec;
if (stop.tv_usec < 0)
stop.tv_sec--, stop.tv_usec += 1000000;
seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
if (!seconds)
seconds = 1;
if (seconds != last_msg) {
last_msg = seconds;
msgInfo("%10d bytes read from %s dist, chunk %2d of %2d @ %.1f KBytes/sec.",
total, dist, chunk + 1, numchunks,
(total / seconds) / 1000.0);
}
}
fclose(fp);
if (!chunksize || (realsize == chunksize)) {
/* No substitution necessary */
retval = write(fd2, buf, realsize);
if (retval != realsize) {
fclose(fp);
dialog_clear_norefresh();
msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, realsize);
goto punt;
}
} else {
for (j = 0; j < realsize; j++) {
/* On finding CRLF, skip the CR; don't exceed end of buffer. */
if ((buf[j] != 0x0d) || (j == total - 1) || (buf[j + 1] != 0x0a)) {
retval = write(fd2, buf + j, 1);
if (retval != 1) {
fclose(fp);
dialog_clear_norefresh();
msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", j, chunksize);
goto punt;
}
}
}
}
}
goto done;
punt:
status = FALSE;
done:
properties_free(dist_attr);
close(fd2);
if (status != FALSE)
status = mediaExtractDistEnd(zpid, cpid);
else
(void)mediaExtractDistEnd(zpid, cpid);
safe_free(buf);
return (status);
}
static Boolean
distExtract(char *parent, Distribution *me)
{
int i, status;
char *path, *dist;
WINDOW *w = savescr();
struct sigaction old, new;
int canceled = 0;
status = TRUE;
if (isDebug())
msgDebug("distExtract: parent: %s, me: %s\n", parent ? parent : "(none)", me->my_name);
/* Make ^C fake a sudden timeout */
new.sa_handler = handle_intr;
new.sa_flags = 0;
(void)sigemptyset(&new.sa_mask);
dialog_clear_norefresh();
dialog_msgbox("Please Wait", "Extracting all requested distributions...", -1, -1, 0);
sigaction(SIGINT, &new, &old);
/* Loop through to see if we're in our parent's plans */
for (i = 0; me[i].my_name && canceled == 0; i++) {
dist = me[i].my_name;
path = parent ? parent : dist;
/* If our bit isn't set, go to the next */
if (!(me[i].my_bit & *(me[i].my_mask)))
continue;
switch (me[i].my_type) {
case DT_SUBDIST:
/* Recurse if we actually have a sub-distribution */
status = distExtract(dist, me[i].my_data.my_dist);
if (!status) {
dialog_clear_norefresh();
msgConfirm("Unable to transfer all components of the %s distribution.\n"
"You may wish to switch media types and try again.\n",
me[i].my_name);
}
break;
case DT_PACKAGE:
dialog_clear_norefresh();
msgNotify("Installing %s distribution...", dist);
status = (package_add(me[i].my_data.my_string) == DITEM_SUCCESS);
if (!status)
dialog_clear_norefresh();
break;
case DT_TARBALL:
status = distExtractTarball(path, dist, me[i].my_data.my_string,
&me[i] == BASE_DIST);
if (!status) {
dialog_clear_norefresh();
if (me[i].my_bit != DIST_LOCAL) {
status = msgYesNo("Unable to transfer the %s distribution from\n%s.\n\n"
"Do you want to try to retrieve it again?",
me[i].my_name, mediaDevice->name);
if (status == 0)
--i;
else
canceled = 1;
status = FALSE;
} else {
// ignore any failures with DIST_LOCAL
status = TRUE;
}
}
break;
}
/*
* If extract was successful, remove ourselves from further
* consideration.
*/
if (status)
*(me[i].my_mask) &= ~(me[i].my_bit);
}
sigaction(SIGINT, &old, NULL); /* Restore signal handler */
restorescr(w);
return status;
}
int
distSetDoc(dialogMenuItem *self)
{
int i;
/* Assume no docs for non-interactive installs. */
if (variable_get(VAR_NONINTERACTIVE))
return DITEM_SUCCESS | DITEM_RESTORE;
dialog_clear_norefresh();
if (!dmenuOpenSimple(&MenuDocInstall, FALSE))
i = DITEM_FAILURE;
else
i = DITEM_SUCCESS;
distVerifyFlags();
return i | DITEM_RESTORE;
}
int
distSetDocMenu(dialogMenuItem *self)
{
int i, status;
WINDOW *w;
if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) {
msgConfirm("This option may only be used after the system is installed, sorry!");
return DITEM_FAILURE;
}
dialog_clear_norefresh();
if (!dmenuOpenSimple(&MenuDocInstall, FALSE))
i = DITEM_FAILURE;
else
i = DITEM_SUCCESS;
distVerifyFlags();
dialog_clear_norefresh();
w = savescr();
msgNotify("Attempting to install all selected documentations...");
for (i = 0; DocDistTable[i].my_name; i++) {
if (!(DocDistTable[i].my_bit & *(DocDistTable[i].my_mask)))
continue;
dialog_clear_norefresh();
msgNotify("Installing %s distribution...", DocDistTable[i].my_name);
status = (package_add(DocDistTable[i].my_data.my_string) == DITEM_SUCCESS);
if (!status)
break;
}
dialog_clear_norefresh();
restorescr(w);
return (status ? DITEM_SUCCESS : DITEM_FAILURE);
}
static void
printSelected(char *buf, int selected, Distribution *me, int *col)
{
int i;
/* Loop through to see if we're in our parent's plans */
for (i = 0; me[i].my_name; i++) {
/* If our bit isn't set, go to the next */
if (!(me[i].my_bit & selected))
continue;
*col += strlen(me[i].my_name);
if (*col > 50) {
*col = 0;
strcat(buf, "\n");
}
sprintf(&buf[strlen(buf)], " %s", me[i].my_name);
/* Recurse if have a sub-distribution */
if (me[i].my_type == DT_SUBDIST)
printSelected(buf, *(me[i].my_mask), me[i].my_data.my_dist, col);
}
}
int
distExtractAll(dialogMenuItem *self)
{
int old_dists, old_kernel, status = DITEM_SUCCESS;
char buf[512];
int extract_status = TRUE;
WINDOW *w;
/* paranoia */
if (!Dists) {
if (!dmenuOpenSimple(&MenuSubDistributions, FALSE) || !Dists)
return DITEM_FAILURE;
}
if (!mediaVerify() || !DEVICE_INIT(mediaDevice))
return DITEM_FAILURE;
old_dists = Dists;
old_kernel = KernelDists;
distVerifyFlags();
dialog_clear_norefresh();
w = savescr();
msgNotify("Attempting to install all selected distributions..");
extract_status = distExtract(NULL, DistTable);
dialog_clear_norefresh();
/* Only do base fixup if base dist was successfully extracted */
if ((old_dists & DIST_BASE) && !(Dists & DIST_BASE))
status |= installFixupBase(self);
/* Only do kernel fixup if kernel dist was successfully extracted */
if ((old_dists & DIST_KERNEL) && !(Dists & DIST_KERNEL))
status |= installFixupKernel(self, old_kernel);
/* Clear any local dist flags now */
Dists &= ~DIST_LOCAL;
if (Dists) {
int col = 0;
buf[0] = '\0';
dialog_clear_norefresh();
printSelected(buf, Dists, DistTable, &col);
dialog_clear_norefresh();
if (col) {
msgConfirm("Couldn't extract the following distributions. This may\n"
"be because they were not available on the installation\n"
"media you've chosen:\n\n\t%s", buf);
}
}
restorescr(w);
if (extract_status == FALSE)
status = FALSE;
return status;
}

View File

@ -1,92 +0,0 @@
/* $FreeBSD$ */
#ifndef _DIST_H_INCLUDE
#define _DIST_H_INCLUDE
/* Bitfields for distributions - hope we never have more than 32! :-) */
#define DIST_BASE 0x00001
#define DIST_GAMES 0x00002
#define DIST_MANPAGES 0x00004
#define DIST_PROFLIBS 0x00008
#define DIST_DICT 0x00010
#define DIST_SRC 0x00020
/* Documentation from FreeBSD docproj */
#define DIST_DOC 0x00040
#define DIST_INFO 0x00080
#define DIST_CATPAGES 0x00200
#define DIST_PORTS 0x00400
#define DIST_LOCAL 0x00800
#if defined(__amd64__) || defined(__powerpc64__)
#define DIST_LIB32 0x01000
#endif
#define DIST_KERNEL 0x02000
/* Userland documentation */
#define DIST_DOCUSERLAND 0x04000
#define DIST_ALL 0xFFFFF
/* Subtypes for DOC packages */
#define DIST_DOC_BN 0x00001
#define DIST_DOC_DA 0x00002
#define DIST_DOC_DE 0x00004
#define DIST_DOC_EL 0x00008
#define DIST_DOC_EN 0x00010
#define DIST_DOC_ES 0x00020
#define DIST_DOC_FR 0x00040
#define DIST_DOC_HU 0x00080
#define DIST_DOC_IT 0x00100
#define DIST_DOC_JA 0x00200
#define DIST_DOC_MN 0x00400
#define DIST_DOC_NL 0x00800
#define DIST_DOC_PL 0x01000
#define DIST_DOC_PT 0x02000
#define DIST_DOC_RU 0x04000
#define DIST_DOC_SR 0x08000
#define DIST_DOC_TR 0x10000
#define DIST_DOC_ZH_CN 0x20000
#define DIST_DOC_ZH_TW 0x40000
#define DIST_DOC_ALL 0xFFFFF
/* Subtypes for SRC distribution */
#define DIST_SRC_BASE 0x00001
#define DIST_SRC_CONTRIB 0x00002
#define DIST_SRC_GNU 0x00004
#define DIST_SRC_ETC 0x00008
#define DIST_SRC_GAMES 0x00010
#define DIST_SRC_INCLUDE 0x00020
#define DIST_SRC_LIB 0x00040
#define DIST_SRC_LIBEXEC 0x00080
#define DIST_SRC_TOOLS 0x00100
#define DIST_SRC_RELEASE 0x00200
#define DIST_SRC_SBIN 0x00400
#define DIST_SRC_SHARE 0x00800
#define DIST_SRC_SYS 0x01000
#define DIST_SRC_UBIN 0x02000
#define DIST_SRC_USBIN 0x04000
#define DIST_SRC_BIN 0x08000
#define DIST_SRC_SCRYPTO 0x10000
#define DIST_SRC_SSECURE 0x20000
#define DIST_SRC_SKERBEROS5 0x40000
#define DIST_SRC_RESCUE 0x80000
#define DIST_SRC_CDDL 0x100000
#define DIST_SRC_ALL 0x3FFFFF
/* Subtypes for KERNEL distribution */
#define DIST_KERNEL_GENERIC 0x00001
#define DIST_KERNEL_SMP 0x00002
#define DIST_KERNEL_ALL 0xFFFFF
#ifdef __powerpc64__
#define GENERIC_KERNEL_NAME "GENERIC64"
#else
#define GENERIC_KERNEL_NAME "GENERIC"
#endif
/* Canned distribution sets */
#define _DIST_USER \
( DIST_BASE | DIST_KERNEL | DIST_DOC | DIST_DOCUSERLAND | DIST_MANPAGES | DIST_DICT )
#define _DIST_DEVELOPER \
( _DIST_USER | DIST_PROFLIBS | DIST_INFO | DIST_SRC )
#endif /* _DIST_H_INCLUDE */

View File

@ -1,393 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/param.h>
#include <errno.h>
#define MAX_MENU 15
static Boolean exited;
int
dmenuDisplayFile(dialogMenuItem *tmp)
{
systemDisplayHelp((char *)tmp->data);
return DITEM_SUCCESS;
}
int
dmenuSubmenu(dialogMenuItem *tmp)
{
return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE);
}
int
dmenuSystemCommand(dialogMenuItem *self)
{
WINDOW *w = NULL; /* Keep lint happy */
/* If aux is set, the command is known not to produce any screen-spoiling output */
if (!self->aux)
w = savescr();
systemExecute((char *)self->data);
if (!self->aux)
restorescr(w);
return DITEM_SUCCESS;
}
int
dmenuSystemCommandBox(dialogMenuItem *tmp)
{
WINDOW *w = savescr();
use_helpfile(NULL);
use_helpline("Select OK to dismiss this dialog");
dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
restorescr(w);
return DITEM_SUCCESS;
}
int
dmenuExit(dialogMenuItem *tmp)
{
exited = TRUE;
return DITEM_LEAVE_MENU;
}
int
dmenuSetVariable(dialogMenuItem *tmp)
{
variable_set((char *)tmp->data, *((char *)tmp->data) != '_');
return DITEM_SUCCESS;
}
int
dmenuSetVariables(dialogMenuItem *tmp)
{
char *cp1, *cp2;
char *copy = strdup((char *)tmp->data);
for (cp1 = copy; cp1 != NULL;) {
cp2 = index(cp1, ',');
if (cp2 != NULL) *cp2++ = '\0';
variable_set(cp1, *cp1 != '_');
cp1 = cp2;
}
free(copy);
return DITEM_SUCCESS;
}
int
dmenuSetCountryVariable(dialogMenuItem *tmp)
{
variable_set((char *)tmp->data, FALSE);
#ifdef WITH_SYSCONS
/* Don't prompt the user for a keymap if they're using the default locale. */
if (!strcmp(variable_get(VAR_COUNTRY), DEFAULT_COUNTRY))
return DITEM_SUCCESS;
return keymapMenuSelect(tmp);
#else
return DITEM_SUCCESS;
#endif
}
int
dmenuSetKmapVariable(dialogMenuItem *tmp)
{
char *lang;
int err;
variable_set((char *)tmp->data, TRUE);
lang = variable_get(VAR_KEYMAP);
if (lang != NULL)
{
err = loadKeymap(lang);
if (err == -1)
msgConfirm("No appropriate keyboard map found, sorry.");
else if (err == -2)
msgConfirm("Error installing keyboard map, errno = %d.", errno);
}
return DITEM_SUCCESS;
}
int
dmenuToggleVariable(dialogMenuItem *tmp)
{
char *var, *cp;
int status;
if (!(var = strdup((char *)tmp->data))) {
msgConfirm("Incorrect data field for `%s'!", tmp->title);
return DITEM_FAILURE;
}
if (!(cp = index(var, '='))) {
msgConfirm("Data field for %s is not in var=value format!", tmp->title);
return DITEM_FAILURE;
}
status = variable_check(var);
*cp = '\0';
variable_set2(var, status ? "NO" : "YES", *var != '_');
free(var);
return DITEM_SUCCESS;
}
int
dmenuISetVariable(dialogMenuItem *tmp)
{
char *ans, *p, *var;
if (!(var = strdup((char *)tmp->data))) {
msgConfirm("Incorrect data field for `%s'!", tmp->title);
return DITEM_FAILURE;
}
if ((p = index(var, '=')) != NULL)
*p = '\0';
ans = msgGetInput(variable_get(var), tmp->title, 1);
if (!ans) {
free(var);
return DITEM_FAILURE;
} else if (!*ans)
variable_unset(var);
else
variable_set2(var, ans, *var != '_');
free(var);
return DITEM_SUCCESS;
}
int
dmenuSetFlag(dialogMenuItem *tmp)
{
if (*((unsigned int *)tmp->data) & tmp->aux)
*((unsigned int *)tmp->data) &= ~tmp->aux;
else
*((unsigned int *)tmp->data) |= tmp->aux;
return DITEM_SUCCESS;
}
int
dmenuSetValue(dialogMenuItem *tmp)
{
*((unsigned int *)tmp->data) = tmp->aux;
return DITEM_SUCCESS;
}
/* Traverse menu but give user no control over positioning */
Boolean
dmenuOpenSimple(DMenu *menu, Boolean buttons)
{
int choice, scroll, curr, max;
choice = scroll = curr = max = 0;
return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons);
}
/* Work functions for the state hook */
int
dmenuFlagCheck(dialogMenuItem *item)
{
return (*((unsigned int *)item->data) & item->aux);
}
int
dmenuVarCheck(dialogMenuItem *item)
{
char *w;
w = (char *)item->aux;
if (!w)
w = (char *)item->data;
return variable_check(w);
}
int
dmenuVarsCheck(dialogMenuItem *item)
{
int res, init;
char *w, *cp1, *cp2;
char *copy;
w = (char *)item->aux;
if (!w)
w = (char *)item->data;
if (!w)
return FALSE;
copy = strdup(w);
res = TRUE;
init = FALSE;
for (cp1 = copy; cp1 != NULL;) {
init = TRUE;
cp2 = index(cp1, ',');
if (cp2 != NULL)
*cp2++ = '\0';
res = res && variable_check(cp1);
cp1 = cp2;
}
free(copy);
return res && init;
}
int
dmenuRadioCheck(dialogMenuItem *item)
{
return (*((int *)item->data) == item->aux);
}
static int
menu_height(DMenu *menu, int n)
{
int max;
char *t;
max = MAX_MENU;
if (StatusLine > 24)
max += StatusLine - 24;
for (t = menu->prompt; *t; t++) {
if (*t == '\n')
--max;
}
return n > max ? max : n;
}
/* Find a menu item that matches any field. */
int
dmenuFindItem(DMenu *menu, const char *prompt, const char *title, void *data)
{
dialogMenuItem *items = menu->items;
int i;
for (i = 0; items[i].prompt; ++i)
if ((prompt && !strcmp(items[i].prompt, prompt)) ||
(title && !strcmp(items[i].title, title)) ||
(data && items[i].data == data))
return i;
return -1;
}
/* Set the default item for a menu by index and scroll to it. */
void
dmenuSetDefaultIndex(DMenu *menu, int *choice, int *scroll, int *curr, int *max)
{
int nitem;
int height;
*curr = *max = 0;
for (nitem = 0; menu->items[nitem].prompt; ++nitem);
height = menu_height(menu, nitem);
if (*choice > height)
{
*scroll = MIN(nitem - height, *choice);
*choice = *choice - *scroll;
}
else
*scroll = 0;
}
/* Set the default menu item that matches any field and scroll to it. */
Boolean
dmenuSetDefaultItem(DMenu *menu, const char *prompt, const char *title, void *data,
int *choice, int *scroll, int *curr, int *max)
{
if ((*choice = dmenuFindItem(menu, prompt, title, data)) != -1)
{
dmenuSetDefaultIndex(menu, choice, scroll, curr, max);
return TRUE;
}
else
{
*choice = *scroll = *curr = *max = 0;
return FALSE;
}
}
/* Traverse over an internal menu */
Boolean
dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
{
int n, rval = 0;
dialogMenuItem *items;
items = menu->items;
if (buttons)
items += 2;
/* Count up all the items */
for (n = 0; items[n].title; n++);
while (1) {
char buf[FILENAME_MAX];
WINDOW *w = savescr();
/* Any helpful hints, put 'em up! */
use_helpline(menu->helpline);
use_helpfile(systemHelpFile(menu->helpfile, buf));
dialog_clear_norefresh();
/* Pop up that dialog! */
if (menu->type & DMENU_NORMAL_TYPE)
rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt,
-1, -1, menu_height(menu, n), -n, items,
(char *)(uintptr_t)buttons, choice, scroll);
else if (menu->type & DMENU_RADIO_TYPE)
rval = dialog_radiolist((u_char *)menu->title,
(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
items, (char *)(uintptr_t)buttons);
else if (menu->type & DMENU_CHECKLIST_TYPE)
rval = dialog_checklist((u_char *)menu->title,
(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
items, (char *)(uintptr_t)buttons);
else
msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
if (exited) {
exited = FALSE;
restorescr(w);
return TRUE;
}
else if (rval) {
restorescr(w);
return FALSE;
}
else if (menu->type & DMENU_SELECTION_RETURNS) {
restorescr(w);
return TRUE;
}
}
}

View File

@ -1,123 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* 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.
*
* $FreeBSD$
*/
#include "sysinstall.h"
/*
* This is called from the main menu. Try to find a copy of Lynx from somewhere
* and fire it up on the first copy of the handbook we can find.
*/
int
docBrowser(dialogMenuItem *self)
{
int ret;
char *browser = variable_get(VAR_BROWSER_PACKAGE);
if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) {
msgConfirm("This option may only be used after the system is installed, sorry!");
return DITEM_FAILURE;
}
/* First, make sure we have whatever browser we've chosen is here */
if (!package_installed(browser)) {
ret = package_add(browser);
if (DITEM_STATUS(ret) != DITEM_SUCCESS) {
msgConfirm("Unable to install the %s HTML browser package. You may\n"
"wish to verify that your media is configured correctly and\n"
"try again.", browser);
return ret;
}
}
if (!file_executable(variable_get(VAR_BROWSER_BINARY))) {
if (!msgYesNo("Hmmm. The %s package claims to have installed, but I can't\n"
"find its binary in %s! You may wish to try a different\n"
"location to load the package from (go to Media menu) and see if that\n"
"makes a difference.\n\n"
"I suggest that we remove the version that was extracted since it does\n"
"not appear to be correct. Would you like me to do that now?",
browser, variable_get(VAR_BROWSER_BINARY)))
vsystem("pkg_delete %s %s", !strcmp(variable_get(VAR_CPIO_VERBOSITY), "high") ? "-v" : "", browser);
return DITEM_FAILURE;
}
/* Run browser on the appropriate doc */
if (dmenuOpenSimple(&MenuHTMLDoc, FALSE))
return DITEM_SUCCESS;
else
return DITEM_FAILURE;
}
/* Try to show one of the documents requested from the HTML doc menu */
int
docShowDocument(dialogMenuItem *self)
{
char tmp[512], target[512];
char *where, *browser = variable_get(VAR_BROWSER_BINARY);
char *str = self->prompt;
if (!file_executable(browser)) {
msgConfirm("Can't find the browser in %s! Please ensure that it's\n"
"properly set in the Options editor.", browser);
return DITEM_FAILURE;
}
/* Default to Home */
where = strcpy(target, "http://www.freebsd.org");
if (strstr(str, "Other")) {
where = msgGetInput("http://www.freebsd.org", "Please enter the URL of the location you wish to visit.");
if (where)
strcpy(target, where);
}
else if (strstr(str, "FAQ")) {
where = strcpy(target, "/usr/local/share/doc/freebsd/faq/index.html");
if (!file_readable(target))
where = strcpy(target, "http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq");
}
else if (strstr(str, "Handbook")) {
where = strcpy(target, "/usr/local/share/doc/freebsd/handbook/index.html");
if (!file_readable(target))
where = strcpy(target, "http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook");
}
if (where) {
sprintf(tmp, "%s %s", browser, target);
systemExecute(tmp);
return DITEM_SUCCESS;
}
else {
msgConfirm("Hmmmmm! I can't seem to access the documentation you selected!\n"
"Have you installed the english documentation? Is your network connected?");
return DITEM_FAILURE;
}
}

View File

@ -1,94 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
* Copyright (c) 1995
* Gary J Palmer. 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/stat.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <grp.h>
#define MSDOSFS
#include <sys/mount.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef MSDOSFS
static Boolean DOSMounted;
static char mountpoint[] = "/dist";
Boolean
mediaInitDOS(Device *dev)
{
struct msdosfs_args args;
if (DOSMounted)
return TRUE;
Mkdir(mountpoint);
memset(&args, 0, sizeof(args));
args.fspec = dev->devname;
args.uid = args.gid = 0;
args.mask = 0777;
if (mount("msdosfs", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) {
msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno);
return FALSE;
}
DOSMounted = TRUE;
return TRUE;
}
FILE *
mediaGetDOS(Device *dev, char *file, Boolean probe)
{
return mediaGenericGet(mountpoint, file);
}
void
mediaShutdownDOS(Device *dev)
{
if (!DOSMounted)
return;
if (unmount(mountpoint, MNT_FORCE) != 0)
msgConfirm("Could not unmount the DOS partition from %s: %s",
mountpoint, strerror(errno));
else
DOSMounted = FALSE;
return;
}

View File

@ -1,158 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
* Copyright (c) 1995
* Gary J Palmer. 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.
*
*/
/* These routines deal with getting things off of floppy media */
#include "sysinstall.h"
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <unistd.h>
#include <grp.h>
#define MSDOSFS
#include <sys/mount.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef MSDOSFS
#include <ufs/ufs/ufsmount.h>
static Boolean floppyMounted;
char *distWanted;
static char mountpoint[] = "/dist";
Boolean
mediaInitFloppy(Device *dev)
{
struct msdosfs_args dosargs;
struct ufs_args u_args;
char *mp;
if (floppyMounted)
return TRUE;
mp = dev->private ? (char *)dev->private : mountpoint;
if (Mkdir(mp)) {
msgConfirm("Unable to make %s directory mountpoint for %s!", mp, dev->devname);
return FALSE;
}
msgDebug("Init floppy called for %s distribution.\n", distWanted ? distWanted : "some");
if (!variable_get(VAR_NONINTERACTIVE)) {
if (!distWanted)
msgConfirm("Please insert floppy in %s", dev->description);
else
msgConfirm("Please insert floppy containing %s in %s",
distWanted, dev->description);
}
memset(&dosargs, 0, sizeof dosargs);
dosargs.fspec = dev->devname;
dosargs.uid = dosargs.gid = 0;
dosargs.mask = 0777;
memset(&u_args, 0, sizeof(u_args));
u_args.fspec = dev->devname;
if (mount("msdosfs", mp, MNT_RDONLY, (caddr_t)&dosargs) != -1)
goto success;
if (mount("ufs", mp, MNT_RDONLY, (caddr_t)&u_args) != -1)
goto success;
msgConfirm("Error mounting floppy %s (%s) on %s : %s",
dev->name, dev->devname, mp, strerror(errno));
return FALSE;
success:
floppyMounted = TRUE;
distWanted = NULL;
return TRUE;
}
FILE *
mediaGetFloppy(Device *dev, char *file, Boolean probe)
{
char buf[PATH_MAX], *mp;
FILE *fp;
int nretries = 5;
/*
* floppies don't use mediaGenericGet() because it's too expensive
* to speculatively open files on a floppy disk. Make user get it
* right or give up with floppies.
*/
mp = dev->private ? (char *)dev->private : mountpoint;
snprintf(buf, PATH_MAX, "%s/%s", mp, file);
if (!file_readable(buf)) {
if (probe)
return NULL;
else {
while (!file_readable(buf)) {
if (!--nretries) {
msgConfirm("GetFloppy: Failed to get %s after retries;\ngiving up.", buf);
return NULL;
}
distWanted = buf;
mediaShutdownFloppy(dev);
if (!mediaInitFloppy(dev))
return NULL;
}
}
}
fp = fopen(buf, "r");
return fp;
}
void
mediaShutdownFloppy(Device *dev)
{
if (floppyMounted) {
char *mp = dev->private ? (char *)dev->private : mountpoint;
if (unmount(mp, MNT_FORCE) != 0)
msgDebug("Umount of floppy on %s failed: %s (%d)\n", mp, strerror(errno), errno);
else {
floppyMounted = FALSE;
if (!variable_get(VAR_NONINTERACTIVE) && variable_cmp(SYSTEM_STATE, "fixit"))
msgConfirm("You may remove the floppy from %s", dev->description);
}
}
}

View File

@ -1,282 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <netdb.h>
#include <pwd.h>
#include <ftpio.h>
Boolean ftpInitted = FALSE;
static FILE *OpenConn;
int FtpPort;
/* List of sub directories to look for under a given FTP server. */
const char *ftp_dirs[] = { ".", "releases/"MACHINE, "snapshots/"MACHINE,
"pub/FreeBSD", "pub/FreeBSD/releases/"MACHINE,
"pub/FreeBSD/snapshots/"MACHINE, NULL };
/* Brings up attached network device, if any - takes FTP device as arg */
static Boolean
netUp(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
return DEVICE_INIT(netdev);
else
return TRUE; /* No net == happy net */
}
/* Brings down attached network device, if any - takes FTP device as arg */
static void
netDown(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
DEVICE_SHUTDOWN(netdev);
}
Boolean
mediaInitFTP(Device *dev)
{
int i, code, af, fdir;
char *cp, *rel, *hostname, *dir;
char *user, *login_name, password[80];
if (ftpInitted)
return TRUE;
if (OpenConn) {
fclose(OpenConn);
OpenConn = NULL;
}
/* If we can't initialize the network, bag it! */
if (!netUp(dev))
return FALSE;
try:
cp = variable_get(VAR_FTP_PATH);
if (!cp) {
if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) {
msgConfirm("Unable to get proper FTP path. FTP media not initialized.");
netDown(dev);
return FALSE;
}
}
hostname = variable_get(VAR_FTP_HOST);
dir = variable_get(VAR_FTP_DIR);
if (!hostname || !dir) {
msgConfirm("Missing FTP host or directory specification. FTP media not initialized,");
netDown(dev);
return FALSE;
}
user = variable_get(VAR_FTP_USER);
login_name = (!user || !*user) ? "anonymous" : user;
if (variable_get(VAR_FTP_PASS))
SAFE_STRCPY(password, variable_get(VAR_FTP_PASS));
else if (RunningAsInit)
sprintf(password, "installer@%s", variable_get(VAR_HOSTNAME));
else {
struct passwd *pw;
char *user;
pw = getpwuid(getuid());
user = pw ? pw->pw_name : "ftp";
sprintf(password, "%s@%s", user, variable_get(VAR_HOSTNAME));
}
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
msgNotify("Logging in to %s@%s..", login_name, hostname);
if ((OpenConn = ftpLoginAf(hostname, af, login_name, password, FtpPort, isDebug(), &code)) == NULL) {
msgConfirm("Couldn't open FTP connection to %s:\n %s.", hostname, ftpErrString(code));
goto punt;
}
ftpPassive(OpenConn, !strcmp(variable_get(VAR_FTP_STATE), "passive"));
ftpBinary(OpenConn);
if (dir && *dir != '\0') {
if ((i = ftpChdir(OpenConn, dir)) != 0) {
if (i == 550)
msgConfirm("No such directory ftp://%s/%s\n"
"please check your URL and try again.", hostname, dir);
else
msgConfirm("FTP chdir to ftp://%s/%s returned error status:\n %s.", hostname, dir, ftpErrString(i));
goto punt;
}
}
/*
* Now that we've verified that the path we're given is ok, let's try to
* be a bit intelligent in locating the release we are looking for. First
* off, if the release is specified as "__RELEASE" or "any", then just
* assume that the current directory is the one we want and give up.
*/
rel = variable_get(VAR_RELNAME);
if (strcmp(rel, "__RELEASE") && strcmp(rel, "any")) {
/*
* Ok, since we have a release variable, let's walk through the list
* of directories looking for a release directory. The first one to
* match wins. For each case, we chdir to ftp_dirs[fdir] first. If
* that fails, we skip to the next one. Otherwise, we try to chdir to
* rel. If it succeeds we break out. If it fails, then we go back to
* the base directory and try again. Lots of chdirs, but oh well. :)
*/
for (fdir = 0; ftp_dirs[fdir]; fdir++) {
/* Avoid sending CWD . commands which confuse some ftp servers */
if (strcmp(ftp_dirs[fdir], ".") &&
(ftpChdir(OpenConn, (char *)ftp_dirs[fdir]) != 0))
continue;
if (ftpChdir(OpenConn, rel) == 0) {
ftpInitted = TRUE;
return TRUE;
}
else /* reset to "root" dir for a fresh try */
ftpChdir(OpenConn, "/");
}
/*
* If we get here, then all of the directories we tried failed, so
* print out the error message and ask the user if they want to try
* again.
*/
if (!msgYesNo("Warning: Can't find the `%s' distribution on this\n"
"FTP server. You may need to visit a different server for\n"
"the release you are trying to fetch or go to the Options\n"
"menu and to set the release name to explicitly match what's\n"
"available on %s (or set to \"any\").\n\n"
"Would you like to select another FTP server?",
rel, hostname)) {
variable_unset(VAR_FTP_PATH);
if (DITEM_STATUS(mediaSetFTP(NULL)) != DITEM_FAILURE)
goto try;
}
} else {
ftpInitted = TRUE;
return TRUE;
}
punt:
ftpInitted = FALSE;
if (OpenConn != NULL) {
fclose(OpenConn);
OpenConn = NULL;
}
netDown(dev);
variable_unset(VAR_FTP_PATH);
return FALSE;
}
FILE *
mediaGetFTP(Device *dev, char *file, Boolean probe)
{
int nretries = 1;
FILE *fp;
char *try, buf[PATH_MAX];
if (!OpenConn) {
msgDebug("No FTP connection open, can't get file %s\n", file);
return NULL;
}
try = file;
while ((fp = ftpGet(OpenConn, try, 0)) == NULL) {
int ftperr = ftpErrno(OpenConn);
/* If a hard fail, try to "bounce" the ftp server to clear it */
if (ftperr != 550) {
if (ftperr != 421) /* Timeout? */
variable_unset(VAR_FTP_PATH);
/* If we can't re-initialize, just forget it */
DEVICE_SHUTDOWN(dev);
if (!DEVICE_INIT(dev)) {
netDown(dev);
if (OpenConn) {
fclose(OpenConn);
OpenConn = NULL;
}
variable_unset(VAR_FTP_PATH);
return NULL;
}
}
else if (probe)
return NULL;
else {
/* Try some alternatives */
switch (nretries++) {
case 1:
sprintf(buf, "releases/%s", file);
try = buf;
break;
case 2:
sprintf(buf, "%s/%s", variable_get(VAR_RELNAME), file);
try = buf;
break;
case 3:
sprintf(buf, "%s/releases/%s", variable_get(VAR_RELNAME), file);
try = buf;
break;
case 4:
try = file;
break;
}
}
}
return fp;
}
void
mediaShutdownFTP(Device *dev)
{
if (!ftpInitted)
return;
if (OpenConn != NULL) {
fclose(OpenConn);
OpenConn = NULL;
}
ftpInitted = FALSE;
}

View File

@ -1,93 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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"
/*
* Various global variables and an initialization hook to set them to
* whatever values we feel are appropriate.
*/
int DebugFD; /* Where diagnostic output goes */
Boolean Fake; /* Only pretend to be useful */
Boolean RunningAsInit; /* Are we running as init? */
Boolean DialogActive; /* Is libdialog initialized? */
Boolean ColorDisplay; /* Are we on a color display? */
Boolean OnVTY; /* Are we on a VTY? */
Boolean Restarting; /* Are we restarting sysinstall? */
Boolean have_volumes; /* Media has more than one volume. */
Variable *VarHead; /* The head of the variable chain */
Device *mediaDevice; /* Where we're installing from */
int BootMgr; /* Which boot manager we're using */
int StatusLine; /* Where to stick our status messages */
int low_volume; /* Lowest volume number */
int high_volume; /* Highest volume number */
jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */
Chunk *HomeChunk;
Chunk *RootChunk;
Chunk *SwapChunk;
Chunk *TmpChunk;
Chunk *UsrChunk;
Chunk *VarChunk;
#ifdef __ia64__
Chunk *EfiChunk;
#endif
/*
* Yes, I know some of these are already automatically initialized as
* globals. I simply find it clearer to set everything explicitly.
*/
void
globalsInit(void)
{
DebugFD = -1;
ColorDisplay = FALSE;
OnVTY = FALSE;
DialogActive = FALSE;
VarHead = NULL;
mediaDevice = NULL;
HomeChunk = NULL;
RootChunk = NULL;
SwapChunk = NULL;
TmpChunk = NULL;
UsrChunk = NULL;
VarChunk = NULL;
#ifdef __ia64__
EfiChunk = NULL;
#endif
}

View File

@ -1,21 +0,0 @@
This screen allows you to configure the anonymous FTP user.
The following configuration values are editable:
UID: The user ID you wish to assign to the anonymous FTP user.
All files uploaded will be owned by this ID.
Group: Which group you wish the anonymous FTP user to be in.
Comment: String describing this user in /etc/passwd
FTP Root Directory:
Where files available for anonymous FTP will be kept.
Upload subdirectory:
Where files uploaded by anonymous FTP users will go.
If you do not wish to allow anonymous uploads, then this
field should be blank - note that this is not the default!

View File

@ -1,10 +0,0 @@
This menu allows you to configure your system after the installation
process is complete. At the minimum, you should probably set the
system manager's password and the system time zone.
For extra goodies like bash, emacs, Pascal, etc., you should look at
the Packages item in this menu.
For setting the timezone after the system is installed, type
``tzsetup''. For more information on the overall general system
configuration, see the ``/etc/defaults/rc.conf'' file.

View File

@ -1,34 +0,0 @@
DISTRIBUTION INFORMATION
------------------------
An ``X-'' prefixed before a distribution set means that the Xorg
base distribution, libraries, manual pages, servers and a set
of default fonts will be selected in addition to the set itself.
If you select such a set, you will also be presented with a set of
menus for customizing the selections to your desired X Window System
setup.
Any distribution may be further customized by selecting the `Custom'
item before leaving the menu.
The current "canned" installations are provided:
All: The base distribution, man pages, dictionary files,
profiling libraries, the FreeBSD compatibility libraries,
the complete source tree, games and your choice of Xorg
distribution components.
Developer: Base distribution, man pages, dictionary files,
profiling libraries and the complete source tree.
Kern-Developer: As Developer, but with only kernel sources instead of
the complete source tree.
User: The base distribution, man pages and dictionary files.
Minimal: Only the base distribution.
Custom: Allows you to create or modify your distribution set on
a piece-by-piece basis.
Reset: Clear all currently selected distributions.

View File

@ -1,92 +0,0 @@
Boot Manager Selection:
-----------------------
If you wish to switch between multiple operating systems on your
machine, or if you are trying to install FreeBSD on a drive other than
your 1st drive, then you must install a boot manager. In the case
where you wish to boot off an alternate drive, it should also be noted
that you still need to install a boot manager on the FIRST drive!
Even if you do not intend to create a FreeBSD partition on that drive
(e.g. it's being wholly used by something else), the boot manager
still needs to reside on the first disk in order to function as a
"redirector" for the boot process.
To do this, simply select your 1st drive in the drive selection menu
and when the partition editor comes up, don't make any changes - just
(Q)uit. At the boot manager menu which follows, select the first
option (install a boot manager) and then proceed to setup the other
drive(s) for FreeBSD as normal.
It should also be noted that "operating systems" such as Windows 95
will completely overwrite your boot manager without so much as a
polite "may I please destroy your boot manager?" prompt if you make
the mistake of installing them second. If this happens to you after
FreeBSD is already installed, all is not lost! Simply revisit your
FreeBSD distribution directory and look for a tools/ subdirectory, in
which you'll find "bootinst.exe" and "boot.bin". To reinstall, simply
say "bootinst boot.bin" while in the tools/ subdirectory.
If you see the boot manager displaying ``F?'' when you try to come up
for the first time and it refuses to change, no matter how often you
whap on the function key assigned to FreeBSD, then you have a geometry
mismatch problem and you should read the next section for important
information on how to prevent that exact problem from happening!
Geometry Translation / Sharing the disk(s) with another OS:
----------------------------------------------------------
If you are going to actually install some portion of FreeBSD on a
drive then PLEASE BE VERY CERTAIN that the Geometry reported in the
Partition Editor is the correct one for your drive and controller
combination!
IDE drives often have a certain geometry set during the PC BIOS setup,
or (in the case of larger IDE drives) have their geometry "translated"
by either the IDE controller or a special boot-sector translation
utility such as that by OnTrack Systems. In these cases, knowing the
correct geometry gets even more complicated as it's not something you
can easily tell by looking at the drive or the PC BIOS setup. The
best way of verifying that your geometry is being correctly calculated
in such situations is to boot DOS (from the hard disk, not a floppy!)
and run the ``pfdisk'' utility provided in the tools/ subdirectory of
the FreeBSD CDROM or FTP site. It will report the geometry that DOS
sees, which is generally the correct one.
If you have no DOS partition sharing the disk at all, then you may
find that you have better luck with Geometry detection if you create a
very small DOS partition first, before installing FreeBSD. Once
FreeBSD is installed you can always delete it again if you need the
space.
It's actually not a bad idea (believe it or not) to have a small
bootable DOS partition on your FreeBSD machine anyway: Should the
machine become unstable or exhibit strange behavior at some point in
the future (which is not uncommon behavior for PC hardware!) you can
then at least use DOS for installing and running one of the
commercially available system diagnostic utilities.
IMPORTANT NOTE:
Any root partition you try to boot from must also reside below the
1024th cylinder. If you're using a translated geometry then this is
probably not a problem, but if you are using a native disk geometry
which exceeds 1024 cylinders then you could have a failure to boot if
you end up installing a root partition (or even just the kernel file
in a root partition) out past cylinder 1024. If you are trying to
share your first disk with FreeBSD and another OS which was installed
previously, you are particularly susceptible to this problem and should
check your disk addresses very carefully.
If you find that you have insufficient space below cylinder 1024 to
make a root partition for FreeBSD (and again, this ONLY applies to the
root partition - once FreeBSD's kernel is loaded, it doesn't care
about the geometry issues) then you will probably need to install on a
completely different disk (see the boot manager section above) or
resize your existing partitions so that both operating systems can
have boot partitions below cylinder 1024.
You may blame IBM for the limitations of a 10 bit cylinder address.
"No one will have a disk with more than 1024 cylinders." I'm sure
someone said.

View File

@ -1,3 +0,0 @@
A special shell will be launched by this option with a fixit floppy
or a FreeBSD CD-ROM (or DVD-ROM) mounted as /mnt2. This provides
access to extra commands under /mnt2.

View File

@ -1,20 +0,0 @@
In this screen, you can jump to remote or local HTML
resources such as the FreeBSD Handbook & FreeBSD FAQ
(Frequently Asked Questions) documents located in:
file:/usr/share/doc/
if you've loaded the doc distribution.
The default browser package used is links (a text based
browser which can render tables), which will be
automatically loaded from the installation media if it
is available. You may change the selection of browser
& browser package to auto-load by visiting the Options
editor.
In order to visit remote URLs, you naturally must have
some sort of working Internet connection. If you have not
yet brought up any network interfaces, please visit
the ``Networking'' item in the Configuration menu
before attempting to reference any http://.. style URLs.

View File

@ -1,54 +0,0 @@
You can install from the following types of media:
CDROM requires one of the following supported CDROM drives:
ATAPI - Any standard ATAPI CDROM drive hooked to
a supported controller (see Hardware Guide).
SCSI - Any standard SCSI CDROM drive hooked to
a supported controller (see Hardware Guide).
DOS A DOS primary partition with the required FreeBSD
distribution files copied onto it (e.g. C:\FREEBSD\)
FS Assuming a disk or partition with an existing
FreeBSD file system and distribution set on it,
get the distribution files from there.
Floppy Get distribution files from one or more DOS or UFS
formatted floppies. Such floppies are assumed to
contain the appropriate distribution pieces - see
ABOUT.TXT for more information about making floppy
distribution media.
FTP Get the distribution files from an anonymous ftp server
(you will be presented with a list). Please note that
you may invoke FTP in "Active" mode, "Passive" mode, or
via an HTTP proxy.
Active mode is the standard way of fetching files and
Passive mode is for use when you're behind a firewall or
some other security mechanism that blocks active FTP
connections. Using an HTTP proxy is sometimes necessary
for firewalls which block all FTP connections.
If you chose to enter your own URL in the FTP menu, please
note that all paths are *relative* to the home directory
of the user being logged in as. By default, this is the
user "ftp" (anonymous ftp) but you may change this in the
Options screen.
NFS Get the distribution files from an NFS server somewhere
(make sure that permissions on the server allow this!).
If this install method hangs on you or refuses to work
properly, you may need to set some special options for
your NFS server. See the Options screen for more details.
Tape Extract distribution files from tape into a temporary
directory and install from there. If the tape was created
with blocksize other than 20, you may wish to change this
in the Options screen.

View File

@ -1,58 +0,0 @@
You can do network installations over 3 types of communications links:
Serial port: SLIP / PPP
Parallel port: PLIP (laplink cable)
Ethernet: A standard Ethernet controller (includes some
PCMCIA networking cards).
SLIP support is rather primitive and limited primarily to directly
connected links, such as a serial cable running between a laptop
computer and another PC. The link must be hard-wired as the SLIP
installation doesn't currently offer a dialing capability (that
facility is offered by the PPP utility, which should be used in
preference to SLIP whenever possible). When you choose the SLIP
option, you'll be given the option of later editing the slattach
command before it's run on the serial line. It is expected that
you'll run slattach (or some equivalent command) on the other end of
the link at that time and bring up the line. FreeBSD will then
install itself at serial speeds of up to 115.2K/baud (the recommended
speed for a hardwired cable).
If you're using a modem then PPP is almost certainly your only choice.
Make sure that you have your service provider's information handy as
you'll need to know it fairly early in the installation process. You
will need to know your service provider's IP address, the IP address
of your provider's DNS server, and possibly your own IP address unless
your ISP supports dynamic negotiation, most do. If you do not choose
a PAP or CHAP login you will also need to know how to use the various
"AT commands" to dial the ISP with your particular brand of modem as
the PPP dialer provides only a very simple terminal emulator and has no
"modem capabilities database". If you choose a PAP or CHAP login you
can simply enter `dial' (without the quotes) at the ppp prompt if your
modem uses the Hayes compatible AT command set.
If a hard-wired connection to another FreeBSD (2.0R or later) machine
is available, you might also consider installing over a "laplink"
parallel port cable. The data rate over the parallel port is much
higher than what is typically possible over a serial line, and speeds
of over 50KB/sec are not uncommon.
Finally, for the fastest possible network installation, an Ethernet
adaptor is always a good choice! FreeBSD supports most common PC
Ethernet cards, a table of which is provided in the FreeBSD Hardware
Guide (see the `Documentation' entry in the main menu). If you are
using one of the supported PCMCIA Ethernet cards, also be sure that
it's plugged in BEFORE the laptop is powered on! Sysinstall does not,
unfortunately, currently support "hot insertion" of PCMCIA cards.
You will also need to know your IP address on the network, the
"netmask" value for your address class, and the name of your machine.
Your system administrator can tell you which values to use for your
particular network setup. If you will be referring to other hosts by
name rather than IP address, you'll also need a name server and
possibly the address of a gateway (if you're using PPP, it's your
provider's IP address) to use in talking to it. If you do not know
the answers to all or most of these questions then you should really
probably talk to your system administrator FIRST before trying this
type of installation! Choosing the wrong IP address on a busy network
will NOT make you popular with your systems administrator! :-)

View File

@ -1,181 +0,0 @@
The following options may be set from this screen. Use the SPACE key
to toggle an option's value, Q to leave when you're done.
NFS Secure: NFS server talks only on a secure port
This is most commonly used when talking to Sun workstations, which
will not talk NFS over "non privileged" ports.
NFS Slow: User is using a slow PC or Ethernet card
Use this option if you have a slow PC (386) or an Ethernet card
with poor performance being "fed" by NFS on a higher-performance
workstation. This will throttle the workstation back to prevent
the PC from becoming swamped with data.
NFS TCP: Use TCP for the NFS mount
This option can be used if your NFS server supports TCP
connections; not all do! This may be useful if your NFS server
is at a remote site in which case it may offer some additional
stability.
NFS version 3: Use NFS version 3
This option forces the use of NFS version 3 and is on by default.
If your NFS server only supports NFS version 2, disable this option.
Debugging: Turn on the extra debugging flag
This turns on a lot of extra noise over on the second screen
(ALT-F2 to see it, ALT-F1 to switch back). If your installation
should fail for any reason, PLEASE turn this flag on when
attempting to reproduce the problem. It will provide a lot of
extra debugging at the failure point and may be very helpful to
the developers in tracking such problems down!
No Warnings: Disable some warnings
This flag tells sysinstall, and particularly the disk editing
routines, that you consider yourself to know what you are
doing and disables various warning. It is not recommended that
you enable this option.
Yes To All: Assume "Yes" answers to all non-critical dialogs
This flag should be used with caution. It will essentially
decide NOT to ask the user about any "boundary" conditions that
might not constitute actual errors but may be warnings indicative
of other problems. It's most useful to those who are doing unattended
installs.
DHCP: Enable DHCP configuration of interfaces
This option specifies whether DHCP configuration of interfaces
may be attempted. The default setting is to interactively ask
the user.
IPv6: Enable IPv6 router solicitation configuration
This option specifies whether automatic configuration of IPv6
interfaces may be attempted. This uses the router solicitation
method of automatic configuration. The default setting is to
interactively ask the user.
FTP username: Specify username and password instead of anonymous.
By default, the installation attempts to log in as the
anonymous user. If you wish to log in as someone else,
specify the username and password with this option.
Editor: Specify which screen editor to use.
At various points during the installation it may be necessary
to customize some text file, at which point the user will be
thrown unceremoniously into a screen editor. A relatively
simplistic editor which shows its command set on-screen is
selected by default, but UNIX purists may wish to change this
setting to `/usr/bin/vi'.
Tape Blocksize: Specify block size in 512 byte blocks of tape.
This defaults to 20 blocks, which should work with most
tape drive + tar combinations. It may not allow your particular
drive to win any records for speed, however, and the more
adventurous among you might try experimenting with larger sizes.
Extract Detail: How to show filenames on debug screen as they're extracted.
While a distribution is being extracted, the default detail level
of "high" will show the full file names as they're extracted.
If you would prefer a more terse form for this, namely dots, select
the "medium" detail level. If you want nothing to be printed
on the debugging screen during extraction, select "low".
Release Name: Which release to attempt to load from installation media.
You should only change this option if you're really sure you know
what you are doing! This will change the release name used by
sysinstall when fetching components of any distributions, and
is a useful way of using a more recent installation boot floppy
with an older release (say, on CDROM).
Install Root: Specify some directory other than / as your "root".
This should be left as / unless you have a really good reason to
change it. One good reason might be if you were installing to a
disk other than your own, as might happen if you needed to prepare a
disk for another machine which couldn't load FreeBSD directly
for some reason.
Note: If you set this option, you will only be able to install
packages if the base distribution is also installed (usually
the case anyway) since /usr/sbin/pkg_add will otherwise not be
found after the chroot() call.
Browser Package: Which package to load for an HTML browser.
By default, this is set to links but may also be set to any other
text capable HTML browser for which a package exists. If you set this
to an X based browser, you will not be able to use it if you're running
in text mode! :)
Browser Exec: Which binary to run for the HTML browser.
The full pathname to the main executable in Browser Package.
Media Type: Which media type is being used.
This is mostly informational and indicates which media type (if any)
was last selected in the Media menu. It's also a convenient short-cut
to the media menu itself.
Package Temp: Where package temporary files should go
Some packages, like emacs, can use a LOT of temporary space - up to
20 or 30MB. If you are going to configure a small / directory and no
separate /var (and hence a small /var/tmp), then you may wish to set
this to point at another location (say, /usr/tmp).
Newfs Args: Specify default arguments to newfs(8)
The default parameters used to build new filesystems.
If you will be running a service that creates millions of small
files or need to specify different default parameters for any
other reason, you may do so here.
Fixit Console: The location of the fixit console
Specifies where sysinstall should start the fixit shell for
interactive repair. Valid arguments are "serial" for a serial
port, or "standard" for VTY4.
Re-scan Devices:
Reprobe the system for devices.
Use Defaults: Use default values.
Reset all options back to their default values.

View File

@ -1,169 +0,0 @@
This is the FreeBSD DiskLabel Editor.
NOTE: If you're entering this editor from the update procedure then
you probably shouldn't (C)reate anything at all but rather use only
the (M)ount command to check and mount existing partitions for
upgrading.
If you would like the label editor to do most of the following for
you, simply type `A' for automatic partitioning of the disk.
If you wish to create partitions manually you may do so by moving the
highlighted selection bar with the arrow keys over the FreeBSD
partition(s) displayed at the top of the screen. Typing (C)reate
while a partition with available free space is selected will allow you
to create a BSD partition inside of it using some or all of its
available space.
Typing (M)ount over an existing partition entry (displayed in the
middle of the screen) will allow you to set a mount point for it
without initializing it. If you want it initialized, use the (T)oggle
command to flip the Newfs flag. When Newfs is set to "Y", the
filesystem in question will be ERASED and rebuilt from scratch!
You should use this editor to create at least the following
filesystems:
Name Purpose Min Size? Optional?
---- ------- --------- ---------
/ Root filesystem 118MB No
swap Swap space 2 * MEM No
/usr System & user files 128MB or more Yes
Note: If you do not create a /usr filesystem then your / filesystem
will need to be bigger - at least 240MB. This is not recommended as
any media errors that may occur during disk I/O to user files will
corrupt the filesystem containing vital system files as well. It is
for this reason that / is generally kept on its own filesystem, where
it should be considered essentially "read only" in your administration
of it.
Swap space is a little tricker, and the rule of "2 * MEM" is simply a
best-guess approximation and not necessarily accurate for your
intended usage of the system. If you intend to use the system heavily
in a server or multi-user application, you may be well advised to
increase this size. You may also create swap space on multiple drives
for a larger "total" swap and this is, in fact, recommended if you
have multiple, fast drives for which such load-balancing can only help
overall I/O performance.
The /usr filesystem should be sized according to what kind of
distributions you're trying to load and how many packages you intend
to install in locations like /usr/local. You can also make /usr/local
a separate filesystem if you don't want to risk filling up your /usr
by mistake.
Another useful filesystem to create is /var, which contains mail, news
printer spool files and other temporary items. It is a popular
candidate for a separate partition and should be sized according to
your estimates of the amount of mail, news or spooled print jobs that
may be stored there.
WARNING: If you do not create a separate filesystem for /var, space
for such files will be allocated out of the root (/) filesystem
instead. You may therefore wish to make the / partition bigger if you
expect a lot of mail or news and do not want to make /var its own
partition.
If you're new to this installation, you might also want to read the
following explanation of how FreeBSD's new "slice" paradigm for
looking at disk storage works:
In FreeBSD's new system, a device name can be broken up into up to 3
parts. Take a typical name like ``/dev/da0s1a'':
The first three characters represent the drive name. If we had
a system with two SCSI drives on it then we'd see /dev/da0 and
/dev/da1 as the device entries representing the entire drives.
Next you have the "slice" (or "FDISK Partition") number,
as seen in the Partition Editor. Assuming that our da0
contained two slices, a FreeBSD slice and a DOS slice, that
would give us /dev/da0s1 and /dev/da0s2 as device entries pointing
to the entire slices.
Next, if a slice is a FreeBSD slice, you can have a number of
(confusingly named) "partitions" inside of it.
These partitions are where various filesystems or swap areas live,
and using our hypothetical two-SCSI-disk machine again, we might
have something like the following layout on da0:
Name Mountpoint
---- ----------
da0s1a /
da0s1b <swap space>
da0s1e /usr
Once you understand all this, then the purpose of the label editor
becomes fairly clear: You're carving up the FreeBSD slices displayed
at the top of the screen into smaller pieces, which are displayed in
the middle of the screen, and then assigning FreeBSD file system names
(mount points) to them.
You can also use the label editor to mount existing partitions/slices
into your filesystem hierarchy, as is frequently done for DOS FAT
slices. For FreeBSD partitions, you can also toggle the "newfs" state
so that the partitions are either (re)created from scratch or simply
checked and mounted (the contents are preserved).
If you set (S)oftUpdates on a filesystem, it will cause the
"Soft Updates" policy to be in effect for it. This basically causes
both metadata and data blocks to be written asynchronously to disk,
but with extra state information which causes the metadata and any
related data blocks to be committed in a single transaction. This
results in async metadata update speeds (which are considerably
faster than the default sync) without the potential for data loss
which could occur if you simply mounted the filesystem with purely
"async" update policy and then had a power failure. If you wish
to later turn the softupdates policy back off, use the command
"tunefs -n disable devicename". NOTE: It is probably not wise
to use this on your root filesystem unless you have a large
(e.g. non-standard size) root. The reason is that smaller filesystems
with significant activity can temporarily overflow if the soft updates
policy results in free'd blocks not being "garbage collected" as fast
as they're being requested.
The UNIX File System (UFS) on FreeBSD supports two different on-disk
layouts: UFS1 and UFS2. UFS1 was the default file system in use
through FreeBSD 5.0-RELEASE; as of FreeBSD 5.1-RELEASE, the default
is now UFS2, with the exception of the PC98 platform. UFS2 provides
sparse inode allocation (faster fsck), 64-bit storage pointers (larger
maximum size), and native extended attributes (required for ACLs, MAC,
and other advanced security and file system services). The selection
of UFS1 or UFS2 must be made when the file system is created--later
conversion is not currently possible. UFS2 is the recommended file
system, but if disks are to be used on older FreeBSD systems, UFS1
improves portability. When dual-booting between FreeBSD 4.x or
earlier and FreeBSD 5.x, UFS1 file systems will be accessible from
both. To toggle a file system to UFS1, press '1'. To restore it to
UFS2, press '2'.
WARNING: FreeBSD on i386 is currently unable to boot from root file
systems larger than 1.5TB.
To add additional flags to the newfs command line for UFS file
systems, press 'N'. These options will be specified before the
device argument of the command line, but after any other options
placed there by sysinstall, such as the UFS version and soft
updates flag; as such, arguments provided may override existing
settings. To completely replace the newfs command used by
sysinstall, press 'Z' to convert a partition to a Custom
partition type. Sysinstall will prompt you with the newfs
command line that it would have used based on existing settings
prior to the change, but allow you to modify any aspect of the
command line. Once a partition has been converted to a custom
partition in the label editor, you will need to restart the
labeling process or delete and recreate the partition to restore
it to a non-custom state. Custom partitions are represented by
the letters "CST" instead of "UFS" or "FAT.
When you're done, type `Q' to exit.
No actual changes will be made to the disk until you (C)ommit from the
Install menu or (W)rite directly from this one. You're working with
what is essentially a copy of the disk label(s), both here and in the
FDISK Partition Editor, and the actual on-disk labels won't be
affected by any changes you make until you explicitly say so.

View File

@ -1,40 +0,0 @@
This menu allows you to configure the Securelevel mechanism in FreeBSD.
Securelevels may be used to limit the privileges assigned to the
root user in multi-user mode, which in turn may limit the effects of
a root compromise, at the cost of reducing administrative functions.
Refer to the security(7) and init(8) manual pages for complete details.
-1 Permanently insecure mode - always run the system in level 0
mode. This is the default initial value.
0 Insecure mode - immutable and append-only flags may be turned
off. All devices may be read or written subject to their
permissions.
1 Secure mode - the system immutable and system append-only
flags may not be turned off; disks for mounted file systems,
/dev/mem, /dev/kmem and /dev/io (if your platform has it)
may not be opened for writing; kernel modules (see kld(4))
may not be loaded or unloaded.
2 Highly secure mode - same as secure mode, plus disks may not
be opened for writing (except by mount(2)) whether mounted or
not. This level precludes tampering with file systems by
unmounting them, but also inhibits running newfs(8) while the
system is multi-user.
In addition, kernel time changes are restricted to less than
or equal to one second. Attempts to change the time by more
than this will log the message ``Time adjustment clamped to +1
second''.
3 Network secure mode - same as highly secure mode, plus IP
packet filter rules (see ipfw(8), ipfirewall(4) and pfctl(8))
cannot be changed and dummynet(4) or pf(4) configuration
cannot be adjusted.
Securelevels must be used in combination with careful system design and
application of protective mechanisms to prevent system configuration
files from being modified in a way that compromises the protections of
the securelevel variable upon reboot.

View File

@ -1,117 +0,0 @@
sysinstall now supports command-line "shortcuts" which can
often replace outdated commands, like pkg_manage. Multiple commands
can be invoked in sequence, and variables may be set on-the-fly to
customize the installation program's behavior in various ways.
Syntax:
/usr/sbin/sysinstall [var=value ..] [command ..]
Where "var" can be one or more of:
blanktime Screen blank time setting in seconds
bootManager Select boot manager: booteasy, standard or none
browserBinary Which doc browser to use (default: links)
browserPackage Which package to get browser from (default: links)
cpioVerbose How verbose to be with cpio: high or low
debug Extra debugging?
defaultrouter IP address of default route
disk Which disk to operate on (ad0, da0, etc).
domainname Domain name
editor Which screen editor to use
ftp Which FTP site/dir to use (URL ftp://site/dir/..)
ftpDirectory Root of the FreeBSD distribution tree on FTP server
ftpHost Which FTP hostname to use (overrides ftp variable)
ftpOnError Set to retry or abort
ftpPass Which password to use when logging into FTP server
ftpPort Which FTP port to use (default: 21)
ftpRetryCount How many times to retry a fetch operation
ftpUser Which username to use when logging into FTP server
gated Use gated instead of routed
geometry Geometry to use for selected disk ("cyl/hd/sec")
hostname Fully qualified domain name for host.
ifconfig_<iface> For each <iface> in network_devices
ipaddr IP address for this host's primary interface
nameserver IP address of name server
netmask Netmask for this host's primary interface
network_interfaces Which network interfaces to configure
nfs Full host:/path/ specification to NFS media
nfsHost Host portion of nfs path
nfsSecure Use NFS secure mount (-P flag)
nfs_server Configure this machine as an NFS server
noConfirm Don't ask for confirmation on non-fatal errors
ntpDate Which ntp clock synchronization server to use
pcnfsd Install the PCNFSD package
ports Path to the ports collection
releaseName Which FreeBSD release to install
rootSize Size of the root partition to create for Auto
routedflags Which flags to pass to routed, if enabled
serialSpeed How fast to run a SLIP/PPP connection
slowEthernetCard PC ethernet card is uncommonly slow
swapSize Size of the swap partition to create for Auto
tapeBlocksize Tape size in blocks
ufs Full path to UFS media directory
usrSize Size of the /usr partition to create for Auto
varSize Size of the /var partition to create for Auto
And "command" can be one or more of:
addGroup Add a new group to the system
addUser Add a new user to the system
configAnonFTP Configure system for anonymous FTP
configInetd Configure the inetd super-server
configNFSServer Configure host as an NFS server
configNTP Configure host as an NTP client
configPackages Browse / install packages
configRouter Configure a routing daemon
configUsers Add users and/or groups to the system
diskLabelCommit Write out any changed label information
diskLabelEditor Label/Newfs/Mount new or existing filesystems
diskPartitionEditor Partition a new or existing disk
diskPartitionWrite Write out any changed partition information
distExtractAll Extract all selected distributions
distReset Reset distribution information
distSetDeveloper Select developer distribution
distSetEverything Select all distributions
distSetKernDeveloper Select kernel developer distribution
distSetMinimum Select minimal distribution
distSetSrc Select source sub-distributions
distSetUser Select user distribution
distSetXDeveloper Select Xorg developer distribution
distSetXOrg Select Xorg sub-distributions
distSetXUser Select Xorg user distribution
docBrowser Browse documentation
installCommit Commit any pending installation operations
installExpress Express installation
installStandard Standard installation
installUpgrade Upgrade installation
mediaGetType Prompt for media type
mediaSetCDROM Select CDROM media
mediaSetCPIOVerbosity Prompt for CPIO verbosity
mediaSetDOS Select DOS media
mediaSetFTP Select FTP media
mediaSetFTPPassive Select FTP media in passive mode
mediaSetFTPUserPass Prompt for FTP username and password
mediaSetFloppy Select floppy media
mediaSetHTTP Select FTP media via HTTP proxy
mediaSetNFS Select NFS media
mediaSetTape Select tape media
mediaSetUFS Select UFS media
optionsEditor Go to options editor
tcpMenuSelect Configure TCP/IP networking
Examples:
/usr/sbin/sysinstall mediaSetFTP configPackages
Selects an FTP site and then goes to the package configuration menu.
/usr/sbin/sysinstall disk=da0 diskPartitionEditor
Invokes the disk partition editor on disk da0.
If /usr/sbin/sysinstall is linked to another filename, say
`/usr/local/bin/configPackages', then the basename will be used
as an implicit command name.

View File

@ -1,57 +0,0 @@
This is the Main Slice (``FDISK'' or PC-style Partition) Editor.
Possible commands are printed at the bottom and the Master Boot Record
contents are shown at the top. You can move up and down with the
arrow keys and (C)reate a new slice whenever the highlighted
selection bar is over a slice whose type is marked as "unused."
You are expected to leave this screen with at least one slice
marked "FreeBSD." Note that unlike Linux, you don't need to create
multiple FreeBSD FDISK partition entries for different things like
swap, file systems, etc. The usual convention is to create ONE
FreeBSD slice (FDISK partition) per drive and then subsection this slice
into swap and file systems with the Label editor.
No actual changes will be made to the disk until you (C)ommit from the
Install menu or use the (W)rite option here! You're working with what
is essentially a copy of the disk label(s), both here and in the Label
Editor.
If you want to use the entire disk for FreeBSD, type `A'. Slices will
be aligned to fictitious cylinder boundaries and space will be reserved
in front of the FreeBSD slice for a [future] possible boot manager.
For the truly dedicated disk case, type `F'. You'll be asked whether or
not you wish to keep the disk (potentially) compatible with other
operating systems, i.e. the information in the FDISK table should be
kept valid. A truly dedicated disk can be achieved by selecting `No'.
In that case, all BIOS geometry considerations will no longer be in
effect and you can safely ignore any ``The detected geometry is
invalid'' warning messages you may later see. It is also not necessary
in this case to set a slice bootable or install an MBR boot manager as
both things are then irrelevant. The FreeBSD slice will start at
absolute sector 0 of the disk (so that FreeBSD's disk label is identical
to the Master Boot Record) and extend to the very last sector of the
disk medium. Needless to say, such a disk cannot have any sort of a
boot manager, `disk manager', or anything else that has to interact with
the BIOS. This option is therefore only considered safe for SCSI disks
and most IDE disks and is primarily intended for people who are going to
set up a dedicated FreeBSD server or workstation, not a typical `home PC'.
If you select the default of `Yes' at the compatibility, slices will be
aligned to fictitious cylinder boundaries and space will be reserved
in front of the FreeBSD slice for a [future] possible boot manager.
This is pretty much equivalent to having chosen `A' originally.
The flags field has the following legend:
'=' -- This slice is properly aligned.
'A' -- This slice is marked active.
'R' -- This slice contains the root (/) filesystem
If no slice is marked Active, you will need to either install
a Boot Manager (the option for which will be presented later in the
installation) or set one Active before leaving this screen.
To leave the slice editor, type `Q'.

View File

@ -1,42 +0,0 @@
This screen allows you to set up your general network parameters
(hostname, domain name, DNS server, etc) as well as the settings for a
given interface (which was selected from the menu before this screen).
PLIP/SLIP users - please read through to the end of this doc!
You can move through the fields with the TAB, BACK-TAB and ENTER
keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A
(control-A) to go to the beginning of the line, ^E (control-E) to go
to the end, ^F (control-F) to go forward a character, ^B (control-B)
to go backward one character, ^D (control-D) to delete the character
under the cursor and ^K (control-K) to delete to the end of the line.
Basically, the standard EMACS motion sequences.
The "Extra options to ifconfig" field is kind of special (read: a
hack :-):
Any valid options to ifconfig can be specified here, so if you need
to do something "special" to get your interface working, then here
is the place to do it.
If you're running SLIP or PLIP, you also need to use it for specifying
the remote end of the link (simply type the foreign IP address in).
In the specific case where you're running PLIP with a Linux host peer
rather than a FreeBSD one, you also must add the "-link0" flag after the
foreign address.
If you're dealing with an ethernet adaptor with multiple media
connectors (e.g. AUI, 10BT, 10B2, etc), you can use this field to
specify which one to use. Examples of valid strings include:
"media 10base5/AUI" - Select the AUI port.
"media 10baseT/UTP" - Select the twisted pair port.
"media 10base2/BNC" - Select the BNC connector.
"media 100baseTX" - Select 100BaseT on a 100/10 dual adaptor.
If you have a wireless interface and must specify arguments such as a
WEP key here, you may use something like:
"wepmode on wepkey 0xFEEDFACE"
When you're done with this form, select OK.

View File

@ -1,65 +0,0 @@
HOW TO USE THIS SYSTEM
======================
[press the PageDown key to go to the next screen when you finish
reading this one]
The following keys are recognized in most of the dialogs you'll
encounter during this installation:
KEY ACTION
--- ------
SPACE Select or toggle the current item.
ENTER Finish with a menu or item.
UP ARROW Move to previous item (or up, in a text display box).
DOWN ARROW Move to next item (or down, in a text display box).
TAB Move to next item or group.
RIGHT ARROW Move to next item or group (same as TAB).
SHIFT-TAB Move to previous item or group.
LEFT ARROW Move to previous item or group (same as SHIFT-TAB).
PAGE UP In text display boxes, scrolls up one page.
PAGE DOWN In text display boxes, scrolls down one page.
F1 Display associated help text.
If you see small "^(-)" or "v(+)" symbols at the edges of a menu, it
means that there are more items above or below the current one that
aren't being shown (due to insufficient screen space). In text
display boxes, the amount of text above the current point will be
displayed as a percentage in the lower right corner. Using the
Up/Down arrow keys will cause the object to scroll by line. The
PageUp and PageDown keys will scroll by entire screens.
Selecting OK in a menu will confirm whatever action it's controlling.
Selecting Cancel will cancel the operation and generally return you to
the previous menu. Use TAB to move the cursor around and select the
buttons.
Most screens obey the Help key (F1) - USE IT! It generally offers useful
context-specific hints on what to do at each stage of the installation,
and if you're at all unsure about what to do at a given stage in the
installation, hit F1!
SPECIAL FEATURES:
=================
It is possible to select a menu item by typing the first character of
its name, if unique. This will generally be an item number.
The console driver contains a scroll-back buffer for reviewing things
that may have scrolled off the screen. To use scroll-back, press the
"Scroll Lock" key on your keyboard and use the arrow or Page Up/Page
Down keys to move through the saved text. To leave scroll-back mode,
press the Scroll Lock key again. This feature is most useful for
reading back through your boot messages (go ahead, try it now!) though
it's also useful when dealing with sub-shells or other "expert modes"
that don't use menus and tend to scroll their output off the top of
the screen.
FreeBSD also supports multiple "virtual consoles" which you can use
in order to have several active sessions at once. Use ALT-F<n> to
switch between screens, where `F<n>' is the function key corresponding
to the screen you wish to see. By default, the system comes with 8
virtual consoles enabled - you can enable more by editing the
/etc/ttys file and turning the "off" field to "on" in the relevant vty
entries (up to 12).

View File

@ -1,89 +0,0 @@
These screens allow you to add groups and users to your system.
You can move through the fields with the TAB, BACK-TAB and ENTER
keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A
(control-A) to go to the beginning of the line, ^E (control-E) to go
to the end, ^F (control-F) to go forward a character, ^B (control-B)
to go backward one character, ^D (control-D) to delete the character
under the cursor and ^K (control-K) to delete to the end of the line.
Basically, the standard EMACS motion sequences.
When you're done with this form, select OK.
Many of the settings get reasonable defaults if you leave them blank.
The first time you have entered the name of the new group or user, the
system will show you what it would chose for most of these fields.
You are free to change them, of course.
User groups
===========
It's certainly almost generally a good idea to first create a new
group for your users. Common names for such a group are "users", or
even simply "other". Group names are used to control file access
permissions for users that belong to the same group. Several group
names are already used for system files.
The numerical user or group IDs are often nothing you want to care for
explicitly. If you don't fill in these fields, the system will choose
reasonable defaults. However, these numbers (rather than the
associated names) are what the operating system actually uses to
distinguish users and groups -- hence they should normally be unique
to each person or group, respectively.
(The initial membership list for a new group is currently
unimplemented, sorry.)
Users
=====
The user's login ID is a short (up to 15 characters) alphanumeric ID
that the user must enter when logging into the system. It's often the
initial letters of the user's name, and commonly used in lower case.
It's also the local mail name for this user (though it's possible to
also set up more descriptive mail alias names later).
The user's login group determines which group access rights the user
will initially get when logging in. If an additional list of groups is
provided which the user will become a member of, (s)he will also be
able to access files of those groups later without providing any
additional password etc. Except for the "wheel" case mentioned below,
the additional group membership list should normally not contain the
login group again.
The user's password can also be set here, and should be chosen with
care - 6 or more characters, intermixing punctuation and numerics, and
*not* a word from the dictionary or related to the username is a good
password choice.
Some of the system's groups have a special meaning. In particular,
members of group "wheel" are the only people who are later allowed to
become superuser using the command su(1). So if you're going to add a
new user who should later perform administrative tasks, don't forget
to add him to this group! (Well, ``he'' will most likely be yourself
in the very first place. :)
Also, members of group "operator" will by default get permissions for
minor administrative operations, like performing system backups, or
shutting down the system -- without first becoming superuser! So,
take care when adding people to this group.
The ``full name'' field serves as a comment only. It is also used by
mail front ends to determine the real name of the user, hence you
should actually fill in the first and last name of this user. By
convention, this field can be divided into comma-separated subfields,
where the office location, the work phone number, and the home phone
number follow the full name of the user.
The home directory is the directory in the filesystem where the user
is being logged into, and where his personalized setup files (``dot
files'', since they usually begin with a `.' and are not displayed by
the ls(1) command by default) will be looked up. It is often created
under /usr/home/ or /home/.
Finally, the shell is the user's initial command interpreter. The
default shell is /bin/sh, some users prefer the more historic
/bin/csh. Other, often more user-friendly and comfortable shells can
be found in the ports and packages collection.

View File

@ -1,279 +0,0 @@
/*
* Copyright (c) 1999
* Philipp Mergenthaler <philipp.mergenthaler@stud.uni-karlsruhe.de>
* 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.
* 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 THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
*
* $FreeBSD$
*/
#include "sysinstall.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/param.h>
#include <netdb.h>
extern const char *ftp_dirs[]; /* defined in ftp.c */
static Boolean
checkAccess(Boolean proxyCheckOnly)
{
/*
* Some proxies fetch files with certain extensions in "ascii mode" instead
* of "binary mode" for FTP. The FTP server then translates all LF to CRLF.
*
* You can force Squid to use binary mode by appending ";type=i" to the URL,
* which is what I do here. For other proxies, the LF->CRLF substitution
* is reverted in distExtract().
*/
int rv, s, af;
bool el, found=FALSE; /* end of header line */
char *cp, buf[PATH_MAX], req[BUFSIZ];
struct addrinfo hints, *res, *res0;
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if ((rv = getaddrinfo(variable_get(VAR_HTTP_HOST),
variable_get(VAR_HTTP_PORT), &hints, &res0)) != 0) {
msgConfirm("%s", gai_strerror(rv));
variable_unset(VAR_HTTP_HOST);
return FALSE;
}
s = -1;
for (res = res0; res; res = res->ai_next) {
if ((s = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) < 0)
continue;
if (connect(s, res->ai_addr, res->ai_addrlen) >= 0)
break;
close(s);
s = -1;
}
freeaddrinfo(res0);
if (s == -1) {
msgConfirm("Couldn't connect to proxy %s:%s",
variable_get(VAR_HTTP_HOST),variable_get(VAR_HTTP_PORT));
variable_unset(VAR_HTTP_HOST);
return FALSE;
}
if (proxyCheckOnly) {
close(s);
return TRUE;
}
msgNotify("Checking access to\n %s", variable_get(VAR_HTTP_PATH));
sprintf(req,"GET %s/ HTTP/1.0\r\n\r\n", variable_get(VAR_HTTP_PATH));
write(s,req,strlen(req));
/*
* scan the headers of the response
* this is extremely quick'n dirty
*
*/
bzero(buf, PATH_MAX);
cp=buf;
el=FALSE;
rv=read(s,cp,1);
variable_set2(VAR_HTTP_FTP_MODE,"",0);
while (rv>0) {
if ((*cp == '\012') && el) {
/* reached end of a header line */
if (!strncmp(buf,"HTTP",4)) {
if (strtol((char *)(buf+9),0,0) == 200) {
found = TRUE;
}
}
if (!strncmp(buf,"Server: ",8)) {
if (!strncmp(buf,"Server: Squid",13)) {
variable_set2(VAR_HTTP_FTP_MODE,";type=i",0);
} else {
variable_set2(VAR_HTTP_FTP_MODE,"",0);
}
}
/* ignore other headers */
/* check for "\015\012" at beginning of line, i.e. end of headers */
if ((cp-buf) == 1)
break;
cp=buf;
rv=read(s,cp,1);
} else {
el=FALSE;
if (*cp == '\015')
el=TRUE;
cp++;
rv=read(s,cp,1);
}
}
close(s);
return found;
}
Boolean
mediaInitHTTP(Device *dev)
{
bool found=FALSE; /* end of header line */
char *rel, req[BUFSIZ];
int fdir;
/*
* First verify the proxy access
*/
checkAccess(TRUE);
while (variable_get(VAR_HTTP_HOST) == NULL) {
if (DITEM_STATUS(mediaSetHTTP(NULL)) == DITEM_FAILURE)
return FALSE;
checkAccess(TRUE);
}
again:
/* If the release is specified as "__RELEASE" or "any", then just
* assume that the path the user gave is ok.
*/
rel = variable_get(VAR_RELNAME);
/*
msgConfirm("rel: -%s-", rel);
*/
if (strcmp(rel, "__RELEASE") && strcmp(rel, "any")) {
for (fdir = 0; ftp_dirs[fdir]; fdir++) {
sprintf(req, "%s/%s/%s", variable_get(VAR_FTP_PATH),
ftp_dirs[fdir], rel);
variable_set2(VAR_HTTP_PATH, req, 0);
if (checkAccess(FALSE)) {
found = TRUE;
break;
}
}
} else {
variable_set2(VAR_HTTP_PATH, variable_get(VAR_FTP_PATH), 0);
found = checkAccess(FALSE);
}
if (!found) {
msgConfirm("No such directory: %s\n"
"please check the URL and try again.", variable_get(VAR_HTTP_PATH));
variable_unset(VAR_HTTP_PATH);
dialog_clear_norefresh();
clear();
if (DITEM_STATUS(mediaSetHTTP(NULL)) != DITEM_FAILURE) goto again;
}
return found;
}
FILE *
mediaGetHTTP(Device *dev, char *file, Boolean probe)
{
FILE *fp;
int rv, s, af;
bool el; /* end of header line */
char *cp, buf[PATH_MAX], req[BUFSIZ];
struct addrinfo hints, *res, *res0;
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if ((rv = getaddrinfo(variable_get(VAR_HTTP_HOST),
variable_get(VAR_HTTP_PORT), &hints, &res0)) != 0) {
msgConfirm("%s", gai_strerror(rv));
return NULL;
}
s = -1;
for (res = res0; res; res = res->ai_next) {
if ((s = socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) < 0)
continue;
if (connect(s, res->ai_addr, res->ai_addrlen) >= 0)
break;
close(s);
s = -1;
}
freeaddrinfo(res0);
if (s == -1) {
msgConfirm("Couldn't connect to proxy %s:%s",
variable_get(VAR_HTTP_HOST),variable_get(VAR_HTTP_PORT));
return NULL;
}
sprintf(req,"GET %s/%s%s HTTP/1.0\r\n\r\n",
variable_get(VAR_HTTP_PATH), file, variable_get(VAR_HTTP_FTP_MODE));
if (isDebug()) {
msgDebug("sending http request: %s\n",req);
}
write(s,req,strlen(req));
/*
* scan the headers of the response
* this is extremely quick'n dirty
*
*/
cp=buf;
el=FALSE;
rv=read(s,cp,1);
while (rv>0) {
if ((*cp == '\012') && el) {
/* reached end of a header line */
if (!strncmp(buf,"HTTP",4)) {
rv=strtol((char *)(buf+9),0,0);
*(cp-1)='\0'; /* chop the CRLF off */
if (probe && (rv != 200)) {
return NULL;
} else if (rv >= 500) {
msgConfirm("Server error %s when sending %s, you could try an other server",buf, req);
return NULL;
} else if (rv == 404) {
msgConfirm("%s was not found, maybe directory or release-version are wrong?",req);
return NULL;
} else if (rv >= 400) {
msgConfirm("Client error %s, you could try an other server",buf);
return NULL;
} else if (rv >= 300) {
msgConfirm("Error %s,",buf);
return NULL;
} else if (rv != 200) {
msgConfirm("Error %s when sending %s, you could try an other server",buf, req);
return NULL;
}
}
/* ignore other headers */
/* check for "\015\012" at beginning of line, i.e. end of headers */
if ((cp-buf) == 1)
break;
cp=buf;
rv=read(s,cp,1);
} else {
el=FALSE;
if (*cp == '\015')
el=TRUE;
cp++;
rv=read(s,cp,1);
}
}
fp=fdopen(s,"r");
return fp;
}

View File

@ -1,893 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* 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.
*
* $FreeBSD$
*/
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ncurses.h>
#include <dialog.h>
#include "sysinstall.h"
/* Macros and magic values */
#define MAX_MENU 12
#define _MAX_DESC 55
/* A structure holding the root, top and plist pointer at once */
struct ListPtrs
{
PkgNodePtr root; /* root of tree */
PkgNodePtr top; /* part of tree we handle */
PkgNodePtr plist; /* list of selected packages */
};
typedef struct ListPtrs* ListPtrsPtr;
static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie);
/* Shared between index_initialize() and the various clients of it */
PkgNode Top, Plist;
/* Smarter strdup */
static inline char *
_strdup(char *ptr)
{
return ptr ? strdup(ptr) : NULL;
}
static char *descrs[] = {
"Package Selection", "To mark a package, move to it and press SPACE. If the package is\n"
"already marked, it will be unmarked or deleted (if installed).\n"
"Items marked with a `D' are dependencies which will be auto-loaded.\n"
"To search for a package by name, press ESC. To select a category,\n"
"press RETURN. NOTE: The All category selection creates a very large\n"
"submenu! If you select it, please be patient while it comes up.",
"Package Targets", "These are the packages you've selected for extraction.\n\n"
"If you're sure of these choices, select OK.\n"
"If not, select Cancel to go back to the package selection menu.\n",
"All", "All available packages in all categories.",
"accessibility", "Ports to help disabled users.",
"afterstep", "Ports to support the AfterStep window manager.",
"arabic", "Ported software for Arab countries.",
"archivers", "Utilities for archiving and unarchiving data.",
"astro", "Applications related to astronomy.",
"audio", "Audio utilities - most require a supported sound card.",
"benchmarks", "Utilities for measuring system performance.",
"biology", "Software related to biology.",
"cad", "Computer Aided Design utilities.",
"chinese", "Ported software for the Chinese market.",
"comms", "Communications utilities.",
"converters", "Format conversion utilities.",
"databases", "Database software.",
"deskutils", "Various Desktop utilities.",
"devel", "Software development utilities and libraries.",
"dns", "Domain Name Service tools.",
"docs", "Meta-ports for FreeBSD documentation.",
"editors", "Editors.",
"elisp", "Things related to Emacs Lisp.",
"emulators", "Utilities for emulating other operating systems.",
"finance", "Monetary, financial and related applications.",
"french", "Ported software for French countries.",
"ftp", "FTP client and server utilities.",
"games", "Various and sundry amusements.",
"german", "Ported software for Germanic countries.",
"geography", "Geography-related software.",
"gnome", "Components of the Gnome Desktop environment.",
"gnustep", "Software for GNUstep desktop environment.",
"graphics", "Graphics libraries and utilities.",
"haskell", "Software related to the Haskell language.",
"hamradio", "Software for amateur radio.",
"hebrew", "Ported software for Hebrew language.",
"hungarian", "Ported software for the Hungarian market.",
"ipv6", "IPv6 related software.",
"irc", "Internet Relay Chat utilities.",
"japanese", "Ported software for the Japanese market.",
"java", "Java language support.",
"kde", "Software for the K Desktop Environment.",
"kld", "Kernel loadable modules",
"korean", "Ported software for the Korean market.",
"lang", "Computer languages.",
"linux", "Linux programs that can run under binary compatibility.",
"lisp", "Software related to the Lisp language.",
"mail", "Electronic mail packages and utilities.",
"math", "Mathematical computation software.",
"mbone", "Applications and utilities for the MBONE.",
"misc", "Miscellaneous utilities.",
"multimedia", "Multimedia software.",
"net", "Networking utilities.",
"net-im", "Instant messaging software.",
"net-mgmt", "Network management tools.",
"net-p2p", "Peer to peer network applications.",
"news", "USENET News support software.",
"palm", "Software support for the Palm(tm) series.",
"parallel", "Applications dealing with parallelism in computing.",
"pear", "Software related to the Pear PHP framework.",
"perl5", "Utilities/modules for the PERL5 language.",
"plan9", "Software from the Plan9 operating system.",
"polish", "Ported software for the Polish market.",
"ports-mgmt", "Utilities for managing ports and packages.",
"portuguese", "Ported software for the Portuguese market.",
"print", "Utilities for dealing with printing.",
"python", "Software related to the Python language.",
"ruby", "Software related to the Ruby language.",
"rubygems", "Ports of RubyGems packages.",
"russian", "Ported software for the Russian market.",
"scheme", "Software related to the Scheme language.",
"science", "Scientific software.",
"security", "System security software.",
"shells", "Various shells (tcsh, bash, etc).",
"spanish", "Ported software for the Spanish market.",
"sysutils", "Various system utilities.",
"tcl", "TCL and packages that depend on it.",
"tcl80", "TCL v8.0 and packages that depend on it.",
"tcl82", "TCL v8.2 and packages that depend on it.",
"tcl83", "TCL v8.3 and packages that depend on it.",
"tcl84", "TCL v8.4 and packages that depend on it.",
"textproc", "Text processing/search utilities.",
"tk", "Tk and packages that depend on it.",
"tk80", "Tk8.0 and packages that depend on it.",
"tk82", "Tk8.2 and packages that depend on it.",
"tk83", "Tk8.3 and packages that depend on it.",
"tk84", "Tk8.4 and packages that depend on it.",
"tkstep80", "Ports to support the TkStep window manager.",
"ukrainian", "Ported software for the Ukrainian market.",
"vietnamese", "Ported software for the Vietnamese market.",
"windowmaker", "Ports to support the WindowMaker window manager.",
"www", "Web utilities (browsers, HTTP servers, etc).",
"x11", "X Window System based utilities.",
"x11-clocks", "X Window System based clocks.",
"x11-drivers", "X Window System drivers.",
"x11-fm", "X Window System based file managers.",
"x11-fonts", "X Window System fonts and font utilities.",
"x11-servers", "X Window System servers.",
"x11-themes", "X Window System themes.",
"x11-toolkits", "X Window System based development toolkits.",
"x11-wm", "X Window System window managers.",
"xfce", "Software related to the Xfce Desktop Environment.",
"zope", "Software related to the Zope platform.",
NULL, NULL,
};
static char *
fetch_desc(char *name)
{
int i;
for (i = 0; descrs[i]; i += 2) {
if (!strcmp(descrs[i], name))
return descrs[i + 1];
}
return "No description provided";
}
static PkgNodePtr
new_pkg_node(char *name, node_type type)
{
PkgNodePtr tmp = safe_malloc(sizeof(PkgNode));
tmp->name = _strdup(name);
tmp->type = type;
return tmp;
}
static char *
strip(char *buf)
{
int i;
for (i = 0; buf[i]; i++)
if (buf[i] == '\t' || buf[i] == '\n')
buf[i] = ' ';
return buf;
}
static IndexEntryPtr
new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *deps, int volume)
{
IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry));
tmp->name = _strdup(name);
tmp->path = _strdup(pathto);
tmp->prefix = _strdup(prefix);
tmp->comment = _strdup(comment);
tmp->descrfile = strip(_strdup(descr));
tmp->maintainer = _strdup(maint);
tmp->deps = _strdup(deps);
tmp->depc = 0;
tmp->installed = package_installed(name);
tmp->vol_checked = 0;
tmp->volume = volume;
if (volume != 0) {
have_volumes = TRUE;
if (low_volume == 0)
low_volume = volume;
else if (low_volume > volume)
low_volume = volume;
if (high_volume < volume)
high_volume = volume;
}
return tmp;
}
static void
index_register(PkgNodePtr top, char *where, IndexEntryPtr ptr)
{
PkgNodePtr p, q;
for (q = NULL, p = top->kids; p; p = p->next) {
if (!strcmp(p->name, where)) {
q = p;
break;
}
}
if (!p) {
/* Add new category */
q = new_pkg_node(where, PLACE);
q->desc = fetch_desc(where);
q->next = top->kids;
top->kids = q;
}
p = new_pkg_node(ptr->name, PACKAGE);
p->desc = ptr->comment;
p->data = ptr;
p->next = q->kids;
q->kids = p;
}
static int
copy_to_sep(char *to, char *from, int sep)
{
char *tok;
tok = strchr(from, sep);
if (!tok) {
*to = '\0';
return 0;
}
*tok = '\0';
strcpy(to, from);
return tok + 1 - from;
}
static int
skip_to_sep(char *from, int sep)
{
char *tok;
tok = strchr(from, sep);
if (!tok)
return 0;
*tok = '\0';
return tok + 1 - from;
}
static int
readline(FILE *fp, char *buf, int max)
{
int rv, i = 0;
char ch;
while ((rv = fread(&ch, 1, 1, fp)) == 1 && ch != '\n' && i < max)
buf[i++] = ch;
if (i < max)
buf[i] = '\0';
return rv;
}
/*
* XXX - this function should do error checking, and skip corrupted INDEX
* lines without a set number of '|' delimited fields.
*/
static int
index_parse(FILE *fp, char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *cats, char *rdeps, int *volume)
{
char line[10240 + 2048 * 7];
char junk[2048];
char volstr[2048];
char *cp;
int i;
i = readline(fp, line, sizeof line);
if (i <= 0)
return EOF;
cp = line;
cp += copy_to_sep(name, cp, '|'); /* package name */
cp += copy_to_sep(pathto, cp, '|'); /* ports directory */
cp += copy_to_sep(prefix, cp, '|'); /* prefix */
cp += copy_to_sep(comment, cp, '|'); /* comment */
cp += copy_to_sep(descr, cp, '|'); /* path to pkg-descr */
cp += copy_to_sep(maint, cp, '|'); /* maintainer */
cp += copy_to_sep(cats, cp, '|'); /* categories */
cp += skip_to_sep(cp, '|'); /* build deps - not used */
cp += copy_to_sep(rdeps, cp, '|'); /* run deps */
if (index(cp, '|'))
cp += skip_to_sep(cp, '|'); /* url - not used */
else {
strncpy(junk, cp, 1023);
*volume = 0;
return 0;
}
if (index(cp, '|'))
cp += skip_to_sep(cp, '|'); /* extract deps - not used */
if (index(cp, '|'))
cp += skip_to_sep(cp, '|'); /* patch deps - not used */
if (index(cp, '|'))
cp += skip_to_sep(cp, '|'); /* fetch deps - not used */
if (index(cp, '|'))
cp += copy_to_sep(volstr, cp, '|'); /* media volume */
else {
strncpy(volstr, cp, 1023);
}
*volume = atoi(volstr);
return 0;
}
int
index_read(FILE *fp, PkgNodePtr papa)
{
char name[127], pathto[255], prefix[255], comment[255], descr[127], maint[127], cats[511], deps[2048 * 8];
int volume;
PkgNodePtr i;
while (index_parse(fp, name, pathto, prefix, comment, descr, maint, cats, deps, &volume) != EOF) {
char *cp, *cp2, tmp[1024];
IndexEntryPtr idx;
idx = new_index(name, pathto, prefix, comment, descr, maint, deps, volume);
/* For now, we only add things to menus if they're in categories. Keywords are ignored */
for (cp = strcpy(tmp, cats); (cp2 = strchr(cp, ' ')) != NULL; cp = cp2 + 1) {
*cp2 = '\0';
index_register(papa, cp, idx);
}
index_register(papa, cp, idx);
/* Add to special "All" category */
index_register(papa, "All", idx);
}
/* Adjust dependency counts */
for (i = papa->kids; i != NULL; i = i->next)
if (strcmp(i->name, "All") == 0)
break;
for (i = i->kids; i != NULL; i = i->next)
if (((IndexEntryPtr)i->data)->installed)
index_recorddeps(TRUE, papa, i->data);
return 0;
}
void
index_init(PkgNodePtr top, PkgNodePtr plist)
{
if (top) {
top->next = top->kids = NULL;
top->name = "Package Selection";
top->type = PLACE;
top->desc = fetch_desc(top->name);
top->data = NULL;
}
if (plist) {
plist->next = plist->kids = NULL;
plist->name = "Package Targets";
plist->type = PLACE;
plist->desc = fetch_desc(plist->name);
plist->data = NULL;
}
}
void
index_print(PkgNodePtr top, int level)
{
int i;
while (top) {
for (i = 0; i < level; i++) putchar('\t');
printf("name [%s]: %s\n", top->type == PLACE ? "place" : "package", top->name);
for (i = 0; i < level; i++) putchar('\t');
printf("desc: %s\n", top->desc);
if (top->kids)
index_print(top->kids, level + 1);
top = top->next;
}
}
/* Swap one node for another */
static void
swap_nodes(PkgNodePtr a, PkgNodePtr b)
{
PkgNode tmp;
tmp = *a;
*a = *b;
a->next = tmp.next;
tmp.next = b->next;
*b = tmp;
}
/* Use a disgustingly simplistic bubble sort to put our lists in order */
void
index_sort(PkgNodePtr top)
{
PkgNodePtr p, q;
/* Sort everything at the top level */
for (p = top->kids; p; p = p->next) {
for (q = top->kids; q; q = q->next) {
if (q->next && strcmp(q->name, q->next->name) > 0)
swap_nodes(q, q->next);
}
}
/* Now sub-sort everything n levels down */
for (p = top->kids; p; p = p->next) {
if (p->kids)
index_sort(p);
}
}
/* Delete an entry out of the list it's in (only the plist, at present) */
static void
index_delete(PkgNodePtr n)
{
if (n->next) {
PkgNodePtr p = n->next;
*n = *(n->next);
safe_free(p);
}
else /* Kludgy end sentinal */
n->name = NULL;
}
/*
* Search for a given node by name, returning the category in if
* tp is non-NULL.
*/
PkgNodePtr
index_search(PkgNodePtr top, char *str, PkgNodePtr *tp)
{
PkgNodePtr p, sp;
for (p = top->kids; p && p->name; p = p->next) {
if (p->type == PACKAGE) {
/* If tp == NULL, we're looking for an exact package match */
if (!tp && !strcmp(p->name, str))
return p;
/* If tp, we're looking for both a package and a pointer to the place it's in */
if (tp && !strncmp(p->name, str, strlen(str))) {
*tp = top;
return p;
}
}
else if (p->kids) {
/* The usual recursion-out-of-laziness ploy */
if ((sp = index_search(p, str, tp)) != NULL)
return sp;
}
}
if (p && !p->name)
p = NULL;
return p;
}
static int
pkg_checked(dialogMenuItem *self)
{
ListPtrsPtr lists = (ListPtrsPtr)self->aux;
PkgNodePtr kp = self->data, plist = lists->plist;
int i;
i = index_search(plist, kp->name, NULL) ? TRUE : FALSE;
if (kp->type == PACKAGE && plist) {
IndexEntryPtr ie = kp->data;
int markD, markX;
markD = ie->depc > 0; /* needed as dependency */
markX = i || ie->installed; /* selected or installed */
self->mark = markX ? 'X' : 'D';
return markD || markX;
} else
return FALSE;
}
static int
pkg_fire(dialogMenuItem *self)
{
int ret;
ListPtrsPtr lists = (ListPtrsPtr)self->aux;
PkgNodePtr sp, kp = self->data, plist = lists->plist;
if (!plist)
ret = DITEM_FAILURE;
else if (kp->type == PACKAGE) {
IndexEntryPtr ie = kp->data;
sp = index_search(plist, kp->name, NULL);
/* Not already selected? */
if (!sp) {
if (!ie->installed) {
PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
*np = *kp;
np->next = plist->kids;
plist->kids = np;
index_recorddeps(TRUE, lists->root, ie);
msgInfo("Added %s to selection list", kp->name);
}
else if (ie->depc == 0) {
if (!msgNoYes("Do you really want to delete %s from the system?", kp->name)) {
if (vsystem("pkg_delete %s %s", isDebug() ? "-v" : "", kp->name)) {
msgConfirm("Warning: pkg_delete of %s failed.\n Check debug output for details.", kp->name);
}
else {
ie->installed = 0;
index_recorddeps(FALSE, lists->root, ie);
}
}
}
else
msgConfirm("Warning: Package %s is needed by\n %d other installed package%s.",
kp->name, ie->depc, (ie->depc != 1) ? "s" : "");
}
else {
index_recorddeps(FALSE, lists->root, ie);
msgInfo("Removed %s from selection list", kp->name);
index_delete(sp);
}
ret = DITEM_SUCCESS;
/* Mark menu for redraw if we had dependencies */
if (strlen(ie->deps) > 0)
ret |= DITEM_REDRAW;
}
else { /* Not a package, must be a directory */
int p, s;
p = s = 0;
index_menu(lists->root, kp, plist, &p, &s);
ret = DITEM_SUCCESS | DITEM_CONTINUE;
}
return ret;
}
static void
pkg_selected(dialogMenuItem *self, int is_selected)
{
PkgNodePtr kp = self->data;
if (!is_selected || kp->type != PACKAGE)
return;
msgInfo("%s", kp->desc);
}
int
index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll)
{
struct ListPtrs lists;
size_t maxname;
int n, rval;
int curr, max;
PkgNodePtr kp;
dialogMenuItem *nitems;
Boolean hasPackages;
WINDOW *w;
lists.root = root;
lists.top = top;
lists.plist = plist;
hasPackages = FALSE;
nitems = NULL;
n = maxname = 0;
/* Figure out if this menu is full of "leaves" or "branches" */
for (kp = top->kids; kp && kp->name; kp = kp->next) {
size_t len;
++n;
if (kp->type == PACKAGE && plist) {
hasPackages = TRUE;
if ((len = strlen(kp->name)) > maxname)
maxname = len;
}
}
if (!n && plist) {
msgConfirm("The %s menu is empty.", top->name);
return DITEM_LEAVE_MENU;
}
w = savescr();
while (1) {
n = 0;
curr = max = 0;
use_helpline(NULL);
use_helpfile(NULL);
kp = top->kids;
if (!hasPackages && plist) {
nitems = item_add(nitems, "OK", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
nitems = item_add(nitems, "Install", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
}
while (kp && kp->name) {
char buf[256];
IndexEntryPtr ie = kp->data;
/* Brutally adjust description to fit in menu */
if (kp->type == PACKAGE)
snprintf(buf, sizeof buf, "[%s]", ie->path ? ie->path : "External vendor");
else
SAFE_STRCPY(buf, kp->desc);
if (strlen(buf) > (_MAX_DESC - maxname))
buf[_MAX_DESC - maxname] = '\0';
nitems = item_add(nitems, kp->name, buf, pkg_checked,
pkg_fire, pkg_selected, kp, &lists,
&curr, &max);
++n;
kp = kp->next;
}
/* NULL delimiter so item_free() knows when to stop later */
nitems = item_add(nitems, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
&curr, &max);
recycle:
dialog_clear_norefresh();
if (hasPackages)
rval = dialog_checklist(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems, NULL);
else
rval = dialog_menu(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems + (plist ? 2 : 0), (char *)plist, pos, scroll);
if (rval == -1 && plist) {
static char *cp;
PkgNodePtr menu;
/* Search */
if ((cp = msgGetInput(cp, "Search by package name. Please enter search string:")) != NULL) {
PkgNodePtr p = index_search(top, cp, &menu);
if (p) {
int pos, scroll;
/* These need to be set to point at the found item, actually. Hmmm! */
pos = scroll = 0;
index_menu(root, menu, plist, &pos, &scroll);
}
else
msgConfirm("Search string: %s yielded no hits.", cp);
}
goto recycle;
}
items_free(nitems, &curr, &max);
restorescr(w);
return rval ? DITEM_FAILURE : DITEM_SUCCESS;
}
}
int
index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended,
int current_volume)
{
int status = DITEM_SUCCESS;
Boolean notyet = FALSE;
PkgNodePtr tmp2;
IndexEntryPtr id = who->data;
WINDOW *w;
/*
* Short-circuit the package dependency checks. We're already
* maintaining a data structure of installed packages, so if a
* package is already installed, don't try to check to make sure
* that all of its dependencies are installed. At best this
* wastes a ton of cycles and can cause minor delays between
* package extraction. At worst it can cause an infinite loop with
* a certain faulty INDEX file.
*/
if (id->installed == 1 || (have_volumes && id->vol_checked == current_volume))
return DITEM_SUCCESS;
w = savescr();
if (id && id->deps && strlen(id->deps)) {
char t[2048 * 8], *cp, *cp2;
SAFE_STRCPY(t, id->deps);
cp = t;
while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) {
if ((cp2 = index(cp, ' ')) != NULL)
*cp2 = '\0';
if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
status = index_extract(dev, top, tmp2, TRUE, current_volume);
if (DITEM_STATUS(status) != DITEM_SUCCESS) {
/* package probably on a future disc volume */
if (status & DITEM_CONTINUE) {
status = DITEM_SUCCESS;
notyet = TRUE;
} else if (variable_get(VAR_NO_CONFIRM))
msgNotify("Loading of dependent package %s failed", cp);
else
msgConfirm("Loading of dependent package %s failed", cp);
}
}
else if (!package_installed(cp)) {
if (variable_get(VAR_NO_CONFIRM))
msgNotify("Warning: %s is a required package but was not found.", cp);
else
msgConfirm("Warning: %s is a required package but was not found.", cp);
}
if (cp2)
cp = cp2 + 1;
else
cp = NULL;
}
}
/*
* If iterating through disc volumes one at a time indicate failure if
* dependency install failed due to package being on a higher volume
* numbered disc, but that we should continue anyway. Note that this
* package has already been processed for this disc volume so we don't
* need to do it again.
*/
if (notyet) {
restorescr(w);
id->vol_checked = current_volume;
return DITEM_FAILURE | DITEM_CONTINUE;
}
/*
* Done with the deps? Try to load the real m'coy. If iterating
* through a multi-volume disc set fail the install if the package
* is on a higher numbered volume to cut down on disc switches the
* user needs to do, but indicate caller should continue processing
* despite error return. Note this package was processed for the
* current disc being checked.
*/
if (DITEM_STATUS(status) == DITEM_SUCCESS) {
/* Prompt user if the package is not available on the current volume. */
if(mediaDevice->type == DEVICE_TYPE_CDROM) {
if (current_volume != 0 && id->volume > current_volume) {
restorescr(w);
id->vol_checked = current_volume;
return DITEM_FAILURE | DITEM_CONTINUE;
}
while (id->volume != dev->volume) {
if (!msgYesNo("This is disc #%d. Package %s is on disc #%d\n"
"Would you like to switch discs now?\n", dev->volume,
id->name, id->volume)) {
DEVICE_SHUTDOWN(mediaDevice);
msgConfirm("Please remove disc #%d from your drive, and add disc #%d\n",
dev->volume, id->volume);
DEVICE_INIT(mediaDevice);
} else {
restorescr(w);
return DITEM_FAILURE;
}
}
}
status = package_extract(dev, who->name, depended);
if (DITEM_STATUS(status) == DITEM_SUCCESS)
id->installed = 1;
}
restorescr(w);
return status;
}
static void
index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie)
{
char depends[1024 * 16], *space, *todo;
PkgNodePtr found;
IndexEntryPtr found_ie;
SAFE_STRCPY(depends, ie->deps);
for (todo = depends; todo != NULL; ) {
space = index(todo, ' ');
if (space != NULL)
*space = '\0';
if (strlen(todo) > 0) { /* only non-empty dependencies */
found = index_search(root, todo, NULL);
if (found != NULL) {
found_ie = found->data;
if (add)
++found_ie->depc;
else
--found_ie->depc;
}
}
if (space != NULL)
todo = space + 1;
else
todo = NULL;
}
}
static Boolean index_initted;
/* Read and initialize global index */
int
index_initialize(char *path)
{
FILE *fp;
WINDOW *w = NULL;
if (!index_initted) {
w = savescr();
dialog_clear_norefresh();
have_volumes = FALSE;
low_volume = high_volume = 0;
/* Got any media? */
if (!mediaVerify()) {
restorescr(w);
return DITEM_FAILURE;
}
/* Does it move when you kick it? */
if (!DEVICE_INIT(mediaDevice)) {
restorescr(w);
return DITEM_FAILURE;
}
dialog_clear_norefresh();
msgNotify("Attempting to fetch %s file from selected media.", path);
fp = DEVICE_GET(mediaDevice, path, TRUE);
if (!fp) {
msgConfirm("Unable to get packages/INDEX file from selected media.\n\n"
"This may be because the packages collection is not available\n"
"on the distribution media you've chosen, most likely an FTP site\n"
"without the packages collection mirrored. Please verify that\n"
"your media, or your path to the media, is correct and try again.");
DEVICE_SHUTDOWN(mediaDevice);
restorescr(w);
return DITEM_FAILURE;
}
dialog_clear_norefresh();
msgNotify("Located INDEX, now reading package data from it...");
index_init(&Top, &Plist);
if (index_read(fp, &Top)) {
msgConfirm("I/O or format error on packages/INDEX file.\n"
"Please verify media (or path to media) and try again.");
fclose(fp);
restorescr(w);
return DITEM_FAILURE;
}
fclose(fp);
index_sort(&Top);
index_initted = TRUE;
restorescr(w);
}
return DITEM_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +0,0 @@
# This is a sample installation configuration file for my test machine,
# crate.cdrom.com.
# It is included here merely as a sort-of-documented example.
#
# $FreeBSD$
# Turn on extra debugging.
debug=yes
################################
# My host specific data
hostname=crate.cdrom.com
domainname=cdrom.com
nameserver=204.216.27.3
defaultrouter=204.216.27.228
ipaddr=204.216.27.230
netmask=255.255.255.240
################################
# Log to a remote syslogd server
syslogdServer=10.0.1.1
################################
# Which installation device to use - ftp is pointed directly at my local
# machine and the installation device is my WD8013 ethernet interface.
# netDev can be set to ANY or a comma-delimited list of interfaces.
_ftpPath=ftp://time.cdrom.com/pub
netDev=ed0
mediaSetFTP
################################
################################
# Select which distributions we want.
dists=base doc manpages info src sbase ssys kernels GENERIC
distSetCustom
################################
################################
# Now set the parameters for the partition editor on ad0. Set to use the
# disk exclusively (could also be "all" to use the whole disk but
# respecting the MBR or "free" to use only unallocated space for FreeBSD).
disk=ad0
partition=exclusive
diskPartitionEditor
# Uncomment this instead to use only the free space and install boot manager.
#partition=free
#bootManager=booteasy
#diskPartitionEditor
################################
################################
# Disk partitioning.
# All sizes are expressed in 512 byte blocks!
# A 512MB root partition
ad0s1-1=ufs 1048576 /
# And a 512MB swap partition
ad0s1-2=swap 1048576 none
# Followed by a /usr partition using all remaining space (size 0 = free space)
# and with softupdates enabled (non-zero arg following mountpoint).
ad0s1-3=ufs 0 /usr 1
# Let's do it!
diskLabelEditor
################################
################################
# Now partition the 2nd disk with a 1GB /var and /usr/src using the
# remainder of the disk.
disk=ad1
partition=exclusive
diskPartitionEditor
ad1s1-1=ufs 2097152 /var
ad1s1-2=ufs 0 /usr/src
diskLabelEditor
################################
################################
# And the 3rd, adding a second 512MB of swap and the rest of the disk
# for /tmp.
disk=da0
partition=exclusive
diskPartitionEditor
da0s1-1=swap 1048576 none
da0s1-2=ufs 0 /tmp
diskLabelEditor
################################
# OK, everything is set. Do it!
installCommit
# Install some packages at the end.
package=bash-3.1.17
packageAdd
package=ncftp-3.2.0
packageAdd

View File

@ -1,526 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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>
static int installUpgradeNonInteractive(dialogMenuItem *self);
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 },
{ JUST_COPY, "X11", TRUE, NULL },
{ JUST_COPY, "adduser.conf", TRUE, NULL },
{ JUST_COPY, "aliases", TRUE, NULL },
{ JUST_COPY, "aliases.db", TRUE, NULL },
{ JUST_COPY, "amd.map", TRUE, NULL },
{ JUST_COPY, "auth.conf", TRUE, NULL },
{ JUST_COPY, "crontab", TRUE, NULL },
{ JUST_COPY, "csh.cshrc", TRUE, NULL },
{ JUST_COPY, "csh.login", TRUE, NULL },
{ JUST_COPY, "csh.logout", TRUE, NULL },
{ JUST_COPY, "cvsupfile", TRUE, NULL },
{ JUST_COPY, "devfs.conf", TRUE, NULL },
{ JUST_COPY, "dhclient.conf", TRUE, NULL },
{ JUST_COPY, "disktab", TRUE, NULL },
{ JUST_COPY, "dumpdates", TRUE, NULL },
{ JUST_COPY, "exports", TRUE, NULL },
{ JUST_COPY, "fbtab", TRUE, NULL },
{ JUST_COPY, "fstab", FALSE, NULL },
{ JUST_COPY, "ftpusers", TRUE, NULL },
{ JUST_COPY, "gettytab", TRUE, NULL },
{ JUST_COPY, "gnats", TRUE, NULL },
{ JUST_COPY, "group", FALSE, NULL },
{ JUST_COPY, "hosts", TRUE, NULL },
{ JUST_COPY, "hosts.allow", TRUE, NULL },
{ JUST_COPY, "hosts.equiv", TRUE, NULL },
{ JUST_COPY, "hosts.lpd", TRUE, NULL },
{ JUST_COPY, "inetd.conf", TRUE, NULL },
{ JUST_COPY, "localtime", TRUE, NULL },
{ JUST_COPY, "login.access", TRUE, NULL },
{ JUST_COPY, "login.conf", TRUE, NULL },
{ JUST_COPY, "mail", TRUE, NULL },
{ JUST_COPY, "mail.rc", TRUE, NULL },
{ JUST_COPY, "mac.conf", TRUE, NULL },
{ JUST_COPY, "make.conf", TRUE, NULL },
{ JUST_COPY, "manpath.config", TRUE, NULL },
{ JUST_COPY, "master.passwd", FALSE, NULL },
{ JUST_COPY, "mergemaster.rc", TRUE, NULL },
{ JUST_COPY, "motd", TRUE, NULL },
{ JUST_COPY, "namedb", TRUE, NULL },
{ JUST_COPY, "networks", TRUE, NULL },
{ JUST_COPY, "newsyslog.conf", TRUE, NULL },
{ JUST_COPY, "nsmb.conf", TRUE, NULL },
{ JUST_COPY, "nsswitch.conf", TRUE, NULL },
{ JUST_COPY, "ntp.conf", TRUE, NULL },
{ JUST_COPY, "pam.conf", TRUE, NULL },
{ JUST_COPY, "passwd", TRUE, NULL },
{ JUST_COPY, "periodic", TRUE, NULL },
{ JUST_COPY, "pf.conf", TRUE, NULL },
{ JUST_COPY, "portsnap.conf", TRUE, NULL },
{ JUST_COPY, "ppp", TRUE, NULL },
{ JUST_COPY, "printcap", TRUE, NULL },
{ JUST_COPY, "profile", TRUE, NULL },
{ JUST_COPY, "protocols", TRUE, NULL },
{ JUST_COPY, "pwd.db", TRUE, NULL },
{ JUST_COPY, "rc.local", TRUE, NULL },
{ JUST_COPY, "rc.firewall", TRUE, NULL },
{ JUST_COPY, "rc.conf.local", TRUE, NULL },
{ JUST_COPY, "remote", TRUE, NULL },
{ JUST_COPY, "resolv.conf", TRUE, NULL },
{ JUST_COPY, "rmt", TRUE, NULL },
{ JUST_COPY, "sendmail.cf", TRUE, NULL },
{ JUST_COPY, "sendmail.cw", TRUE, NULL },
{ JUST_COPY, "services", TRUE, NULL },
{ JUST_COPY, "shells", TRUE, NULL },
{ JUST_COPY, "skeykeys", TRUE, NULL },
{ JUST_COPY, "snmpd.config", TRUE, NULL },
{ JUST_COPY, "spwd.db", TRUE, NULL },
{ JUST_COPY, "src.conf", TRUE, NULL },
{ JUST_COPY, "ssh", TRUE, NULL },
{ JUST_COPY, "sysctl.conf", TRUE, NULL },
{ JUST_COPY, "syslog.conf", TRUE, NULL },
{ JUST_COPY, "ttys", TRUE, NULL },
{ 0, NULL, FALSE, NULL },
};
static void
traverseHitlist(HitList *h)
{
system("rm -rf /etc/upgrade");
Mkdir("/etc/upgrade");
while (h->name) {
if (!file_readable(h->name)) {
if (!h->optional)
msgConfirm("Unable to find an old /etc/%s file! That is decidedly non-standard and\n"
"your upgraded system may function a little strangely as a result.", h->name);
}
else {
if (h->action == JUST_COPY) {
/* Move the just-loaded copy aside */
vsystem("mv /etc/%s /etc/upgrade/%s", h->name, h->name);
/* Copy the old one into its place */
msgNotify("Resurrecting %s..", h->name);
/* Do this with tar so that symlinks and such are preserved */
if (vsystem("tar cf - %s | tar xpf - -C /etc", h->name))
msgConfirm("Unable to resurrect your old /etc/%s! Hmmmm.", h->name);
}
else /* call handler */
h->handler(h);
}
++h;
}
}
int
installUpgrade(dialogMenuItem *self)
{
char saved_etc[FILENAME_MAX];
Boolean extractingBin = TRUE;
if (variable_get(VAR_NONINTERACTIVE))
return installUpgradeNonInteractive(self);
variable_set2(SYSTEM_STATE, "upgrade", 0);
dialog_clear();
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)
return DITEM_FAILURE;
if (!Dists) {
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.");
if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists)
return DITEM_FAILURE;
}
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"
"This one is pretty vital to a successful upgrade. Are you SURE you don't\n"
"want to select the base distribution? Chose No to bring up the Distributions\n"
"menu again.") != 0) {
if (!dmenuOpenSimple(&MenuDistributions, FALSE))
return DITEM_FAILURE;
}
}
/* Still?! OK! They must know what they're doing.. */
if (!(Dists & DIST_BASE))
extractingBin = FALSE;
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 | DITEM_RESTORE;
}
else {
/* Enable all the drives before we start */
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.");
return DITEM_FAILURE | DITEM_RESTORE;
}
/* Don't write out MBR info */
variable_set2(DISK_PARTITIONED, "written", 0);
if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
"aborted.");
variable_unset(DISK_PARTITIONED);
return DITEM_FAILURE | DITEM_RESTORE;
}
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);
return DITEM_FAILURE | DITEM_RESTORE;
}
chdir("/");
installEnvironment();
systemCreateHoloshell();
}
saved_etc[0] = '\0';
/* Don't allow sources to be upgraded if we have src already */
if (directory_exists("/usr/src/") && (Dists & DIST_SRC)) {
Dists &= ~DIST_SRC;
SrcDists = 0;
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");
}
if (extractingBin) {
while (!*saved_etc) {
char *cp = msgGetInput("/var/tmp/etc", "Under which directory do you wish to save your current /etc?");
if (!cp || !*cp || Mkdir(cp)) {
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"
"bad idea! Do you want to go back and specify the save directory again?") != 0)
break;
}
else {
SAFE_STRCPY(saved_etc, cp);
}
}
if (saved_etc[0]) {
msgNotify("Preserving /etc directory..");
if (vsystem("tar -cBpf - -C /etc . | tar --unlink -xBpf - -C %s", saved_etc))
if (msgYesNo("Unable to backup your /etc into %s.\n"
"Do you want to continue anyway?", saved_etc) != 0)
return DITEM_FAILURE;
msgNotify("Preserving /root directory..");
vsystem("tar -cBpf - -C / root | tar --unlink -xBpf - -C %s", saved_etc);
}
msgNotify("chflags'ing old binaries - please wait.");
(void)vsystem("chflags -R noschg /bin /sbin /lib /libexec /usr/bin /usr/sbin /usr/lib /usr/libexec /var/empty /boot/kernel*");
if (directory_exists("/boot/kernel")) {
if (directory_exists("/boot/kernel.prev")) {
msgNotify("Removing /boot/kernel.prev");
if (system("rm -fr /boot/kernel.prev")) {
msgConfirm("NOTICE: I'm trying to back up /boot/kernel to\n"
"/boot/kernel.prev, but /boot/kernel.prev exists and I\n"
"can't remove it. This means that the backup will, in\n"
"all probability, fail.");
}
}
msgNotify("Moving old kernel to /boot/kernel.prev");
if (system("mv /boot/kernel /boot/kernel.prev")) {
if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n"
"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"
"and start over from the beginning. Select Yes to reboot now"))
systemShutdown(1);
}
else
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.");
}
}
media:
/* We do this very late, but we unfortunately need to back up /etc first */
if (!mediaVerify())
return DITEM_FAILURE;
if (!DEVICE_INIT(mediaDevice)) {
if (!msgYesNo("Couldn't initialize the media. Would you like\n"
"to adjust your media selection and try again?")) {
mediaDevice = NULL;
goto media;
}
else
return DITEM_FAILURE | DITEM_REDRAW | DITEM_RESTORE;
}
msgNotify("Beginning extraction of distributions.");
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
else if (Dists) {
if (!extractingBin || !(Dists & DIST_BASE)) {
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 load.");
}
else {
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
}
if (extractingBin)
vsystem("disklabel -B `awk '$2~/\\/$/ {print substr($1, 6, 5)}' /etc/fstab`");
msgNotify("First stage of upgrade completed successfully!\n\n"
"Next comes stage 2, where we attempt to resurrect your /etc\n"
"directory!");
if (chdir(saved_etc)) {
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"
"important customizations you wanted to keep in there.. :(", saved_etc);
}
else {
/* Now try to resurrect the /etc files */
traverseHitlist(etc_files);
/* Resurrect the root dotfiles */
vsystem("tar -cBpf - root | tar -xBpf - -C / && rm -rf root");
}
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.");
return DITEM_SUCCESS | DITEM_REDRAW | DITEM_RESTORE;
}
static int
installUpgradeNonInteractive(dialogMenuItem *self)
{
char *saved_etc;
Boolean extractingBin = TRUE;
variable_set2(SYSTEM_STATE, "upgrade", 0);
/* Make sure at least BIN is selected */
Dists |= DIST_BASE;
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 {
/* Enable all the drives before we start */
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.");
return DITEM_FAILURE;
}
/* Don't write out MBR info */
variable_set2(DISK_PARTITIONED, "written", 0);
if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
"aborted.");
variable_unset(DISK_PARTITIONED);
return DITEM_FAILURE;
}
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);
return DITEM_FAILURE;
}
chdir("/");
systemCreateHoloshell();
}
if (!mediaVerify() || !DEVICE_INIT(mediaDevice)) {
msgNotify("Upgrade: Couldn't initialize media.");
return DITEM_FAILURE;
}
saved_etc = "/var/tmp/etc";
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);
return DITEM_FAILURE;
}
/*
* Back up the old kernel, leaving it in place in case we
* crash and reboot.
*/
if (directory_exists("/boot/kernel")) {
if (directory_exists("/boot/kernel.prev")) {
msgNotify("Removing /boot/kernel.prev");
if (system("rm -fr /boot/kernel.prev")) {
msgConfirm("NOTICE: I'm trying to back up /boot/kernel to\n"
"/boot/kernel.prev, but /boot/kernel.prev exists and I\n"
"can't remove it. This means that the backup will, in\n"
"all probability, fail.");
}
}
msgNotify("Copying old kernel to /boot/kernel.prev");
vsystem("cp -Rp /boot/kernel /boot/kernel.prev");
}
msgNotify("Beginning extraction of distributions.");
if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
"should be considered a failure and started from the beginning, sorry!\n"
"The system will reboot now.");
dialog_clear();
systemShutdown(1);
}
else if (Dists) {
if (!(Dists & DIST_BASE)) {
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 {
msgConfirm("Hmmmm. We couldn't even extract the base distribution. This upgrade\n"
"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!");
return DITEM_FAILURE;
}
return DITEM_SUCCESS | DITEM_REDRAW;
}

View File

@ -1,172 +0,0 @@
/*
* Copyright (c) 1996 Joerg Wunsch
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 THE DEVELOPERS 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.
*
* $FreeBSD$
*
*/
#include "sysinstall.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/kbio.h>
struct keymapInfo {
const char *name;
const struct keymap *map;
};
#include "keymap.h"
/*
* keymap.h is being automatically generated by the Makefile. It
* contains definitions for all desired keymaps. Note that since we
* don't support font loading nor screen mapping during installation,
* we simply don't care for any other keys than the ASCII subset.
*
* Therefore, if no keymap with the exact name has been found in the
* first pass, we make a second pass over the table looking just for
* the language name only.
*/
#ifdef WITH_SYSCONS
static int
keymapSetDefault(const char *prefix)
{
dialogMenuItem *items = MenuSysconsKeymap.items;
int i;
size_t plen = strlen(prefix);
for (i = 0; items[i].data; ++i)
if (!strncmp(prefix, items[i].data, plen))
return i;
return -1;
}
int
keymapMenuSelect(dialogMenuItem *self)
{
static const struct {
const char *country, *lang;
} map[] = {
{"dk", "danish"},
{"ee", "estonian"},
{"fi", "finnish"},
{"de", "german"},
{"is", "icelandic"},
{"no", "norwegian"},
{"pl", "pl_PL"},
{"es", "spanish"},
{"se", "swedish"},
{"ch", "swiss"},
{"gb", "uk"},
{"gg", "uk"},
{"ie", "uk"},
{"im", "uk"},
{"je", "uk"},
{NULL, NULL}
};
const char *country, *lang;
int i;
int choice, scroll, curr, max;
char prefix[16 + 1];
if ((country = variable_get(VAR_COUNTRY)) != NULL)
{
lang = country;
for (i = 0; map[i].country; ++i)
if (!strcmp(country, map[i].country))
{
lang = map[i].lang;
break;
}
snprintf(prefix, sizeof(prefix), "keymap=%s.iso", lang);
if ((choice = keymapSetDefault(prefix)) == -1)
{
snprintf(prefix, sizeof(prefix), "keymap=%s", lang);
if ((choice = keymapSetDefault(prefix)) == -1) {
#ifdef PC98
snprintf(prefix, sizeof(prefix), "keymap=jp.pc98");
#else
snprintf(prefix, sizeof(prefix), "keymap=us.iso");
#endif
if ((choice = keymapSetDefault(prefix)) == -1)
choice = 0;
}
}
dmenuSetDefaultIndex(&MenuSysconsKeymap, &choice, &scroll, &curr, &max);
return dmenuOpen(&MenuSysconsKeymap, &choice, &scroll, &curr, &max, FALSE);
}
else
return dmenuOpenSimple(&MenuSysconsKeymap, FALSE) ? DITEM_SUCCESS :
DITEM_FAILURE;
}
#endif
/*
* Return values:
*
* 0: OK
* -1: no appropriate keymap found
* -2: error installing map (other than ENXIO which means we're not on syscons)
*/
int
loadKeymap(const char *lang)
{
int passno, err;
char *llang;
size_t l;
struct keymapInfo *kip;
llang = strdup(lang);
if (llang == NULL)
abort();
for (passno = 0; passno < 2; passno++)
{
if (passno > 0)
{
/* make the match more fuzzy */
l = strspn(llang, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
llang[l] = '\0';
}
l = strlen(llang);
for (kip = keymapInfos; kip->name; kip++)
if (strncmp(kip->name, llang, l) == 0)
{
/* Yep, got it! */
err = ioctl(0, PIO_KEYMAP, kip->map);
free(llang);
return (err == -1 && errno != ENOTTY)? -2: 0;
}
}
free(llang);
return -1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1997 FreeBSD, Inc.
* 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 PAUL TRAINA ``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 PAUL TRAINA OR HIS KILLER RATS 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.
*
*/
/* The structure */
typedef struct _qelement {
struct _qelement *q_forw;
struct _qelement *q_back;
} qelement;
#define INITQUE(Xhead) { \
(Xhead).q_forw = &(Xhead); \
(Xhead).q_back = &(Xhead); \
}
#define EMPTYQUE(Xhead) \
((Xhead).q_forw == &(Xhead))
#define INSQUEUE(elem, pred) { \
register qelement *Xe = (qelement *) (elem); \
register qelement *Xp = (qelement *) (pred); \
Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \
}
#define REMQUE(elem) { \
register qelement *Xe = (qelement *) (elem); \
(Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \
}

View File

@ -1,224 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/signal.h>
#include <sys/fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
const char *StartName; /* Initial contents of argv[0] */
const char *ProgName = "sysinstall";
static void
screech(int sig)
{
msgDebug("\007Signal %d caught! That's bad!\n", sig);
longjmp(BailOut, sig);
}
int
main(int argc, char **argv)
{
int choice, scroll, curr, max, status;
char titlestr[80], *arch, *osrel, *ostype;
struct rlimit rlim;
char *arg;
int i;
int optionArgs = 0;
/* Record name to be able to restart */
StartName = argv[0];
Restarting = FALSE;
RunningAsInit = FALSE;
Fake = FALSE;
for (i = 1; i < argc; i++) {
arg = argv[i];
if (arg[0] != '-')
break;
optionArgs++;
if (!strcmp(arg, "-fake")) {
variable_set2(VAR_DEBUG, "YES", 0);
Fake = TRUE;
} else if (!strcmp(arg, "-restart")) {
Restarting = TRUE;
} else if (!strcmp(arg, "-fakeInit")) {
RunningAsInit = TRUE;
}
arg = argv[optionArgs+1];
}
if (getpid() == 1)
RunningAsInit = TRUE;
/* Catch fatal signals and complain about them if running as init */
if (RunningAsInit) {
signal(SIGBUS, screech);
signal(SIGSEGV, screech);
}
signal(SIGPIPE, SIG_IGN);
/* We don't work too well when running as non-root anymore */
if (geteuid() != 0) {
fprintf(stderr, "Error: This utility should only be run as root.\n");
return 1;
}
/*
* Given what it does sysinstall (and stuff sysinstall runs like
* pkg_add) shouldn't be subject to process limits. Better to just
* let them have what they think they need than have them blow
* their brains out during an install (in sometimes strange and
* mysterious ways).
*/
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_DATA, &rlim) != 0)
fprintf(stderr, "Warning: setrlimit() of datasize failed.\n");
if (setrlimit(RLIMIT_STACK, &rlim) != 0)
fprintf(stderr, "Warning: setrlimit() of stacksize failed.\n");
#ifdef PC98
{
/* XXX */
char *p = getenv("TERM");
if (p && strcmp(p, "cons25") == 0)
setenv("TERM", "cons25w", 1);
}
#endif
/* Set up whatever things need setting up */
systemInitialize(argc, argv);
/* Set default flag and variable values */
installVarDefaults(NULL);
/* only when multi-user is it reasonable to do this here */
if (!RunningAsInit)
installEnvironment();
if (Fake)
msgConfirm("I'll be just faking it from here on out, OK?");
/* Try to preserve our scroll-back buffer */
if (OnVTY) {
for (curr = 0; curr < 25; curr++)
putchar('\n');
}
/* Move stderr aside */
if (DebugFD)
dup2(DebugFD, 2);
/* Initialize driver modules, if we haven't already done so (ie,
the user hit Ctrl-C -> Restart. */
if (!pvariable_get("modulesInitialize")) {
moduleInitialize();
pvariable_set("modulesInitialize=1");
}
/* Probe for all relevant devices on the system */
deviceGetAll();
/* Prompt for the driver floppy if appropriate. */
if (!pvariable_get("driverFloppyCheck")) {
driverFloppyCheck();
pvariable_set("driverFloppyCheck=1");
}
/* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
if (!RunningAsInit) {
for (i = optionArgs+1; i < argc; i++) {
if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS)
systemShutdown(1);
}
/* If we were given commands to process on the command line, just exit
* now */
if (argc > optionArgs+1)
systemShutdown(0);
}
else
dispatch_load_file_int(TRUE);
status = setjmp(BailOut);
if (status) {
msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
"down. If you can reproduce the problem, please turn Debug on\n"
"in the Options menu for the extra information it provides\n"
"in debugging problems like this.", status);
systemShutdown(status);
}
/* Get user's country and keymap */
if (RunningAsInit)
configCountry(NULL);
/* Add FreeBSD version info to the menu title */
arch = getsysctlbyname("hw.machine_arch");
osrel = getsysctlbyname("kern.osrelease");
ostype = getsysctlbyname("kern.ostype");
snprintf(titlestr, sizeof(titlestr), "%s/%s %s - %s", ostype, arch,
osrel, MenuInitial.title);
free(arch);
free(osrel);
free(ostype);
MenuInitial.title = titlestr;
/* Begin user dialog at outer menu */
dialog_clear();
while (1) {
choice = scroll = curr = max = 0;
dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE);
if (!RunningAsInit
#if defined(__sparc64__)
|| !msgNoYes("Are you sure you wish to exit? The system will halt.")
#else
|| !msgNoYes("Are you sure you wish to exit? The system will reboot.")
#endif
)
break;
}
/* Say goodnight, Gracie */
systemShutdown(0);
return 0; /* We should never get here */
}

View File

@ -1,877 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* 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 <signal.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <resolv.h>
static Boolean got_intr = FALSE;
static Boolean ftp_skip_resolve = FALSE;
/* timeout handler */
static void
handle_intr(int sig)
{
msgDebug("User generated interrupt.\n");
got_intr = TRUE;
}
static int
check_for_interrupt(void)
{
if (got_intr) {
got_intr = FALSE;
return TRUE;
}
return FALSE;
}
static int
genericHook(dialogMenuItem *self, DeviceType type)
{
Device **devs;
devs = deviceFind(self->prompt, type);
if (devs)
mediaDevice = devs[0];
return (devs ? DITEM_LEAVE_MENU : DITEM_FAILURE);
}
static int
cdromHook(dialogMenuItem *self)
{
return genericHook(self, DEVICE_TYPE_CDROM);
}
static void
kickstart_dns(void)
{
static Boolean initted = FALSE;
int time;
char *cp;
cp = variable_get(VAR_MEDIA_TIMEOUT);
if (!cp)
time = MEDIA_TIMEOUT;
else
time = atoi(cp);
if (!time)
time = 100;
if (!initted) {
res_init();
_res.retry = 2; /* 2 times seems a reasonable number to me */
_res.retrans = time / 2; /* so spend half our alloted time on each try */
initted = TRUE;
}
}
char *
cpioVerbosity()
{
char *cp = variable_get(VAR_CPIO_VERBOSITY);
if (cp && !strcmp(cp, "high"))
return "-v";
return "";
}
int
mediaOpen(void)
{
if (!mediaDevice || !mediaVerify() || !DEVICE_INIT(mediaDevice))
return DITEM_FAILURE;
return DITEM_SUCCESS;
}
void
mediaClose(void)
{
if (mediaDevice)
DEVICE_SHUTDOWN(mediaDevice);
mediaDevice = NULL;
}
/*
* Return 1 if we successfully found and set the installation type to
* be a CD.
*/
int
mediaSetCDROM(dialogMenuItem *self)
{
Device **devs;
int cnt;
mediaClose();
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
if (!cnt) {
if (self) /* Interactive? */
msgConfirm("No CD/DVD devices found! Please check that your system's\n"
"configuration is correct and that the CD/DVD drive is of a supported\n"
"type. For more information, consult the hardware guide\n"
"in the Doc menu.");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
DMenu *menu;
int status;
menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook, NULL);
if (!menu)
msgFatal("Unable to create CDROM menu! Something is seriously wrong.");
status = dmenuOpenSimple(menu, FALSE);
free(menu);
if (!status)
return DITEM_FAILURE;
}
else
mediaDevice = devs[0];
return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE);
}
static int
floppyHook(dialogMenuItem *self)
{
return genericHook(self, DEVICE_TYPE_FLOPPY);
}
/*
* Return 1 if we successfully found and set the installation type to
* be a floppy
*/
int
mediaSetFloppy(dialogMenuItem *self)
{
Device **devs;
int cnt;
mediaClose();
devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY);
cnt = deviceCount(devs);
if (!cnt) {
msgConfirm("No floppy devices found! Please check that your system's configuration\n"
"is correct. For more information, consult the hardware guide in the Doc\n"
"menu.");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
DMenu *menu;
int status;
menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook, NULL);
if (!menu)
msgFatal("Unable to create Floppy menu! Something is seriously wrong.");
status = dmenuOpenSimple(menu, FALSE);
free(menu);
if (!status)
return DITEM_FAILURE;
}
else
mediaDevice = devs[0];
if (mediaDevice)
mediaDevice->private = NULL;
return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
}
static int
USBHook(dialogMenuItem *self)
{
return genericHook(self, DEVICE_TYPE_USB);
}
/*
* Attempt to use USB as the installation media type.
*/
int
mediaSetUSB(dialogMenuItem *self)
{
Device **devs;
int cnt;
mediaClose();
devs = deviceFind(NULL, DEVICE_TYPE_USB);
cnt = deviceCount(devs);
if (!cnt) {
msgConfirm("No USB devices found (try Options/Re-scan Devices)");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
DMenu *menu;
int status;
menu = deviceCreateMenu(&MenuMediaUSB, DEVICE_TYPE_USB, USBHook,
NULL);
if (!menu)
msgFatal("Unable to create USB menu! Something is " \
"seriously wrong.");
status = dmenuOpenSimple(menu, FALSE);
free(menu);
if (!status)
return DITEM_FAILURE;
}
else
mediaDevice = devs[0];
if (mediaDevice)
mediaDevice->private = NULL;
if (!variable_get(VAR_NONINTERACTIVE))
msgConfirm("Using USB device: %s", mediaDevice->name);
return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
}
static int
DOSHook(dialogMenuItem *self)
{
return genericHook(self, DEVICE_TYPE_DOS);
}
/*
* Return 1 if we successfully found and set the installation type to
* be a DOS partition.
*/
int
mediaSetDOS(dialogMenuItem *self)
{
Device **devs;
int cnt;
mediaClose();
devs = deviceFind(NULL, DEVICE_TYPE_DOS);
cnt = deviceCount(devs);
if (!cnt) {
msgConfirm("No DOS primary partitions found! This installation method is unavailable");
return DITEM_FAILURE | DITEM_CONTINUE;
}
else if (cnt > 1) {
DMenu *menu;
int status;
menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook, NULL);
if (!menu)
msgFatal("Unable to create DOS menu! Something is seriously wrong.");
status = dmenuOpenSimple(menu, FALSE);
free(menu);
if (!status)
return DITEM_FAILURE;
}
else
mediaDevice = devs[0];
return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
}
/*
* Return 0 if we successfully found and set the installation type to
* be an ftp server
*/
int
mediaSetFTP(dialogMenuItem *self)
{
static Device ftpDevice;
char *cp, hbuf[MAXHOSTNAMELEN], *hostname, *dir;
struct addrinfo hints, *res;
int af;
size_t urllen;
extern int FtpPort;
static Device *networkDev = NULL;
mediaClose();
cp = variable_get(VAR_FTP_PATH);
/* If we've been through here before ... */
if (networkDev && cp && msgYesNo("Re-use old FTP site selection values?"))
cp = NULL;
if (!cp) {
if (!dmenuOpenSimple(&MenuMediaFTP, FALSE))
return DITEM_FAILURE;
else
cp = variable_get(VAR_FTP_PATH);
}
if (!cp)
return DITEM_FAILURE;
else if (!strcmp(cp, "other")) {
variable_set2(VAR_FTP_PATH, "ftp://", 0);
cp = variable_get_value(VAR_FTP_PATH, "Please specify the URL of a FreeBSD distribution on a\n"
"remote ftp site. This site must accept either anonymous\n"
"ftp or you should have set an ftp username and password\n"
"in the Options screen.\n\n"
"A URL looks like this: ftp://<hostname>/<path>\n"
"Where <path> is relative to the anonymous ftp directory or the\n"
"home directory of the user being logged in as.", 0);
if (!cp || !*cp || !strcmp(cp, "ftp://")) {
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
urllen = strlen(cp);
if (urllen >= sizeof(ftpDevice.name)) {
msgConfirm("Length of specified URL is %zu characters. Allowable maximum is %zu.",
urllen,sizeof(ftpDevice.name)-1);
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
}
if (strncmp("ftp://", cp, 6)) {
msgConfirm("Sorry, %s is an invalid URL!", cp);
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
SAFE_STRCPY(ftpDevice.name, cp);
SAFE_STRCPY(hbuf, cp + 6);
hostname = hbuf;
if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
"would you like to skip over it now?") != 0) {
if (networkDev)
DEVICE_SHUTDOWN(networkDev);
if (!(networkDev = tcpDeviceSelect())) {
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
}
if (!DEVICE_INIT(networkDev)) {
if (isDebug())
msgDebug("mediaSetFTP: Net device init failed.\n");
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
if (*hostname == '[' && (cp = index(hostname + 1, ']')) != NULL &&
(*++cp == '\0' || *cp == '/' || *cp == ':')) {
++hostname;
*(cp - 1) = '\0';
}
else
cp = index(hostname, ':');
if (cp != NULL && *cp == ':') {
*(cp++) = '\0';
FtpPort = strtol(cp, 0, 0);
}
else
FtpPort = 21;
if ((dir = index(cp ? cp : hostname, '/')) != NULL)
*(dir++) = '\0';
if (isDebug()) {
msgDebug("hostname = `%s'\n", hostname);
msgDebug("dir = `%s'\n", dir ? dir : "/");
msgDebug("port # = `%d'\n", FtpPort);
}
if (!ftp_skip_resolve && variable_get(VAR_NAMESERVER)) {
msgNotify("Looking up host %s.", hostname);
if (isDebug())
msgDebug("Starting DNS.\n");
kickstart_dns();
if (isDebug())
msgDebug("Looking up hostname, %s, using getaddrinfo(AI_NUMERICHOST).\n", hostname);
af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC;
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
if (getaddrinfo(hostname, NULL, &hints, &res) != 0) {
if (isDebug())
msgDebug("Looking up hostname, %s, using getaddrinfo().\n",
hostname);
hints.ai_flags = AI_PASSIVE;
if (getaddrinfo(hostname, NULL, &hints, &res) != 0) {
msgConfirm("Cannot resolve hostname `%s'! Are you sure that"
" your\nname server, gateway and network interface are"
" correctly configured?", hostname);
if (networkDev)
DEVICE_SHUTDOWN(networkDev);
networkDev = NULL;
variable_unset(VAR_FTP_PATH);
return DITEM_FAILURE;
}
}
freeaddrinfo(res);
if (isDebug())
msgDebug("Found DNS entry for %s successfully..\n", hostname);
}
variable_set2(VAR_FTP_HOST, hostname, 0);
variable_set2(VAR_FTP_DIR, dir ? dir : "/", 0);
variable_set2(VAR_FTP_PORT, itoa(FtpPort), 0);
ftpDevice.type = DEVICE_TYPE_FTP;
ftpDevice.init = mediaInitFTP;
ftpDevice.get = mediaGetFTP;
ftpDevice.shutdown = mediaShutdownFTP;
ftpDevice.private = networkDev;
mediaDevice = &ftpDevice;
return DITEM_SUCCESS | DITEM_LEAVE_MENU | DITEM_RESTORE;
}
int
mediaSetFTPActive(dialogMenuItem *self)
{
variable_set2(VAR_FTP_STATE, "active", 0);
return mediaSetFTP(self);
}
int
mediaSetFTPPassive(dialogMenuItem *self)
{
variable_set2(VAR_FTP_STATE, "passive", 0);
return mediaSetFTP(self);
}
int mediaSetHTTP(dialogMenuItem *self)
{
Boolean tmp;
int result;
char *cp, *idx, hbuf[MAXHOSTNAMELEN], *hostname;
int HttpPort;
int what = DITEM_RESTORE;
tmp = ftp_skip_resolve;
ftp_skip_resolve = TRUE;
result = mediaSetFTP(self);
ftp_skip_resolve = tmp;
if (DITEM_STATUS(result) != DITEM_SUCCESS)
return result;
cp = variable_get_value(VAR_HTTP_PROXY,
"Please enter the address of the HTTP proxy in this format:\n"
" hostname:port (the ':port' is optional, default is 3128)",0);
if (!cp)
return DITEM_FAILURE;
SAFE_STRCPY(hbuf, cp);
hostname = hbuf;
if (*hostname == '[' && (idx = index(hostname + 1, ']')) != NULL &&
(*++idx == '\0' || *idx == ':')) {
++hostname;
*(idx - 1) = '\0';
} else
idx = index(hostname, ':');
if (idx == NULL || *idx != ':')
HttpPort = 3128; /* try this as default */
else {
*(idx++) = '\0';
HttpPort = strtol(idx, 0, 0);
}
variable_set2(VAR_HTTP_HOST, hostname, 0);
variable_set2(VAR_HTTP_PORT, itoa(HttpPort), 0);
if (isDebug()) {
msgDebug("VAR_FTP_PATH : %s\n",variable_get(VAR_FTP_PATH));
msgDebug("VAR_HTTP_HOST, _PORT: %s:%s\n",variable_get(VAR_HTTP_HOST),
variable_get(VAR_HTTP_PORT));
}
/* mediaDevice has been set by mediaSetFTP(), overwrite partly: */
mediaDevice->type = DEVICE_TYPE_HTTP;
mediaDevice->init = mediaInitHTTP;
mediaDevice->get = mediaGetHTTP;
mediaDevice->shutdown = dummyShutdown;
return DITEM_SUCCESS | DITEM_LEAVE_MENU | what;
}
int
mediaSetUFS(dialogMenuItem *self)
{
static Device ufsDevice;
struct statfs st;
char *cp;
mediaClose();
cp = variable_get_value(VAR_UFS_PATH, "Enter a fully qualified pathname for the directory\n"
"containing the FreeBSD distribution files:", 0);
if (!cp)
return DITEM_FAILURE;
/* If they gave us a CDROM or something, try and pick a better name */
if (statfs(cp, &st))
strcpy(ufsDevice.name, "ufs");
else
strcpy(ufsDevice.name, st.f_fstypename);
ufsDevice.type = DEVICE_TYPE_UFS;
ufsDevice.init = dummyInit;
ufsDevice.get = mediaGetUFS;
ufsDevice.shutdown = dummyShutdown;
ufsDevice.private = strdup(cp);
mediaDevice = &ufsDevice;
return DITEM_LEAVE_MENU;
}
int
mediaSetNFS(dialogMenuItem *self)
{
static Device nfsDevice;
static Device *networkDev = NULL;
char *cp, *idx;
char hostname[MAXPATHLEN];
size_t pathlen;
mediaClose();
cp = variable_get_value(VAR_NFS_PATH, "Please enter the full NFS file specification for the remote\n"
"host and directory containing the FreeBSD distribution files.\n"
"This should be in the format: hostname:/some/freebsd/dir", 0);
if (!cp)
return DITEM_FAILURE;
SAFE_STRCPY(hostname, cp);
if (!(idx = index(hostname, ':'))) {
msgConfirm("Invalid NFS path specification. Must be of the form:\n"
"host:/full/pathname/to/FreeBSD/distdir");
return DITEM_FAILURE;
}
pathlen = strlen(hostname);
if (pathlen >= sizeof(nfsDevice.name)) {
msgConfirm("Length of specified NFS path is %zu characters. Allowable maximum is %zu.",
pathlen,sizeof(nfsDevice.name)-1);
variable_unset(VAR_NFS_PATH);
return DITEM_FAILURE;
}
SAFE_STRCPY(nfsDevice.name, hostname);
*idx = '\0';
if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
"would you like to skip over it now?") != 0) {
if (networkDev)
DEVICE_SHUTDOWN(networkDev);
if (!(networkDev = tcpDeviceSelect()))
return DITEM_FAILURE;
}
if (!DEVICE_INIT(networkDev)) {
if (isDebug())
msgDebug("mediaSetNFS: Net device init failed\n");
}
if (variable_get(VAR_NAMESERVER)) {
kickstart_dns();
if ((inet_addr(hostname) == INADDR_NONE) && (gethostbyname(hostname) == NULL)) {
msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n"
"name server, gateway and network interface are correctly configured?", hostname);
if (networkDev)
DEVICE_SHUTDOWN(networkDev);
networkDev = NULL;
variable_unset(VAR_NFS_PATH);
return DITEM_FAILURE;
}
else {
if (isDebug())
msgDebug("Found DNS entry for %s successfully..\n", hostname);
}
}
variable_set2(VAR_NFS_HOST, hostname, 0);
nfsDevice.type = DEVICE_TYPE_NFS;
nfsDevice.init = mediaInitNFS;
nfsDevice.get = mediaGetNFS;
nfsDevice.shutdown = mediaShutdownNFS;
nfsDevice.private = networkDev;
mediaDevice = &nfsDevice;
return DITEM_LEAVE_MENU;
}
Boolean
mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid)
{
int i, pfd[2],qfd[2];
if (!dir)
dir = "/";
Mkdir(dir);
chdir(dir);
pipe(pfd);
pipe(qfd);
*zpid = fork();
if (!*zpid) {
char *unzipper = RunningAsInit ? "/stand/" UNZIPPER
: "/usr/bin/" UNZIPPER;
dup2(qfd[0], 0); close(qfd[0]);
dup2(pfd[1], 1); close(pfd[1]);
if (DebugFD != -1)
dup2(DebugFD, 2);
else {
close(2);
open("/dev/null", O_WRONLY);
}
close(qfd[1]);
close(pfd[0]);
i = execl(unzipper, unzipper, (char *)0);
if (isDebug())
msgDebug("%s command returns %d status\n", unzipper, i);
exit(i);
}
*fd = qfd[1];
close(qfd[0]);
*cpid = fork();
if (!*cpid) {
char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio";
dup2(pfd[0], 0); close(pfd[0]);
close(pfd[1]);
close(qfd[1]);
if (DebugFD != -1) {
dup2(DebugFD, 1);
dup2(DebugFD, 2);
}
else {
close(1); open("/dev/null", O_WRONLY);
dup2(1, 2);
}
if (strlen(cpioVerbosity()))
i = execl(cpio, cpio, "-idum", cpioVerbosity(), (char *)0);
else
i = execl(cpio, cpio, "-idum", (char *)0);
if (isDebug())
msgDebug("%s command returns %d status\n", cpio, i);
exit(i);
}
close(pfd[0]);
close(pfd[1]);
return TRUE;
}
Boolean
mediaExtractDistEnd(int zpid, int cpid)
{
int i,j;
i = waitpid(zpid, &j, 0);
/* Don't check exit status - gunzip seems to return a bogus one! */
if (i < 0) {
if (isDebug())
msgDebug("wait for %s returned status of %d!\n", UNZIPPER, i);
return FALSE;
}
i = waitpid(cpid, &j, 0);
if (i < 0 || WEXITSTATUS(j)) {
if (isDebug())
msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
return FALSE;
}
return TRUE;
}
Boolean
mediaExtractDist(char *dir, char *dist, FILE *fp)
{
int i, j, total, seconds, zpid, cpid, pfd[2], qfd[2];
char buf[BUFSIZ];
struct timeval start, stop;
struct sigaction new, old;
if (!dir)
dir = "/";
Mkdir(dir);
chdir(dir);
pipe(pfd); /* read end */
pipe(qfd); /* write end */
zpid = fork();
if (!zpid) {
char *unzipper = RunningAsInit ? "/stand/" UNZIPPER
: "/usr/bin/" UNZIPPER;
fclose(fp);
close(qfd[1]);
dup2(qfd[0], 0); close(qfd[0]);
close(pfd[0]);
dup2(pfd[1], 1); close(pfd[1]);
if (DebugFD != -1)
dup2(DebugFD, 2);
else {
close(2);
open("/dev/null", O_WRONLY);
}
i = execl(unzipper, unzipper, (char *)0);
if (isDebug())
msgDebug("%s command returns %d status\n", unzipper, i);
exit(i);
}
cpid = fork();
if (!cpid) {
char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio";
close(pfd[1]);
dup2(pfd[0], 0); close(pfd[0]);
close (qfd[0]); close(qfd[1]);
fclose(fp);
if (DebugFD != -1) {
dup2(DebugFD, 1);
dup2(DebugFD, 2);
}
else {
dup2(open("/dev/null", O_WRONLY), 1);
dup2(1, 2);
}
if (strlen(cpioVerbosity()))
i = execl(cpio, cpio, "-idum", cpioVerbosity(), (char *)0);
else
i = execl(cpio, cpio, "-idum", "--block-size", (char *)0);
if (isDebug())
msgDebug("%s command returns %d status\n", cpio, i);
exit(i);
}
close(pfd[0]); close(pfd[1]);
close(qfd[0]);
total = 0;
(void)gettimeofday(&start, (struct timezone *)0);
/* Make ^C abort the current transfer rather than the whole show */
new.sa_handler = handle_intr;
new.sa_flags = 0;
(void)sigemptyset(&new.sa_mask);
sigaction(SIGINT, &new, &old);
while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) {
if (check_for_interrupt()) {
msgConfirm("Failure to read from media: User interrupt.");
break;
}
if (write(qfd[1], buf, i) != i) {
msgConfirm("Write error on transfer to cpio process, try of %d bytes.", i);
break;
}
else {
(void)gettimeofday(&stop, (struct timezone *)0);
stop.tv_sec = stop.tv_sec - start.tv_sec;
stop.tv_usec = stop.tv_usec - start.tv_usec;
if (stop.tv_usec < 0)
stop.tv_sec--, stop.tv_usec += 1000000;
seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
if (!seconds)
seconds = 1;
total += i;
msgInfo("%10d bytes read from %s dist @ %.1f KB/sec.",
total, dist, (total / seconds) / 1024.0);
}
}
sigaction(SIGINT, &old, NULL); /* restore sigint */
close(qfd[1]);
i = waitpid(zpid, &j, 0);
/* Don't check exit status - gunzip seems to return a bogus one! */
if (i < 0) {
if (isDebug())
msgDebug("wait for %s returned status of %d!\n", UNZIPPER, i);
return FALSE;
}
i = waitpid(cpid, &j, 0);
if (i < 0 || WEXITSTATUS(j)) {
if (isDebug())
msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
return FALSE;
}
return TRUE;
}
int
mediaGetType(dialogMenuItem *self)
{
return ((dmenuOpenSimple(&MenuMedia, FALSE) && mediaDevice) ? DITEM_SUCCESS : DITEM_FAILURE);
}
/* Return TRUE if all the media variables are set up correctly */
Boolean
mediaVerify(void)
{
if (!mediaDevice)
return (DITEM_STATUS(mediaGetType(NULL)) == DITEM_SUCCESS);
return TRUE;
}
/* Set the FTP username and password fields */
int
mediaSetFTPUserPass(dialogMenuItem *self)
{
char *pass;
if (variable_get_value(VAR_FTP_USER, "Please enter the username you wish to login as:", 0)) {
DialogInputAttrs |= DITEM_NO_ECHO;
pass = variable_get_value(VAR_FTP_PASS, "Please enter the password for this user:", 0);
DialogInputAttrs &= ~DITEM_NO_ECHO;
}
else
pass = NULL;
return (pass ? DITEM_SUCCESS : DITEM_FAILURE);
}
/* Set CPIO verbosity level */
int
mediaSetCPIOVerbosity(dialogMenuItem *self)
{
char *cp = variable_get(VAR_CPIO_VERBOSITY);
if (!cp) {
msgConfirm("CPIO Verbosity is not set to anything!");
return DITEM_FAILURE;
}
else {
if (!strcmp(cp, "low"))
variable_set2(VAR_CPIO_VERBOSITY, "high", 0);
else /* must be "high" - wrap around */
variable_set2(VAR_CPIO_VERBOSITY, "low", 0);
}
return DITEM_SUCCESS;
}
/* A generic open which follows a well-known "path" of places to look */
FILE *
mediaGenericGet(char *base, const char *file)
{
char buf[PATH_MAX];
snprintf(buf, PATH_MAX, "%s/%s", base, file);
if (file_readable(buf))
return fopen(buf, "r");
snprintf(buf, PATH_MAX, "%s/FreeBSD/%s", base, file);
if (file_readable(buf))
return fopen(buf, "r");
snprintf(buf, PATH_MAX, "%s/releases/%s", base, file);
if (file_readable(buf))
return fopen(buf, "r");
snprintf(buf, PATH_MAX, "%s/%s/%s", base, variable_get(VAR_RELNAME), file);
if (file_readable(buf))
return fopen(buf, "r");
snprintf(buf, PATH_MAX, "%s/releases/%s/%s", base, variable_get(VAR_RELNAME), file);
return fopen(buf, "r");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,553 +0,0 @@
/*
* Miscellaneous support routines..
*
* $FreeBSD$
*
* 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 <ctype.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <ufs/ufs/ufsmount.h>
#include <sys/reboot.h>
#include <sys/disklabel.h>
#include <fs/msdosfs/msdosfsmount.h>
#include <sys/sysctl.h>
/* Quick check to see if a file is readable */
Boolean
file_readable(char *fname)
{
if (!access(fname, F_OK))
return TRUE;
return FALSE;
}
/* Quick check to see if a file is executable */
Boolean
file_executable(char *fname)
{
if (!access(fname, X_OK))
return TRUE;
return FALSE;
}
/* Concatenate two strings into static storage */
char *
string_concat(char *one, char *two)
{
static char tmp[FILENAME_MAX];
/* Yes, we're deliberately cavalier about not checking for overflow */
strcpy(tmp, one);
strcat(tmp, two);
return tmp;
}
/* sane strncpy() function */
char *
sstrncpy(char *dst, const char *src, int size)
{
dst[size] = '\0';
return strncpy(dst, src, size);
}
/* Concatenate three strings into static storage */
char *
string_concat3(char *one, char *two, char *three)
{
static char tmp[FILENAME_MAX];
/* Yes, we're deliberately cavalier about not checking for overflow */
strcpy(tmp, one);
strcat(tmp, two);
strcat(tmp, three);
return tmp;
}
/* Clip the whitespace off the end of a string */
char *
string_prune(char *str)
{
int len = str ? strlen(str) : 0;
while (len && isspace(str[len - 1]))
str[--len] = '\0';
return str;
}
/* run the whitespace off the front of a string */
char *
string_skipwhite(char *str)
{
while (*str && isspace(*str))
++str;
return str;
}
/* copy optionally and allow second arg to be null */
char *
string_copy(char *s1, char *s2)
{
if (!s1)
return NULL;
if (!s2)
s1[0] = '\0';
else
strcpy(s1, s2);
return s1;
}
/* convert an integer to a string, using a static buffer */
char *
itoa(int value)
{
static char buf[13];
snprintf(buf, 12, "%d", value);
return buf;
}
Boolean
directory_exists(const char *dirname)
{
DIR *tptr;
if (!dirname)
return FALSE;
if (!strlen(dirname))
return FALSE;
tptr = opendir(dirname);
if (!tptr)
return (FALSE);
closedir(tptr);
return (TRUE);
}
char *
pathBaseName(const char *path)
{
char *pt;
char *ret = (char *)path;
pt = strrchr(path,(int)'/');
if (pt != 0) /* if there is a slash */
{
ret = ++pt; /* start the file after it */
}
return(ret);
}
/* A free guaranteed to take NULL ptrs */
void
safe_free(void *ptr)
{
if (ptr)
free(ptr);
}
/* A malloc that checks errors */
void *
safe_malloc(size_t size)
{
void *ptr;
if (size <= 0)
msgFatal("Invalid malloc size of %ld!", (long)size);
ptr = malloc(size);
if (!ptr)
msgFatal("Out of memory!");
bzero(ptr, size);
return ptr;
}
/* A realloc that checks errors */
void *
safe_realloc(void *orig, size_t size)
{
void *ptr;
if (size <= 0)
msgFatal("Invalid realloc size of %ld!", (long)size);
ptr = reallocf(orig, size);
if (!ptr)
msgFatal("Out of memory!");
return ptr;
}
/* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */
char *
root_bias(char *path)
{
static char tmp[FILENAME_MAX];
char *cp = variable_get(VAR_INSTALL_ROOT);
if (!strcmp(cp, "/"))
return path;
strcpy(tmp, variable_get(VAR_INSTALL_ROOT));
strcat(tmp, path);
return tmp;
}
/*
* These next routines are kind of specialized just for building item lists
* for dialog_menu().
*/
/* Add an item to an item list */
dialogMenuItem *
item_add(dialogMenuItem *list, char *prompt, char *title,
int (*checked)(dialogMenuItem *self),
int (*fire)(dialogMenuItem *self),
void (*selected)(dialogMenuItem *self, int is_selected),
void *data, void *aux, int *curr, int *max)
{
dialogMenuItem *d;
if (*curr == *max) {
*max += 20;
list = (dialogMenuItem *)safe_realloc(list, sizeof(dialogMenuItem) * *max);
}
d = &list[(*curr)++];
bzero(d, sizeof(*d));
d->prompt = prompt ? strdup(prompt) : NULL;
d->title = title ? strdup(title) : NULL;
d->checked = checked;
d->fire = fire;
d->selected = selected;
d->data = data;
d->aux = (long)aux;
return list;
}
/* Toss the items out */
void
items_free(dialogMenuItem *list, int *curr, int *max)
{
int i;
for (i = 0; list[i].prompt; i++) {
safe_free(list[i].prompt);
safe_free(list[i].title);
}
safe_free(list);
*curr = *max = 0;
}
int
Mkdir(char *ipath)
{
struct stat sb;
int final;
char *p, *path;
if (file_readable(ipath) || Fake)
return DITEM_SUCCESS;
path = strcpy(alloca(strlen(ipath) + 1), ipath);
if (isDebug())
msgDebug("mkdir(%s)\n", path);
p = path;
if (p[0] == '/') /* Skip leading '/'. */
++p;
for (final = FALSE; !final; ++p) {
if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
final = TRUE;
else if (p[0] != '/')
continue;
*p = '\0';
if (stat(path, &sb)) {
if (errno != ENOENT) {
msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
return DITEM_FAILURE;
}
if (isDebug())
msgDebug("mkdir(%s..)\n", path);
if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
return DITEM_FAILURE;
}
}
*p = '/';
}
return DITEM_SUCCESS;
}
int
Mkdir_command(char *key, void *dir)
{
return (Mkdir((char*)dir));
}
int
Mount(char *mountp, void *dev)
{
struct ufs_args ufsargs;
char device[80];
char mountpoint[FILENAME_MAX];
if (Fake)
return DITEM_SUCCESS;
if (*((char *)dev) != '/') {
sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
}
else {
strcpy(device, dev);
strcpy(mountpoint, mountp);
}
memset(&ufsargs,0,sizeof ufsargs);
if (Mkdir(mountpoint)) {
msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
return DITEM_FAILURE;
}
if (isDebug())
msgDebug("mount %s %s\n", device, mountpoint);
ufsargs.fspec = device;
if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0,
(caddr_t)&ufsargs) == -1) {
msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
return DITEM_FAILURE;
}
return DITEM_SUCCESS;
}
int
Mount_msdosfs(char *mountp, void *dev)
{
struct msdosfs_args mount_args;
char device[80];
char mountpoint[FILENAME_MAX];
if (Fake)
return DITEM_SUCCESS;
if (*((char *)dev) != '/') {
sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
}
else {
strcpy(device, dev);
strcpy(mountpoint, mountp);
}
if (Mkdir(mountpoint)) {
msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
return DITEM_FAILURE;
}
if (isDebug())
msgDebug("mount %s %s\n", device, mountpoint);
memset(&mount_args, 0, sizeof(mount_args));
mount_args.fspec = device;
mount_args.magic = MSDOSFS_ARGSMAGIC;
mount_args.mask = S_IRWXU | S_IRWXG | S_IRWXO;
if (mount("msdosfs", mountpoint, RunningAsInit ? MNT_ASYNC|MNT_NOATIME : 0,
(caddr_t)&mount_args) == -1) {
msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
return DITEM_FAILURE;
}
return DITEM_SUCCESS;
}
WINDOW *
openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
{
WINDOW *win;
static char help[FILENAME_MAX];
/* We need a curses window */
win = newwin(LINES, COLS, 0, 0);
if (win) {
/* Say where our help comes from */
if (helpfile) {
use_helpline("Press F1 for more information on this screen.");
use_helpfile(systemHelpFile(helpfile, help));
}
/* Setup a nice screen for us to splat stuff onto */
draw_box(win, y, x, height, width, dialog_attr, border_attr);
wattrset(win, dialog_attr);
mvwaddstr(win, y, x + (COLS - strlen(title)) / 2, title);
}
return win;
}
ComposeObj *
initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
{
ComposeObj *obj = NULL, *first;
int n;
/* Loop over the layout list, create the objects, and add them
onto the chain of objects that dialog uses for traversal*/
n = 0;
while (layout[n].help != NULL) {
int t = TYPE_OF_OBJ(layout[n].type);
switch (t) {
case STRINGOBJ:
layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
break;
case BUTTONOBJ:
layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x);
break;
default:
msgFatal("Don't support this object yet!");
}
AddObj(&obj, t, (void *) layout[n].obj);
n++;
}
*max = n - 1;
/* Find the first object in the list */
for (first = obj; first->prev; first = first->prev);
return first;
}
int
layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel)
{
char help_line[80];
int ret, i, len = strlen(layout[*n].help);
/* Display the help line at the bottom of the screen */
for (i = 0; i < 79; i++)
help_line[i] = (i < len) ? layout[*n].help[i] : ' ';
help_line[i] = '\0';
use_helpline(help_line);
display_helpline(win, LINES - 1, COLS - 1);
wrefresh(win);
/* Ask for libdialog to do its stuff */
ret = PollObj(obj);
/* Handle special case stuff that libdialog misses. Sigh */
switch (ret) {
case SEL_ESC: /* Bail out */
*cancel = TRUE;
return FALSE;
/* This doesn't work for list dialogs. Oh well. Perhaps
should special case the move from the OK button ``up''
to make it go to the interface list, but then it gets
awkward for the user to go back and correct screw up's
in the per-interface section */
case KEY_DOWN:
case SEL_CR:
case SEL_TAB:
if (*n < max)
++*n;
else
*n = 0;
break;
/* The user has pressed enter over a button object */
case SEL_BUTTON:
if (cbutton && *cbutton)
*cancel = TRUE;
else
*cancel = FALSE;
return FALSE;
case KEY_UP:
case SEL_BACKTAB:
if (*n)
--*n;
else
*n = max;
break;
case KEY_F(1):
display_helpfile();
/* They tried some key combination we don't support - tootle them forcefully! */
default:
beep();
}
return TRUE;
}
WINDOW *
savescr(void)
{
WINDOW *w;
w = dupwin(newscr);
return w;
}
void
restorescr(WINDOW *w)
{
touchwin(w);
wrefresh(w);
delwin(w);
}
/*
* Get a sysctl variable as a string or "<unknown>" if sysctl fails.
* Caller must free returned string.
*/
char *
getsysctlbyname(const char *sysctlname)
{
char *buf;
size_t sz, buf_sz = 0;
const char unk_str[] = "<unknown>";
sysctlbyname(sysctlname, NULL, &buf_sz, NULL, 0);
buf_sz = MAX(sizeof(unk_str), buf_sz) + 1;
sz = buf_sz - 1;
buf = (char *)safe_malloc(buf_sz);
if (sysctlbyname(sysctlname, buf, &sz, NULL, 0) != -1)
buf[sz] = '\0';
else
strlcpy(buf, unk_str, buf_sz);
return buf;
}

View File

@ -1,223 +0,0 @@
/*-
* Copyright (c) 2000 "HOSOKAWA, Tatsumi" <hosokawa@FreeBSD.org>
* 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.
* 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 THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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.
*
* $FreeBSD$
*/
#include "sysinstall.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/linker.h>
#include <dirent.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <kenv.h>
/* Prototypes */
static int kldModuleFire(dialogMenuItem *self);
#define MODULESDIR "/modules"
#define DISTMOUNT "/dist"
void
moduleInitialize(void)
{
int fd, len;
DIR *dirp;
struct dirent *dp;
char module[MAXPATHLEN], desc[MAXPATHLEN];
char desc_str[BUFSIZ];
if (!RunningAsInit && !Fake) {
/* It's not my job... */
return;
}
dirp = opendir(MODULESDIR);
if (dirp) {
while ((dp = readdir(dirp))) {
if (dp->d_namlen < (sizeof(".ko") - 1)) continue;
if (strcmp(dp->d_name + dp->d_namlen - (sizeof(".ko") - 1), ".ko") == 0) {
strcpy(module, MODULESDIR);
strcat(module, "/");
strcat(module, dp->d_name);
strcpy(desc, module);
len = strlen(desc);
strcpy(desc + (len - (sizeof(".ko") - 1)), ".dsc");
fd = open(module, O_RDONLY);
if (fd < 0) continue;
close(fd);
fd = open(desc, O_RDONLY);
if (fd < 0) {
desc_str[0] = 0;
}
else {
len = read(fd, desc_str, BUFSIZ);
close(fd);
if (len < BUFSIZ) desc_str[len] = 0;
}
if (desc_str[0])
msgDebug("Loading module %s (%s)\n", dp->d_name, desc_str);
else
msgDebug("Loading module %s\n", dp->d_name);
if (kldload(module) < 0 && errno != EEXIST) {
if (desc_str[0])
msgConfirm("Loading module %s failed\n%s", dp->d_name, desc_str);
else
msgConfirm("Loading module %s failed", dp->d_name);
}
}
if (strcmp(dp->d_name + dp->d_namlen - (sizeof(".ko.gz") - 1), ".ko.gz") == 0) {
snprintf(module, sizeof(module), "/tmp/%s", dp->d_name);
module[strlen(module) - sizeof(".gz")] = '\0';
snprintf(desc, sizeof(desc), "zcat < %s/%s > %s", MODULESDIR,
dp->d_name, module);
system(desc);
if (kldload(module) < 0 && errno != EEXIST) {
if (desc_str[0])
msgConfirm("Loading module %s failed\n%s", dp->d_name, desc_str);
else
msgConfirm("Loading module %s failed", dp->d_name);
}
unlink(module);
}
}
closedir(dirp);
}
}
void
driverFloppyCheck(void)
{
/* Prompt for the driver floppy if requested. */
if (kenv(KENV_GET, "driver_floppy", NULL, 0) >= 0 &&
!msgYesNo("Would you like to load kernel modules from the driver floppy?"))
(void)kldBrowser(NULL);
}
int
kldBrowser(dialogMenuItem *self)
{
DMenu *menu = NULL;
int i, what = DITEM_SUCCESS, msize, count;
DIR *dir;
struct dirent *de;
char *err;
err = NULL;
count = 0;
if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
err = "Unable to set media device to floppy.";
goto errout;
}
if (!DEVICE_INIT(mediaDevice)) {
err = "Unable to mount floppy filesystem.";
goto errout;
}
msize = sizeof(DMenu) + (sizeof(dialogMenuItem) * 2);
if ((menu = malloc(msize)) == NULL) {
err = "Failed to allocate memory for menu";
goto errout;
}
bcopy(&MenuKLD, menu, sizeof(DMenu));
bzero(&menu->items[count], sizeof(menu->items[0]));
menu->items[count].prompt = strdup("X Exit");
menu->items[count].title = strdup("Exit this menu (returning to previous)");
menu->items[count].fire = dmenuExit;
count++;
if ((dir = opendir(DISTMOUNT)) == NULL) {
err = "Couldn't open directory";
goto errout;
}
while ((de = readdir(dir)) != NULL) {
if (fnmatch("*.ko", de->d_name, FNM_CASEFOLD))
continue;
msize += sizeof(dialogMenuItem);
if ((menu = realloc(menu, msize)) == NULL) {
err = "Failed to allocate memory for menu item";
goto errout;
}
bzero(&menu->items[count], sizeof(menu->items[0]));
menu->items[count].fire = kldModuleFire;
menu->items[count].prompt = strdup(de->d_name);
menu->items[count].title = menu->items[count].prompt;
count++;
}
closedir(dir);
menu->items[count].prompt = NULL;
menu->items[count].title = NULL;
dmenuOpenSimple(menu, FALSE);
deviceRescan();
errout:
mediaClose();
for (i = 0; i < count; i++)
free(menu->items[i].prompt);
free(menu);
if (err != NULL) {
what |= DITEM_FAILURE;
if (!variable_get(VAR_NO_ERROR))
msgConfirm(err);
}
return (what);
}
static int
kldModuleFire(dialogMenuItem *self) {
char fname[256];
bzero(fname, sizeof(fname));
snprintf(fname, sizeof(fname), "%s/%s", DISTMOUNT, self->prompt);
if (kldload(fname) < 0 && errno != EEXIST) {
if (!variable_get(VAR_NO_ERROR))
msgConfirm("Loading module %s failed\n", fname);
} else {
if (!variable_get(VAR_NO_ERROR))
msgConfirm("Loaded module %s OK", fname);
}
return(0);
}

View File

@ -1,103 +0,0 @@
/*-
* Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
* 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.
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHRO AND CONTRIBUTORS ``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 THE AUTHRO OR CONTRIBUTORS 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.
*
* $FreeBSD$
*/
#include "sysinstall.h"
#include <string.h>
int
mousedTest(dialogMenuItem *self)
{
char *type;
char *port;
char *flags;
int ret;
type = variable_get(VAR_MOUSED_TYPE);
port = variable_get(VAR_MOUSED_PORT);
flags = variable_get(VAR_MOUSED_FLAGS);
if ((type == NULL) || (port == NULL)
|| (strlen(type) <= 0) || (strlen(port) <= 0)
|| (strcmp(type, "NO") == 0)) {
msgConfirm("Please select a mouse protocol and a port first.");
return DITEM_FAILURE;
}
msgNotify("Trying to start the mouse daemon...");
if (file_readable("/var/run/moused.pid"))
vsystem("kill `cat /var/run/moused.pid`");
systemExecute("vidcontrol -m on");
if (flags != NULL)
vsystem("moused -t %s -p %s %s", type, port, flags);
else
vsystem("moused -t %s -p %s", type, port);
ret = msgYesNo("Now move the mouse and see if it works.\n"
"(Note that buttons don't have any effect for now.)\n\n"
" Is the mouse cursor moving?\n");
systemExecute("vidcontrol -m off");
if (ret) {
if (file_readable("/var/run/moused.pid"))
vsystem("kill `cat /var/run/moused.pid`");
variable_set2(VAR_MOUSED, "NO", 1);
} else {
variable_set2(VAR_MOUSED, "YES", 1);
vsystem("ln -fs /dev/sysmouse /dev/mouse"); /* backwards compat */
}
return DITEM_SUCCESS | DITEM_RESTORE;
}
int
mousedDisable(dialogMenuItem *self)
{
if (file_readable("/var/run/moused.pid"))
vsystem("kill `cat /var/run/moused.pid`");
variable_set2(VAR_MOUSED, "NO", 1);
variable_set2(VAR_MOUSED_TYPE, "NO", 1);
variable_unset(VAR_MOUSED_PORT);
variable_unset(VAR_MOUSED_FLAGS);
msgConfirm("The mouse daemon is disabled.");
return DITEM_SUCCESS;
}
int
setMouseFlags(dialogMenuItem *self)
{
int ret;
ret = variable_get_value(VAR_MOUSED_FLAGS,
"Please Specify the mouse daemon flags. If you would like to\n"
"emulate 3 buttons, use -3 here.\n", 1)
? DITEM_SUCCESS : DITEM_FAILURE;
if (ret != DITEM_SUCCESS)
variable_unset(VAR_MOUSED_FLAGS);
return ret;
}

View File

@ -1,428 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* 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 <sys/ioctl.h>
#include <sys/consio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdarg.h>
#include <syslog.h>
#include "sysinstall.h"
Boolean
isDebug(void)
{
char *cp;
return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no");
}
static Boolean
isNetworkUp(void)
{
if (!(RunningAsInit) ||
(variable_check("NETWORK_CONFIGURED=NO")) != TRUE) {
return TRUE;
}
return FALSE;
}
void
msgSyslog(const char *errstr)
{
struct sockaddr_in server;
struct hostent *hp;
char *host, *line;
int sock;
if (!isNetworkUp())
return;
if (!(host = variable_get(VAR_SYSLOG_SERVER)))
return;
if (!(hp = gethostbyname2(host, AF_INET)))
return;
if (!(sock = socket(AF_INET, SOCK_DGRAM, 0)))
return;
bzero(&server, sizeof(struct sockaddr_in));
server.sin_family = AF_INET;
server.sin_port = htons(514);
bcopy((char *)hp->h_addr, (char *)&server.sin_addr, hp->h_length);
asprintf(&line, "<%d>%s", LOG_NOTICE, errstr);
sendto(sock, line, strlen(line), 0, (struct sockaddr *)&server,
sizeof(struct sockaddr_in));
close(sock);
free(line);
}
/* Whack up an informational message on the status line, in stand-out */
void
msgYap(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
attrs = getattrs(stdscr);
attrset(A_REVERSE);
mvaddstr(StatusLine, 0, errstr);
attrset(attrs);
refresh();
}
/* Whack up an informational message on the status line */
void
msgInfo(char *fmt, ...)
{
va_list args;
char *errstr;
int i, attrs;
char line[81];
attrs = getattrs(stdscr);
/* NULL is a special convention meaning "erase the old stuff" */
if (!fmt) {
move(StatusLine, 0);
clrtoeol();
return;
}
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
memset(line, ' ', 80);
for (i = 0; i < 80; i++) {
if (errstr[i])
line[i] = errstr[i];
else
break;
}
line[80] = '\0';
attrset(ATTR_TITLE);
mvaddstr(StatusLine, 0, line);
attrset(attrs);
move(StatusLine, 79);
refresh();
msgSyslog(errstr);
}
/* Whack up a warning on the status line */
void
msgWarn(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)alloca(FILENAME_MAX);
strcpy(errstr, "Warning: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
attrs = getattrs(stdscr);
beep();
attrset(ATTR_TITLE);
mvaddstr(StatusLine, 0, errstr);
attrset(attrs);
refresh();
/* we don't want this hitting syslog twice */
if (isDebug()) {
if (OnVTY)
msgDebug("Warning message `%s'\n", errstr);
else
msgSyslog(errstr);
}
}
/* Whack up an error on the status line */
void
msgError(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)alloca(FILENAME_MAX);
strcpy(errstr, "Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
beep();
attrs = getattrs(stdscr);
attrset(ATTR_TITLE);
mvaddstr(StatusLine, 0, errstr);
attrset(attrs);
refresh();
/* we don't want this hitting syslog twice */
if (isDebug()) {
if (OnVTY)
msgDebug("Error message `%s'\n", errstr);
else
msgSyslog(errstr);
}
}
/* Whack up a fatal error on the status line */
void
msgFatal(char *fmt, ...)
{
va_list args;
char *errstr;
int attrs;
errstr = (char *)alloca(FILENAME_MAX);
strcpy(errstr, "Fatal Error: ");
va_start(args, fmt);
vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
va_end(args);
beep();
attrs = getattrs(stdscr);
attrset(ATTR_TITLE);
mvaddstr(StatusLine, 0, errstr);
addstr(" - ");
addstr("PRESS ANY KEY TO ");
if (RunningAsInit)
addstr("REBOOT");
else
addstr("QUIT");
attrset(attrs);
refresh();
if (OnVTY)
msgDebug("Fatal error `%s'!\n", errstr);
else
msgSyslog(errstr);
getch();
systemShutdown(1);
}
/* Put up a message in a popup confirmation box */
void
msgConfirm(char *fmt, ...)
{
va_list args;
char *errstr;
WINDOW *w = savescr();
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
if (OnVTY) {
ioctl(0, VT_ACTIVATE, 1);
msgInfo(NULL);
}
dialog_notify(errstr);
restorescr(w);
}
/* Put up a message in a popup information box */
void
msgNotify(char *fmt, ...)
{
va_list args;
char *errstr;
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
if (isDebug())
msgDebug("Notify: %s\n", errstr);
dialog_msgbox(NULL, errstr, -1, -1, 0);
}
/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
int
msgYesNo(char *fmt, ...)
{
va_list args;
char *errstr;
int ret;
WINDOW *w = savescr();
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
if (OnVTY) {
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
msgInfo(NULL);
}
if (variable_get(VAR_NONINTERACTIVE))
return 0; /* If non-interactive, return YES all the time */
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
restorescr(w);
return ret;
}
/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */
int
msgNoYes(char *fmt, ...)
{
va_list args;
char *errstr;
int ret;
WINDOW *w = savescr();
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
if (OnVTY) {
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
msgInfo(NULL);
}
if (variable_get(VAR_NONINTERACTIVE))
return 1; /* If non-interactive, return NO all the time */
ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1);
restorescr(w);
return ret;
}
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, char *fmt, ...)
{
va_list args;
char *errstr;
static char input_buffer[256];
int rval;
WINDOW *w = savescr();
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
if (buf)
SAFE_STRCPY(input_buffer, buf);
else
input_buffer[0] = '\0';
if (OnVTY) {
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
msgInfo(NULL);
}
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
restorescr(w);
if (!rval)
return input_buffer;
else
return NULL;
}
/* Write something to the debugging port */
void
msgDebug(char *fmt, ...)
{
va_list args;
char *dbg;
if (DebugFD == -1)
return;
dbg = (char *)alloca(FILENAME_MAX);
strcpy(dbg, "DEBUG: ");
va_start(args, fmt);
vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args);
va_end(args);
msgSyslog(dbg);
write(DebugFD, dbg, strlen(dbg));
}
/* Tell the user there's some output to go look at */
void
msgWeHaveOutput(char *fmt, ...)
{
va_list args;
char *errstr;
WINDOW *w = savescr();
errstr = (char *)alloca(FILENAME_MAX);
va_start(args, fmt);
vsnprintf(errstr, FILENAME_MAX, fmt, args);
va_end(args);
use_helpline(NULL);
use_helpfile(NULL);
msgDebug("Notify: %s\n", errstr);
dialog_clear_norefresh();
sleep(2);
dialog_msgbox(NULL, errstr, -1, -1, 0);
restorescr(w);
}
/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
int
msgSimpleConfirm(char *str)
{
msgConfirm("%s", str);
return DITEM_SUCCESS;
}
int
msgSimpleNotify(char *str)
{
msgNotify("%s", str);
return DITEM_SUCCESS;
}

View File

@ -1,149 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* 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.
*
*/
/* These routines deal with getting things off of network media */
#include "sysinstall.h"
#include <signal.h>
#include <termios.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
static Boolean networkInitialized;
Boolean
mediaInitNetwork(Device *dev)
{
int i;
char *rp;
char *cp, ifconfig[255];
WINDOW *w;
if (!RunningAsInit || networkInitialized)
return TRUE;
if (isDebug())
msgDebug("Init routine called for network device %s.\n", dev->name);
if (!file_readable("/etc/resolv.conf")) {
if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) {
msgConfirm("Can't seem to write out /etc/resolv.conf. Net cannot be used.");
return FALSE;
}
}
w = savescr();
dialog_clear_norefresh();
snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name);
cp = variable_get(ifconfig);
if (cp) {
/*
* If this interface isn't a DHCP one, bring it up.
* If it is, then it's already up.
*/
if (strstr(cp, "DHCP") == NULL) {
msgDebug("Not a DHCP interface.\n");
i = vsystem("ifconfig %s %s", dev->name, cp);
if (i) {
msgConfirm("Unable to configure the %s interface!\n"
"This installation method cannot be used.",
dev->name);
return FALSE;
}
rp = variable_get(VAR_GATEWAY);
if (!rp || *rp == '0') {
msgConfirm("No gateway has been set. You will be unable to access hosts\n"
"not on your local network");
}
else {
/*
* Explicitly flush all routes to get back to a known sane
* state. We don't need to check this exit code because if
* anything fails it will show up in the route add below.
*/
system("route -n flush");
msgDebug("Adding default route to %s.\n", rp);
if (vsystem("route -n add default %s", rp) != 0) {
msgConfirm("Failed to add a default route; please check "
"your network configuration");
return FALSE;
}
}
} else {
msgDebug("A DHCP interface. Should already be up.\n");
}
} else if ((cp = variable_get(VAR_IPV6ADDR)) == NULL || *cp == '\0') {
msgConfirm("The %s device is not configured. You will need to do so\n"
"in the Networking configuration menu before proceeding.", dev->name);
return FALSE;
}
if (isDebug())
msgDebug("Network initialized successfully.\n");
networkInitialized = TRUE;
return TRUE;
}
void
mediaShutdownNetwork(Device *dev)
{
char *cp;
if (!RunningAsInit || !networkInitialized)
return;
msgDebug("Shutdown called for network device %s\n", dev->name);
int i;
char ifconfig[255];
snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name);
cp = variable_get(ifconfig);
if (!cp)
return;
msgDebug("ifconfig %s down\n", dev->name);
i = vsystem("ifconfig %s down", dev->name);
if (i)
msgConfirm("Warning: Unable to down the %s interface properly", dev->name);
cp = variable_get(VAR_GATEWAY);
if (cp) {
msgDebug("Deleting default route.\n");
vsystem("route -n delete default");
}
}

View File

@ -1,101 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
* $FreeBSD$
*
* 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/errno.h>
#include <sys/fcntl.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <limits.h>
Boolean NFSMounted;
static char mountpoint[] = "/dist";
Boolean
mediaInitNFS(Device *dev)
{
Device *netDevice = (Device *)dev->private;
WINDOW *w = savescr();
if (NFSMounted)
return TRUE;
if (!DEVICE_INIT(netDevice))
return FALSE;
if (Mkdir(mountpoint))
return FALSE;
msgNotify("Mounting %s over NFS on %s", dev->name, mountpoint);
if (vsystem("mount_nfs %s %s %s %s %s %s",
!variable_cmp(VAR_NFS_TCP, "YES") ? "-T" : "",
!variable_cmp(VAR_NFS_V3, "YES") ? "-3" : "",
!variable_cmp(VAR_SLOW_ETHER, "YES") ?
"-r 1024 -w 1024" : "-r 4096 -w 4096",
!variable_cmp(VAR_NFS_SECURE, "YES") ? "-P" : "",
dev->name, mountpoint)) {
msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno));
if (netDevice)
DEVICE_SHUTDOWN(netDevice);
restorescr(w);
return FALSE;
}
NFSMounted = TRUE;
if (isDebug())
msgDebug("Mounted NFS device %s onto %s\n", dev->name, mountpoint);
restorescr(w);
return TRUE;
}
FILE *
mediaGetNFS(Device *dev, char *file, Boolean probe)
{
return mediaGenericGet(mountpoint, file);
}
void
mediaShutdownNFS(Device *dev)
{
if (!NFSMounted)
return;
msgDebug("Unmounting NFS partition on %s\n", mountpoint);
if (unmount(mountpoint, MNT_FORCE) != 0)
msgConfirm("Could not unmount the NFS partition: %s", strerror(errno));
NFSMounted = FALSE;
return;
}

View File

@ -1,336 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* 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 <ctype.h>
#include <curses.h>
#include <term.h>
int fixitTtyWhich(dialogMenuItem *);
static char *
varCheck(Option *opt)
{
char *cp = NULL;
if (opt->aux)
cp = variable_get((char *)opt->aux);
if (!cp)
return "NO";
return cp;
}
/* Show our little logo */
static char *
resetLogo(Option *opt)
{
return "[RESET!]";
}
static char *
mediaCheck(Option *opt)
{
if (mediaDevice) {
switch(mediaDevice->type) {
case DEVICE_TYPE_UFS:
case DEVICE_TYPE_DISK:
return "File system";
case DEVICE_TYPE_FLOPPY:
return "Floppy";
case DEVICE_TYPE_FTP:
return "FTP";
case DEVICE_TYPE_CDROM:
return "CDROM";
case DEVICE_TYPE_USB:
return "USB";
case DEVICE_TYPE_DOS:
return "DOS";
case DEVICE_TYPE_NFS:
return "NFS";
case DEVICE_TYPE_NONE:
case DEVICE_TYPE_NETWORK:
case DEVICE_TYPE_ANY:
default:
return "<unknown>";
}
}
return "<not yet set>";
}
#define NEWFS_PROMPT "Please enter newfs(8) parameters:"
#define RELNAME_PROMPT "Please specify the release you wish to load or\n\"any\" for a generic release install:"
#define BPKG_PROMPT "Please specify the name of the HTML browser package:"
#define BBIN_PROMPT "Please specify a full pathname to the HTML browser binary:"
#define EDITOR_PROMPT "Please specify the name of the text editor you wish to use:"
#define PKG_PROMPT "Please specify a temporary directory with lots of free space:"
#define INSTROOT_PROMPT "Please specify a root directory if installing somewhere other than /"
#define TIMEOUT_PROMPT "Please specify the number of seconds to wait for slow media:"
static Option Options[] = {
{ "NFS Secure", "NFS server talks only on a secure port",
OPT_IS_VAR, NULL, VAR_NFS_SECURE, varCheck },
{ "NFS Slow", "User is using a slow PC or ethernet card",
OPT_IS_VAR, NULL, VAR_SLOW_ETHER, varCheck },
{ "NFS TCP", "Use TCP protocol for NFS",
OPT_IS_VAR, NULL, VAR_NFS_TCP, varCheck },
{ "NFS version 3", "Use NFS version 3",
OPT_IS_VAR, NULL, VAR_NFS_V3, varCheck },
{ "Debugging", "Emit extra debugging output on VTY2 (ALT-F2)",
OPT_IS_VAR, NULL, VAR_DEBUG, varCheck },
{ "No Warnings", "Don't Warn the user when a setting seems incorrect",
OPT_IS_VAR, NULL, VAR_NO_WARN, varCheck },
{ "Yes to All", "Assume \"Yes\" answers to all non-critical dialogs",
OPT_IS_VAR, NULL, VAR_NO_CONFIRM, varCheck },
{ "DHCP", "Attempt automatic DHCP configuration of interfaces",
OPT_IS_VAR, NULL, VAR_TRY_DHCP, varCheck },
{ "IPv6", "Attempt IPv6 configuration of interfaces",
OPT_IS_VAR, NULL, VAR_TRY_RTSOL, varCheck },
{ "FTP username", "Username and password to use instead of anonymous",
OPT_IS_FUNC, mediaSetFTPUserPass, VAR_FTP_USER, varCheck },
{ "Editor", "Which text editor to use during installation",
OPT_IS_VAR, EDITOR_PROMPT, VAR_EDITOR, varCheck },
{ "Extract Detail", "How verbosely to display file name information during extractions",
OPT_IS_FUNC, mediaSetCPIOVerbosity, VAR_CPIO_VERBOSITY, varCheck },
{ "Release Name", "Which release to attempt to load from installation media",
OPT_IS_VAR, RELNAME_PROMPT, VAR_RELNAME, varCheck },
{ "Install Root", "Which directory to unpack distributions or packages relative to",
OPT_IS_VAR, INSTROOT_PROMPT, VAR_INSTALL_ROOT, varCheck },
{ "Browser package", "This is the browser package that will be used for viewing HTML docs",
OPT_IS_VAR, BPKG_PROMPT, VAR_BROWSER_PACKAGE, varCheck },
{ "Browser Exec", "This is the path to the main binary of the browser package",
OPT_IS_VAR, BBIN_PROMPT, VAR_BROWSER_BINARY, varCheck },
{ "Media Type", "The current installation media type.",
OPT_IS_FUNC, mediaGetType, VAR_MEDIA_TYPE, mediaCheck },
{ "Media Timeout", "Timeout value in seconds for slow media.",
OPT_IS_VAR, TIMEOUT_PROMPT, VAR_MEDIA_TIMEOUT, varCheck },
{ "Package Temp", "The directory where package temporary files should go",
OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck },
{ "Newfs Args", "Default parameters for newfs(8)",
OPT_IS_VAR, NEWFS_PROMPT, VAR_NEWFS_ARGS, varCheck },
{ "Fixit Console", "Which tty to use for the Fixit action.",
OPT_IS_FUNC, fixitTtyWhich, VAR_FIXIT_TTY, varCheck },
{ "Re-scan Devices", "Re-run sysinstall's initial device probe",
OPT_IS_FUNC, deviceRescan, NULL, NULL },
{ "Use Defaults", "Reset all values to startup defaults",
OPT_IS_FUNC, installVarDefaults, NULL, resetLogo },
{ NULL, NULL, 0, NULL, NULL, NULL },
};
#define OPT_START_ROW 4
#define OPT_END_ROW 19
#define OPT_NAME_COL 0
#define OPT_VALUE_COL 16
#define GROUP_OFFSET 40
static char *
value_of(Option opt)
{
static char ival[40];
switch (opt.type) {
case OPT_IS_STRING:
return (char *)opt.data;
case OPT_IS_INT:
sprintf(ival, "%lu", (long)opt.data);
return ival;
case OPT_IS_FUNC:
case OPT_IS_VAR:
if (opt.check)
return opt.check(&opt);
else
return "<*>";
}
return "<unknown>";
}
static int
fire(Option opt)
{
int status = 0;
if (opt.type == OPT_IS_FUNC) {
int (*cp)(char *) = opt.data, rcode;
rcode = cp(NULL);
status = 1;
}
else if (opt.type == OPT_IS_VAR) {
if (opt.data) {
(void)variable_get_value(opt.aux, opt.data, -1);
status = 1;
}
else if (variable_get(opt.aux)) {
if (!variable_cmp(opt.aux, "YES"))
variable_set2(opt.aux, "NO", -1);
else
variable_set2(opt.aux, "YES", -1);
}
else
variable_set2(opt.aux, "YES", 0);
}
if (opt.check)
opt.check(&opt);
refresh();
return status;
}
int
optionsEditor(dialogMenuItem *self)
{
int i, optcol, optrow, key;
static int currOpt = 0;
WINDOW *w = savescr();
dialog_clear();
clear();
while (1) {
/* Whap up the header */
attrset(A_REVERSE); mvaddstr(0, 0, "Options Editor"); attrset(A_NORMAL);
for (i = 0; i < 2; i++) {
mvaddstr(OPT_START_ROW - 2, OPT_NAME_COL + (i * GROUP_OFFSET), "Name");
mvaddstr(OPT_START_ROW - 1, OPT_NAME_COL + (i * GROUP_OFFSET), "----");
mvaddstr(OPT_START_ROW - 2, OPT_VALUE_COL + (i * GROUP_OFFSET), "Value");
mvaddstr(OPT_START_ROW - 1, OPT_VALUE_COL + (i * GROUP_OFFSET), "-----");
}
/* And the footer */
mvprintw(OPT_END_ROW + 1, 0, "Use SPACE to select/toggle an option, arrow keys to move,");
mvprintw(OPT_END_ROW + 2, 0, "? or F1 for more help. When you're done, type Q to Quit.");
optrow = OPT_START_ROW;
optcol = OPT_NAME_COL;
for (i = 0; Options[i].name; i++) {
/* Names are painted somewhat gratuitously each time, but it's easier this way */
mvprintw(optrow, OPT_NAME_COL + optcol, Options[i].name);
if (currOpt == i)
attrset(ATTR_SELECTED);
mvprintw(optrow++, OPT_VALUE_COL + optcol, value_of(Options[i]));
if (currOpt == i)
attrset(A_NORMAL);
if (optrow == OPT_END_ROW) {
optrow = OPT_START_ROW;
optcol += GROUP_OFFSET;
}
clrtoeol();
}
attrset(ATTR_TITLE);
mvaddstr(OPT_END_ROW + 4, 0, Options[currOpt].desc);
attrset(A_NORMAL);
clrtoeol();
move(0, 14);
refresh();
/* Start the edit loop */
key = toupper(getch());
switch (key) {
case KEY_F(1):
case '?':
systemDisplayHelp("options");
clear();
break;
case '\020': /* ^P */
case KEY_UP:
if (currOpt)
--currOpt;
else
for (currOpt = 0; Options[currOpt + 1].name; currOpt++);
continue;
case '\016': /* ^N */
case KEY_DOWN:
if (Options[currOpt + 1].name)
++currOpt;
else
currOpt = 0;
continue;
case KEY_HOME:
currOpt = 0;
continue;
case KEY_END:
while (Options[currOpt + 1].name)
++currOpt;
continue;
case ' ':
if (fire(Options[currOpt]))
clear();
continue;
case '\033': /* ESC */
case 'Q':
clear();
dialog_clear();
restorescr(w);
return DITEM_SUCCESS | DITEM_CONTINUE;
default:
beep();
}
}
/* NOTREACHED */
return DITEM_SUCCESS;
}
int
fixitTtyWhich(dialogMenuItem *self)
{
char *cp = variable_get(VAR_FIXIT_TTY);
if (!cp) {
msgConfirm("The Fix-it TTY setting is not set to anything!");
return DITEM_FAILURE;
}
else {
if (!strcmp(cp, "standard"))
variable_set2(VAR_FIXIT_TTY, "serial", 0);
else /* must be "serial" - wrap around */
variable_set2(VAR_FIXIT_TTY, "standard", 0);
}
return DITEM_SUCCESS;
}

View File

@ -1,270 +0,0 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* 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.
*
* $FreeBSD$
*/
#include "sysinstall.h"
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
static Boolean sigpipe_caught;
static void
catch_pipe(int sig)
{
sigpipe_caught = TRUE;
}
extern PkgNode Top;
/* Like package_extract, but assumes current media device and chases deps */
int
package_add(char *name)
{
PkgNodePtr tmp;
int i, current, low, high;
if (!mediaVerify())
return DITEM_FAILURE;
if (!DEVICE_INIT(mediaDevice))
return DITEM_FAILURE;
i = index_initialize("packages/INDEX");
if (DITEM_STATUS(i) != DITEM_SUCCESS)
return i;
tmp = index_search(&Top, name, &tmp);
if (tmp) {
if (have_volumes) {
low = low_volume;
high = high_volume;
} else
low = high = 0;
for (current = low; current <= high; current++)
i = index_extract(mediaDevice, &Top, tmp, FALSE, current);
return i;
} else {
msgConfirm("Sorry, package %s was not found in the INDEX.", name);
return DITEM_FAILURE;
}
}
/* For use by dispatch */
int
packageAdd(dialogMenuItem *self)
{
char *cp;
cp = variable_get(VAR_PACKAGE);
if (!cp) {
msgDebug("packageAdd: No package name passed in package variable\n");
return DITEM_FAILURE;
}
else
return package_add(cp);
}
Boolean
package_installed(char *name)
{
char fname[FILENAME_MAX];
int status /* = vsystem("pkg_info -e %s", name) */;
/* XXX KLUDGE ALERT! This makes evil assumptions about how XXX
* packages register themselves and should *really be done with
* `pkg_info -e <name>' except that this it's too slow for an
* item check routine.. :-(
*/
snprintf(fname, FILENAME_MAX, "/var/db/pkg/%s", name);
status = access(fname, R_OK);
if (isDebug())
msgDebug("package check for %s returns %s.\n", name, status ? "failure" : "success");
return !status;
}
/* Extract a package based on a namespec and a media device */
int
package_extract(Device *dev, char *name, Boolean depended)
{
char path[MAXPATHLEN];
const char *PkgExts[] = { "", ".tbz", ".tbz2", ".tgz" };
int last_msg, pathend, ret;
size_t ext;
FILE *fp;
last_msg = 0;
/* Check to make sure it's not already there */
if (package_installed(name))
return DITEM_SUCCESS;
if (!DEVICE_INIT(dev)) {
msgConfirm("Unable to initialize media type for package extract.");
return DITEM_FAILURE;
}
/* If necessary, initialize the ldconfig hints */
if (!file_readable("/var/run/ld-elf.so.hints"))
vsystem("ldconfig /usr/lib /usr/lib/compat /usr/local/lib");
/* Be initially optimistic */
ret = DITEM_SUCCESS;
/* Make a couple of paranoid locations for temp files to live if user specified none */
if (!variable_get(VAR_PKG_TMPDIR)) {
/* Set it to a location with as much space as possible */
variable_set2(VAR_PKG_TMPDIR, "/var/tmp", 0);
}
Mkdir(variable_get(VAR_PKG_TMPDIR));
vsystem("chmod 1777 %s", variable_get(VAR_PKG_TMPDIR));
if (!index(name, '/')) {
if (!strpbrk(name, "-_"))
pathend = snprintf(path, sizeof path, "packages/Latest/%s", name);
else
pathend = snprintf(path, sizeof path, "packages/All/%s", name);
}
else
pathend = snprintf(path, sizeof path, "%s", name);
/* We have a path, call the device strategy routine to get the file */
for (ext = 0 ; ext < sizeof PkgExts / sizeof PkgExts[0]; ++ext) {
strlcpy(path + pathend, PkgExts[ext], sizeof path - pathend);
if ((fp = DEVICE_GET(dev, path, TRUE)))
break;
}
if (fp) {
int i = 0, tot, pfd[2];
pid_t pid;
WINDOW *w = savescr();
sigpipe_caught = FALSE;
signal(SIGPIPE, catch_pipe);
dialog_clear_norefresh();
msgNotify("Adding %s%s\nfrom %s", path, depended ? " (as a dependency)" : "", dev->name);
pipe(pfd);
pid = fork();
if (!pid) {
dup2(pfd[0], 0); close(pfd[0]);
dup2(DebugFD, 1); dup2(1, 2);
close(pfd[1]);
/* Prevent pkg_add from wanting to interact in bad ways */
setenv("BATCH", "t", 1);
if (isDebug())
i = execl("/usr/sbin/pkg_add", "/usr/sbin/pkg_add", "-v", "-",
(char *)0);
else
i = execl("/usr/sbin/pkg_add", "/usr/sbin/pkg_add", "-",
(char *)0);
}
else {
char buf[BUFSIZ];
struct timeval start, stop;
close(pfd[0]);
tot = 0;
(void)gettimeofday(&start, (struct timezone *)0);
while (!sigpipe_caught && (i = fread(buf, 1, BUFSIZ, fp)) > 0) {
int seconds;
tot += i;
/* Print statistics about how we're doing */
(void) gettimeofday(&stop, (struct timezone *)0);
stop.tv_sec = stop.tv_sec - start.tv_sec;
stop.tv_usec = stop.tv_usec - start.tv_usec;
if (stop.tv_usec < 0)
stop.tv_sec--, stop.tv_usec += 1000000;
seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
if (!seconds)
seconds = 1;
if (seconds != last_msg) {
last_msg = seconds;
msgInfo("%10d bytes read from package %s @ %4.1f KBytes/second", tot, name, (tot / seconds) / 1000.0);
}
/* Write it out */
if (sigpipe_caught || write(pfd[1], buf, i) != i) {
msgInfo("Write failure to pkg_add! Package may be corrupt.");
break;
}
}
close(pfd[1]);
fclose(fp);
if (sigpipe_caught)
msgInfo("pkg_add(1) apparently did not like the %s package.", name);
else if (i == -1)
msgInfo("I/O error while reading in the %s package.", name);
else
msgInfo("Package %s read successfully - waiting for pkg_add(1)", name);
refresh();
i = waitpid(pid, &tot, 0);
dialog_clear_norefresh();
if (sigpipe_caught || i < 0 || WEXITSTATUS(tot)) {
ret = DITEM_FAILURE;
if (variable_get(VAR_NO_CONFIRM))
msgNotify("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
else
msgConfirm("Add of package %s aborted, error code %d -\n"
"Please check the debug screen for more info.", name, WEXITSTATUS(tot));
}
else
msgNotify("Package %s was added successfully", name);
/* Now catch any stragglers */
while (wait3(&tot, WNOHANG, NULL) > 0);
sleep(1);
restorescr(w);
}
}
else {
dialog_clear_norefresh();
if (variable_get(VAR_NO_CONFIRM))
msgNotify("Unable to fetch package %s from selected media.\n"
"No package add will be done.", name);
else
msgConfirm("Unable to fetch package %s from selected media.\n"
"No package add will be done.", name);
ret = DITEM_FAILURE;
}
signal(SIGPIPE, SIG_IGN);
return ret;
}

Some files were not shown because too many files have changed in this diff Show More