File: alias-link.sh

package info (click to toggle)
squid-langpack 20100628-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,844 kB
  • sloc: sh: 45; makefile: 26
file content (43 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download | duplicates (10)
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
#!/bin/sh
#
# Generate Symlinks for a set of aliases.
# Our base content is the bundled .po translation output
#
# This file creates the authoritative ISO aliases.
#

LN="${1}"
RM="${2}"
DIR="${3}"
ALIASFILE="${4}"

if ! test -f ${ALIASFILE} ; then
	echo "FATAL: Alias file ${ALIASFILE} does not exist!"
	exit 1
fi

if ! test -d ${DIR} ; then
	echo "WARNING: Destination directory does not exist. Nothing to do."
	exit 0
fi

# Parse the alias file
cat ${ALIASFILE} |
while read base aliases; do
	# file may be commented or have empty lines
	if test "${base}" = "#" || test "${base}" = ""; then
		continue;
	fi
	# ignore destination languages that do not exist. (no dead links)
	if ! test -x ${DIR}/${base} ; then
		echo "WARNING: ${base} translations do not exist. Nothing to do for: ${aliases}"
		continue;
	fi

	# split aliases based on whitespace and create a symlink for each
	# Remove and replace any pre-existing content/link
	for alia in ${aliases}; do
		${RM} -f -r ${DIR}/${alia} || exit 1
		${LN} -s ${base} ${DIR}/${alia} || exit 1
	done
done