File: alternatives.sh

package info (click to toggle)
gem 1%3A0.94-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,704 kB
  • sloc: cpp: 174,297; ansic: 42,132; makefile: 3,867; sh: 1,096; objc: 389
file content (99 lines) | stat: -rwxr-xr-x 1,673 bytes parent folder | download | duplicates (3)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh


list_alternatives() {
cat <<EOF
gem-plugin-glfw3	70 gemdefaultwindow.pd gemdefaultwindow-glfw3.pd
gem-plugin-sdl		70 gemdefaultwindow.pd gemdefaultwindow-sdl.pd
gem-plugin-glut		70 gemdefaultwindow.pd gemdefaultwindow-glut.pd
gem			50 gemdefaultwindow.pd gemdefaultwindow-glx.pd
EOF
}

build_alternatives () {
list_alternatives  | while read pkg prio name alt; do
  cat > debian/${pkg}.alternatives <<EOF
Name: ${name}
Link: /usr/lib/pd/extra/Gem/${name}
Alternative: /usr/lib/pd/extra/Gem/${alt}
Priority: ${prio}
EOF
done
}

#build_alternatives; exit $?

echo "NOTE: with dh>=13.1 there's a new dh_installalternatives" 1>&2
echo "see $0 for more info" 1>&2

INFILE=debian/alternatives
BASEDIR=/usr/lib/pd/extra/Gem
DOLLAR1='$1'

make_postinst() {
cat <<EOL
#! /bin/sh

set -e

#DEBHELPER#

EOL

 egrep "^$1[ 	]" "${INFILE}" | while read pkg priority dst src
 do
   echo "        update-alternatives --install ${BASEDIR}/${dst} ${dst} ${BASEDIR}/${src} ${priority}"
 done

cat <<EOL

exit 0
EOL
}

make_prerm() {
cat <<EOL
#!/bin/sh -e

set -e

#DEBHELPER#

case "$DOLLAR1" in
    (remove|deconfigure)
EOL

 egrep "^$1[ 	]" "${INFILE}" | while read pkg priority dst src
 do
   echo "        update-alternatives --remove ${dst} ${BASEDIR}/${src}"
 done

cat <<EOL
    ;;
    (upgrade)
    ;;

    (failed-upgrade)
    ;;

    (*)
        echo "prerm called with unknown argument \\\`$DOLLAR1'" >&2
        exit 0
    ;;
esac

exit 0
EOL
}


make_alternative() {
   make_postinst $1 > debian/$1.postinst
   make_prerm $1 > debian/$1.prerm
}


cat ${INFILE} | sed -e 's|#.*||' | grep . | awk '{print $1}' | sort -u | while read pkg
do
 make_alternative $pkg
done