summaryrefslogtreecommitdiff
path: root/print/dvipdfmx/files/map.tmpl
blob: ca9cad657ce87cb8edd056b7a719046014dbb794 (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
# $NetBSD: map.tmpl,v 1.2 2005/11/20 18:51:54 minskim Exp $
#
# Update dvipdfmx.cfg.
#

###############################################################################
# replace_line(file, pattern, line)
#   The first line in file that matches pattern gets replaced by line.
#   line will be added at the end of the file if pattern does not match.
###############################################################################
replace_line()
{
  file=$1; pat=$2; line=$3

  if grep "$pat" "$file" >/dev/null; then
    ed "$file" >/dev/null 2>&1 <<-eof
	/$pat/
	c
	$line
	.
	w
	q
eof
  else
    echo "$line" >> "$file"
  fi
}

case ${STAGE} in
POST-INSTALL)
	if ${TEST} ! -f @DVIPDFMX_CONFIG_DIR@/dvipdfmx.cfg; then
		@CP@ @DVIPDFMX_CONFIG_DIR@/dvipdfmx-base.cfg \
		     @DVIPDFMX_CONFIG_DIR@/dvipdfmx.cfg
	fi
	for map in @DVIPDFMX_FONTMAPS@; do
		replace_line "@DVIPDFMX_CONFIG_DIR@/dvipdfmx.cfg" \
			"^%![ 	]*$map" "f $map"
	done
	;;
DEINSTALL)
	for map in @DVIPDFMX_FONTMAPS@; do
		replace_line "@DVIPDFMX_CONFIG_DIR@/dvipdfmx.cfg" \
			"^f[ 	]*$map" "%! f $map"
	done
	;;
*)
	;;
esac