summaryrefslogtreecommitdiffstats
path: root/collect-potfiles
blob: e72786fc415ef08891613df1afe257da72522e74 (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
#!/bin/bash
#
#  Collect .pot files from a set of source packages and place them in
#  a specified output directory.
#

outdir=$1
shift

if [ -z "$outdir" ] ; then
	echo usage: `basename $0` output_directory sourcerpm '[...]'
	exit 1
fi

tmpdir=`mktemp -d ${TMPDIR:-/tmp}/collect-potfilesXXXXXX`
if [ -z "$tmpdir" ] ; then
	echo error creating tmpdir
	exit 1
fi

exec < /dev/null

cleanup()
{
	rm -fr $tmpdir
}
trap cleanup PIPE INT KILL TERM

for sourcepackage in $@ ; do
	rpm \
		--define "_topdir $tmpdir" \
		--define "_sourcedir $tmpdir" \
		--define "_specdir $tmpdir" \
		--define "_builddir $tmpdir" \
		--define "_srpmdir $tmpdir" \
		--define "_rpmdir $tmpdir" \
		-U $sourcepackage > /dev/null 2> /dev/null &&
	rpmbuild  \
		--define "_topdir $tmpdir" \
		--define "_sourcedir $tmpdir" \
		--define "_specdir $tmpdir" \
		--define "_builddir $tmpdir" \
		--define "_srpmdir $tmpdir" \
		--define "_rpmdir $tmpdir" \
		-bp $tmpdir/*.spec > /dev/null 2> /dev/null
	for potfile in `find $tmpdir -name "*.pot"`; do
		basename $potfile
		cp -f $potfile $outdir/
	done
	chmod -R u+rw $tmpdir/*
	rm -fr $tmpdir/*
done

cleanup