[net.sources] Preparing Files for Extraction

rose@uw-june (Scott Rose) (09/04/84)

Files submitted to net.sources are prepared for submission in such a fashion
  that they may be simply extracted using sh.  How is this done?  I would
  like to see a brief tutorial on this topic in order that I might submit
  some material I have.
				uw-june!rose

bsa@ncoast.UUCP (The WITNESS) (09/07/84)

[gollum :-)]

> From: rose@uw-june.UUCP

> Files submitted to net.sources are prepared for submission in such a fashion
>   that they may be simply extracted using sh.  How is this done?

It can be done fairly easily.  I have the following shell script, not great but
it works:
============================================================
: shar - shell script maker for "archiving" FTP on net.sources

if [ $# -eq 0 ]
then	echo "usage: shar file1 file2 ..."
	exit 1
elif [ $# -eq 1 ]
then	echo "usage: shar file1 file2 ..."
	exit 1
fi
FILE=/tmp/shar$$
echo 'Output will be in shar.out'
>$FILE
for file
do	if [ ! -r $file ]
	then	echo "shar: $file cannot be read" >&2
		continue
	fi
	echo "shar - `basename $file`"
	echo "echo 'sh - `basename $file`'" >>$FILE
	echo "sed 's/^X//' <<'________This_Is_The_END________' >>`basename $file`" >>$FILE
	sed 's/^/X/' <$file >>$FILE
	echo '________This_Is_The_END________' >>$FILE
done
mv $FILE shar.out || echo "shar:  could not make shar.out: output is in $FILE" >&2
============================================================
It could be simplified a little, but our 'test' is stupid and chokes on -a and
-o (AND and OR).

--bsa

spaf@gatech.UUCP (Gene Spafford) (09/19/84)

Submission #2.
After my first posting I received a number of suggestions for changes
and enhancements.  Thanks to jpl@allegra, and most especially to
Corey Satten (corey@fluke), I now submit the following for
your consideration and use.

This runs under "csh" but produces shar archives which are
unbundled with "sh".


#! /bin/csh 
# bundle:  group files into distribution package in "shar" format
#          suitable for extraction with sh, not csh.
#

set command = $0
set errors = 0

if (! ${#argv}) then
	echo "usage: $command:t file1 file2 file3 ... fileN > file.shar"
	exit 1
	endif

echo ': to unbundle, "sh" this file -- DO NOT use csh'
echo ':  SHAR archive format.  Archive created '`date`

foreach file ($argv)
	if (! (-r $file && -f $file) ) then
		echo $command:t": cannot archive '$file'" > /dev/tty
		@ errors++
		continue
		endif
	echo "echo x - $file:t"
	echo "sed 's/^X//' > $file:t <<'+FUNKY+STUFF+'"
	sed 's/^/X/' $file
	echo "+FUNKY+STUFF+"
	if (-d $file:h) then
		echo "echo '`(cd $file:h; ls -l $file:t)`    (as sent)'"
	else
		echo "echo '`ls -l $file:t`    (as sent)'"
		endif
	ls -l $file | sed \
		-e 's/^.\(...\)\(...\)\(...\).*/u=\1,g=\2,o=\3/' \
		-e 's/-//g' \
		-e 's/.*/chmod & '"$file:t/"
	echo "ls -l $file:t"
	end
echo "exit 0"

exit $errors
-- 
Off the Wall of Gene Spafford
The Clouds Project, School of ICS, Georgia Tech, Atlanta GA 30332
Phone:	(404) 894-6169, (404) 894-6170 [messages]
CSNet:	Spaf @ GATech		ARPA:	Spaf%GATech.CSNet @ CSNet-Relay.ARPA
uucp:	...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!spaf
	...!{rlgvax,sb1,seismo,uf-cgrl,unmvax,ut-sally}!gatech!spaf