2
by Colin Watson
Make post-base-installer.d/10preseed executable again. |
1 |
#!/bin/sh
|
2 |
set -e
|
|
3 |
||
6.1.2
by Otavio Salvador, Philip Hands, Frans Pop
[ Philip Hands ] |
4 |
OLDIFS="$IFS" |
5 |
CR=$(echo -en "\r") |
|
6 |
NL=" |
|
7 |
"
|
|
8 |
||
2
by Colin Watson
Make post-base-installer.d/10preseed executable again. |
9 |
export DEBIAN_FRONTEND=none |
10 |
. /usr/share/debconf/confmodule |
|
5.1.6
by Joey Hess, Colin Watson, Joey Hess, Updated translations
[ Colin Watson ] |
11 |
. /lib/preseed/preseed.sh |
2
by Colin Watson
Make post-base-installer.d/10preseed executable again. |
12 |
|
13 |
SEEN=1 |
|
14 |
if [ "$1" = --unseen ]; then |
|
15 |
SEEN= |
|
16 |
shift
|
|
17 |
fi
|
|
18 |
||
19 |
file="$1" |
|
20 |
||
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
21 |
parse_error() { |
22 |
echo "$1" >> $logfile |
|
23 |
log "Error parsing preconfiguration file; see '$logfile' for details" |
|
24 |
exit 1 |
|
25 |
}
|
|
26 |
||
27 |
# Returns the first field in the current line
|
|
28 |
first_field() { |
|
29 |
echo "$line" | grep -q "[[:space:]]" || return 1 |
|
30 |
echo "$line" | sed -r 's/^([^[:space:]]*).*/\1/' |
|
31 |
}
|
|
32 |
# Returns any fields after the first field in the current line
|
|
33 |
rest_line() { |
|
34 |
if echo "$line" | grep -q "[[:space:]]"; then |
|
35 |
echo "$line" | sed 's/^[^[:space:]]*[[:space:]]*//' |
|
36 |
fi
|
|
37 |
}
|
|
38 |
||
6.1.2
by Otavio Salvador, Philip Hands, Frans Pop
[ Philip Hands ] |
39 |
IFS="$NL" |
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
40 |
multiline="" |
3
by Colin Watson
Resynchronise with Debian. |
41 |
# TODO: this squashes \r elsewhere in the line too
|
13
by Colin Watson
* Ignore whitespace-only lines in preseed files (LP: #245256). |
42 |
for line in $(grep -v '^#\|^[[:space:]]*$' "$file" | sed "s/$CR//g"); do |
2
by Colin Watson
Make post-base-installer.d/10preseed executable again. |
43 |
IFS="$OLDIFS" |
3
by Colin Watson
Resynchronise with Debian. |
44 |
|
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
45 |
line="$(echo "$line" | sed 's/^[[:space:]]*//')" |
46 |
if echo "$line" | grep -q '\\$'; then |
|
47 |
multiline="${multiline:+$multiline }$(echo "$line" | \ |
|
48 |
sed 's/[[:space:]]*\\$//')" |
|
3
by Colin Watson
Resynchronise with Debian. |
49 |
continue
|
50 |
elif [ -n "$multiline" ]; then |
|
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
51 |
line="$multiline $line" |
3
by Colin Watson
Resynchronise with Debian. |
52 |
multiline="" |
53 |
fi
|
|
54 |
||
5.1.6
by Joey Hess, Colin Watson, Joey Hess, Updated translations
[ Colin Watson ] |
55 |
echo "$line" >> $logfile |
56 |
||
11
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
57 |
package="" |
58 |
var="" |
|
59 |
type="" |
|
60 |
val="" |
|
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
61 |
if ! package="$(first_field)"; then |
62 |
parse_error "Syntax error: unable to determine template owner"
|
|
63 |
fi
|
|
64 |
line="$(rest_line)" |
|
65 |
if ! var="$(first_field)"; then |
|
66 |
parse_error "Syntax error: unable to determine template name"
|
|
67 |
fi
|
|
68 |
line="$(rest_line)" |
|
69 |
if ! type="$(first_field)"; then |
|
70 |
# Allow for lines without separator before an empty value
|
|
71 |
if [ "$line" ]; then |
|
72 |
type="$line" |
|
73 |
else
|
|
74 |
parse_error "Syntax error: unable to determine template type"
|
|
11
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
75 |
fi
|
6.1.1
by Frans Pop
* Improvements to debconf-set-selections. |
76 |
fi
|
77 |
line="$(rest_line)" |
|
78 |
val="$line" |
|
11
by Colin Watson
* Resynchronise with Debian. Remaining changes: |
79 |
|
2
by Colin Watson
Make post-base-installer.d/10preseed executable again. |
80 |
if [ "$type" = seen ]; then |
81 |
# Set seen flag.
|
|
82 |
db_fset "$var" "$type" "$val" || true # how to handle this error? |
|
83 |
else
|
|
84 |
if ! db_set "$var" "$val"; then |
|
85 |
# Question does not exist yet.
|
|
86 |
db_register debian-installer/dummy "$var" |
|
87 |
db_set "$var" "$val" |
|
88 |
db_subst "$var" ID "$var" |
|
89 |
fi
|
|
90 |
if [ "$SEEN" ]; then |
|
91 |
db_fset "$var" seen true |
|
92 |
fi
|
|
93 |
fi
|
|
94 |
done
|