summaryrefslogtreecommitdiff
path: root/bootstrap/pkg.sh
blob: 28fb82c45ea74c04d9c216a9956e56965ba3cdee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
#! /bin/sh
#
# $NetBSD: pkg.sh,v 1.1.1.1 2004/03/11 13:03:59 grant Exp $
#
#
# Copyright (c) 2002 Alistair G. Crooks.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#	This product includes software developed by Alistair G. Crooks
#	for the NetBSD project.
# 4. The name of the author may not be used to endorse or promote
#    products derived from this software without specific prior written
#    permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#set -x

version=20020615

opsys=`uname -s`

case "$opsys" in
Darwin)
	awkprog=/usr/bin/awk
	catprog=/bin/cat
	chmodprog=/bin/chmod
	cpprog=/bin/cp
	lnprog=/bin/ln
	mkdirprog=/bin/mkdir
	rmprog=/bin/rm
	sedprog=/usr/bin/sed
	;;
Linux)
	awkprog=/usr/bin/awk
	catprog=/bin/cat
	chmodprog=/bin/chmod
	cpprog=/bin/cp
	lnprog=/bin/ln
	mkdirprog=/bin/mkdir
	rmprog=/bin/rm
	sedprog=/bin/sed
	;;
NetBSD)
	awkprog=/usr/bin/awk
	catprog=/bin/cat
	chmodprog=/bin/chmod
	cpprog=/bin/cp
	lnprog=/bin/ln
	mkdirprog=/bin/mkdir
	rmprog=/bin/rm
	sedprog=/usr/bin/sed
	;;
SunOS)
	awkprog=/usr/bin/nawk
	catprog=/usr/bin/cat
	chmodprog=/usr/bin/chmod
	cpprog=/usr/bin/cp
	lnprog=/usr/bin/ln
	mkdirprog=/usr/bin/mkdir
	rmprog=/usr/bin/rm
	sedprog=/usr/xpg4/bin/sed
	;;
*)
	awkprog=awk
	catprog=cat
	chmodprog=chmod
	cpprog=cp
	lnprog=ln
	mkdirprog=mkdir
	rmprog=rm
	sedprog=sed
	;;
esac

getpkg()
{
	if test -d $PKG_DBDIR/$1; then
		d=$PKG_DBDIR/$1
	else
		d="`echo $PKG_DBDIR/${1}-*`"
	fi
	echo $d
}

case "$DIGESTPROG" in
"")	DIGESTPROG=/usr/pkg/bin/digest ;;
esac
case "$PKG_DBDIR" in
"")     PKG_DBDIR=/var/db/pkg ;;
esac
case "$PKG_DIGEST" in
"")	PKG_DIGEST=sha1 ;;
esac

ALLDIGESTS="sha1 sha512"

case "$0" in
*pkg_create)	cmd=create ;;
*pkg_delete)	cmd=delete ;;
*pkg_info)	cmd=info ;;
*pkg.sh|*pkg)	cmd=$1; shift ;;
esac

case "$cmd" in
create)
	if [ $# -lt 1 ]; then
		echo "Usage: pkg create ..." > /dev/stderr
		exit 1
	fi

	BUILDINFOFILE=""		# done
	BUILDVERSIONFILE=""		# done
	CONFLICTS=""			# done
	comment=""			# done
	DISPLAYFILE=""			# done
	DESCRFILE=""			# done
	plist=""			# done
	minush=no
	realprefix=""
	installfile=""			# done
	deinstallfile=""		# done
	srcdir=""
	relsymlinks=no
	mtreefile=""
	plistonly=no
	PREREQS=""
	#prefix=""
	reorder=no
	requirements=""
	allsizefile=""			# done
	thissizefile=""			# done
	updatefilecache=yes
	excludefrom=""

	while [ $# -gt 0 ]; do
		case "$1" in
		-B)	BUILDINFOFILE="$2"; shift ;;
		-C)	CONFLICTS="$2"; shift ;;
		-D)	DISPLAYFILE="$2"; shift ;;
		-I)	realprefix="$2"; shift ;;
		-L)	srcdir="$2"; shift ;;
		-O)	plistonly=yes ;;
		-P)	PREREQS="$PREREQS $2"; shift ;;
		-R)	reorder=yes ;;
		-S)	allsizefile="$2"; shift ;;
		-U)	updatefilecache=no ;;
		-V)	echo $version; exit 0 ;;
		-X)	excludefrom="$excludefrom $2"; shift ;;
		-b)	BUILDVERSIONFILE="$2"; shift ;;
		-c)	case "$2" in
			-*)	comment="`echo $2 | $sedprog -e 's|^-||'`"; shift ;;
			*)	comment=`$catprog $2` ;;
			esac
			shift ;;
		-d)	DESCRFILE=$2; shift ;;
		-f)	plist="$2"; shift ;;
		-h)	minush=yes ;;
		-i)	installfile="$2"; shift ;;
		-k)	deinstallfile="$2"; shift ;;
		-l)	relsymlinks=yes ;;
		-m)	mtreefile="$2"; shift ;;
		-p)	PREFIX="$2"; shift ;;
		-r)	requirements="$2"; shift ;;
		-s)	thissizefile="$2"; shift ;;
		-t)	shift ;;
		-v)	set -x ;;
		--)	shift; break ;;
		*)	break ;;
		esac
		shift
	done

	PKGNAME=$1

	if [ ! -d $PKG_DBDIR/$PKGNAME ]; then
		$mkdirprog $PKG_DBDIR/$PKGNAME
	fi

	if [ -f "$BUILDINFOFILE" ]; then
		$cpprog $BUILDINFOFILE $PKG_DBDIR/$PKGNAME/+BUILD_INFO
	fi
	if [ -f "$BUILDVERSIONFILE" ]; then
		$cpprog $BUILDVERSIONFILE $PKG_DBDIR/$PKGNAME/+BUILD_VERSION
	fi
	echo $comment > $PKG_DBDIR/$PKGNAME/+COMMENT
	$cpprog $DESCRFILE $PKG_DBDIR/$PKGNAME/+DESC

	case "$installfile" in
	"")	;;
	*)	$cpprog $installfile $PKG_DBDIR/$PKGNAME/+INSTALL ;;
	esac
	case "$deinstallfile" in
	"")	;;
	*)	$cpprog $deinstallfile $PKG_DBDIR/$PKGNAME/+DEINSTALL ;;
	esac
	case "$DISPLAYFILE" in
	"")	;;
	*)	$cpprog $DISPLAYFILE $PKG_DBDIR/$PKGNAME/+DISPLAY ;;
	esac
	case "$allsizefile" in
	"")	;;
	*)	$cpprog $allsizefile $PKG_DBDIR/$PKGNAME/+SIZE_ALL ;;
	esac
	case "$thissizefile" in
	"")	;;
	*)	$cpprog $thissizefile $PKG_DBDIR/$PKGNAME/+SIZE_PKG ;;
	esac

	export PREFIX PKGNAME CONFLICTS PREREQS DIGESTPROG PKG_DIGEST

	$awkprog '
	BEGIN	{
		if (ENVIRON["CONFLICTS"] != "") {
			cflc = split(ENVIRON["CONFLICTS"], cflv);
			for (i = 1 ; i <= cflc ; i++)
				printf("@pkgcfl %s\n", cflv[i])
		}
		if (ENVIRON["PREREQS"] != "") {
			prec = split(ENVIRON["PREREQS"], prev);
			for (i = 1 ; i <= prec ; i++)
				printf("@pkgdep %s\n", prev[i])
		}
		prefix = ENVIRON["PREFIX"];
		printf("@name %s\n@cwd %s\n", ENVIRON["PKGNAME"], prefix) }
	/^@(comment|dirrm|src)/	{ print $0; next }
	/^@(un)?exec/	{	last = filename; gsub(".*/", "", last); gsub("%f", last);
		fc = split(filename, fv, "/"); fn = prefix; for (i = 1 ; i < fc ; i++) fn = fn "/" fv[i]; gsub("%B", fn);
		gsub("%F", filename);
		gsub("%D", prefix); print $0; next }
	{ filename = $0; printf("%s\n@comment MD5:", $0); cmd = sprintf("'$catprog' %s/%s | %s %s", prefix, $0, ENVIRON["DIGESTPROG"], ENVIRON["PKG_DIGEST"]); system(cmd) }
	' < $plist > $PKG_DBDIR/$PKGNAME/+CONTENTS

	# construct the digests of all the metafiles
	echo "#! /bin/sh" > $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo 'case $# in' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '0) ;;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '*) cd '$PKG_DBDIR/$PKGNAME ';;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo 'esac' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "$awkprog '" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo 'BEGIN	{ ex = 0 }' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo 'END	{ exit(ex) }' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '/^@cwd/	{ prefix = $2; next }' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '/^@/	{ next }' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '	{' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '	for (done = 0 ; !done ; ) {' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '		filename = prefix "/" $0;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '		getline;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '		if ($0 ~ /^@comment (MD5|SHA1):/) {' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			alg = dig = $2;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			gsub(":.*", "", alg);' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			gsub("[A-Za-z0-9]*:", "", dig);' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			cmd = sprintf("s=`'$catprog' %s | '$DIGESTPROG' %s`; if test \"%s\" != \"$s\"; then echo \"Checksum mismatch (%s): expected %s, got $s\"; fi", filename, alg, dig, filename, dig);' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			if (system(cmd) != 0) ex = 1' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '			done = 1;' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '		}' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo '	}' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "}' +CONTENTS" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "$awkprog '" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "BEGIN	{ ex = 0 }" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "END	{ exit(ex) }" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "          {" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo 'cmd = sprintf("s=`'$catprog' %s | '$DIGESTPROG' %s`; if test \"%s\" != \"$s\"; then echo \"Checksum mismatch (%s): expected %s, got $s\"; fi", $1, $2, $3, $1, $3);' >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "if (system(cmd) != 0) ex = 1" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	echo "}' << filesEOF" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	# construct the digests of all the metafiles
	for f in +BUILD_INFO +BUILD_VERSION +COMMENT +CONTENTS +DEINSTALL +DESC +DISPLAY +INSTALL +SIZE_ALL +SIZE_PKG; do
		if [ -f $PKG_DBDIR/$PKGNAME/$f ]; then
			for dig in $ALLDIGESTS; do
				echo "$f $dig `$catprog $PKG_DBDIR/$PKGNAME/$f | $DIGESTPROG $dig`" >> $PKG_DBDIR/$PKGNAME/+VERIFY
			done
		fi
	done
	echo "filesEOF" >> $PKG_DBDIR/$PKGNAME/+VERIFY
	$chmodprog 0755 $PKG_DBDIR/$PKGNAME/+VERIFY

	# change absolute symlinks to relative ones
	case "$relsymlinks" in
	yes)	for f in `$awkprog '
			$1 == "prefix"	{ prefix = $2; next }
			$1 == "file"	{ printf("%s/%s\n", prefix, $0) }
			' < $PKG_DBDIR/$PKGNAME/+INVENTORY`; do
			if [ -h $f ]; then
				target="`ls -al $1 | awk '{ print $11 }'`"
				case "$target" in
				/*)	echo $prefix $target $f | /usr/bin/awk '
						{
							pc = split($1, pv, "/");
							tc = split($2, tv, "/");
							for (i = tc - pc + 2 ; i <= tc ; i++)
								linkname = linkname "../";
							for (i = pc + 1 ; i <= tc ; i++)
								linkname = linkname "/" tv[i];
							cmd = sprintf("'$rmprog' -f %s && '$lnprog' -s %s %s", $3, linkname, $3);
							exit(system(cmd));
						}'
					;;
				esac
			fi
		done
		;;
	esac

	;;

delete)
	deinstall=yes
	force=no
	doit=yes
	justdb=no
	prefix=""
	needs=no
	reqs=no
	while [ $# -gt 0 ]; do
		case "$1" in
		-D)	deinstall=no ;;
		-O)	justdb=yes ;;
		-R)	needs=yes ;;
		-f)	force=yes ;;
		-n)	doit=no ;;
		-p)	prefix=$2; shift ;;
		-r)	reqs=yes ;;
		esac
		shift
	done
	for pkg in $@; do
		d=`getpkg $pkg`
		hitme=yes
		if [ -f $d/+REQUIRED_BY ]; then
			hitme=no
			case "$force" in
			yes)	hitme=yes ;;
			esac
			case "$needs" in
			yes)	hitme=yes ;;
			esac
			case "$hitme" in
			no)	echo "pkg_delete: package $pkg is required by other packages:"
				$catprog $d/+REQUIRED_BY
				echo "pkg_delete: 1 package deletion failed"
				continue
				;;
			esac
		fi
		case "$hitme" in
		yes)	if [ -f $d/+VERIFY ]; then
				$d/+VERIFY
			fi
			;;
		esac
		case "$reqs" in
		yes)	;;
		esac
	done
	;;

info)
	allpackages=no
	buildinfo=no
	buildversion=no
	comment=no
	display=no
	descr=no
	exist=no
	filedb=no
	plist=no
	index=no
	install=no
	deinstall=no
	entries=no
	needs=no
	prefix=no
	reqby=no
	sizeall=no
	sizepkg=no
	version=no
	if [ $# -eq 0 ]; then
		set -- -I -a
	fi
	while [ $# -gt 0 ]; do
		case "$1" in
		-B)	buildinfo=yes ;;
		-D)	display=yes ;;
		-F)	filedb=yes ;;
		-I)	index=yes ;;
		-L)	entries=yes ;;
		-S)	sizeall=yes ;;
		-V)	version=yes ;;
		-a)	allpackages=yes ;;
		-b)	buildversion=yes ;;
		-c)	comment=yes ;;
		-d)	descr=yes ;;
		-e)	exist=yes ;;
		-f)	plist=yes ;;
		-i)	install=yes ;;
		-k)	deinstall=yes ;;
		-n)	needs=yes ;;
		-p)	prefix=yes ;;
		-r)	reqby=yes ;;
		-s)	sizepkg=yes ;;
		*)	break ;;
		esac
		shift
	done
	case "$version" in
	yes)	echo $version; exit 0 ;;
	esac
	case "$filedb" in
	yes)	echo "-F is unimplemented" ;;
	esac
	case "$exist" in
	yes)	echo "-e is unimplemented" ;;
	esac
	case "$allpackages" in
	yes)	pkglist="`(cd $PKG_DBDIR; ls -d *-*)`" ;;
	*)	pkglist="$@" ;;
	esac
	for pkg in $pkglist; do
		d=`getpkg $pkg`
		case "$buildinfo" in
		yes)	$catprog $d/+BUILD_INFO ;;
		esac
		case "$display" in
		yes)	if [ -f  $d/+DISPLAY ]; then
				$catprog $d/+DISPLAY
			fi ;;
		esac
		case "$index" in
		yes)	echo "`echo $d | $sedprog -e 's|.*/||'`	`$catprog $d/+COMMENT`" ;;
		esac
		case "$entries" in
		yes)	$awkprog '
				/^@cwd/ { prefix = $2 }
				/^@/	{ next }
					{ printf("%s/%s\n", prefix, $0) }
				' < $d/+CONTENTS ;;
		esac
		case "$buildversion" in
		yes)	$catprog $d/+BUILD_VERSION ;;
		esac
		case "$comment" in
		yes)	$catprog $d/+COMMENT ;;
		esac
		case "$descr" in
		yes)	$catprog $d/+DESC ;;
		esac
		case "$install" in
		yes)	if [ -f  $d/+INSTALL ]; then
				$catprog $d/+INSTALL
			fi ;;
		esac
		case "$deinstall" in
		yes)	if [ -f  $d/+DEINSTALL ]; then
				$catprog $d/+DEINSTALL
			fi ;;
		esac
		case "$needs" in
		yes)	$awkprog '/^@pkgdep/ { print $2 }' < $d/+CONTENTS ;;
		esac
		case "$prefix" in
		yes)	$awkprog '/^@cwd/ { print $2; exit }' < $d/+CONTENTS ;;
		esac
		case "$reqby" in
		yes)	if [ -f  $d/+REQUIRED_BY ]; then
				$catprog $d/+REQUIRED_BY
			fi ;;
		esac
		case "$sizeall" in
		yes)	$catprog $d/+SIZE_ALL
		esac
		case "$sizepkg" in
		yes)	$catprog $d/+SIZE_PKG
		esac
	done
	;;

show)	
	if [ $# -lt 1 ]; then
		echo "Usage: pkg show type packages" > /dev/stderr
		exit 1
	fi

	showtype=$1
	shift
	for pkg in $@; do
		d=`getpkg $pkg`
		case "$d" in
		"")	echo "No such package ($pkg)" ;;
		*)	
			case "$showtype" in
			allsizes)
				$catprog $d/+SIZE_ALL ;;
			blddep|blddeps)
				$awkprog '/^@blddep/ { print $2 }' $d/+CONTENTS ;;
			comment)
				$catprog $d/+COMMENT ;;
			description|desc|descr)
				$catprog $d/+DESC ;;
			deinstall)
				if [ -f  $d/+DEINSTALL ]; then
					$catprog $d/+DEINSTALL
				fi ;;
			display)
				if [ -f  $d/+DISPLAY ]; then
					$catprog $d/+DISPLAY
				fi ;;
			files)
				$awkprog '
				/^@cwd/ { prefix = $2 }
				/^@/	{ next }
					{ printf("%s/%s\n", prefix, $0) }
				' < $d/+CONTENTS ;;
			index)
				echo "`echo $d | $sedprog -e 's|.*/||'`	`$catprog $d/+COMMENT`" ;;
			info)
				$catprog $d/+BUILD_INFO ;;
			install)
				if [ -f  $d/+INSTALL ]; then
					$catprog $d/+INSTALL
				fi ;;
			prefix)
				$awkprog '/^@cwd/ { print $2 }' $d/+CONTENTS ;;
			prereqs|pkgdep)
				$awkprog '/^@pkgdep/ { print $2 }' $d/+CONTENTS ;;
			size)
				$catprog $d/+SIZE_PKG ;;
			version)
				$catprog $d/+BUILD_VERSION ;;
			*)
				echo "Unknown type \"$showtype\""
				exit 1 ;;
			esac
		esac
	done
	;;

version)
	echo $version
	exit 0
	;;

*)	echo "$0: \"$cmd\" not found"
	exit 1
	;;
esac

exit 0