1#!/bin/sh
2
3if [ -f rcmd.c ] ; then
4	cd ..
5fi
6wd=`pwd`
7for f in libncftp sio Strn doc ; do
8	if [ ! -f "$f" ] && [ ! -d "$f" ] ; then
9		echo "Missing directory $f ?" 1>&2
10		exit 1
11	fi
12done
13
14( cd libncftp ; make clean )
15
16TMPDIR=/tmp
17if [ "$#" -lt 2 ] ; then
18	TARDIR="libncftp"
19	STGZFILE="$TARDIR.tar.gz"
20else
21	TARDIR="$1"
22	STGZFILE="$2"
23fi
24
25rm -rf $TMPDIR/TAR
26mkdir -p -m755 $TMPDIR/TAR/$TARDIR 2>/dev/null
27
28chmod 755 configure sh/* install-sh 2>/dev/null
29
30find . -depth -follow -type f | sed '
31/sio\/configure$/d
32/Strn\/configure$/d
33/\.o$/d
34/\.so$/d
35/\.a$/d
36/\.lib$/d
37/\.ncb$/d
38/\.pdb$/d
39/\.idb$/d
40/\.pch$/d
41/\.ilk$/d
42/\.res$/d
43/\.aps$/d
44/\.opt$/d
45/\.plg$/d
46/\.obj$/d
47/\.exe$/d
48/\.zip$/d
49/\.gz$/d
50/\.tgz$/d
51/\.tar$/d
52/\.swp$/d
53/\.orig$/d
54/\.rej$/d
55/\/Makefile\.bin$/p
56/\.bin$/d
57/\/bin/d
58/\/core$/d
59/\/^[Rr]elease$/d
60/\/^[Dd]ebug$/d
61/\/sio\/.*\//d
62/shit/d
63/\/upload/d
64/\/config\.h\.in$/p
65/\/config\./d
66/\/Makefile$/d
67/\/OLD/d
68/\/old/d' | cut -c3- | tee "$wd/doc/manifest.txt" | cpio -Lpdm $TMPDIR/TAR/$TARDIR
69
70( cd "$TMPDIR/TAR/$TARDIR" ; ln -s doc/README.txt README )
71
72x=`tar --help 2>&1 | sed -n 's/.*owner=NAME.*/owner=NAME/g;/owner=NAME/p'`
73case "$x" in
74	*owner=NAME*)
75		TARFLAGS="-c --owner=bin --group=bin --verbose -f"
76		TAR=tar
77		;;
78	*)
79		TARFLAGS="cvf"
80		TAR=tar
81		x2=`gtar --help 2>&1 | sed -n 's/.*owner=NAME.*/owner=NAME/g;/owner=NAME/p'`
82		case "$x2" in
83			*owner=NAME*)
84				TARFLAGS="-c --owner=bin --group=bin --verbose -f"
85				TAR=gtar
86				;;
87		esac
88		;;
89esac
90
91( cd $TMPDIR/TAR ; $TAR $TARFLAGS - $TARDIR | gzip -c > $STGZFILE )
92cp $TMPDIR/TAR/$STGZFILE .
93chmod 644 $STGZFILE
94rm -rf $TMPDIR/TAR
95ls -l $STGZFILE 2>/dev/null
96mv $TGZFILE newbin/ 2>/dev/null
97exit 0
98