summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf.d/0003-debconf
blob: 92d9f0e0e85792c9d047c49c6ee1e11763c60893 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
#!/bin/sh

# container-tools - Manage systemd-nspawn containers
# Copyright (C) 2014-2016 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -e

DEBCONF_NOWARNINGS="true"
export DEBCONF_NOWARNINGS

. /usr/share/debconf/confmodule

Distribution ()
{
	db_get cnt-debconf/distribution
	DISTRIBUTION="${RET}" # select

	if [ -z "${DISTRIBUTION}" ]
	then
		case "${MODE}" in
			debian)
				db_subst cnt-debconf/distribution CHOICES "Debian GNU/Linux 8 \"jessie\", Debian GNU/Linux 9 \"stretch\", Debian GNU/Linux unstable/sid"
				db_subst cnt-debconf/distribution CHOICES_C "jessie, stretch, sid"

				db_set cnt-debconf/distribution jessie
				db_fset cnt-debconf/distribution seen false
				;;

			progress-linux)
				db_subst cnt-debconf/distribution CHOICES "Progress Linux 3 (cairon), Progress Linux 3+ (cairon-backports)"
				db_subst cnt-debconf/distribution CHOICES_C "cairon, cairon-backports"

				db_set cnt-debconf/distribution cairon-backports
				db_fset cnt-debconf/distribution seen false
				;;
		esac

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/distribution || true
		db_go

		db_get cnt-debconf/distribution
		DISTRIBUTION="${RET}" # select
	fi

	echo "DISTRIBUTION=\"${DISTRIBUTION}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export DISTRIBUTION
}

Parent_distribution ()
{
	db_get cnt-debconf/parent-distribution
	PARENT_DISTRIBUTION="${RET}"

	if [ -z "${PARENT_DISTRIBUTION}" ]
	then
		case "${MODE}" in
			progress-linux)
				case "${DISTRIBUTION}" in
					cairon*)
						PARENT_DISTRIBUTION="jessie"
						;;
				esac
				;;

			*)
				PARENT_DISTRIBUTION="${DISTRIBUTION}"
				;;
		esac
	fi

	echo "PARENT_DISTRIBUTION=\"${PARENT_DISTRIBUTION}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PARENT_DISTRIBUTION
}

Architecture ()
{
	case "$(dpkg --print-architecture)" in
		amd64)
			DEFAULT="amd64"
			CHOICES="Automatic, 32-bit PC (i386), 64-bit PC (amd64)"
			CHOICES_C="auto, i386, amd64"
			;;

		arm64)
			DEFAULT="arm64"
			CHOICES="Automatic, Rpi1 (armel), Rpi2 (armhf), Rpi3 (arm64)"
			CHOICES_C="auto, armel, armhf, arm64"
			;;

		armel)
			DEFAULT="armel"
			CHOICES="Automatic, Rpi1 (armel)"
			CHOICES_C="auto, armel"
			;;

		armhf)
			DEFAULT="armhf"
			CHOICES="Automatic, Rpi1 (armel), Rpi2 (armhf)"
			CHOICES_C="auto, armel, armhf"
			;;

		i386)
			case "$(uname -m)" in
				x86_64)
					DEFAULT="amd64"
					CHOICES="Automatic, 32-bit PC (i386), 64-bit PC (amd64)"
					CHOICES_C="auto, i386, amd64"
					;;

				*)
					DEFAULT="i386"
					CHOICES=""
					CHOICES_C=""
					;;
			esac
			;;

		*)
			echo "E: Architecture current not yet supported."
			exit 1
	esac

	db_get cnt-debconf/architecture
	ARCHITECTURE="${RET}" # select

	if [ -z "${ARCHITECTURE}" ] && [ -n "${CHOICES}" ]
	then
		db_subst cnt-debconf/architecture CHOICES ${CHOICES}
		db_subst cnt-debconf/architecture CHOICES_C ${CHOICES_C}

		db_set cnt-debconf/architecture ${DEFAULT}
		db_fset cnt-debconf/distribution seen false

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/architecture || true
		db_go

		db_get cnt-debconf/architecture
		ARCHITECTURE="${RET}" # select
	fi

	case "${ARCHITECTURE}" in
		auto)
			ARCHITECTURE="${DEFAULT}"
			;;
	esac

	echo "ARCHITECTURE=\"${ARCHITECTURE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export ARCHITECTURE
}

Archives ()
{
	db_get cnt-debconf/archives
	ARCHIVES="${RET}" # multiselect

	if [ -z "${ARCHIVES}" ]
	then
		case "${MODE}" in
			debian)
				case "${PARENT_DISTRIBUTION}" in
					sid)
						db_subst cnt-debconf/archives CHOICES "Experimental"
						db_subst cnt-debconf/archives CHOICES_C "experimental"

						db_set cnt-debconf/archives ""
						db_fset cnt-debconf/archives seen false
						;;

					*)
						db_subst cnt-debconf/archives CHOICES "Security, Updates, LTS, Backports, Proposed Updates"
						db_subst cnt-debconf/archives CHOICES_C "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-lts, ${DISTRIBUTION}-backports, ${DISTRIBUTION}-proposed-updates"

						case "${PARENT_DISTRIBUTION}" in
							sid)
								db_set cnt-debconf/archives ""
								;;

							*)
								#db_set cnt-debconf/archives "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-lts, ${DISTRIBUTION}-backports"
								db_set cnt-debconf/archives "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates"
								;;
						esac

						db_fset cnt-debconf/archives seen false
						;;
				esac
				;;

			progress-linux)
				DIST="$(echo ${DISTRIBUTION} | sed -e 's|-backports||')"

				db_subst cnt-debconf/archives CHOICES "staging, Security, Security (staging), Updates, Updates (staging), LTS, LTS (staging), Extras, Extras (staging), Backports, Backports (staging), Backports Extras, Backports Extras (staging)"
				db_subst cnt-debconf/archives CHOICES_C "${DIST}-staging, ${DIST}-security, ${DIST}-security-staging, ${DIST}-updates, ${DIST}-updates-staging, ${DIST}-lts, ${DIST}-lts-staging, ${DIST}-extras, ${DIST}-extras-staging, ${DIST}-backports, ${DIST}-backports-staging, ${DIST}-backports-extras, ${DIST}-backports-extras-staging"

				db_set cnt-debconf/archives "${DIST}-security, ${DIST}-updates, ${DIST}-lts, ${DIST}-extras, ${DIST}-backports, ${DIST}-backports-extras"
				db_fset cnt-debconf/archives seen false
				;;
		esac

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/archives || true
		db_go

		db_get cnt-debconf/archives
		ARCHIVES="${RET}" # multiselect
	fi

	ARCHIVES="$(echo ${ARCHIVES} | sed -e 's|, | |g')"

	echo "ARCHIVES=\"${ARCHIVES}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export ARCHIVES
}

Parent_archives ()
{
	db_get cnt-debconf/parent-archives
	PARENT_ARCHIVES="${RET}" # multiselect (w/o empty)

	if [ -z "${PARENT_ARCHIVES}" ]
	then
		case "${MODE}" in
			progress-linux)
				db_subst cnt-debconf/parent-archives CHOICES "Security, Updates, LTS, Backports, Proposed Updates"
				db_subst cnt-debconf/parent-archives CHOICES_C "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-lts, ${PARENT_DISTRIBUTION}-backports, ${PARENT_DISTRIBUTION}-proposed-updates"

				case "${PARENT_DISTRIBUTION}" in
					*)
						#db_set cnt-debconf/parent-archives "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-lts, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-backports"
						db_set cnt-debconf/parent-archives "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
						;;
				esac

				db_fset cnt-debconf/parent-archives seen false

				db_settitle cnt-debconf/title
				db_input high cnt-debconf/parent-archives || true
				db_go
				;;

			*)
				db_subst cnt-debconf/parent-archives CHOICES "Security, Updates, LTS, Backports, Proposed Updates"
				db_subst cnt-debconf/parent-archives CHOICES_C "${ARCHIVES}"

				db_set cnt-debconf/parent-archives "${ARCHIVES}"
				db_fset cnt-debconf/parent-archives seen true
				;;
		esac

		db_get cnt-debconf/parent-archives
		PARENT_ARCHIVES="${RET}" # multiselect (w/o empty)

		if [ -z "${PARENT_ARCHIVES}" ]
		then
			case "${MODE}" in
				progress-linux)
					case "${PARENT_DISTRIBUTION}" in
						*)
							#PARENT_ARCHIVES="${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-lts, ${PARENT_DISTRIBUTION}-backports"
							PARENT_ARCHIVES="${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
							;;
					esac
					;;

				*)
					PARENT_ARCHIVES="${ARCHIVES}"
					;;
			esac
		fi
	fi

	PARENT_ARCHIVES="$(echo ${PARENT_ARCHIVES} | sed -e 's|, | |g')"

	echo "PARENT_ARCHIVES=\"${PARENT_ARCHIVES}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PARENT_ARCHIVES
}

Mirror ()
{
	db_get cnt-debconf/mirror
	MIRROR="${RET}"

	if [ -z "${MIRROR}" ]
	then
		case "${MODE}" in
			debian)
				db_set cnt-debconf/mirror https://deb.debian.org/debian
				db_fset cnt-debconf/mirror seen false
				;;

			progress-linux)
				db_set cnt-debconf/mirror https://cdn.archive.progress-linux.org/packages
				db_fset cnt-debconf/mirror seen false
				;;
		esac

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/mirror || true
		db_go

		db_get cnt-debconf/mirror
		MIRROR="${RET}" # string (w/o empty)

		if [ -z "${MIRROR}" ]
		then
			case "${MODE}" in
				debian)
					MIRROR="https://deb.debian.org/debian"
					;;

				progress-linux)
					MIRROR="https://cdn.archive.progress-linux.org/packages"
					;;
			esac
		fi
	fi

	echo "MIRROR=\"${MIRROR}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export MIRROR
}

Mirror_security ()
{
	if ! echo "${ARCHIVES}" | grep -qs "-security"
	then
		return 0
	fi

	db_get cnt-debconf/mirror-security
	MIRROR_SECURITY="${RET}" # string (w/o empty)

	if [ -z "${MIRROR_SECURITY}" ]
	then
		case "${MODE}" in
			debian)
				db_set cnt-debconf/mirror-security http://security.debian.org
				db_fset cnt-debconf/mirror-security seen false
				;;

			*)
				db_set cnt-debconf/mirror-security ${MIRROR}
				db_fset cnt-debconf/mirror-security seen true
				;;
		esac

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/mirror-security || true
		db_go

		db_get cnt-debconf/mirror-security
		MIRROR_SECURITY="${RET}" # string (w/o empty)

		if [ -z "${MIRROR_SECURITY}" ]
		then
			case "${MODE}" in
				debian)
					MIRROR_SECURITY="http://security.debian.org"
					;;

				*)
					MIRROR_SECURITY="${MIRROR}"
					;;
			esac
		fi
	fi

	echo "MIRROR_SECURITY=\"${MIRROR_SECURITY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export MIRROR_SECURITY
}

Parent_mirror ()
{
	db_get cnt-debconf/parent-mirror
	PARENT_MIRROR="${RET}" # string (w/o empty)

	if [ -z "${PARENT_MIRROR}" ]
	then
		case "${MODE}" in
			progress-linux)
				db_set cnt-debconf/parent-mirror https://deb.debian.org/debian
				db_fset cnt-debconf/parent-mirror seen false

				db_settitle cnt-debconf/title
				db_input high cnt-debconf/parent-mirror || true
				db_go
				;;

			*)
				db_set cnt-debconf/parent-mirror ${MIRROR}
				db_fset cnt-debconf/parent-mirror seen true
				;;
		esac

		db_get cnt-debconf/parent-mirror
		PARENT_MIRROR="${RET}" # string (w/o empty)

		if [ -z "${PARENT_MIRROR}" ]
		then
			case "${MODE}" in
				progress-linux)
					PARENT_MIRROR="https://deb.debian.org/debian"
					;;

				*)
					PARENT_MIRROR="${MIRROR}"
					;;
			esac
		fi
	fi

	echo "PARENT_MIRROR=\"${PARENT_MIRROR}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PARENT_MIRROR
}

Parent_mirror_security ()
{
	if ! echo "${PARENT_ARCHIVES}" | grep -qs "-security"
	then
		return 0
	fi

	db_get cnt-debconf/parent-mirror-security
	PARENT_MIRROR_SECURITY="${RET}" # string (w/o empty)

	if [ -z "${PARENT_MIRROR_SECURITY}" ]
	then
		case "${MODE}" in
			progress-linux)
				db_set cnt-debconf/parent-mirror-security http://security.debian.org
				db_fset cnt-debconf/parent-mirror-security seen false

				db_settitle cnt-debconf/title
				db_input high cnt-debconf/parent-mirror-security || true
				db_go
				;;

			*)
				db_set cnt-debconf/parent-mirror-security ${MIRROR_SECURITY}
				db_fset cnt-debconf/parent-mirror-security seen true
				;;
		esac

		db_get cnt-debconf/parent-mirror-security
		PARENT_MIRROR_SECURITY="${RET}" # string (w/o empty)

		if [ -z "${PARENT_MIRROR_SECURITY}" ]
		then
			case "${MODE}" in
				progress-linux)
					PARENT_MIRROR_SECURITY="http://security.debian.org"
					;;

				*)
					PARENT_MIRROR_SECURITY="${MIRROR_SECURITY}"
					;;
			esac
		fi
	fi

	echo "PARENT_MIRROR_SECURITY=\"${PARENT_MIRROR_SECURITY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PARENT_MIRROR_SECURITY
}

Archive_areas ()
{
	db_get cnt-debconf/archive-areas
	ARCHIVE_AREAS="${RET}"

	if [ -z "${ARCHIVE_AREAS}" ]
	then
		case "${MODE}" in
			progress-linux)
				db_subst cnt-debconf/archive-areas CHOICES "main, contrib, non-free"

				db_set cnt-debconf/archive-areas "main, contrib, non-free"
				db_fset cnt-debconf/archive-areas seen false
				;;

			*)
				db_subst cnt-debconf/archive-areas CHOICES "main, contrib, non-free"

				db_set cnt-debconf/archive-areas "main"
				db_fset cnt-debconf/archive-areas seen false
				;;
		esac

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/archive-areas || true
		db_go

		db_get cnt-debconf/archive-areas
		ARCHIVE_AREAS="${RET}" # multiselect (w/o empty)

		if [ -z "${ARCHIVE_AREAS}" ]
		then
			case "${MODE}" in
				debian)
					ARCHIVE_AREAS="main"
					;;

				progress-linux)
					ARCHIVE_AREAS="main, contrib, non-free"
					;;
			esac
		fi
	fi

	ARCHIVE_AREAS="$(echo ${ARCHIVE_AREAS} | sed -e 's| ||g')"

	echo "ARCHIVE_AREAS=\"${ARCHIVE_AREAS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export ARCHIVE_AREAS
}

Parent_archive_areas ()
{
	db_get cnt-debconf/parent-archive-areas
	PARENT_ARCHIVE_AREAS="${RET}" # multiselect (w/o empty)

	if [ -z "${PARENT_ARCHIVE_AREAS}" ]
	then
		case "${MODE}" in
			progress-linux)
				db_subst cnt-debconf/parent-archive-areas CHOICES "main, contrib, non-free"

				db_set cnt-debconf/parent-archive-areas "main, contrib, non-free"
				db_fset cnt-debconf/parent-archive-areas seen false

				db_settitle cnt-debconf/title
				db_input high cnt-debconf/parent-archive-areas || true
				db_go
				;;

			*)
				db_subst cnt-debconf/parent-archive-areas CHOICES "${ARCHIVE_AREAS}"

				db_set cnt-debconf/parent-archive-areas "${ARCHIVE_AREAS}"
				db_fset cnt-debconf/parent-archive-areas seen true
				;;
		esac

		db_get cnt-debconf/parent-archive-areas
		PARENT_ARCHIVE_AREAS="${RET}" # multiselect (w/o empty)

		if [ -z "${PARENT_ARCHIVE_AREAS}" ]
		then
			case "${MODE}" in
				progress-linux)
					PARENT_ARCHIVE_AREAS="main, contrib, non-free"
					;;

				*)
					PARENT_ARCHIVE_AREAS="${ARCHIVE_AREAS}"
					;;
			esac
		fi
	fi

	PARENT_ARCHIVE_AREAS="$(echo ${PARENT_ARCHIVE_AREAS} | sed -e 's| ||g')"

	echo "PARENT_ARCHIVE_AREAS=\"${PARENT_ARCHIVE_AREAS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PARENT_ARCHIVE_AREAS
}

Packages ()
{
	db_get cnt-debconf/packages
	PACKAGES="${RET}" # string (w/ empty)

	if [ -z "${PACKAGES}" ]
	then
		db_settitle cnt-debconf/title
		db_input high cnt-debconf/packages || true
		db_go

		db_get cnt-debconf/packages
		PACKAGES="${RET}" # string (w/ empty)
	fi

	echo "PACKAGES=\"${PACKAGES}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	export PACKAGES
}

Local_archives ()
{
	NUMBER="0"

	while db_get cnt-debconf/archive${NUMBER}/repository && [ "${RET}" ]
	do
		mkdir -p "${DEBCONF_TMPDIR}/apt"

		REPOSITORY="${RET#deb }"

		LIST="archive${NUMBER}.list"
		if db_get cnt-debconf/archive${NUMBER}/list
		then
			LIST="$(basename ${RET} .list).list"
		fi

		COMMENT=""
		if db_get cnt-debconf/archive${NUMBER}/comment
		then
			COMMENT="${RET}"

			echo "# ${COMMENT}" > "${DEBCONF_TMPDIR}/apt/${LIST}"
		fi

		echo "deb ${REPOSITORY}" >> "${DEBCONF_TMPDIR}/apt/${LIST}"

		if db_get cnt-debconf/archive${NUMBER}/source && [ "$RET" = true ]
		then
			echo "deb-src ${REPOSITORY}" >> "${DEBCONF_TMPDIR}/apt/${LIST}"
		fi

		KEY=""
		if db_get cnt-debconf/archive${NUMBER}/key
		then
			KEY="${RET}"

			wget -q "${KEY}" -O "${DEBCONF_TMPDIR}/apt/$(basename ${LIST} .list).key"
		fi

		PREFERENCES_PACKAGE=""
		PREFERENCES_PIN=""
		PREFERENCES_PIN_PRIORITY=""
		if db_get cnt-debconf/archive${NUMBER}/preferences-package
		then
			PREFERENCES_PACKAGE="${RET}"

			if db_get cnt-debconf/archive${NUMBER}/preferences-pin
			then
				PREFERENCES_PIN="${RET}"
			fi

			if db_get cnt-debconf/archive${NUMBER}/preferences-pin-priority
			then
				PREFERENCES_PIN_PRIORITY="${RET}"
			fi

			if [ -n "${PREFERENCES_PACKAGE}" ] || [ -n "${PREFERENCES_PIN}" ] || [ -n "${PREFERENCES_PIN_PRIORITY}" ]
			then

cat > "${DEBCONF_TMPDIR}/apt/$(basename ${LIST} .list).pref" << EOF
Package: ${PREFERENCES_PACKAGE}
Pin: ${PREFERENCES_PIN}
Pin-Priority: ${PREFERENCES_PIN_PRIORITY}
EOF

			fi
		fi

		NUMBER="$((${NUMBER} + 1))"
	done
}

Network_defaults ()
{
	# FIXME:
	#   * use interfaces.d where possible
	#   * respect pre-existing interfaces (or interfaces.d)
	#   * add support for bridges (make interface configuration more generic?)

	HOSTNAME_SHORT="$(echo veth-$(echo ${NAME} | cut -c-8)-0)"
	VETH_NAME="$(echo ${HOSTNAME_SHORT:-veth0})"

	NETWORK0_VETH="${NETWORK0_VETH:-$VETH_NAME}"
	NETWORK0_BRIDGE="${NETWORK0_BRIDGE:-br0}"
	NETWORK0_IPV4_METHOD="${NETWORK0_IPV4_METHOD:-dhcp}"
	NETWORK0_IPV4_ADDRESS="${NETWORK0_IPV4_ADDRESS:-192.168.1.2}"
	NETWORK0_IPV4_NETMASK="${NETWORK0_IPV4_NETMASK:-255.255.255.0}"

	if [ "${NETWORK0_IPV4_METHOD}" = "static" ] && [ -e /etc/resolv.conf ]
	then
		NAMESERVER_SERVER="${NAMESERVER_SERVER:-$(if [ -e /etc/resolv.conf ]; then awk '/^nameserver / {$1=""; print $0}' /etc/resolv.conf; fi)}"
		# Workaround to get rid of newlines since debconf can not handle multiline return value in assignments
		NAMESERVER_SERVER="$(echo ${NAMESERVER_SERVER})"

		NAMESERVER_DOMAIN="${NAMESERVER_DOMAIN:-$(if [ -e /etc/resolv.conf ]; then awk '/^domain / {$1=""; print $0}' /etc/resolv.conf; fi)}"
		NAMESERVER_SEARCH="${NAMESERVER_SEARCH:-$(if [ -e /etc/resolv.conf ]; then awk '/^search / {$1=""; print $0}' /etc/resolv.conf; fi)}"
		NAMESERVER_OPTIONS="${NAMESERVER_OPTIONS:-$(if [ -e /etc/resolv.conf ]; then awk '/^options / {$1=""; print $0}' /etc/resolv.conf; fi)}"
	fi
}

Network ()
{
	db_get cnt-debconf/network0/bridge
	NETWORK0_BRIDGE="${RET}" # string (w/o empty)

	db_get cnt-debconf/network0/veth
	NETWORK0_VETH="${RET}" # string (w/o empty)

	db_get cnt-debconf/network0/ipv4-method
	NETWORK0_IPV4_METHOD="${RET}" # select

	db_get cnt-debconf/network0/ipv4-comment
	NETWORK0_IPV4_COMMENT="${RET}" # string (w/ empty)

	db_get cnt-debconf/network0/ipv4-address
	NETWORK0_IPV4_ADDRESS="${RET}" # string (w/o empty)

	db_get cnt-debconf/network0/ipv4-gateway
	NETWORK0_IPV4_GATEWAY="${RET}" # string (w/ empty)

	db_get cnt-debconf/network0/ipv4-netmask
	NETWORK0_IPV4_NETMASK="${RET}" # string (w/o empty)

	db_get cnt-debconf/network0/ipv4-post-up
	NETWORK0_IPV4_POST_UP="${RET}" # string (w/ empty)

	db_get cnt-debconf/network0/ipv4-post-down
	NETWORK0_IPV4_POST_DOWN="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/server
	NAMESERVER_SERVER="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/domain
	NAMESERVER_DOMAIN="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/search
	NAMESERVER_SEARCH="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/options
	NAMESERVER_OPTIONS="${RET}" # string (w/ empty)

	Network_defaults

	db_set cnt-debconf/network0/bridge "${NETWORK0_BRIDGE}"
	db_fset cnt-debconf/network0/bridge seen false

	db_set cnt-debconf/network0/veth "${NETWORK0_VETH}"
	db_fset cnt-debconf/network0/veth seen false

	db_set cnt-debconf/network0/ipv4-method "${NETWORK0_IPV4_METHOD}"
	db_fset cnt-debconf/network0/ipv4-method seen false

	db_set cnt-debconf/network0/ipv4-comment "${NETWORK0_IPV4_COMMENT}"
	db_fset cnt-debconf/network0/ipv4-comment seen false

	db_set cnt-debconf/network0/ipv4-address "${NETWORK0_IPV4_ADDRESS}"
	db_fset cnt-debconf/network0/ipv4-address seen false

	db_set cnt-debconf/network0/ipv4-gateway "${NETWORK0_IPV4_GATEWAY}"
	db_fset cnt-debconf/network0/ipv4-gateway seen false

	db_set cnt-debconf/network0/ipv4-netmask "${NETWORK0_IPV4_NETMASK}"
	db_fset cnt-debconf/network0/ipv4-netmask seen false

	db_set cnt-debconf/network0/ipv4-post-up "${NETWORK0_IPV4_POST_UP}"
	db_fset cnt-debconf/network0/ipv4-post-up seen false

	db_set cnt-debconf/network0/ipv4-post-down "${NETWORK0_IPV4_POST_DOWN}"
	db_fset cnt-debconf/network0/ipv4-post-down seen false

	db_set cnt-debconf/nameserver/server "${NAMESERVER_SERVER}"
	db_fset cnt-debconf/nameserver/server seen false

	db_set cnt-debconf/nameserver/domain "${NAMESERVER_DOMAIN}"
	db_fset cnt-debconf/nameserver/domain seen false

	db_set cnt-debconf/nameserver/search "${NAMESERVER_SEARCH}"
	db_fset cnt-debconf/nameserver/search seen false

	db_set cnt-debconf/nameserver/options "${NAMESERVER_OPTIONS}"
	db_fset cnt-debconf/nameserver/options seen false

	db_settitle cnt-debconf/title
	db_input high cnt-debconf/network0/ipv4-method || true
	db_go

	db_get cnt-debconf/network0/bridge
	NETWORK0_BRIDGE="${RET}" # select

	db_get cnt-debconf/network0/veth
	NETWORK0_VETH="${RET}" # select

	db_get cnt-debconf/network0/ipv4-method
	NETWORK0_IPV4_METHOD="${RET}" # select

	case "${NETWORK0_IPV4_METHOD}" in
		none|dhcp)
			;;

		static)
			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-comment || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-address || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-gateway || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-netmask || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-post-up || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/network0/ipv4-post-down || true
			db_go

			db_settitle cnt-debconf/title
			db_input high cnt-debconf/nameserver/server || true
			db_go
			;;
	esac

	NUMBER="0"

	while db_get cnt-debconf/network${NUMBER}/ipv4-method && [ "${RET}" ]
	do
		if db_get cnt-debconf/network${NUMBER}/bridge
		then
			eval NETWORK${NUMBER}_BRIDGE="\"${RET}\"" # string (w/o empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/veth
		then
			eval NETWORK${NUMBER}_VETH="\"${RET}\"" # string (w/o empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-comment
		then
			eval NETWORK${NUMBER}_IPV4_COMMENT="\"${RET}\"" # string (w/ empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-method
		then
			eval NETWORK${NUMBER}_IPV4_METHOD="\"${RET}\"" # select
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-address
		then
			eval NETWORK${NUMBER}_IPV4_ADDRESS="\"${RET}\"" # string (w/o empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-gateway
		then
			eval NETWORK${NUMBER}_IPV4_GATEWAY="\"${RET}\"" # string (w/ empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-netmask
		then
			eval NETWORK${NUMBER}_IPV4_NETMASK="\"${RET}\"" # string (w/o empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-post-up
		then
			eval NETWORK${NUMBER}_IPV4_POST_UP="\"${RET}\"" # string (w/ empty)
		fi

		if db_get cnt-debconf/network${NUMBER}/ipv4-post-down
		then
			eval NETWORK${NUMBER}_IPV4_POST_DOWN="\"${RET}\"" # string (w/ empty)
		fi

		NUMBER="$((${NUMBER} + 1))"
	done

	NETWORK_NUMBER="${NUMBER}"

	db_get cnt-debconf/nameserver/server
	NAMESERVER_SERVER="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/domain
	NAMESERVER_DOMAIN="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/search
	NAMESERVER_SEARCH="${RET}" # string (w/ empty)

	db_get cnt-debconf/nameserver/options
	NAMESERVER_OPTIONS="${RET}" # string (w/ empty)

	Network_defaults

	echo "NETWORK_NUMBER=\"${NETWORK_NUMBER}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	for NUMBER in $(seq 0 ${NETWORK_NUMBER})
	do
		eval BRIDGE="$`echo NETWORK${NUMBER}_BRIDGE`"
		echo "NETWORK${NUMBER}_BRIDGE=\"${BRIDGE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval VETH="$`echo NETWORK${NUMBER}_VETH`"
		echo "NETWORK${NUMBER}_VETH=\"${VETH}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval COMMENT="$`echo NETWORK${NUMBER}_IPV4_COMMENT`"
		echo "NETWORK${NUMBER}_IPV4_COMMENT=\"${COMMENT}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`"
		echo "NETWORK${NUMBER}_IPV4_METHOD=\"${METHOD}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`"
		echo "NETWORK${NUMBER}_IPV4_ADDRESS=\"${ADDRESS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval GATEWAY="$`echo NETWORK${NUMBER}_IPV4_GATEWAY`"
		echo "NETWORK${NUMBER}_IPV4_GATEWAY=\"${GATEWAY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval NETMASK="$`echo NETWORK${NUMBER}_IPV4_NETMASK`"
		echo "NETWORK${NUMBER}_IPV4_NETMASK=\"${NETMASK}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval POST_UP="$`echo NETWORK${NUMBER}_IPV4_POST_UP`"
		echo "NETWORK${NUMBER}_IPV4_POST_UP=\"${POST_UP}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

		eval POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`"
		echo "NETWORK${NUMBER}_IPV4_POST_DOWN=\"${POST_DOWN}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	done

	echo "NAMESERVER_SERVER=\"${NAMESERVER_SERVER}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	echo "NAMESERVER_DOMAIN=\"${NAMESERVER_DOMAIN}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	echo "NAMESERVER_SEARCH=\"${NAMESERVER_SEARCH}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
	echo "NAMESERVER_OPTIONS=\"${NAMESERVER_OPTIONS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
}

Root_password ()
{
	if db_get cnt-debconf/root-password
	then
		ROOT_PASSWORD="${RET}" # string (w/o empty)
	fi

	if [ -z "${ROOT_PASSWORD}" ]
	then
		# Create a random password as suggestion for the user
		RANDOM_PASSWORD="$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)"

		db_set cnt-debconf/root-password ${RANDOM_PASSWORD}
		db_fset cnt-debconf/root-password seen false

		db_settitle cnt-debconf/title
		db_input high cnt-debconf/root-password || true
		db_go

		db_get cnt-debconf/root-password
		ROOT_PASSWORD="${RET}"

		if [ -z "${ROOT_PASSWORD}" ]
		then
			# User did set not set a password, falling back to random password
			ROOT_PASSWORD="${RANDOM_PASSWORD}"
		fi

		if [ "${ROOT_PASSWORD}" = "${RANDOM_PASSWORD}" ]
		then
			echo "ROOT_RANDOM_PASSWORD=\"true\"" >> "${DEBCONF_TMPDIR}/debconf.default"
		fi
	fi

	echo "ROOT_PASSWORD=\"${ROOT_PASSWORD}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
}

Internal_options ()
{
	if db_get cnt-debconf/apt-recommends
	then
		APT_RECOMMENDS="${RET}" # boolean (w/ empty)
	fi

	echo "APT_RECOMMENDS=\"${APT_RECOMMENDS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/debconf-frontend
	then
		DEBCONF_FRONTEND="${RET}" # select
	fi

	DEBCONF_FRONTEND="${DEBCONF_FRONTEND:-dialog}"
	echo "DEBCONF_FRONTEND=\"${DEBCONF_FRONTEND}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/debconf-priority
	then
		DEBCONF_PRIORITY="${RET}" # select
	fi

	DEBCONF_PRIORITY="${DEBCONF_PRIORITY:-high}"
	echo "DEBCONF_PRIORITY=\"${DEBCONF_PRIORITY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/container-command
	then
		CONTAINER_COMMAND="${RET}" # string (w/ empty)
	fi

	echo "CONTAINER_COMMAND=\"${CONTAINER_COMMAND}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/host-command
	then
		HOST_COMMAND="${RET}" # string (w/ empty)
	fi

	echo "HOST_COMMAND=\"${HOST_COMMAND}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/auto
	then
		CNT_AUTO="${RET:-FQDN}" # string (w/o empty)
	fi

	CNT_AUTO="${CNT_AUTO:-FQDN}"

	case "${CNT_AUTO}" in
		FQDN)
			CNT_AUTO="$(hostname -f)"
			;;
	esac

	echo "CNT_AUTO=\"${CNT_AUTO}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/bind
	then
		BIND="${RET}" # string (w/ empty)
	fi

	echo "BIND=\"${BIND}\"" >> "${DEBCONF_TMPDIR}/debconf.default"

	if db_get cnt-debconf/overlay
	then
		CNT_OVERLAY="${RET}" # string (w/ empty)
	fi

	echo "CNT_OVERLAY=\"${CNT_OVERLAY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
}

Distribution
Parent_distribution

Architecture

Archives
Parent_archives

Mirror
Mirror_security

Parent_mirror
Parent_mirror_security

Archive_areas
Parent_archive_areas

Packages
Local_archives

Network
Root_password

Internal_options

db_stop