]> git.ipfire.org Git - thirdparty/squid.git/blob - errors/alias-link.sh
SourceFormat Enforcement
[thirdparty/squid.git] / errors / alias-link.sh
1 #!/bin/sh
2 #
3 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 ##
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
8 ##
9
10 #
11 # Generate Symlinks for a set of aliases.
12 # Our base content is the bundled .po translation output
13 #
14 # This file creates the authoritative ISO aliases.
15 #
16
17 LN="${1}"
18 RM="${2}"
19 DIR="${3}"
20 ALIASFILE="${4}"
21
22 if ! test -f ${ALIASFILE} ; then
23 echo "FATAL: Alias file ${ALIASFILE} does not exist!"
24 exit 1
25 fi
26
27 if ! test -d ${DIR} ; then
28 echo "WARNING: Destination directory does not exist. Nothing to do."
29 exit 0
30 fi
31
32 # Parse the alias file
33 cat ${ALIASFILE} |
34 while read base aliases; do
35 # file may be commented or have empty lines
36 if test "${base}" = "#" || test "${base}" = ""; then
37 continue;
38 fi
39 # ignore destination languages that do not exist. (no dead links)
40 if ! test -x ${DIR}/${base} ; then
41 echo "WARNING: ${base} translations do not exist. Nothing to do for: ${aliases}"
42 continue;
43 fi
44
45 # split aliases based on whitespace and create a symlink for each
46 # Remove and replace any pre-existing content/link
47 for alia in ${aliases}; do
48 ${RM} -f -r ${DIR}/${alia} || exit 1
49 ${LN} -s ${base} ${DIR}/${alia} || exit 1
50 done
51 done