1#!/bin/sh
2#
3# @(#)makerel.sh	6.28 03/12/12
4#
5# Make software binary release
6#
7#    xmcd  - Motif(R) CD Audio Player/Ripper
8#    cda   - Command-line CD Audio Player/Ripper
9#
10#    Copyright (C) 1993-2004  Ti Kan
11#    E-mail: xmcd@amb.org
12#
13#    This program is free software; you can redistribute it and/or modify
14#    it under the terms of the GNU General Public License as published by
15#    the Free Software Foundation; either version 2 of the License, or
16#    (at your option) any later version.
17#
18#    This program is distributed in the hope that it will be useful,
19#    but WITHOUT ANY WARRANTY; without even the implied warranty of
20#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21#    GNU General Public License for more details.
22#
23#    You should have received a copy of the GNU General Public License
24#    along with this program; if not, write to the Free Software
25#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26#
27
28# The file containing a list of binary release files
29BINLIST=misc_d/BINLIST
30TMPDIR=/tmp/_makerel_d
31TOPDIR=xmcdbin
32ZFILE=xmcdbin.tar.gz
33UUEFILE=xmcdbin.uue
34COMPRESS=gzip
35UNCOMPRESS=gunzip
36ENCODE=uuencode
37DECODE=uudecode
38TAR=/usr/local/bin/scotar
39
40# Use Sysv echo if possible
41if [ -x /usr/5bin/echo ]				# SunOS SysV echo
42then
43	ECHO=/usr/5bin/echo
44elif [ -z "`(echo -e a) 2>/dev/null | fgrep e`" ]	# GNU bash, etc.
45then
46	ECHO="echo -e"
47else							# generic SysV
48	ECHO=echo
49fi
50
51# Select tar program
52if [ ! -x $TAR ]
53then
54	TAR=tar
55fi
56
57CURDIR=`pwd`
58if [ `basename "$CURDIR"` = misc_d ]
59then
60	cd ..
61elif [ ! -f install.sh ]
62then
63	$ECHO "You must run the makerel.sh script while in the xmcd"
64	$ECHO "source code distribution top-level directory or in the"
65	$ECHO "misc_d subdirectory."
66	exit 1
67fi
68
69if [ ! -r $BINLIST ]
70then
71	$ECHO "Error: Cannot open $BINLIST"
72	exit 2
73fi
74
75VERS=`grep "VERSION=" $BINLIST | sed 's/^.*VERSION=//'`
76
77$ECHO "Creating xmcd/cda version $VERS binary release...\n"
78
79trap "$ECHO 'Interrupted!'; rm -rf $TMPDIR $ZFILE $UUEFILE; exit 1" 1 2 3 5 15
80
81# Make temp directory and copy release files to it
82rm -rf $TMPDIR
83mkdir -p $TMPDIR
84for i in `awk '!/^#/ { print $1 }' $BINLIST`
85do
86	$ECHO "\t$i"
87	DEST=`dirname $TMPDIR/$TOPDIR/$i`
88	mkdir -p $DEST >/dev/null 2>&1
89	cp $i $DEST
90done
91
92# Copy CDDB2 shared library into binary bundle
93case `uname -s` in
94HP-UX)
95	shlib=libcddb.sl
96	;;
97SunOS)
98	case `uname -r` in
99	4*)
100		shlib=libcddb.so.1.0
101		;;
102	5*)
103		shlib=libcddb.so.1
104		;;
105	*)
106		shlib=libcddb.so.1
107		;;
108	esac
109	;;
110*)
111	shlib=libcddb.so.1
112	;;
113esac
114
115for d in /usr/lib /usr/local/lib /lib /usr/ccs/lib
116do
117	if [ -f $d/$shlib ]
118	then
119		DEST=$TMPDIR/$TOPDIR/cddb_d
120		mkdir -p $DEST >/dev/null 2>&1
121		cp $d/$shlib $DEST
122		$ECHO "\tcddb_d/$shlib"
123		break
124	fi
125done
126
127if [ ! -d $TMPDIR/$TOPDIR/cddb_d ]
128then
129	$ECHO "\nNOTICE: CDDB shared library not included."
130fi
131
132# Strip the binary symbol tables
133strip $TMPDIR/$TOPDIR/xmcd_d/xmcd >/dev/null 2>&1
134strip $TMPDIR/$TOPDIR/cda_d/cda >/dev/null 2>&1
135strip $TMPDIR/$TOPDIR/util_d/gobrowser >/dev/null 2>&1
136
137# Remove comment section of binaries if possible
138(mcs -da "@(#)xmcd $VERS (C) Ti Kan 1993-2004" \
139	$TMPDIR/$TOPDIR/xmcd_d/xmcd) >/dev/null 2>&1
140(mcs -da "@(#)cda $VERS (C) Ti Kan 1993-2004" \
141	$TMPDIR/$TOPDIR/cda_d/cda) >/dev/null 2>&1
142(mcs -da "@(#)gobrowser $VERS" \
143	$TMPDIR/$TOPDIR/util_d/gobrowser) >/dev/null 2>&1
144
145$ECHO "\nFixing permissions..."
146(cd $TMPDIR; find * -type d -print | xargs chmod 755)
147(cd $TMPDIR; find * -type f -print | xargs chmod 444)
148
149$ECHO "\nCreating \"$COMPRESS\"ed tar archive..."
150# Create tar archive and compress it
151(cd $TMPDIR; $TAR cf - *) | $COMPRESS >$ZFILE
152
153$ECHO "\n\"$ENCODE\"ing..."
154
155$ECHO '
156Instructions to unpack xmcd v_VERS_ binary and other info
157------------------------------------------------------
158
159At the end of this message is a "_COMPRESS_"ed and "_ENCODE_"ed
160tar file containing the xmcd and cda executables as well as
161their supporting files.  To extract, save this message in a
162file "_UUEFILE_", login as root and do the following:
163
164	_DECODE_ _UUEFILE_
165	_UNCOMPRESS_ < _ZFILE_ | tar xvf -
166	cd _TOPDIR_
167	sh ./install.sh
168
169Be sure to run the "install.sh" script to install and configure
170the software.  Otherwise, it will not work properly.
171
172For further information, see the XMCDLIB/docs/README file after
173installation.
174
175' | sed	-e "s/_VERS_/$VERS/g" \
176	-e "s/_UUEFILE_/$UUEFILE/g" \
177	-e "s/_ZFILE_/$ZFILE/g" \
178	-e "s/_TOPDIR_/$TOPDIR/g" \
179	-e "s/_COMPRESS_/$COMPRESS/g" \
180	-e "s/_UNCOMPRESS_/$UNCOMPRESS/g" \
181	-e "s/_ENCODE_/$ENCODE/g" \
182	-e "s/_DECODE_/$DECODE/g" >$UUEFILE
183
184# Uuencode
185$ENCODE $ZFILE $ZFILE >>$UUEFILE
186$ECHO "\n\n\n" >>$UUEFILE
187
188rm -rf $TMPDIR
189
190$ECHO ""
191ls -l $ZFILE $UUEFILE
192
193exit 0
194
195