summaryrefslogtreecommitdiff
path: root/make.sh
blob: 545e2c3aab39e3b4257ee618e9b2170203f6df40 (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
#!/bin/bash

LANGS="de es fr fi nl ru"
DIST_FILES="COPYING CREDITS FAQ HISTORY INSTALL README README.translators REQUIREMENTS contrib convert.pl install.sh lib locale make.sh template uninstall.sh vdradmind.pl vdradmind.pl.1"
INSTALL_SH=./install.sh
TMPDIR=/tmp

#TODO:
# - dist / distclean / clean

function Usage()
{
	echo "Usage: $0 cvs"
	echo "  cvs       - always use this after a \"cvs update \" or \"cvs checkout\""
	echo "  install   - install VDRAdmin-AM"
	echo "  uninstall - uninstall VDRAdmin-AM"
	echo "  po        - convert .po files to .mo files"
	echo "  dist      - create distribution archive"
	exit 1
}

function Error()
{
	[ "$1" ] && echo $*
	exit 1
}

function do_po()
{
	for L in $LANGS
	do
		[  -d locale/$L/LC_MESSAGES/ ] || mkdir -p locale/$L/LC_MESSAGES/
		msgfmt po/$L.po -o po/$L.mo
		install -m 644 po/$L.mo locale/$L/LC_MESSAGES/vdradmin.mo
	done
}

function do_cvs()
{
	# Create missing symbolic links
	[ -e uninstall.sh ] || ln -s install.sh uninstall.sh
	[ -e README ] || ln -s INSTALL README
}

function getVersion()
{
	grep "^my \$VERSION" vdradmind.pl | sed -e 's/^[^\"]*\"\([^\"]*\)\".*$/\1/'
}

function do_dist()
{
	local DIST_NAME=vdradmin-am-$(getVersion)
	mkdir -p $TMPDIR/$DIST_NAME
	cp -a $DIST_FILES $TMPDIR/$DIST_NAME
	mkdir -p $TMPDIR/$DIST_NAME/po
	cp -a po/*.po po/*.pot $TMPDIR/$DIST_NAME/po
	(
		cd $TMPDIR
		tar --exclude CVS -cjf $DIST_NAME.tar.bz2 $DIST_NAME
		rm -rf $TMPDIR/$DIST_NAME
	)
	mv $TMPDIR/$DIST_NAME.tar.bz2 .
}

[ "$1" ] || Usage
[ -x $INSTALL_SH ] || Error "$INSTALL_SH not found!"

while [ $1 ]
do
	case $1 in
		cvs)
			do_cvs
			;;

		install)
			$INSTALL_SH -c
			;;

		uninstall)
			$INSTALL_SH -u
			;;

		po)
			do_po
			;;

		dist)
			do_dist
			;;

		*)
			Error "Unknown command \"$1\""
			;;
	esac
	shift
done