File: vim-variant.postinst

package info (click to toggle)
vim 1%3A7.0-122%2B1etch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 9,992 kB
  • ctags: 55
  • sloc: makefile: 444; sh: 224; perl: 97; python: 25
file content (84 lines) | stat: -rw-r--r-- 2,311 bytes parent folder | download | duplicates (2)
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
82
83
84
#!/bin/bash -e

pkg=@PKG@
variant=@VARIANT@
mandir=/usr/share/man

# two things to do:
# 1) add /usr/bin/vim.variant as alternative for /usr/bin/vim. Priority are
#    chosen accordingly to the principle: ``more features, higher priority''
# 2) add /usr/bin/gvim as an alternative for gnome-text-editor for variants
#    built with gnome support. Same principle for the priority above, with the
#    additional constraint that priority should not be higher than gedit's

add_gnome_alternative () {
  if [ -f /usr/bin/gvim ]; then
    update-alternatives --install /usr/bin/gnome-text-editor \
      gnome-text-editor /usr/bin/vim.$variant $1
  fi
}

add_variant_alternative () {
  update-alternatives --install /usr/bin/vim vim /usr/bin/vim.$variant $1
  update-alternatives --install /usr/bin/vimdiff vimdiff /usr/bin/vim.$variant $1
  update-alternatives --install /usr/bin/rvim rvim /usr/bin/vim.$variant $1
  update-alternatives --install /usr/bin/rview rview /usr/bin/vim.$variant $1
  # Since other packages provide these commands, we'll setup alternatives for
  # their manpages, too.
  for i in vi view ex editor ; do
    update-alternatives \
      --install /usr/bin/$i $i /usr/bin/vim.$variant $1 \
      @LANG_ALTS@
      --slave $mandir/man1/$i.1.gz $i.1.gz \
              $mandir/man1/vim.1.gz
  done
  case "$variant" in
    gtk|lesstif|perl|python|ruby|tcl|gnome|full) # gui enabled variants
      add_gui_variant_alternative $1
      ;;
  esac
}

add_gui_variant_alternative () {
  for i in gvim gview rgview rgvim evim eview gvimdiff ; do
    update-alternatives --install /usr/bin/$i $i /usr/bin/vim.$variant $1
  done
}

replace_dir_w_symlink () {
  if [ -d $1 -a ! -L $1 ]; then
    (rmdir $1 && ln -fs $2 $1) || true
  fi
}

case "$1" in
  configure)
    case "$pkg" in
      vim-tiny)
	add_variant_alternative 10
	;;
      vim)
	add_variant_alternative 30
	replace_dir_w_symlink /usr/share/doc/vim vim-common
	;;
      vim-gtk|vim-lesstif)
	add_variant_alternative 40
	;;
      vim-gnome) # gnome enabled variant
	add_variant_alternative 40
	add_gnome_alternative 40
	;;
      vim-perl|vim-python|vim-ruby|vim-tcl)
	add_variant_alternative 50
	;;
      vim-full) # gnome enabled variant
	add_variant_alternative 60
	add_gnome_alternative 45
	;;
    esac
    ;;
esac

#DEBHELPER#

exit 0