[comp.sources.d] How do you create a shell archive?

dave@clsib21.UUCP (David P. Hansen) (09/16/87)

Being rather new to Unix, I haven't yet discovered what utilities are
used to pack a shell archive. What's available or does everyone have
there own program. Would anyone out there like to share what they have??

steve@cit5.UUCP (09/18/87)

In article <545@clsib21.UUCP>, dave@clsib21.UUCP (David P. Hansen) writes:
> Being rather new to Unix, I haven't yet discovered what utilities are
> used to pack a shell archive. What's available or does everyone have
> there own program. Would anyone out there like to share what they have??

I hope people don't mind this appearing in this newsgroup, but my spur-of-the-
moment scripts for creating shar files follows below. I make no pretence that 
it is the best way to do it, but it does work. Each time you run it, you should
rename the output file which is called "shar_out" to something else. One day, I
may even fix this deficiency up. (if I get the time :-)
If you need to do any other shell-type commands, then these can be added in
with an editor after all the files are archived.
The main file follows.....

------cut-------cut--------cut---------cut---------cut---------cut-------cut---
# Creates a shar file for posting sources to ACSnet.
# Output is always to "shar_out"
#
# Usage: mkshar file_template
#
# Calls subroutine "mksh" for each member file.
#
if test -f 'shar_out'
then
	echo "mkshar: \"'shar_out'\" already exists; will not over-write."
else
echo "#---cut here---cut here---cut here---cut here---cut here---" >shar_out
echo "#! /bin/sh" >>shar_out
echo "# This is a shell archive, meaning:" >>shar_out
echo "# 1. Remove everything above the #! /bin/sh line." >>shar_out
echo "# 2. Save the resulting text in a file." >>shar_out
echo "# 3. Execute the file with /bin/sh (not csh) to create the files." >>shar_out
echo "# This archive created: `date`" >>shar_out
echo "# Archived by: `cat $HOME/.netname`" >>shar_out
echo "export PATH; PATH=/bin:\$PATH" >>shar_out
ff=`ls $*`
for f in $ff
do
	echo mkshar: packing \'$f\'
	mksh $f `wc -c <$f`
done
echo "#	End of shell archive" >>shar_out
echo "exit 0" >>shar_out
echo
echo "***** Resulting shar file is in 'shar_out'"
fi
cat $HOME/.signature >>shar_out
------cut-------cut--------cut---------cut---------cut---------cut-------cut---


The following script is called "mksh" and is called by "mkshar" for each file
to be archived.

------cut-------cut--------cut---------cut---------cut---------cut-------cut---
# Called by "mkshar" to create the file part of a shar file.
#
# Usage: mksh filename filesize
#
# Must be called by "mkshar" otherwise the header and trailer of the shar file
# will be missing.
#
echo "echo shar: extracting \"'$1'\" '($2 characters)'" >>shar_out
echo "if test -f '$1'" >>shar_out
echo "then" >>shar_out
echo "	echo shar: will not over-write existing file \"'$1'\"" >>shar_out
echo "else" >>shar_out
echo "sed 's/^X//' << \\SHAR_EOF > '$1'" >>shar_out
sed 's/^/X/' <$1 >>shar_out
echo "SHAR_EOF" >>shar_out
echo "if test $2 -ne \"\`wc -c < '$1'\`\"" >>shar_out
echo "then" >>shar_out
echo "	echo shar: error transmitting \"'$1'\" '(should have been $2 characters)'" >>shar_out
echo "fi" >>shar_out
echo "fi # end of overwriting check" >>shar_out
------cut-------cut--------cut---------cut---------cut---------cut-------cut---

I hope this helps you out,
				Steve.

-		-		-		-		-
		(It's my opinion and not my employers)
Steve Balogh	VK3YMY			| steve@cit5.cit.oz (...oz.au)
Chisholm Institute of Technology	| steve%cit5.cit.oz@uunet.uu.net
PO Box 197, Caulfield East		| 
Melbourne, AUSTRALIA. 3145		| {hplabs,mcvax,uunet,ukc}!munnari\
+61 3 573 2266 (Ans Machine)		|  !cit5.cit.oz!steve

sa@ttidca.TTI.COM (Steve Alter) (09/20/87)

In article <545@clsib21.UUCP> dave@clsib21.UUCP (David P. Hansen) writes:
> Being rather new to Unix, I haven't yet discovered what utilities are
> used to pack a shell archive. What's available or does everyone have
> there own program. Would anyone out there like to share what they have??

There are lots of shell scripts that usually go by the name of "shar"
that people use to pack archives.  I've got a version written in C
that completely blows all the shell-versions away--here's the section
of the manual-page that mentions all who worked on this one:

    Gary Perlman (based on a shell version by James Gosling, with
    additions motivated by many people on the UNIX network:  Derek
    Zahn, Michael Thompson, H. Morrow Long, Fred Avolio, Gran
    Uddeborg, Chuck Wegrzyn, nucleus!randy@TORONTO, & Bill McKeeman)

Ask around your site and neighboring sites; somebody's bound to have
something you can use.  I've got my own little list of improvements to
be made to the C-written version--I'll post to comp.sources.unix when
done.  (P.S. to r$: do you maintain archives?)

-- Steve Alter
...!{csun,rdlvax,trwrb,psivax}!ttidca!alter  or  alter@tti.com
Citicorp/TTI, Santa Monica CA  (213) 452-9191 x2541

gwyn@brl-smoke.ARPA (Doug Gwyn ) (09/21/87)

In article <545@clsib21.UUCP> dave@clsib21.UUCP (David P. Hansen) writes:
>Being rather new to Unix, I haven't yet discovered what utilities are
>used to pack a shell archive.

Use "bundle" from Kernighan & Pike.  That's essentially what
I do, and I have yet to hear of anyone having a problem
extracting sources I've mailed to them.

Many people think that shell archives should protect against
mailers that mangle files containing (for example) lines
starting with a dot.  I think the mailers should be fixed.

jewett@hpl-opus.HP.COM (Bob Jewett) (09/22/87)

> Use "bundle" from Kernighan & Pike.  That's essentially what
> I do, and I have yet to hear of anyone having a problem
> extracting sources I've mailed to them.

    For occasional light use for well-controlled inputs, bundle is OK.
    (Bundle is a 10-line shell script that generates a shar of its arguments.)
    Bundle can not perform any sort of error checking during unpacking.

> Many people think that shell archives should protect against
> mailers that mangle files containing (for example) lines
> starting with a dot.  I think the mailers should be fixed.

    Our local shar is written in C, can send binary files, can do error
    checking at the receiving end, and protects against mailer
    stupidity.  It is very nice to be able to shar up arbitrary files.
    The binaries are encoded into printable ASCII, and an unpacking
    program (in C) is included in the shar.  It is possible to shar and
    mail compressed files.

    I agree that the mailers should be fixed, but for now we need robust
    shars.

    Bob

bd@hpsemc.UUCP (bob desinger) (09/23/87)

> Our local shar is written in C, can send binary files, can do error
> checking at the receiving end, and protects against mailer
> stupidity.  It is very nice to be able to shar up arbitrary files.
> The binaries are encoded into printable ASCII, and an unpacking
> program (in C) is included in the shar.  It is possible to shar and
> mail compressed files.

this is jack applin's shar, posted to net.sources when it was called
that a long time ago.  i combined jack's shar with some features of
rich salz's (based on larry wall's) for support of multi-part kits,
then added yet another option that i wanted---an auto-compress with
auto-decompress upon unpacking---and sent the result to rich salz of
comp.sources.unix fame.  this shar has been tested on system v and
rich is testing it on berkeley.

watch for it in comp.sources.unix in a week or two, maybe less.

bob desinger