1
by joey
move from cvs import |
1 |
#!/bin/sh
|
2 |
# This is a shell library to interface to the Debian configration management
|
|
3 |
# system.
|
|
4 |
#
|
|
5 |
# This library is obsolete. Do not use.
|
|
6 |
||
7 |
###############################################################################
|
|
8 |
# Initialization.
|
|
9 |
||
10 |
# Check to see if a FrontEnd is running.
|
|
11 |
if [ ! "$DEBIAN_HAS_FRONTEND" ]; then |
|
125
by joeyh
* Joey Hess |
12 |
PERL_DL_NONLAZY=1 |
13 |
export PERL_DL_NONLAZY
|
|
1
by joey
move from cvs import |
14 |
# Ok, this is pretty crazy. Since there is no FrontEnd, this
|
15 |
# program execs a FrontEnd. It will then run a new copy of $0 that
|
|
16 |
# can talk to it.
|
|
17 |
exec /usr/share/debconf/frontend $0 $* |
|
18 |
fi
|
|
19 |
||
20 |
# Only do this once.
|
|
21 |
if [ -z "$DEBCONF_REDIR" ]; then |
|
22 |
# Redirect standard output to standard error. This prevents common
|
|
23 |
# mistakes by making all the output of the postinst or whatever
|
|
24 |
# script is using this library not be parsed as confmodule commands.
|
|
25 |
#
|
|
26 |
# To actually send something to standard output, send it to fd 3.
|
|
27 |
exec 3>&1 1>&2 |
|
28 |
DEBCONF_REDIR=1 |
|
29 |
export DEBCONF_REDIR
|
|
30 |
fi
|
|
31 |
||
32 |
# For internal use, send text to the frontend.
|
|
33 |
_command () { |
|
34 |
echo $* >&3 |
|
35 |
}
|
|
36 |
||
37 |
echo "WARNING: Using deprecated debconf compatibility library." |
|
38 |
||
39 |
###############################################################################
|
|
40 |
# Commands.
|
|
41 |
||
42 |
# Generate subroutines for all commands that don't have special handlers.
|
|
43 |
# Each command must be listed twice, once in lower case, once in upper.
|
|
44 |
# Doing that saves us a lot of calls to tr at load time. I just wish shell had
|
|
45 |
# an upper-case function.
|
|
46 |
old_opts="$@" |
|
47 |
for i in "capb CAPB" "set SET" "reset RESET" "title TITLE" \ |
|
48 |
"input INPUT" "beginblock BEGINBLOCK" "endblock ENDBLOCK" "go GO" \ |
|
49 |
"get GET" "register REGISTER" "unregister UNREGISTER" "subst SUBST" \ |
|
75
by joey
* Change the shell confmodule to not construct functions on the fly. |
50 |
"fset FSET" "fget FGET" "visible VISIBLE" "purge PURGE" \ |
614
by joeyh
another typo fix |
51 |
"metaget METAGET" "exist EXIST" \ |
611
by cjwatson
typo |
52 |
"x_loadtemplatefile X_LOADTEMPLATEFILE"; do |
1
by joey
move from cvs import |
53 |
# Break string up into words.
|
54 |
set -- $i |
|
55 |
eval "db_$1 () { |
|
56 |
_command \"$2 \$@\" |
|
57 |
read _RET
|
|
58 |
old_opts="\$@" |
|
59 |
set -- \$_RET
|
|
60 |
shift
|
|
61 |
RET="\$*" |
|
62 |
set -- \$old_opts
|
|
63 |
unset old_opts
|
|
64 |
}"
|
|
65 |
done
|
|
66 |
# $@ was clobbered above, unclobber.
|
|
67 |
set -- $old_opts |
|
68 |
unset old_opts
|
|
69 |
||
70 |
# By default, 1.0 protocol version is sent to the frontend. You can
|
|
71 |
# pass in a different version to override this.
|
|
72 |
db_version () { |
|
73 |
if [ "$1" ]; then |
|
74 |
_command "VERSION $1" |
|
75 |
else
|
|
76 |
_command "VERSION 1.0"
|
|
77 |
fi
|
|
78 |
# Not quite correct, but not worth fixing in obsolete code.
|
|
79 |
read -r RET
|
|
80 |
}
|
|
81 |
||
82 |
# Here for backwards compatibility.
|
|
83 |
db_go () { |
|
84 |
_command "GO"
|
|
85 |
read -r RET
|
|
86 |
if [ "$RET" = 30 ]; then |
|
87 |
RET='back' |
|
88 |
fi
|
|
89 |
}
|
|
90 |
||
91 |
# Just an alias for input. It tends to make more sense to use this to display
|
|
92 |
# text, since displaying text isn't really asking for input.
|
|
93 |
db_text () { |
|
94 |
db_input $@
|
|
95 |
}
|
|
96 |
||
97 |
# Cannot read a return code, since there is none and we would block.
|
|
98 |
db_stop () { |
|
99 |
echo STOP >&3 |
|
100 |
}
|