~xnox/debian-cd/drop-dead-groovy

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
#!/bin/bash
#
# Do install stuff for amd64, including making bootable CDs
# Works with debian-installer
#
# $1 is the CD number
# $2 is the temporary CD build dir

. $BASEDIR/tools/boot/$DI_CODENAME/common.sh

set -e

N=$1
CDDIR=$2
BOOTDIR=
if [ "$DI_WWW_HOME" = "default" ];then
   DI_WWW_HOME="http://debian-amd64.alioth.debian.org/debian-installer/daily"
fi
if [ ! "$DI_DIST" ]; then
   export DI_DIST="$DI_CODENAME"
fi
if [ -z "$DI_PATH" ]; then
   DI_PATH="$($BASEDIR/tools/find-newest-installer)"
fi

default_preseed
default_language

cd $CDDIR/..

#
# This script is called with $1 (now $N) as the CD to 
# make bootable.  N may be in the form "n" or "n_NONUS"
# There may be more than 4 disks...support extras.

# Strip NONUS part of disk number
# NN will be 1...N so it can be used as an index
#
NN=`echo $N | sed -e 's/_NONUS//'`

if [ "$CDIMAGE_ADDON" ]; then
    # second disk, at least in spirit
    NN=2
fi

> $N.mkisofs_opts

case "$MKISOFS" in
    *xorriso*)
        echo -n "-isohybrid-mbr syslinux/usr/lib/ISOLINUX/isohdpfx.bin " >> $N.mkisofs_opts
        # uncomment to add a small FAT partition on the media
        # /sbin/mkfs.msdos -n Bla -C test.fat 8192
        # echo -n "-append_partition 2 0x01 test.fat " >> $N.mkisofs_opts
        ;;
esac

# List of boot image for each CD
KTYPE[1]="" #isolinux multiboot in fact
KTYPE[2]=""
# XXX add net-image back when it's fixed
KTYPE[3]=""
KTYPE[4]=""
KTYPE[5]=""
KTYPE[6]=""
KTYPE[7]=""
KTYPE[8]=""
KTYPE[9]=""
KTYPE[10]=""

THISTYPE=${KTYPE[$NN]}

PREFIX_PRESEED="$(dirname "$DEFAULT_PRESEED")/"
PREFIX_GA=""
PREFIX_HWE=""
KERNEL_PREFIXES="PREFIX_GA"
if [ "$BACKPORT_KERNEL" ]; then
    PREFIX_HWE="hwe-"
    if [ "$PROJECT" = ubuntu-server ]; then
        KERNEL_PREFIXES="$KERNEL_PREFIXES PREFIX_HWE"
    fi
fi

DISK_IMAGES=""
BOOT_IMAGES=""
TAR_IMAGES=""
for kp in $KERNEL_PREFIXES; do
    BOOT_IMAGES="$BOOT_IMAGES ${!kp}cdrom/initrd.gz ${!kp}cdrom/vmlinuz ${!kp}cdrom/debian-cd_info.tar.gz"
    TAR_IMAGES="$TAR_IMAGES ${!kp}netboot/netboot.tar.gz"
done

case $PROJECT in
    ubuntustudio)
	if [ "$CDIMAGE_LIVE" ]; then
	    FLAVOUR=lowlatency
	else
	    FLAVOUR=generic
	fi
	;;
    *)
	FLAVOUR=generic
	;;
esac

# Download boot images
for image in MANIFEST.udebs $BOOT_IMAGES $DISK_IMAGES $TAR_IMAGES; do
    if [ ! -e "$image" ]; then
	dir=$(dirname $image)
	mkdir -p $dir
	if [ ! "$DI_WWW_HOME" ];then
		cp "$DI_PATH/current/legacy-images/$image" "$image"
	else
		wget "$DI_WWW_HOME/$image" -O "$image"
	fi
    fi
done

if [ "$NN" = "1" ]; then
    list_kernel_abis $BOOT_IMAGES | check_kernel_sync $FLAVOUR

    echo "Using ISOLINUX boot-disks image on CD$N"
    mkdir -p $CDDIR/../syslinux boot$N/isolinux
    SYSLINUXDEB="$($BASEDIR/tools/apt-selection cache show syslinux-common | \
	grep ^Filename | awk '{print $2}')"
    (dpkg --fsys-tarfile "$MIRROR/$SYSLINUXDEB" | \
	tar xf - -C $CDDIR/../syslinux ./usr/lib)
    ISOLINUXDEB="$($BASEDIR/tools/apt-selection cache show isolinux | \
	grep ^Filename | awk '{print $2}')"
    (dpkg --fsys-tarfile "$MIRROR/$ISOLINUXDEB" | \
	tar xf - -C $CDDIR/../syslinux ./usr/lib)
    cp -f $CDDIR/../syslinux/usr/lib/ISOLINUX/isolinux.bin boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/vesamenu.c32 boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/ldlinux.c32 boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/libcom32.c32 boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/libutil.c32 boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/gfxboot.c32 boot$N/isolinux/
    cp -f $CDDIR/../syslinux/usr/lib/syslinux/modules/bios/chain.c32 boot$N/isolinux/

    GFXBOOT=
    if THEMEDEB="$($BASEDIR/tools/apt-selection cache show gfxboot-theme-ubuntu)"; then
	THEMEDEB="$(echo "$THEMEDEB" | grep ^Filename | awk '{print $2}')"
	dpkg --fsys-tarfile "$MIRROR/$THEMEDEB" | tar xf - -C . ./usr/share/gfxboot-theme-ubuntu/bootlogo.tar.gz
	tar zxf usr/share/gfxboot-theme-ubuntu/bootlogo.tar.gz -C boot$N/isolinux
	GFXBOOT=1
    fi

    rm -rf usr
    if [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
    for kp in $KERNEL_PREFIXES; do
      cp -lf "${!kp}cdrom/vmlinuz" "$CDDIR/install/${!kp}vmlinuz"
      cp -lf "${!kp}cdrom/initrd.gz" "$CDDIR/install/${!kp}initrd.gz"
    done
    fi
    if [ "$CDIMAGE_LIVE" = 1 ]; then
	CASPER_KERNEL=/casper/vmlinuz
	CASPER_INITRD=/casper/initrd
	for kernel in $CDDIR/casper/filesystem.kernel-*; do
	    flavour=${kernel##*filesystem.kernel-}
	    flavour2="-${flavour}"
	    [ "$flavour" = "${FLAVOUR}" ] && flavour2=""
	    mv $CDDIR/casper/filesystem.kernel-$flavour $CDDIR$CASPER_KERNEL${flavour2}
	    mv $CDDIR/casper/filesystem.initrd-$flavour $CDDIR$CASPER_INITRD${flavour2}
	done
    fi
    echo -n "-cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table " >> $N.mkisofs_opts
    case "$MKISOFS" in
	*xorriso*)
	    echo -n "-eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus " >> $N.mkisofs_opts
	    ;;
	*)
	    echo -n "-eltorito-alt-boot -efi-boot boot/grub/efi.img -no-emul-boot " >> $N.mkisofs_opts
	    ;;
    esac
else
    if [ -n "$THISTYPE" ]; then
	echo "Using $THISTYPE boot-disks image on CD$N"
	mkdir -p boot$N/boot
	cp $THISTYPE/boot.img boot$N/boot/
	echo -n "-cache-inodes -J -l -b boot/boot.img " >> $N.mkisofs_opts
    else
	mkdir boot$N
	echo -n "-cache-inodes -J -l " >> $N.mkisofs_opts
    fi
fi

case "$MKISOFS" in
    *xorriso*)
	;;
    *)
	"$BASEDIR/tools/sorting_weights" "$N" boot$N/isolinux/isolinux.bin boot$N/isolinux/boot.cat
	echo -n "-sort $(pwd)/$N.weights " >> $N.mkisofs_opts
	;;
esac

#install_languages $CDDIR

# Only disk one gets the extra files installed
#
if [ "$NN" = "1" ]; then


HIDDEN_TIMEOUT=
if [ "$CDIMAGE_LIVE" = 1 ] && [ "$CDIMAGE_DVD" != 1 ]; then
    case $PROJECT in
	mythbuntu)
	    HIDDEN_TIMEOUT=1
	    ;;
	lubuntu)
	    # Lubuntu appears to be an exception, being a live image but not
	    # using hidden timeout.
	    ;;
	*)
	    HIDDEN_TIMEOUT=2
	    ;;
    esac
    if [ -e "$BASEDIR/data/$DI_CODENAME/$PROJECT-access.pcx" ]; then
	ACCESSPCX="$PROJECT-access.pcx"
    else
	ACCESSPCX=access-new.pcx
    fi
    if [ -e "$BASEDIR/data/$DI_CODENAME/$PROJECT-blank.pcx" ]; then
	BLANKPCX="$PROJECT-blank.pcx"
    else
	BLANKPCX=blank.pcx
    fi
fi

# populate the install directory as well
for disk in $DISK_IMAGES; do
	dir=$(dirname $disk)
	mkdir -p $CDDIR/install/$dir
	cp -lf $disk $CDDIR/install/$dir
done

if [ "$CDIMAGE_INSTALL" = 1 ]; then
	for tar in $TAR_IMAGES; do
		dir=$(dirname $tar)
		mkdir -p $CDDIR/install/$dir
		tar -C $CDDIR/install/$dir -xzpf $tar
	done
fi

# ISOLINUX setup

if [ "$CDIMAGE_INSTALL" = 1 ]; then
    # Include Smart Boot Manager image for people where isolinux fails
    gzip -dc $BASEDIR/data/$DI_CODENAME/sbm.bin.gz > $CDDIR/install/sbm.bin
    # Keep the original file timestamp
    touch -r $BASEDIR/data/$DI_CODENAME/sbm.bin.gz $CDDIR/install/sbm.bin
    cp -p $BASEDIR/data/$DI_CODENAME/README.sbm $CDDIR/install/
fi
# Extract memtest86+ from the archive
MEMTEST86DEB="$($BASEDIR/tools/apt-selection cache show memtest86+ | \
	grep ^Filename | awk '{print $2}')"
dpkg --fsys-tarfile "$MIRROR/$MEMTEST86DEB" | \
	tar xf - -C $CDDIR/install/ ./boot/memtest86+.bin
mv $CDDIR/install/boot/memtest86+.bin $CDDIR/install/mt86plus
rm -rf $CDDIR/install/boot
# Isolinux help files come from d-i.
cat cdrom/debian-cd_info.tar.gz | (cd boot$N/isolinux/; tar zx)
# Override splash screen.
if [ "$SPLASHRLE" ] && [ -e "$SPLASHRLE" ]; then
    cp -p "$SPLASHRLE" boot$N/isolinux/splash.rle
fi
if [ "$GFXSPLASH" ] && [ -e "$GFXSPLASH" ]; then
    cp -p "$GFXSPLASH" boot$N/isolinux/splash.pcx
fi
if [ "$SPLASHPNG" ] && [ -e "$SPLASHPNG" ]; then
    cp -p "$SPLASHPNG" boot$N/isolinux/splash.png
fi
if [ "$HIDDEN_TIMEOUT" ] && [ "$ACCESSPCX" ]; then
    cp -p "$BASEDIR/data/$DI_CODENAME/$ACCESSPCX" boot$N/isolinux/access.pcx
fi
if [ "$HIDDEN_TIMEOUT" = 2 ]; then
    cp -p "$BASEDIR/data/$DI_CODENAME/$BLANKPCX" boot$N/isolinux/blank.pcx
fi
if [ "$PROJECT" = kubuntu ] || [ "$PROJECT" = kubuntu-plasma5 ]; then
    # No language menu.
    echo en >boot$N/isolinux/lang
elif [ "$PROJECT" = ubuntukylin ]; then
    echo zh_CN >boot$N/isolinux/lang
fi
# Remove elilo configuration; only for Macs.
rm -f boot$N/isolinux/elilo*
rm -f boot$N/isolinux/*.msg*
if [ "$CDIMAGE_INSTALL" = 1 ]; then
    rm -f boot$N/isolinux/*.txt.live
    rm -f boot$N/isolinux/*.hlp.live
else
    for x in boot$N/isolinux/*.txt.live; do
	[ -f "$x" ] || continue
	mv "$x" "${x%.live}"
    done
    for x in boot$N/isolinux/*.hlp.live; do
	[ -f "$x" ] || continue
	mv "$x" "${x%.live}"
    done
fi
# Nuke the GTK menu items for now.
rm -f boot$N/isolinux/*gtk.cfg
rm -f boot$N/isolinux/*.txt.withgtk
# We only support single-architecture images.
sed -i 's|%install%|install|' boot$N/isolinux/*.cfg
# Move GRUB files to the right place.
mkdir -p $CDDIR/EFI/BOOT
mcopy -i boot$N/isolinux/grub/efi.img ::EFI/BOOT/BOOTx64.EFI $CDDIR/EFI/BOOT/BOOTx64.EFI
mcopy -i boot$N/isolinux/grub/efi.img ::EFI/BOOT/grubx64.efi $CDDIR/EFI/BOOT/grubx64.efi
mcopy -i boot$N/isolinux/grub/efi.img ::EFI/BOOT/mmx64.efi $CDDIR/EFI/BOOT/mmx64.efi
mkdir -p $CDDIR/boot/grub
mv boot$N/isolinux/grub/* $CDDIR/boot/grub/
rmdir boot$N/isolinux/grub
sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg


# FIXME: dmi_modalias.cfg should be shipped in grub, with autopkgtest
cp $BASEDIR/tools/boot/$DI_CODENAME/dmi_modalias.cfg $CDDIR/boot/grub

# This dumps all oem meta packages in the cache, dumps their Modaliases fields,
# extracts all dmi: modaliases, joins them together using |, and then converts
# to a regular expressions by: anchoring it using ^(...)$, and converting *
# to .*.
# Then it uses grub's regexp module to match that one regex against the
# dmi_modalias variable that dmi_modalias.cfg generated for us.
cat >> $CDDIR/boot/grub/grub.cfg <<EOF
set casper_flavour=""
source \$prefix/dmi_modalias.cfg
if regexp '$($BASEDIR/tools/apt-selection cache show ^oem-.*-meta$ | grep-dctrl -v -XF Ubuntu-OEM-Kernel-Flavour default | grep-dctrl -P "" -nsModaliases | grep -o 'dmi:[^), ]*'  | tr '\n' '|'  | sed -E -e 's/(.*)/^(\1)$/' -e 's/\*/.*/g')' "\$dmi_modalias"; then
    set casper_flavour="-oem"
fi
EOF

if [ "$BACKPORT_KERNEL" ]; then
    cat > $CDDIR/boot/grub/hwe-grub.cfg <<EOF
submenu 'Boot and Install with the HWE kernel' {
EOF
    : > boot$N/isolinux/hwe-gfxboot.cfg
fi

# Menu timeout, in seconds.
# gfxboots will need it in deciseconds (it is converted as needed)
menu_timeout=30

# When using hidden timeout; use a shorter timeout while the user
# only sees the accessibility logo at the bottom of the screen.
if [ "$HIDDEN_TIMEOUT" ]; then
    menu_timeout=5
fi

# Set timeout for the GRUB menu
cat >> $CDDIR/boot/grub/grub.cfg <<EOF
set timeout=$menu_timeout
EOF

# Set gfxboot timeouts (for hidden-timeout or for the language picker)
sed -i "s/^timeout .*/timeout $(($menu_timeout * 10))/" \
    boot$N/isolinux/isolinux.cfg boot$N/isolinux/prompt.cfg

# Set up-to-date build dates. Kludgy because d-i sets its own version as
# the build date.
DI_VERSION="$(perl -lne 'if (/built on ([0-9a-z]*)/) { print $1 }' \
			"boot$N/isolinux/f1.txt")"
if [ "$DI_VERSION" ]; then
    : "${CDIMAGE_DATE:=$(date +%Y%m%d)}"
    sed -i "s/$DI_VERSION/$CDIMAGE_DATE/g" \
	"boot$N"/isolinux/*.txt "boot$N"/isolinux/*.hlp
fi

# Isolinux config file.
if [ "$CDIMAGE_LIVE" = 1 ]; then
    DEFAULT_LABEL=live
else
    DEFAULT_LABEL=install
fi
cat > boot$N/isolinux/txt.cfg <<EOF
default $DEFAULT_LABEL
EOF
> boot$N/isolinux/adtxt.cfg
if [ "$GFXBOOT" ]; then
    cat >> boot$N/isolinux/isolinux.cfg <<EOF
ui gfxboot bootlogo
EOF
fi
if [ "$PROJECT" = ubuntu ] || [ "$PROJECT" = ubuntu-server ] || \
   [ "$PROJECT" = ubuntu-mid ] || [ "$PROJECT" = ubuntu-netbook ] || \
   [ "$PROJECT" = mythbuntu ] || [ "$PROJECT" = ubuntukylin ] || \
   [ "$PROJECT" = ubuntu-desktop-next ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
foreground=0xFFFFFF
background=0x958490
screen-colour=0x270A1E
EOF
fi
if [ "$PROJECT" = ubuntu-gnome ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
screen-colour=0x2D3335
EOF
fi
if [ "$PROJECT" = ubuntu-budgie ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
foreground=0xffffff
background=0xd3dae3
screen-colour=0x383c4a
EOF
fi
if [ "$PROJECT" = ubuntu-mate ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
foreground=0xffffff
background=0x87a556
screen-colour=0x3c3b37
EOF
fi
if [ "$HIDDEN_TIMEOUT" ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
hidden-timeout=$HIDDEN_TIMEOUT
EOF
fi
# access-options default: v1 v2 v3 brltty m1 m2
# d-i only supports v1 and brltty right now.
if [ "$CDIMAGE_LIVE" != 1 ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
access-options=v1 brltty
access-options-v1=access=v1 FRONTEND_BACKGROUND=dark
EOF
elif [ "$PROJECT" = kubuntu ] || [ "$PROJECT" = kubuntu-plasma5 ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
access-options=v1 v2 brltty m1
EOF
elif [ "$PROJECT" = xubuntu ]; then
    # v1 and m1 don't have the necessary sed calls for Xubuntu yet.
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
access-options=v2 v3 brltty m2
EOF
fi
cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label normal=Normal
append normal=
EOF
if [ "$CDIMAGE_LIVE" = 1 ]; then
    QUIET=quiet
    SPLASH=splash
    case "$PROJECT" in
        kubuntu|kubuntu-plasma5)
            livelabel="^Start $HUMANPROJECT"
            liveparams=' maybe-ubiquity'
            NOTRYONLYDO=true
            ;;
        lubuntu)
            livelabel="^Start $HUMANPROJECT"
            liveparams=
            NOTRYONLYDO=true
            ;;
        ubuntu-server)
            livelabel="^Install $HUMANPROJECT"
            liveparams=
            SPLASH=
            NOTRYONLYDO=true
            ;;
        ubuntu-mid)
            livelabel="^Try $HUMANPROJECT without installing"
            liveparams=
            NOTRYONLYDO=true
            ;;
        *)
            livelabel="^Try $HUMANPROJECT without installing"
            liveparams=
    esac

    LAYERFS_PATH_OPT=$(add_layerfs_path_opt)

for variant in "" " (safe graphics)^ nomodeset"; do
    suffix="${variant%^*}"
    extra_kopt="${variant#*^}"
    cat >> boot$N/isolinux/txt.cfg <<EOF
label live$(echo "${extra_kopt}"|tr ' ' '-')
  menu label ${livelabel}${suffix}
  kernel $CASPER_KERNEL
  append $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT initrd=$CASPER_INITRD $QUIET $SPLASH$extra_kopt ---
EOF
    cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "${livelabel#^}${suffix}" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT $QUIET $SPLASH$extra_kopt ---
	initrd	$CASPER_INITRD\$casper_flavour
}
EOF
done
    cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
menuentry "${livelabel#^}" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
	initrd	$CASPER_INITRD\$casper_flavour
}
EOF
    if [ "$NOTRYONLYDO" != "true" ]; then
	for variant in "" " (safe graphics)^ nomodeset"; do
	    suffix="${variant%^*}"
	    extra_kopt="${variant#*^}"
	    cat >> boot$N/isolinux/txt.cfg <<EOF
label live-install$(echo "${extra_kopt}"|tr ' ' '-')
  menu label ^Install $HUMANPROJECT${suffix}
  kernel $CASPER_KERNEL
  append $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity initrd=$CASPER_INITRD $QUIET $SPLASH$extra_kopt ---
EOF
	    cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "Install $HUMANPROJECT${suffix}" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity $QUIET $SPLASH$extra_kopt ---
	initrd	$CASPER_INITRD\$casper_flavour
}
EOF
	done
	cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
menuentry "Install $HUMANPROJECT" {
	linux	$CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
	initrd	$CASPER_INITRD\$casper_flavour
}
EOF
    fi
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label driverupdates=Use driver update disc
append driverupdates=debian-installer/driver-update=true
applies driverupdates=live live-install live-nomodeset live-install-nomodeset
EOF
fi
if [ "$CDIMAGE_INSTALL" = 1 ]; then
    if [ "$CDIMAGE_LIVE" != 1 ]; then
    for kp in $KERNEL_PREFIXES; do
	cat >> boot$N/isolinux/txt.cfg <<EOF
label ${!kp}install
  menu label ^Install $HUMANPROJECT${!kp:+ with the HWE kernel}
  kernel /install/${!kp}vmlinuz
  append $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}} vga=788 initrd=/install/${!kp}initrd.gz quiet ---
EOF
	cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
menuentry "Install $HUMANPROJECT" {
	set gfxpayload=keep
	linux	/install/${!kp}vmlinuz $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}} quiet ---
	initrd	/install/${!kp}initrd.gz
}
EOF
    done
    else
	cat >> boot$N/isolinux/txt.cfg <<EOF
label install
  menu label ^Install $HUMANPROJECT in text mode
  kernel /install/vmlinuz
  append $KERNEL_PARAMS $DEFAULT_PRESEED vga=788 initrd=/install/initrd.gz quiet ---
EOF
	cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "Install $HUMANPROJECT in text mode" {
	set gfxpayload=keep
	linux	/install/vmlinuz $KERNEL_PARAMS $DEFAULT_PRESEED quiet ---
	initrd	/install/initrd.gz
}
EOF
    fi
    cat >> boot$N/isolinux/adtxt.cfg <<EOF
label expert
  menu hide
  kernel /install/vmlinuz
  append $KERNEL_PARAMS $DEFAULT_PRESEED priority=low vga=788 initrd=/install/initrd.gz ---
EOF
    if [ "$PROJECT" = edubuntu ]; then
	cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label workstation=Install a workstation
replace workstation=file=/cdrom/preseed/workstation.seed
applies workstation=install
EOF
    fi
    if [ "$CDIMAGE_DVD" = 1 ] && [ "$PROJECT" != edubuntu ] && [ "$PROJECT" != ubuntu-server ]; then
	cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label server=Install a server
replace server=file=/cdrom/preseed/ubuntu-server.seed
applies server=install
EOF
    fi
fi
# No OEM mode on ubuntu-server live
if ! ([ "$PROJECT" = ubuntu-server ] && [ "$CDIMAGE_LIVE" = 1 ]); then
# The GRUB versions of this only correspond to single isolinux labels,
# because we don't yet have the necessary technology in our GRUB menu stack
# to have a two-dimensional set of boot options, as is implemented for
# isolinux using the gfxboot "applies" keyword.
for kp in $KERNEL_PREFIXES; do
cat >> boot$N/isolinux/${!kp}gfxboot.cfg <<EOF
label ${!kp}oem=OEM install (for manufacturers)
append ${!kp}oem=oem-config/enable=true
EOF
if [ "$CDIMAGE_LIVE" = 1 ]; then
    cat >> boot$N/isolinux/${!kp}gfxboot.cfg <<EOF
applies ${!kp}oem=live live-install install live-nomodeset live-install-nomodeset
EOF
    cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
menuentry "OEM install (for manufacturers)" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}}$LAYERFS_PATH_OPT only-ubiquity quiet splash oem-config/enable=true ---
	initrd	$CASPER_INITRD\$casper_flavour
}
EOF
else
    cat >> boot$N/isolinux/${!kp}gfxboot.cfg <<EOF
applies ${!kp}oem=${!kp}install
EOF
    cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
menuentry "OEM install (for manufacturers)" {
	set gfxpayload=keep
	linux	/install/${!kp}vmlinuz $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}} quiet oem-config/enable=true ---
	initrd	/install/${!kp}initrd.gz
}
EOF
fi
done
fi # No OEM mode on ubuntu-server live
if [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
    if [ "$PROJECT" != ubuntu-server ]; then
	cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label cli=Install a command-line system
replace cli=file=/cdrom/preseed/cli.seed
applies cli=install
EOF
    else
    for kp in $KERNEL_PREFIXES; do
	cat >> boot$N/isolinux/${!kp}gfxboot.cfg <<EOF
label ${!kp}minimal=Install a minimal system
replace ${!kp}minimal=file=/cdrom/preseed/${!kp}ubuntu-server-minimal.seed
applies ${!kp}minimal=${!kp}install
label ${!kp}minimalvm=Install a minimal virtual machine
replace ${!kp}minimalvm=file=/cdrom/preseed/${!kp}ubuntu-server-minimalvm.seed
applies ${!kp}minimalvm=${!kp}install
EOF
    done
    fi
fi
if [ "$CDIMAGE_INSTALL" = 1 ] && ([ "$PROJECT" = ubuntu ] || [ "$PROJECT" = xubuntu ] || [ "$PROJECT" = edubuntu ] || [ "$PROJECT" = ubuntu-mate ]); then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label ltsp=Install an LTSP server
replace ltsp=file=/cdrom/preseed/ltsp.seed
applies ltsp=install
EOF
fi
if [ "$CDIMAGE_INSTALL" = 1 ] && [ "$PROJECT" = mythbuntu ]; then
    cat >> boot$N/isolinux/gfxboot.cfg <<EOF
label ltsp=Install a Diskless Image Server
replace ltsp=file=/cdrom/preseed/ltsp.seed
applies ltsp=install
EOF
fi
if [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
    cat >> boot$N/isolinux/txt.cfg <<EOF
label check
  menu label ^Check disc for defects
  kernel /install/vmlinuz
  append $KERNEL_PARAMS $FRONTEND_BACKGROUND MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet ---
EOF
    for kp in $KERNEL_PREFIXES; do
    cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
menuentry "Check disc for defects" {
	set gfxpayload=keep
	linux	/install/${!kp}vmlinuz $KERNEL_PARAMS MENU=/bin/cdrom-checker-menu quiet ---
	initrd	/install/${!kp}initrd.gz
}
EOF
    done
fi
if [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
    cat >> boot$N/isolinux/adtxt.cfg <<EOF
label rescue
  menu label ^Rescue a broken system
  kernel /install/vmlinuz
  append $KERNEL_PARAMS $FRONTEND_BACKGROUND rescue/enable=true vga=788 initrd=/install/initrd.gz ---
EOF
    for kp in $KERNEL_PREFIXES; do
    cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
menuentry "Rescue a broken system" {
	set gfxpayload=keep
	linux	/install/${!kp}vmlinuz $KERNEL_PARAMS rescue/enable=true ---
	initrd	/install/${!kp}initrd.gz
}
EOF
    done
fi
cat >> boot$N/isolinux/txt.cfg <<EOF
label memtest
  menu label Test ^memory
  kernel /install/mt86plus
label hd
  menu label ^Boot from first hard disk
  localboot 0x80
EOF
cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
menuentry "Test memory" {
	linux16	/install/mt86plus
}
EOF
cat >> $CDDIR/boot/grub/grub.cfg <<EOF
grub_platform
if [ "\$grub_platform" = "efi" ]; then
menuentry 'Boot from next volume' {
	exit
}
menuentry 'UEFI Firmware Settings' {
	fwsetup
}
fi
EOF
fi

if [ "$BACKPORT_KERNEL" ] && [ "$PROJECT" = ubuntu-server ]; then
    cat >> $CDDIR/boot/grub/hwe-grub.cfg <<EOF
}
EOF
    cat $CDDIR/boot/grub/hwe-grub.cfg >> $CDDIR/boot/grub/grub.cfg
    cat boot$N/isolinux/hwe-gfxboot.cfg >> boot$N/isolinux/gfxboot.cfg
fi
rm -f $CDDIR/boot/grub/hwe-grub.cfg boot$N/isolinux/hwe-gfxboot.cfg

# write final lines to mkisofs_opts
if [ "$NN" = "1" ]; then
    echo -n "boot$N " >> $N.mkisofs_opts
else
    if [ -n "$THISTYPE" ]; then
	echo -n "-c boot/boot.catalog boot$N "  >> $N.mkisofs_opts
    fi
fi

# Hack around the removal of support in gfxboot for reading from outside
# the bootlogo archive.  This makes customisation harder and is not ideal.
tmpdir="$(mktemp -d)"
(cd "$tmpdir" && cpio -i) < boot$N/isolinux/bootlogo
cp -a boot$N/isolinux/*.fnt \
      boot$N/isolinux/*.hlp \
      boot$N/isolinux/*.jpg \
      boot$N/isolinux/*.pcx \
      boot$N/isolinux/*.tr \
      boot$N/isolinux/*.cfg \
      $(test -e boot$N/isolinux/lang && echo boot$N/isolinux/lang) \
      boot$N/isolinux/langlist \
      "$tmpdir/"
(cd "$tmpdir" && ls -1 | cpio --quiet -o) > boot$N/isolinux/bootlogo
rm -rf "$tmpdir"

# th,th, thats all