File: confmodule.in

package info (click to toggle)
cdebconf 0.227
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,552 kB
  • sloc: ansic: 16,568; sh: 549; makefile: 456; sql: 52; perl: 13
file content (59 lines) | stat: -rw-r--r-- 1,796 bytes parent folder | download | duplicates (8)
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
#!/bin/sh
# This is a shell library to interface to the Debian configuration management
# system.

###############################################################################
# Initialization.

# Check to see if a FrontEnd is running.
if [ ! "$DEBIAN_HAS_FRONTEND" ]; then
	# Since there is no FrontEnd, this program execs a FrontEnd.
	# It will then run a new copy of $0 that can talk to it.
	exec /usr/share/debconf/frontend -- $0 "$@"
fi

# Only do this once.
if [ -z "$DEBCONF_REDIR" ]; then
	# Redirect standard output to standard error. This prevents common
	# mistakes by making all the output of the postinst or whatever
	# script is using this library not be parsed as confmodule commands.
	#
	# To actually send something to standard output, send it to fd 3.
	exec 3>&1 1>&5
	DEBCONF_REDIR=1
	export DEBCONF_REDIR
fi

# The original stdin/stdout/stderr fds are duplicated onto fds
# DEBCONF_OLD_FD_BASE to DEBCONF_OLD_FD_BASE + 2. These values are exported
# so that you can get the original fds back. This is kind of a hack:
# ideally, we might use something like a socket for the debconf protocol
# instead of stdio.
DEBCONF_OLD_FD_BASE='@DEBCONF_OLD_FD_BASE@'
export DEBCONF_OLD_FD_BASE

###############################################################################
# Commands.

_db_cmd () {
	IFS=' ' printf '%s\n' "$*" >&3
	# Set to newline to get whole line.
	IFS='
' read -r _db_internal_line
	# Disgusting, but it's the only good way to split the line,
	# preserving all other whitespace.
	RET="${_db_internal_line#[! 	][ 	]}"
	return ${_db_internal_line%%[ 	]*}
}

REPEAT: db_@command@ ()	{ _db_cmd "@COMMAND@ $@"; }

# An old alias for input.
db_text () {
	db_input $@
}

# Cannot read a return code, since there is none and it would block.
db_stop () {
	echo STOP >&3
}