blob: 7ce9131902db38701040bb28e61a3ea1d2438853 (
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
|
#!/bin/bash
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: 2009-10-08
# License: GPL v3+
set -e
# depends on grub2
# specify the first argument as the new installer image:
output="$1"
# optionally specify the second argument as a preseed file:
preseed="$2"
SUITE=${SUITE:-stable}
ARCH=${ARCH:-amd64}
DISTRO=${DISTRO:-debian}
if [ -z "$output" ] ; then
printf "you must specify a file name for the image to be built" >&2
exit 1
fi
if [ -e "$output" ] ; then
printf "file '%s' already exists" "$output" >&2
exit 1
fi
preseed_args=''
if [ "$preseed" ] ; then
if ! [ -r "$preseed" ] ; then
printf "could not read preseed file '%s'\n" "$preseed" >&2
exit 1
fi
checksum=$(md5sum - < "$preseed" | cut -f1 -d\ )
preseed_args="preseed/file=/cdrom/preseed.cfg preseed/file/checksum=$checksum"
fi
WORKDIR=$(mktemp -d)
cleanup() {
rm -rf "$WORKDIR"
}
trap cleanup EXIT
case "$DISTRO" in
debian)
BASEPATH="http://ftp.nl.debian.org/debian/dists/$SUITE/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH"
;;
ubuntu)
BASEPATH="http://archive.ubuntu.com/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH"
;;
esac
KERNEL=linux
INITRAMFS=initrd.gz
BOOTINSTRUCTIONS="
linux /$KERNEL verbose $preseed_args -- console=ttyS0,115200n8
initrd /$INITRAMFS
"
case "$ARCH" in
kfreebsd-*)
# FIXME: this discards the requested SUITE, and just pulls the
# latest d-i, because dkg is lazy
SUITE=sid
KERNEL=kfreebsd.gz
BASEPATH="http://d-i.debian.org/daily-images/$ARCH/daily/monolithic/"
BOOTINSTRUCTIONS='
# this set came from mini.iso
kfreebsd /kfreebsd.gz
kfreebsd_module /initrd.gz type=mfs_root
set kFreeBSD.vfs.root.mountfrom=ufs:/dev/md0
set kFreeBSD.hw.ata.ata_dma=0 # needed for qemu hard disk # TODO: delete
set kFreeBSD.hw.ata.atapi_dma=0 # needed for qemu cd # TODO: 1
# this set came from http://jdc.parodius.com/freebsd/pxeboot_serial_install_7.html
set kFreeBSD.comconsole_speed="115200"
set kFreeBSD.console="comconsole"
'
esac
( cd "$WORKDIR" && wget "$BASEPATH"/{$KERNEL,$INITRAMFS} )
if [ "$preseed" ]; then
cp "$preseed" "${WORKDIR}/preseed.cfg"
fi
mkdir -p "$WORKDIR/boot/grub"
cat > "$WORKDIR/boot/grub/grub.cfg" <<EOF
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal_output serial
terminal_input serial
menuentry "$SUITE d-i $ARCH (created $(date -R))" {
$BOOTINSTRUCTIONS
}
EOF
absoutput="$(pwd)/$output"
## no longer using genisoimage with grub2:
# genisoimage -R -input-charset utf-8 -b boot/grub/stage2_eltorito -no-emul-boot --boot-load-size 4 -boot-info-table "$WORKDIR"
(cd "$WORKDIR" && grub-mkrescue --output="$absoutput" .)
|