~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
#!/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_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

# 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

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

FLAVOUR=generic

# 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

    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
	if [ -e "$CDDIR/casper/filesystem.kernel-$FLAVOUR.efi.signed" ]; then
	    mv $CDDIR/casper/filesystem.kernel-$FLAVOUR.efi.signed $CDDIR/casper/vmlinuz.efi
	    rm -f $CDDIR/casper/filesystem.kernel-$FLAVOUR
	    CASPER_KERNEL=/casper/vmlinuz.efi
	else
	    mv $CDDIR/casper/filesystem.kernel-$FLAVOUR $CDDIR/casper/vmlinuz
	    CASPER_KERNEL=/casper/vmlinuz
	fi
	CASPER_INITRD="/casper/initrd$(initrd_suffix "$CDDIR/casper/filesystem.initrd-$FLAVOUR")"
	mv $CDDIR/casper/filesystem.initrd-$FLAVOUR "$CDDIR$CASPER_INITRD"
    fi
    echo -n "-J -l -c boot/boot.cat -partition_offset 16 " >> $N.mkisofs_opts
    # Once we move to xorriso >= 1.4.4, we should consider changing from
    #  "-e boot/grub/efi.img"
    #    to
    #  "-e --interval:appended_partition_2:all::"
    # This will point the el torito catalog to the appended partition instead
    # of the in-ISO file, which will allow us to remove efi.img from the ISO
    # filesystem and recover it's space.
    echo -n "-append_partition 2 0xef $CDDIR/boot/grub/efi.img -e boot/grub/efi.img -no-emul-boot " >> $N.mkisofs_opts
fi

#install_languages $CDDIR

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


# 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

mkdir -p $CDDIR/boot
cat cdrom/debian-cd_info.tar.gz | (cd $CDDIR/boot/; tar xz)
# If we want a copy of grub on the ISO as well, seems redundant:
#mkdir -p $CDDIR/EFI/BOOT
#mcopy -i $CDDIR/boot/grub/efi.img ::EFI/BOOT/bootaa64.efi $CDDIR/EFI/BOOT/bootaa64.efi
sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg

# Set a timeout for grub.
cat >> $CDDIR/boot/grub/grub.cfg <<EOF
set timeout=30
EOF

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

LAYERFS_PATH_OPT=$(add_layerfs_path_opt)

if [ "$CDIMAGE_LIVE" = 1 ]; then
    if [ "$PROJECT" = kubuntu ] || [ "$PROJECT" = kubuntu-plasma5 ]; then
	livelabel="^Start $HUMANPROJECT"
	liveparams=' maybe-ubiquity'
    else
	livelabel="^Try $HUMANPROJECT without installing"
	liveparams=
    fi
    cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "${livelabel#^}" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT quiet splash ---
	initrd	$CASPER_INITRD
}
EOF
    cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
menuentry "${livelabel#^}" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} quiet splash ---
	initrd	$CASPER_INITRD
}
EOF
    if [ "$PROJECT" != ubuntu-mid ] && [ "$PROJECT" != kubuntu ] && [ "$PROJECT" != kubuntu-plasma5 ]; then
	cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "Install $HUMANPROJECT" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity quiet splash ---
	initrd	$CASPER_INITRD
}
EOF
	cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
menuentry "Install $HUMANPROJECT" {
	linux	$CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} quiet splash ---
	initrd	$CASPER_INITRD
}
EOF
    fi
fi
if [ "$CDIMAGE_INSTALL" = 1 ]; then
  if [ "$CDIMAGE_LIVE" != 1 ]; then
    for kp in $KERNEL_PREFIXES; do
	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 >> $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
fi
# 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.
if [ "$CDIMAGE_LIVE" = 1 ]; then
    cat >> $CDDIR/boot/grub/grub.cfg <<EOF
menuentry "OEM install (for manufacturers)" {
	set gfxpayload=keep
	linux	$CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity quiet splash oem-config/enable=true ---
	initrd	$CASPER_INITRD
}
EOF
else
  for kp in $KERNEL_PREFIXES; do
    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
  done
fi
if [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
  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
    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
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
fi
rm -f $CDDIR/boot/grub/hwe-grub.cfg
fi

# th,th, thats all