summaryrefslogtreecommitdiff
path: root/checkfiles
diff options
context:
space:
mode:
Diffstat (limited to 'checkfiles')
-rwxr-xr-xcheckfiles95
1 files changed, 56 insertions, 39 deletions
diff --git a/checkfiles b/checkfiles
index c3d325b..6336fda 100755
--- a/checkfiles
+++ b/checkfiles
@@ -1,56 +1,72 @@
#!/bin/sh
# run from the prerm and postinst
-set -e
+set -ex
-install=$1
+script=$1
+mode=$2
-check_file () {
- dckey=$1; regexp=$2; file=$3
-
- if ! test -f $file; then return; fi
-
- if $install; then
- if test -e $file.not-trad; then return; fi
- before=misc
- after=trad
- newfile=$file.trad
- oldfile=$file.not-trad
- else
- if ! test -e $file.not-trad; then return; fi
- before=trad
- after=misc
- newfile=$file.undo-trad
- oldfile=$file.trad
- fi
+. /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/
- ' <$file >$file
- if cmp -s $file $newfile; then
- rm $newfile
+ ' <$infile >$outfile.tmp
+ if cmp -s $outfile.tmp $outfile; then
+ rm $outfile.tmp
return
fi
-
- db_get $dckey
- if [ $RET != true ]; then return; fi
-
- if $install; then
- db_get $dckey-done || true
- if [ $RET = true ]; then return; fi
-
- echo "Updating $file to use traditional fixed..."
- else
- echo "Restoring $file with nontraditional fixed..."
- fi
- rm -f $oldfile
- ln $file $oldfile
- mv -f $newfile $file
+ 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
- db_set $dckey-done $install
+ 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
}
@@ -62,3 +78,4 @@ check_file reconfigure-xterm '\*VT100\.utf8Fonts\.font\:' \
check_file remap-fixed 'fixed' \
/etc/X11/fonts/misc/xfonts-base.alias
+true