summaryrefslogtreecommitdiff
path: root/cp-po-back
blob: 146645b3ad61887ca8fe5efa79de65ba15479997 (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
#!/bin/sh

# Copies PO files from a PostgreSQL source tree to a PgFoundry repository
# structure.
#
# Usage: cp-po-back SOURCEDIR DESTDIR
#
# Written by Peter Eisentraut
# Public domain

set -e

me=$(basename $0)

srcdir=$1
if [ -z "$srcdir" ]; then
	echo "$me: no source directory specified" 1>&2
	exit 1
fi

destdir=$2
if [ -z "$destdir" ]; then
	echo "$me: no destination directory specified" 1>&2
	exit 1
fi

for srcfile in $(find "$srcdir" -name '*.po'); do
	base=$(echo X"$srcfile" | sed "s,^X$srcdir/*,,")
	lang=$(expr $base : '.*/\([^/]*\)\.po$')
	srccat=$(cat $(dirname $srcfile)/../nls.mk | sed -n 's/CATALOG_NAME.*:*= *\([^ ]*\)$/\1/p')

	targetfile=$destdir/$lang/$srccat.po
	used="$used $lang/$srccat.po "
	if ! [ -e $targetfile ] || ! diff $srcfile $targetfile >/dev/null; then
		[ -e $targetfile ] || new="$new $lang/$srccat.po"
		echo " cp $srcfile $targetfile"
		mkdir -p $(dirname $targetfile)
		cp $srcfile $targetfile
	fi
done

for file in $(find "$destdir" -name '*.po'); do
	base=$(echo X"$file" | sed "s,^X$destdir/*,,")
	if ! echo "$used" | fgrep -q " $base "; then
		delete="$delete $base"
	fi
done

if [ -n "$delete" ]; then
	echo "DELETE$delete"
fi

if [ -n "$new" ]; then
	echo "ADD$new"
fi