#! /bin/gsh
#
# This is a script that builds a bootable system given the components
# of a partial v2.0.6, plus an available v2.0.4 distribution.  It is
# an interim hack.
# 
# Devin Reade, September 1997.
#
# $Id: fudgeinstall,v 1.9 1999/02/15 21:39:11 gdr-ftp Exp $

# What is our release directory?  (The second one must be HFS, and 
# may be the same as the first.)
setenv RELDIR	/gno
setenv RELDIR2	/gno-hfs
setenv RELBOOT	/gno.boot

# What is the "root" filesystem for the currently running GNO?
setenv ROOT	/trenco3/v.206

# Where are the GNO (and other) sources?
setenv SRC	/src
setenv DIST	/dist

# Where do we keep the Finder.Data, Finder.Root, and icons files
# that are created on the GS and copied over to the GNO boot disk?
# Unfortunately, we can't put these into the repository because of
# their resource forks (unless we were to binscii them)
setenv BINSRC	/scratch/gnoboot.bins

# We need a scratch file for some operations
setenv JUNKFILE	/tmp/finstall.junk

#==================================

# Create the directories we need.  Unfortunately, gsh is too stupid to
# even allow us multiline commands by escaping the newline, so we have
# to call install many times.
echo "creating directories"
install -dV $RELDIR2/HFSinclude
install -dV $RELDIR/Icons
install -dV $RELDIR/System/Desk.Accs
install -dV $RELDIR/System/Drivers
install -dV $RELDIR/System/System.Setup
install -dV $RELDIR/bin
install -dV $RELDIR/dev
install -dV $RELDIR/doc
install -dV $RELDIR/etc
install -dV $RELDIR/home/root
install -dV $RELDIR/lang/orca/shell
install -dV $RELDIR/lang/orca/languages
install -dV $RELDIR/lib/orcacdefs
install -dV $RELDIR/lib/rinclude
install -dV $RELDIR/sbin
install -dV $RELDIR/usr/ainclude
install -dV $RELDIR/usr/bin
# when we finally get a working cp(1) again, we can eliminate creating
# of the /usr/include and /HFSinclude directories.
install -dV $RELDIR/usr/include/arpa
install -dV $RELDIR/usr/include/gno
install -dV $RELDIR/usr/include/machine
install -dV $RELDIR/usr/include/net
install -dV $RELDIR/usr/include/netinet
install -dV $RELDIR/usr/include/protocols
install -dV $RELDIR/usr/include/rpc
install -dV $RELDIR/usr/include/sys
install -dV $RELDIR2/HFSinclude/net
install -dV $RELDIR2/HFSinclude/netinet
install -dV $RELDIR2/HFSinclude/sys
install -dV $RELDIR/usr/games
install -dV $RELDIR/usr/guest/operator
install -dV $RELDIR/usr/lib/tmac
install -dV $RELDIR/usr/man/man1
install -dV $RELDIR/usr/man/man2
install -dV $RELDIR/usr/man/man3
install -dV $RELDIR/usr/man/man4
install -dV $RELDIR/usr/man/man5
install -dV $RELDIR/usr/man/man6
install -dV $RELDIR/usr/man/man7
install -dV $RELDIR/usr/man/man8
install -dV $RELDIR/usr/man/cat1
install -dV $RELDIR/usr/man/cat2
install -dV $RELDIR/usr/man/cat3
install -dV $RELDIR/usr/man/cat4
install -dV $RELDIR/usr/man/cat5
install -dV $RELDIR/usr/man/cat6
install -dV $RELDIR/usr/man/cat7
install -dV $RELDIR/usr/man/cat8
install -dV $RELDIR/usr/orca/bin
install -dV $RELDIR/usr/sbin
install -dV $RELDIR/var/adm
install -dV $RELDIR/var/adm/newuser/skel
install -dV $RELDIR/var/run
install -dV $RELDIR/var/spool

echo "installing files in /"
install -V	$ROOT/kern.971027		$RELDIR/kern
install -V	$SRC/gno/verbatim/initrc	$RELDIR

echo "installing files in /HFSinclude"
install -V	/HFSinclude/net/*.h	$RELDIR2/HFSinclude/net
install -V	/HFSinclude/netinet/*.h	$RELDIR2/HFSinclude/netinet
install -V	/HFSinclude/sys/*.h	$RELDIR2/HFSinclude/sys

echo "installing files in /Icons"
install -V	$BINSRC/Icons/GNO.Icon	$RELDIR/Icons

# These ones should eventually be installed as part of the 'release'
# target.
echo "installing files in /System"
install -V  $BINSRC/System/Desk.Accs/GNOSnooperII $RELDIR/System/Desk.Accs
install -V  $BINSRC/System/Desk.Accs/SuspDA       $RELDIR/System/Desk.Accs
install -V  $BINSRC/System/Desk.Accs/TMTerm2.v1.0 $RELDIR/System/Desk.Accs/TMTerm
install -V  $BINSRC/System/Drivers/FilePort       $RELDIR/System/Drivers
install -V  $BINSRC/System/Drivers/FilePort.Data  $RELDIR/System/Drivers
install -V  $BINSRC/System/Drivers/NullPort       $RELDIR/System/Drivers
install -V  $BINSRC/System/System.Setup/GNOBug    $RELDIR/System/System.Setup
install -V  $BINSRC/System/System.Setup/SIM       $RELDIR/System/System.Setup

echo "installing files in /bin"
# aroff		done
# binprint	done
# cat		done
install -V	/bin/center	$RELDIR/bin
install -V	/usr/orca/bin/chmod	$RELDIR/bin
# chtyp		done
# cmp		done
install -V	/bin/compress	$RELDIR/bin
install -V	/bin/cp		$RELDIR/bin
install -V	/bin/date	$RELDIR/bin
# df		done
install -V	/bin/du		$RELDIR/bin
install -V	/bin/echo	$RELDIR/bin
install -V	/bin/egrep	$RELDIR/bin
# false		done
install -V	/bin/fgrep	$RELDIR/bin
install -V	/bin/freeze	$RELDIR/bin
install -V	/bin/grep	$RELDIR/bin
# gsh		done
# head		done
install -V	/bin/hostname	$RELDIR/bin
install -V	/bin/init	$RELDIR/bin
# kill		done
install -V	/bin/less	$RELDIR/bin
install -V	/bin/ls		$RELDIR/bin
install -V	/bin/mkdir	$RELDIR/bin
install -V	/bin/more	$RELDIR/bin
# mv is actually cp
install -V	/bin/passwd	$RELDIR/bin
install -V	/usr/bin/eps	$RELDIR/bin/ps
install -V	/bin/purge	$RELDIR/bin
# pwd		done
# rmdir		done
# sleep		done
# split		done
install -V	/bin/strings	$RELDIR/bin
install -V	/bin/stty	$RELDIR/bin
install -V	/bin/su		$RELDIR/bin
# tail		done
install -V	/bin/tar	$RELDIR/bin
# tee		done
# test		done
install -V	/bin/time	$RELDIR/bin
install -V	/usr/local/bin/touch	$RELDIR/bin
# tr		done
# true		done
# uname		done
install -V	/bin/uncompress	$RELDIR/bin
# uniq		done
install -V	/bin/vi		$RELDIR/bin
# wc		done
# yes		done

echo "installing files in /dev"
install -V	/dev/modem	$RELDIR/dev
install -V	/dev/printer	$RELDIR/dev
install -V	/dev/null	$RELDIR/dev

echo "installing files in /etc"
# don't need cronlog, crontab yet
install -V	/etc/freeze.cnf	$RELDIR/etc
# gettytab	done
install -V	$SRC/gno/verbatim/etc/glogin	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/group	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/hosts	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/inittab	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/motd	$RELDIR/etc
echo >>					$RELDIR/etc/motd
echo -n 'GNO release build date: ' >>	$RELDIR/etc/motd
date >>					$RELDIR/etc/motd
install -V	$SRC/gno/verbatim/etc/networks	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/namespace	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/passwd	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/rchost	$RELDIR/etc
install -V	/etc/syslog.conf		$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/termcap		$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/tty.config	$RELDIR/etc
install -V	$SRC/gno/verbatim/etc/ttys		$RELDIR/etc
touch $RELDIR/etc/wtmp; chtyp -tbin -a0 $RELDIR/etc/wtmp

echo "installing files in /home/root"
install -V	$SRC/gno/verbatim/home/root/gshrc	$RELDIR/home/root

# echo "installing files in /lib"
# install		13/libc		$RELDIR/lib
# install		13/lsaneglue	$RELDIR/lib
# install		13/orcalib	$RELDIR/lib
# install		13/sysfloat	$RELDIR/lib

echo "installing files in /lib/orcacdefs"
install -V	$SRC/gno/orcacdefs/defaults.h	$RELDIR/lib/orcacdefs

echo "installing files in /sbin"
install -V	/usr/sbin/initd				$RELDIR/sbin
# renram5	done

echo "installing files in /usr/bin"
# apropos	done
# asml			should be copied from compile
# assemble		should be copied from compile
# awk		done
# basename	done
# catrez	done
# cksum		done
# colcrt	done
# cmpl			should be copied from compile
install -V	/usr/local/bin/coff	$RELDIR/usr/bin
# compile	done
install -V	/usr/bin/copycat	$RELDIR/usr/bin
install -V	/usr/bin/cpp		$RELDIR/usr/bin
# cut		done
# ctags		done
install -V	/usr/bin/diff		$RELDIR/usr/bin
# dirname	done
install -V	/usr/local/bin/dmake	$RELDIR/usr/bin
# fmt		done
# getvers	done
# help		done
# install	done
# last		done
install -V	/usr/bin/launch		$RELDIR/usr/bin
# link		done
# lseg		done
# man		done
# nroff		done
# removerez	done
# rlogin	done
# rsh		done
install -V	/bin/script		$RELDIR/usr/bin
# sed		done
install -V	/usr/bin/setvers	$RELDIR/usr/bin
install -V	/usr/bin/unshar		$RELDIR/usr/bin
install -V	/usr/bin/uptime		$RELDIR/usr/bin
# whatis	done
# whereis	done
# who		done
# whois		done
install -V	/usr/bin/yankit		$RELDIR/usr/bin

echo "installing files in /usr/ainclude"
chtyp -lasm	$SRC/gno/ainclude/m*
install -V	$SRC/gno/ainclude/m*		$RELDIR/usr/ainclude

echo "installing files in /lib/rinclude"
chtyp -lrez	$SRC/gno/rinclude/*.rez
install -V	$SRC/gno/rinclude/*.rez		$RELDIR/lib/rinclude

echo "installing files in /usr/include"
# The cd is (maybe) necessary due to PR#110
cd $SRC/gno/include;	install -V *.h		$RELDIR/usr/include
install -V	$SRC/gno/include/arpa/*.h	$RELDIR/usr/include/arpa
install -V	$SRC/gno/include/gno/*.h	$RELDIR/usr/include/gno
install -V	$SRC/gno/include/machine/*.h	$RELDIR/usr/include/machine
install -V	$SRC/gno/include/net/*.h	$RELDIR/usr/include/net
install -V	$SRC/gno/include/netinet/*.h	$RELDIR/usr/include/netinet
install -V	$SRC/gno/include/protocols/*.h	$RELDIR/usr/include/protocols
install -V	$SRC/gno/include/rpc/*.h	$RELDIR/usr/include/rpc
install -V	$SRC/gno/include/sys/*.h	$RELDIR/usr/include/sys
cd $SRC/gno/include;	chtyp -lcc 	$RELDIR/usr/include/*.h
chtyp -lcc 	$RELDIR/usr/include/arpa/*.h
chtyp -lcc 	$RELDIR/usr/include/gno/*.h
chtyp -lcc 	$RELDIR/usr/include/machine/*.h
chtyp -lcc 	$RELDIR/usr/include/net/*.h
chtyp -lcc 	$RELDIR/usr/include/netinet/*.h
chtyp -lcc 	$RELDIR/usr/include/protocols/*.h
chtyp -lcc 	$RELDIR/usr/include/rpc/*.h
chtyp -lcc 	$RELDIR/usr/include/sys/*.h

echo "installing files in /usr/lib"
install -V	$SRC/gno/doc/describe/describe.src $RELDIR/usr/lib
# libcontrib	done
# libcrypt	done
install -V	/usr/lib/curses.lib		$RELDIR/usr/lib/libcurses
# libedit		IS MISSING
# libnetdb	done
# libsim		IS MISSING
# libtermcap	done
# libutil	done
# liby		done
install -V	$SRC/gno/build.tools/dmake.startup $RELDIR/usr/lib/startup.mk
# /usr/lib/tmac/tmac.an		done
# /usr/lib/tmac/tmac.s		done

echo "installing files in /usr/orca/bin"
# describe	done
install -V	17/occ		$RELDIR/usr/orca/bin
# udl		done

# install man pages
# We have to do a cd here because it seems that there is a 2k upper limit
# on the number of bytes on the command line.  Exceeding this causes a 
# crash.  See PR#110.
echo "installing files in /usr/man/man1"
cd $SRC/gno/usr.man/man1;	install -V *.1 $RELDIR/usr/man/man1
echo "installing files in /usr/man/man2"
cd $SRC/gno/usr.man/man2;	install -V *.2 $RELDIR/usr/man/man2
echo "installing files in /usr/man/man3"
cd $SRC/gno/usr.man/man3;	install -V *.3 $RELDIR/usr/man/man3
echo "installing files in /usr/man/man4"
cd $SRC/gno/usr.man/man4;	install -V *.4 $RELDIR/usr/man/man4
echo "installing files in /usr/man/man5"
cd $SRC/gno/usr.man/man5;	install -V *.5 $RELDIR/usr/man/man5
echo "installing files in /usr/man/man6"
cd $SRC/gno/usr.man/man6;	install -V *.6 $RELDIR/usr/man/man6
echo "installing files in /usr/man/man7"
cd $SRC/gno/usr.man/man7;	install -V *.7 $RELDIR/usr/man/man7
echo "installing files in /usr/man/man8"
cd $SRC/gno/usr.man/man8;	install -V *.8 $RELDIR/usr/man/man8

echo "installing files in /usr/sbin"
# catman	done
install -V	/usr/sbin/cron		$RELDIR/usr/sbin
# descu		done
# descc		done
# getty		done
install -V	/usr/sbin/initd		$RELDIR/usr/sbin
# login		done
# lpc?
install -V	/usr/sbin/lpd		$RELDIR/usr/sbin
# makewhatis	done
install -V	/usr/sbin/mktmp		$RELDIR/usr/sbin
# newuser	done
# newuserv	done
install -V	/usr/sbin/runover	$RELDIR/usr/sbin
install -V	$SRC/gno/verbatim/usr/sbin/slpscrpt.direct $RELDIR/usr/sbin
install -V	/usr/sbin/uptimed	$RELDIR/usr/sbin

echo "installing files in /var/adm/newuser"
install -V	$SRC/gno/verbatim/var/adm/newuser/newid	$RELDIR/var/adm/newuser
install -V	$SRC/gno/verbatim/var/adm/newuser/skel/glogin $RELDIR/var/adm/newuser/skel
install -V	$SRC/gno/verbatim/var/adm/newuser/skel/gshrc $RELDIR/var/adm/newuser/skel

echo "creating log files"
touch		$RELDIR/var/adm/messages
touch		$RELDIR/var/adm/debug
touch		$RELDIR/var/adm/utmp $RELDIR/var/adm/wtmp $RELDIR/var/adm/lastlog
chtyp -tbin -a0	$RELDIR/var/adm/utmp $RELDIR/var/adm/wtmp $RELDIR/var/adm/lastlog

# We make the .so links at user installation time.  We leave the comments in
# from the file /src/gno/usr.man/mkso.data, but strip the comments out of
# all of the others.
echo "creating the /usr/man/mkso.data file"
install $SRC/gno/usr.man/mkso.data $RELDIR/usr/man/mkso.data
cat $DIST/install/mkso.* | egrep -v -e '^#' > $JUNKFILE
msort $JUNKFILE >> $RELDIR/usr/man/mkso.data

# We won't use these directories, but they should be created for the user
echo "creating /usr/local hierarchy"
install -dV $RELDIR/usr/local/bin
install -dV $RELDIR/usr/local/doc
install -dV $RELDIR/usr/local/etc
install -dV $RELDIR/usr/local/include
install -dV $RELDIR/usr/local/lib
install -dV $RELDIR/usr/local/man/man1
install -dV $RELDIR/usr/local/man/man2
install -dV $RELDIR/usr/local/man/man3
install -dV $RELDIR/usr/local/man/man4
install -dV $RELDIR/usr/local/man/man5
install -dV $RELDIR/usr/local/man/man6
install -dV $RELDIR/usr/local/man/man7
install -dV $RELDIR/usr/local/man/man8
install -dV $RELDIR/usr/local/man/cat1
install -dV $RELDIR/usr/local/man/cat2
install -dV $RELDIR/usr/local/man/cat3
install -dV $RELDIR/usr/local/man/cat4
install -dV $RELDIR/usr/local/man/cat5
install -dV $RELDIR/usr/local/man/cat6
install -dV $RELDIR/usr/local/man/cat7
install -dV $RELDIR/usr/local/man/cat8
install -dV $RELDIR/usr/local/sbin

echo "done"