~asac/live-build/virtual-hdd-mtab-hack

« back to all changes in this revision

Viewing changes to helpers/lh_binary_iso

  • Committer: Daniel Baumann
  • Date: 2009-11-22 13:38:00 UTC
  • Revision ID: git-v1:a62f12110b19a52a58d7eae871012202cfa16055
Renaming categories to archive areas (Closes: #519690).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# lh_binary_iso(1) - build iso binary image
 
4
# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org>
 
5
#
 
6
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 
7
# This is free software, and you are welcome to redistribute it
 
8
# under certain conditions; see COPYING for details.
 
9
 
 
10
set -e
 
11
 
 
12
# Including common functions
 
13
. "${LH_BASE:-/usr/share/live-helper}"/functions.sh
 
14
 
 
15
# Setting static variables
 
16
DESCRIPTION="$(Echo 'build iso binary image')"
 
17
HELP=""
 
18
USAGE="${PROGRAM} [--force]"
 
19
 
 
20
Arguments "${@}"
 
21
 
 
22
# Reading configuration files
 
23
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
 
24
Set_defaults
 
25
 
 
26
if ! In_list iso "${LH_BINARY_IMAGES}"
 
27
then
 
28
        exit 0
 
29
fi
 
30
 
 
31
Echo_message "Begin building binary iso image..."
 
32
 
 
33
# Requiring stage file
 
34
Require_stagefile .stage/config .stage/bootstrap
 
35
 
 
36
# Checking stage file
 
37
Check_stagefile .stage/binary_iso
 
38
 
 
39
# Checking lock file
 
40
Check_lockfile .lock
 
41
 
 
42
# Creating lock file
 
43
Create_lockfile .lock
 
44
 
 
45
# Checking depends
 
46
Check_package chroot/usr/bin/genisoimage genisoimage
 
47
 
 
48
# Restoring cache
 
49
Restore_cache cache/packages_binary
 
50
 
 
51
# Installing depends
 
52
Install_package
 
53
 
 
54
# Remove old iso image
 
55
if [ -f binary.iso ]
 
56
then
 
57
        rm -f binary.iso
 
58
fi
 
59
 
 
60
# Handle genisoimage generic options
 
61
GENISOIMAGE_OPTIONS="-J -l -cache-inodes -allow-multidot"
 
62
 
 
63
# Handle genisoimage live-helper specific options
 
64
if [ "${_QUIET}" = "enabled" ]
 
65
then
 
66
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -quiet"
 
67
fi
 
68
 
 
69
if [ "${_VERBOSE}" = "enabled" ]
 
70
then
 
71
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -v"
 
72
fi
 
73
 
 
74
if [ -n "${LH_ISO_APPLICATION}" ] && [ "${LH_ISO_APPLICATION}" != "none" ]
 
75
then
 
76
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -A \"${LH_ISO_APPLICATION}\""
 
77
fi
 
78
 
 
79
if [ -n "${LH_ISO_PREPARER}" ] && [ "${LH_ISO_PREPARER}" != "none" ]
 
80
then
 
81
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -p \"${LH_ISO_PREPARER}\""
 
82
fi
 
83
 
 
84
if [ -n "${LH_ISO_PUBLISHER}" ] && [ "${LH_ISO_PUBLISHER}" != "none" ]
 
85
then
 
86
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -publisher \"${LH_ISO_PUBLISHER}\""
 
87
fi
 
88
 
 
89
if [ -n "${LH_ISO_VOLUME}" ] && [ "${LH_ISO_VOLUME}" != "none" ]
 
90
then
 
91
        GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -V \"${LH_ISO_VOLUME}\""
 
92
fi
 
93
 
 
94
# Handle genisoimage architecture specific options
 
95
case "${LH_BOOTLOADER}" in
 
96
        grub)
 
97
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
 
98
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b boot/grub/stage2_eltorito"
 
99
                GENISOIMAGE_EXCLUDE="boot/grub/stage2_eltorito"
 
100
                ;;
 
101
 
 
102
        grub2)
 
103
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
 
104
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b boot/grub/grub_eltorito -J"
 
105
                GENISOIMAGE_EXCLUDE="boot/grub/grub_eltorito"
 
106
                ;;
 
107
 
 
108
        silo)
 
109
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -G boot/isofs.b -B ..."
 
110
                GENISOIMAGE_EXCLUDE="boot/isofs.b"
 
111
                ;;
 
112
 
 
113
        syslinux)
 
114
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
 
115
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b isolinux/isolinux.bin -c isolinux/boot.cat"
 
116
                GENISOIMAGE_EXCLUDE="isolinux/isolinux.bin"
 
117
                ;;
 
118
 
 
119
        yaboot)
 
120
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r --iso-level 2 --netatalk -hfs -probe -map"
 
121
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} binary/yaboot/hfs.map --chrp-boot -part -no-desktop"
 
122
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -hfs-bless binary/yaboot -hfs-volid Debian/Live_powerpc"
 
123
                GENISOIMAGE_EXCLUDE="yaboot/hfs.map"
 
124
                ;;
 
125
 
 
126
        *)
 
127
                Echo_warning "Bootloader on your architecture not yet supported by live-helper."
 
128
                Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)."
 
129
                sleep 5
 
130
                ;;
 
131
esac
 
132
 
 
133
if In_list "stripped minimal" "${LH_PACKAGES_LISTS}"
 
134
then
 
135
        if [ "${LH_DEBIAN_INSTALLER}" != "live" ]
 
136
        then
 
137
                GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -m ${GENISOIMAGE_EXCLUDE}"
 
138
        fi
 
139
fi
 
140
 
 
141
if [ "${LH_BOOTLOADER}" = "grub2" ]
 
142
then
 
143
 
 
144
cat > binary.sh << EOF
 
145
#!/bin/sh
 
146
 
 
147
input_dir=/usr/lib/grub/i386-pc
 
148
 
 
149
# build core.img
 
150
core_img=\$(mktemp)
 
151
grub-mkimage -d \${input_dir} -o \${core_img} biosdisk iso9660
 
152
 
 
153
# build grub_eltorito image
 
154
cat \${input_dir}/cdboot.img \${core_img} > binary/boot/grub/grub_eltorito
 
155
 
 
156
rm -f \${core_img}
 
157
 
 
158
for file in \${input_dir}/*.mod \${input_dir}/efiemu??.o \
 
159
        \${input_dir}/command.lst \${input_dir}/moddep.lst \${input_dir}/fs.lst \
 
160
        \${input_dir}/handler.lst \${input_dir}/parttool.lst
 
161
do
 
162
        if test -f "\$file"
 
163
        then
 
164
                cp -f "\$file" binary/boot/grub
 
165
        fi
 
166
done
 
167
EOF
 
168
 
 
169
else
 
170
        echo "#!/bin/sh" > binary.sh
 
171
fi
 
172
 
 
173
cat >> binary.sh << EOF
 
174
 
 
175
genisoimage ${GENISOIMAGE_OPTIONS} -o binary.iso binary
 
176
EOF
 
177
 
 
178
case "${LH_CHROOT_BUILD}" in
 
179
        enabled)
 
180
                # Moving image
 
181
                mv binary.sh chroot
 
182
                mv binary chroot
 
183
 
 
184
                Chroot chroot "sh binary.sh"
 
185
 
 
186
                # Move image
 
187
                mv chroot/binary chroot/binary.iso ./
 
188
                rm -f chroot/binary.sh
 
189
                ;;
 
190
 
 
191
        disabled)
 
192
                sh binary.sh
 
193
                rm -f binary.sh
 
194
                ;;
 
195
esac
 
196
 
 
197
# Saving cache
 
198
Save_cache cache/packages_binary
 
199
 
 
200
# Removing depends
 
201
Remove_package
 
202
 
 
203
# Creating stage file
 
204
Create_stagefile .stage/binary_iso