# issue needs to be same group as root
cp baseexec /tmp
chmod +x /tmp/baseexec

echo "do you want to re-create the file 'files' (y/n) ?"
read ANS
if [ "$ANS" = 'y' ]
then
	echo "creating files, this may take a while"

# create dummy pslinks files so that update will include them

	for i in DWB acctcom admin base bc cflow config extfile fortran ipcrm \
		 lp mailx manprog profiler sccs sgs spell sysdef units uucp
	do
		touch /tmp/$i\links
	done
	awk -f awkscript /issue/BASE | update >files
	chmod 644 /etc/mkroom_list
fi


/bin/rm -f missing.files tmp.files .issueflop d/* 2> /dev/null

fgrep -v LINK_ files | filelist 2> missing.files |\
sort -t\	 +1 -2 >  tmp.files

# note that the awkscript can only cope with up to 10 product sets
# at the moment this is sufficient as not all product sets need links

/bin/rm -f /tmp/*links
fgrep LINK_ files |\
fgrep -v '?' |\
awk '{printf("ln %s %s\n",substr($3,6),$1) > "/tmp/" $4 "links"}'
chmod 700 /tmp/*links

if [ -f missing.files ]
then
	set `wc missing.files`
	echo "there are $1 files missing, they are listed in missing.files\n"
fi

sed -e 's/\([^ 	]*\).*/\1/' tmp.files | cat devfiles bootonly lfonly - \
     > tape.file 
echo tmp/dolinks > tape.cpio
echo tmp/baseexec >> tape.cpio
sed -e 's/^\///' -e '/^tmp\/.*links/d' tape.file >> tape.cpio
rm tape.file tmp.files

cat /tmp/*links > /tmp/iss$$
mv /tmp/iss$$ /tmp/dolinks

echo "do you want to build the issue tape (y/n) ?"

read ANS
if [ "$ANS" = 'y' ]
then
	tp -l
	tp -r
	cd / ; cpio -ov < /issue/tape.cpio | wbuf
	tp -r
	tp -u
fi

