File: checkfiles

package info (click to toggle)
xfonts-traditional 1.8.0
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 1,100 kB
  • ctags: 24
  • sloc: perl: 577; sh: 251; makefile: 32
file content (81 lines) | stat: -rwxr-xr-x 1,570 bytes parent folder | download | duplicates (4)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
# run from the prerm and postinst
set -e

script=$1
mode=$2

. /usr/share/debconf/confmodule

gen_file_overwrite () {
	before=$1; after=$2; infile=$3; outfile=$4; backupmode=$5; backup=$6
	perl -pe '
 s/^('"$regexp"'\s+)\-'$before'\-(fixed-medium-r-semicondensed)/$1-'$after'-$2/
		' <$infile >$outfile.tmp
	if cmp -s $outfile.tmp $outfile; then
		rm $outfile.tmp
		return
	fi
	echo " Updating $file ($before=>$after)..."
	case $backupmode in
	once)
		if ! test -e $backup; then
			ln $outfile $backup
		fi
		;;
	never)
		;;
	esac
	mv -f $outfile.tmp $outfile

	case "$file" in
	*.alias) update-fonts-alias misc ;;
	esac
}

check_file () {
	dckey=$1; regexp=$2; file=$3

	if ! test -f $file; then return; fi

	needundo=true

	case "$script.$mode" in
	postinst.*)
		db_get xfonts-traditional/$dckey ||:
		if [ $RET = true ]; then
			gen_file_overwrite misc trad \
				$file $file once $file.backup.not-trad
			needundo=false
		else
			gen_file_overwrite misc trad \
				$file $file.trad never
		fi
		;;
	prerm.upgrade*)
		needundo=false
		;;
	prerm.remove*)
		;;
	*)
		echo >&2 "huh $script.mode ?"
		exit 1
		;;
	esac
	if $needundo && test -f $file.backup.not-trad; then
		gen_file_overwrite trad misc \
			$file $file $file.backup.trad
		mv -f $file.backup.not-trad $file.old.not-trad
	fi
	# only ever do this once, unless we've actually undone it since
}

echo "Checking configuration..."

check_file reconfigure-xterm '\*VT100\.utf8Fonts\.font\:' \
	/etc/X11/app-defaults/XTerm

check_file remap-fixed 'fixed' \
	/etc/X11/fonts/misc/xfonts-base.alias

true