File: boot-hurd-common

package info (click to toggle)
debian-cd 3.2.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,848 kB
  • sloc: sh: 6,129; perl: 4,129; makefile: 413
file content (169 lines) | stat: -rw-r--r-- 5,179 bytes parent folder | download | duplicates (6)
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
# This script gets sourced from boot-hurd-i386.
#
# Do install stuff for hurd, 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
. $BASEDIR/tools/boot/$DI_CODENAME/x86-desktop.sh

set -e
#set -x

# Have we been told to use just one boot method? If none listed,
# assume all are desired. Order also matters. Possible values are
# "BIOS", "EFI" and "BIOS EFI". We'll also accept "EFI BIOS" for
# completeness, but we will switch the order.
if [ "$BOOT_METHODS"x = ""x ] \
    || [ "$BOOT_METHODS"x = "BIOS EFI"x ] \
    || [ "$BOOT_METHODS"x = "EFI BIOS"x ] ; then
    BOOT_BIOS=1
    BOOT_EFI=2
elif [ "$BOOT_METHODS"x = "BIOS"x ] ; then
    BOOT_BIOS=1
    BOOT_EFI=0
elif [ "$BOOT_METHODS"x = "EFI"x ] ; then
    BOOT_EFI=1
    BOOT_BIOS=0
else
    echo "ERROR: Unrecognized boot method choice $BOOT_METHODS"
    exit 1
fi

N=$1
CDDIR=$2
INSTALLDIR="install"

# Common options for all disks
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-l"

# Exit if this is not CD#1/DVD#1
if [ $N != "1" ]; then
    exit 0
fi

if [ "$DI_WWW_HOME" = "default" ]; then
    DI_WWW_HOME="https://d-i.debian.org/daily-images/hurd-i386/daily/"
    try_di_image_cache
else
    DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,")
fi

case "$MKISOFS" in
    *xorriso*)
        XORRISO_VER=$(xorriso_version)
        ;;
    *)
	echo "ERROR: debian-cd now depends on xorriso for making x86 bootable CDs."
	exit 1;
	;;
esac

cd $CDDIR/..

# Download boot images.
BOOT_IMAGES="cdrom/debian-cd_info.tar.gz cdrom/gnumach.gz cdrom/initrd.gz cdrom/gtk/initrd.gz cdrom/ext2fs.static cdrom/exec.static"

for image in $BOOT_IMAGES; do
       if [ ! -e "$image" ]; then
               dir=$(dirname $image)
               mkdir -p $dir
               if [ ! "$DI_WWW_HOME" ];then
                       if [ ! "$DI_DIR" ];then
                               DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
                       fi
                       cp "$DI_DIR/$image" $image
               else
                       $WGET "$DI_WWW_HOME/$image" -O $image
               fi
       fi
done

# Install kernel and initrd
mkdir -p $CDDIR/boot/kernel/
mkdir -p $CDDIR/boot/gtk/
cp "cdrom/gnumach.gz" "$CDDIR/boot/kernel/gnumach.gz"
cp "cdrom/initrd.gz" "$CDDIR/boot/initrd.gz"
cp "cdrom/gtk/initrd.gz" "$CDDIR/boot/gtk/initrd.gz"
cp "cdrom/ext2fs.static" "$CDDIR/boot/kernel/ext2fs.static"
cp "cdrom/exec.static" "$CDDIR/boot/kernel/exec.static"

# Install bootloader
mkdir -p boot$N
tar -C boot$N -zxf cdrom/debian-cd_info.tar.gz
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-b boot/grub/grub_eltorito"
[ -f boot$N/boot/grub/grub_embed ] && add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "--embedded-boot boot$N/boot/grub/grub_embed"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-c boot/boot.cat"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-no-emul-boot"

bls=4 # Specify 4 for BIOS boot, don't calculate it
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-load-size $bls"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-boot-info-table"
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-cache-inodes"
add_mkisofs_opt $CDDIR/../$N.mkisofs_dirs "boot$N"

# Add autorun
if [ -f $CDDIR/README.html ]; then
       todos > $CDDIR/autorun.inf <<EOF
[autorun]
open=autorun.bat
label=Install Debian GNU/Hurd
EOF
       todos > $CDDIR/autorun.bat <<EOF
@echo Starting "README.html"...
@start README.html
@exit
EOF
fi

# Cleanup
rm -rf cdrom

if [ $BOOT_EFI -ne 0 ] ; then
    echo "  Adding EFI boot code for $ARCH on CD$N"

    # Move GRUB files to the right place.
    mkdir -p $CDDIR/EFI/boot
    mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI
    mkdir -p $CDDIR/boot/grub
    mv boot$N/grub/* $CDDIR/boot/grub/
    rmdir boot$N/grub

    change_grub_cfg_uuid $CDDIR

    # Stuff the EFI boot files into a FAT filesystem, making it as
    # small as possible. We end up re-packing like this in case we're
    # making a multi-arch image

    # First, work out how many blocks we need
    blocks=$(calculate_efi_image_size $CDDIR)

    # Now make a new image to contain the files
    rm -f $CDDIR/boot/grub/efi.img
    mkfs.msdos --invariant -v -i deb00001 -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null

    # And copy them into place
    mmd -i "$CDDIR/boot/grub/efi.img" ::efi
    mcopy -o -s -i "$CDDIR/boot/grub/efi.img" $CDDIR/EFI/* \
        "::efi"

    if [ $BOOT_EFI = 2 ] ; then
	# We're being added alongside (after) a BIOS boot record. Tell
	# xorriso to create a (secondary) ElTorito boot record for the
	# EFI bootloader. Otherwise, xorriso will create it as the
	# primary.
        add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-eltorito-alt-boot"
    fi

    add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
    add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
else
    echo "  No EFI boot code for $ARCH on CD$N"
fi

# done