[comp.unix.microport] cpio of uport dist disks

bill@alembic.ACS.COM (Bill Hatch) (06/05/89)

From inco!uunet!bts!bill Sun Jun  4 16:42:43 1989
Received: by inco.UUCP (smail2.5)
	id AA21716; 4 Jun 89 16:22:08 EDT (Sun)
Received: from bts.UUCP by uunet.uu.net (5.61/1.14) with UUCP 
	id AA11205; Sun, 4 Jun 89 15:48:54 -0400
Date: Sun, 4 Jun 89 15:48:54 -0400
From: uunet!bts!bill
Message-Id: <8906041948.AA11205@uunet.uu.net>
Apparently-To: alembic!bill
Status: R

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README hdcount.c head.c stripbytes.c upinstall upstrip.c
# Wrapped by bill@bts on Sun Jun  4 14:45:27 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1419 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
My firm has recently switched from Microport to Xenix for our
X80386 machines.
X
I was faced with the problem of installing files from Microport
V386 3.0e distribution floppies on a XENIX 386 system.   It seems that
XXENIX and uport text preparation packages complement each other nicely.
XXENIX includes the complete on line manuals. Uport delivered ditroff,
graphics utilities (grap, pic), and some other things like style.
We also needed some parts of the 3.0e software development system.
X
The uport distribution floppies are in cpio format but the installation must
be done from /dev/rdsk/f0q15d  by the "installit" script (not from f0q15dt).
XXENIX 386 does not have this entry in /dev/rdsk and my attempts to
use installit and cpio to install the uport software development
system failed.
X
My solution to this problem is detailed in the "upinstall" script and
the "upstrip.c" program.  The other short C programs in this package
were developed and used to analyze the problem.
Another possible option (not investigated) is to create the dev entry
X"/dev/rdsk/f0q15dt" under XENIX.  
X
As far as I know, this solution works only for Microport V386 3.0e
distribution disks.  I release this code to the public domain
with no claims to copyright or any other credits. 
X
X	Bill Hatch
X	uunet!bts!bill
X
X	Computational Engineering
X	14504 Greenview Drive Suite 500
X	Laurel, Maryland 20708
X	Phone (301)470-3839
X	FAX (301)776-5451
END_OF_FILE
if test 1419 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'hdcount.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'hdcount.c'\"
else
echo shar: Extracting \"'hdcount.c'\" \(681 characters\)
sed "s/^X//" >'hdcount.c' <<'END_OF_FILE'
X/* 
X	hdcount - count the number of files in a cpio file
X	by counting the number of times the cpio magic number
X	"07070700" occurs.
X
X	W. Hatch 6/4/89
X*/
X#include <stdio.h>
main()
X{
X	int i;
X	for(;;)
X	{
X		if(gethdr() == (-1))
X			exit();
X		++i;
X		printf("hd count: %d\n", i);
X	}
X
X}
int gethdr()
X{
X	int c; 
X	int state = 0;
X	while((c=getchar()) != EOF)
X	{
X		switch(state)
X		{
X			case 0: 
X			case 2:
X			case 4:
X			case 6:
X			        if(c=='0')
X					++state;
X				else
X					state = 0;
X				break;
X
X			case 1:
X			case 3:
X			case 5: if(c=='7')
X					++state;
X				else
X					state = 0;
X				break;
X			case 7: if(c == '0')
X					return(0);
X				else
X					state = 0;
X				break;
X
X		}
X	}
X	return(-1);
X}
END_OF_FILE
if test 681 -ne `wc -c <'hdcount.c'`; then
    echo shar: \"'hdcount.c'\" unpacked with wrong size!
fi
# end of 'hdcount.c'
fi
if test -f 'head.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'head.c'\"
else
echo shar: Extracting \"'head.c'\" \(396 characters\)
sed "s/^X//" >'head.c' <<'END_OF_FILE'
X/*
X	head - to extract the beginning og a file
X
X	usage: head [count] <file
X
X		where count is the number of lines to extract
X
X	W. Hatch  6/4/89
X
X*/
X#include <stdio.h>
main(argc, argv)
int argc;
char *argv[];
X{
X	int	count = 20;
X	int	i = 0;
X	char	buffer[500];
X	if(argc > 1)
X	{
X		count = atoi(argv[1]);
X	}
X	while(i++ <= count)
X	{
X		if(gets(buffer) == NULL)
X			break;
X		puts(buffer);
X	}
X	exit(0);
X	
X}
X
END_OF_FILE
if test 396 -ne `wc -c <'head.c'`; then
    echo shar: \"'head.c'\" unpacked with wrong size!
fi
# end of 'head.c'
fi
if test -f 'stripbytes.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stripbytes.c'\"
else
echo shar: Extracting \"'stripbytes.c'\" \(410 characters\)
sed "s/^X//" >'stripbytes.c' <<'END_OF_FILE'
X/*
X	stripbytes - strip off the first n bytes of stdin
X
X	usage:  stripbytes [n] <infile
X
X		where n is the number of bytes to strip
X		default is 1920
X
X	W. Hatch  6/4/89
X*/
X#include <stdio.h>
main(argc, argv)
int argc;
char *argv[];
X{
X	int n = 1921;
X	int i = 0;
X	int c;
X
X	for(i=0; i < n; i++)
X	{
X		if((c = getchar()) == EOF)
X			exit(1);
X	}
X	while(1)
X	{
X		if((c = getchar()) == EOF)
X			exit(0);
X		putchar(c);
X	}
X}
END_OF_FILE
if test 410 -ne `wc -c <'stripbytes.c'`; then
    echo shar: \"'stripbytes.c'\" unpacked with wrong size!
fi
# end of 'stripbytes.c'
fi
if test -f 'upinstall' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'upinstall'\"
else
echo shar: Extracting \"'upinstall'\" \(771 characters\)
sed "s/^X//" >'upinstall' <<'END_OF_FILE'
X#!/bin/sh
X#+++
X#	NAME	: upinstall
X#
X#	PURPOSE : install files from uport "install" disks on a system
X#		  like XENIX 386 that does not have /dev/rdsk/f0q15d
X#
X#	AUTHOR	: W. Hatch
X#			Computational Engineering
X#			14504 Greenview Drive Suite 500
X#			Laurel, Maryland 20708
X#			(301)470-3839
X#			uunet!bts!bill
X#	DATE	: 6/4/89
X#
X#	USAGE	: upinstall (no arg)
X#
X#	LIMITS	: does not execute any installation scripts that were
X#		  on the microport distribution disk, also the installation
X#		  paths are taken "as is" from the distribution disk. Thus
X#		  the user should "cd" to the root directory for the
X#		  installation.
X#------------------------------------------------------------------------
dd if=/dev/dsk/f0q15dt  of=$$tmp
upstrip < $$tmp | cpio -ivcdmu
rm -f $$tmp
END_OF_FILE
if test 771 -ne `wc -c <'upinstall'`; then
    echo shar: \"'upinstall'\" unpacked with wrong size!
fi
chmod +x 'upinstall'
# end of 'upinstall'
fi
if test -f 'upstrip.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'upstrip.c'\"
else
echo shar: Extracting \"'upstrip.c'\" \(1470 characters\)
sed "s/^X//" >'upstrip.c' <<'END_OF_FILE'
X#include <stdio.h>
main()
X{
X	int c;
X	if(get366trans() == (-1))
X	{
X		fprintf(stderr, "could not get 366 to 0 transition\n");
X		exit(2);
X	}
X	if(gethdr() == (-1))
X	{
X		fprintf(stderr, "could not get 07070700 header");
X		exit(2);
X	}
X	printf("07070700");
X	while((c=getchar()) != EOF)
X		putchar(c);
X	exit(1);
X
X}
int gethdr()
X{
X	int c; 
X	int state = 0;
X	while((c=getchar()) != EOF)
X	{
X		switch(state)
X		{
X			case 0: 
X			case 2:
X			case 4:
X			case 6:
X			        if(c=='0')
X					++state;
X				else
X					state = 0;
X				break;
X
X			case 1:
X			case 3:
X			case 5: if(c=='7')
X					++state;
X				else
X					state = 0;
X				break;
X			case 7: if(c == '0')
X					return(0);
X				else
X					state = 0;
X				break;
X
X		}
X	}
X	return(-1);
X}
int get366trans()
X{
X	int c;
X	int state = 0;
X	int count = 0;
X	while((c=getchar()) != EOF)
X	{
X		switch(state)
X		{
X			case 0:  if(c == 246)
X				{
X					state = 1;
X					++count;
X				}
X				 else 
X					state = 0;
X				break;
X
X			case 1:  if(c == 246)
X				{
X					++count;
X					state = 2;
X				}
X				else
X					state = 0;
X				break;
X
X			case 2:	if(c == 246) 
X				{
X					++count;
X					break;
X				}
X				else if( c == '0')
X				{
X					if(ungetc(c,stdin)==EOF)
X					{
X				 	  fprintf(stderr,"ungetc() failed\n");
X					  return((-1));
X					}
X					return(0);
X				}
X				else
X				{
X					state = 0;
X					break;
X				}
X			default:
X			   fprintf(stderr,"get366trans() illegal state\n");
X			   return((-1));
X				
X		}
X	}
X	fprintf(stderr, "count of 0366 char: %d\n",count);
X	return(-1);
X}
END_OF_FILE
if test 1470 -ne `wc -c <'upstrip.c'`; then
    echo shar: \"'upstrip.c'\" unpacked with wrong size!
fi
# end of 'upstrip.c'
fi
echo shar: End of shell archive.
exit 0