2 # Cloned-and-hacked from preseed/debconf-set-selections for live-initramfs.
10 . /scripts/live-functions
13 # Returns the first field in the current line
15 echo "$line" | grep -q "[[:space:]]" || return 1
16 echo "$line" | sed -r 's/^([^[:space:]]*).*/\1/'
19 # Returns any fields after the first field in the current line
21 if echo "$line" | grep -q "[[:space:]]"; then
22 echo "$line" | sed 's/^[^[:space:]]*[[:space:]]*//'
27 if [ "$1" = --unseen ]; then
35 echo "Error parsing preconfiguration file: $*" >&2
41 # TODO: this squashes \r elsewhere in the line too
42 for line in $(grep -v '^#\|^[[:space:]]*$' "$file" | sed "s/$CR//g"); do
45 line="$(echo "$line" | sed 's/^[[:space:]]*//')"
46 if echo "$line" | grep -q '\\$'; then
47 multiline="${multiline:+$multiline }$(echo "$line" | \
48 sed 's/[[:space:]]*\\$//')"
50 elif [ -n "$multiline" ]; then
51 line="$multiline $line"
59 if ! package="$(first_field)"; then
60 parse_error "Syntax error: unable to determine template owner"
63 if ! var="$(first_field)"; then
64 parse_error "Syntax error: unable to determine template name"
67 if ! type="$(first_field)"; then
68 # Allow for lines without separator before an empty value
72 parse_error "Syntax error: unable to determine template type"
78 if [ "$type" = seen ]; then
80 db_fset "$var" "$type" "$val" || true # how to handle this error?
82 if ! db_set "$var" "$val"; then
83 # Question does not exist yet.
84 db_register debian-installer/dummy "$var"
86 db_subst "$var" ID "$var"
89 db_fset "$var" seen true