/[debconf]/trunk/src/debconf/confmodule
ViewVC logotype

Contents of /trunk/src/debconf/confmodule

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2212 - (show annotations) (download)
Sat Jun 30 17:22:18 2007 UTC (5 years, 10 months ago) by cjwatson
File size: 2577 byte(s)
* Add confmodule bindings for the DATA command.
1 #!/bin/sh
2 # This is a shell library to interface to the Debian configuration management
3 # system.
4
5 ###############################################################################
6 # Initialization.
7
8 # Check to see if a FrontEnd is running.
9 if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
10 PERL_DL_NONLAZY=1
11 export PERL_DL_NONLAZY
12 # Since there is no FrontEnd, this program execs a FrontEnd.
13 # It will then run a new copy of $0 that can talk to it.
14 if [ "$DEBCONF_USE_CDEBCONF" ]; then
15 exec /usr/lib/cdebconf/debconf $0 "$@"
16 else
17 exec /usr/share/debconf/frontend $0 "$@"
18 fi
19 fi
20
21 # Only do this once.
22 if [ -z "$DEBCONF_REDIR" ]; then
23 # Redirect standard output to standard error. This prevents common
24 # mistakes by making all the output of the postinst or whatever
25 # script is using this library not be parsed as confmodule commands.
26 #
27 # To actually send something to standard output, send it to fd 3.
28 exec 3>&1
29 if [ "$DEBCONF_USE_CDEBCONF" ]; then
30 exec 1>&5
31 else
32 exec 1>&2
33 fi
34 DEBCONF_REDIR=1
35 export DEBCONF_REDIR
36 fi
37
38 ###############################################################################
39 # Commands.
40
41 _db_cmd () {
42 IFS=' ' printf '%s\n' "$*" >&3
43 # Set to newline to get whole line.
44 IFS='
45 ' read -r _db_internal_line
46 # Disgusting, but it's the only good way to split the line,
47 # preserving all other whitespace.
48 RET="${_db_internal_line#[! ][ ]}"
49 case ${_db_internal_line%%[ ]*} in
50 1) # escaped data
51 RET="$(printf '%s' "$RET" | debconf-escape -u)"
52 return 0
53 ;;
54 esac
55 return ${_db_internal_line%%[ ]*}
56 }
57
58 db_capb () { _db_cmd "CAPB $@"; }
59 db_set () { _db_cmd "SET $@"; }
60 db_reset () { _db_cmd "RESET $@"; }
61 db_title () { _db_cmd "TITLE $@"; }
62 db_input () { _db_cmd "INPUT $@"; }
63 db_beginblock () { _db_cmd "BEGINBLOCK $@"; }
64 db_endblock () { _db_cmd "ENDBLOCK $@"; }
65 db_go () { _db_cmd "GO $@"; }
66 db_get () { _db_cmd "GET $@"; }
67 db_register () { _db_cmd "REGISTER $@"; }
68 db_unregister () { _db_cmd "UNREGISTER $@"; }
69 db_subst () { _db_cmd "SUBST $@"; }
70 db_fset () { _db_cmd "FSET $@"; }
71 db_fget () { _db_cmd "FGET $@"; }
72 db_purge () { _db_cmd "PURGE $@"; }
73 db_metaget () { _db_cmd "METAGET $@"; }
74 db_version () { _db_cmd "VERSION $@"; }
75 db_clear () { _db_cmd "CLEAR $@"; }
76 db_settitle () { _db_cmd "SETTITLE $@"; }
77 db_previous_module () { _db_cmd "PREVIOUS_MODULE $@"; }
78 db_info () { _db_cmd "INFO $@"; }
79 db_progress () { _db_cmd "PROGRESS $@"; }
80 db_data () { _db_cmd "DATA $@"; }
81
82 # An old alias for input.
83 db_text () {
84 db_input $@
85 }
86
87 # Cannot read a return code, since there is none and it would block.
88 db_stop () {
89 echo STOP >&3
90 }

  ViewVC Help
Powered by ViewVC 1.1.5