2
# Caller should set -e.
10
die "Failed to parse $1 options"
14
die "Unimplemented $1 option $2"
18
die "Unimplemented $1 $2 argument $3"
21
# Allow handler files to register functions to be called at the end of
22
# processing; this lets them build up preseed answers over several handler
26
final_handlers="$final_handlers $1"
30
for handler in "$HANDLERS"/*; do
34
# Expects kickstart file on stdin.
40
# Deal with %include directives.
41
if [ "$keyword" = '%include' ]; then
45
elif [ "$keyword" = '%final' ]; then
46
die "%final reserved for internal use"
50
done; echo %final) | while read line; do
51
# Work out the section.
53
if [ -z "$keyword" ] || [ "${keyword#\#}" != "$keyword" ]; then
54
# Ignore empty lines and comments.
56
elif [ "$keyword" = '%packages' ]; then
59
elif [ "$keyword" = '%pre' ]; then
62
elif [ "$keyword" = '%post' ]; then
65
elif [ "$keyword" = '%final' ]; then
66
for handler in $final_handlers; do
72
if [ "$SECTION" = main ]; then
73
# Delegate to directive handlers.
74
if type "${keyword}_handler" >/dev/null 2>&1; then
76
"${keyword}_handler" ${line#* }
78
die "Unrecognised kickstart command: $keyword"
80
elif [ "$SECTION" = packages ] && [ "$keyword" = '@' ]; then
81
die "Package groups not implemented"
83
echo "$line" >> "$SPOOL/$SECTION.section"
87
if [ -s "$SPOOL/packages.section" ]; then
89
# TODO: doesn't allow removal of packages from ubuntu-base
91
packages="$(< "$SPOOL/packages.section")"
95
for pkg in $packages; do
96
if [ "${pkg#-}" != "$pkg" ]; then
97
negatives="$negatives ${pkg#-}"
99
positives="$positives $pkg"
103
# pattern gets: (pos|pos|pos)!neg!neg!neg
105
for pkg in $positives; do
106
if [ "$pkg" = . ]; then
109
joinpositives="${joinpositives:+$joinpositives|}$pkg"
111
pattern="($joinpositives)"
112
for pkg in $negatives; do
113
if [ "$pkg" = . ]; then
116
pattern="$pattern!$pkg"
118
# introduced in base-config 2.61ubuntu2; Debian would need
119
# tasksel preseeding instead
120
preseed base-config base-config/package-selection string \