~timrchavez/live-build/lb-sg-2.x-add-suppport-for-pxz

« back to all changes in this revision

Viewing changes to helpers/binary_yaboot

  • Committer: Daniel Baumann
  • Date: 2011-03-09 18:17:15 UTC
  • Revision ID: daniel@debian.org-20110309181715-2s6s9tqa8xup5aep
Rearranging helpers scripts in source tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
# lh_binary_yaboot(1) - installs yaboot into binary
4
 
# Copyright (C) 2006-2010 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}"/live-helper.sh
14
 
 
15
 
# Setting static variables
16
 
DESCRIPTION="$(Echo 'installs yaboot into binary')"
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 [ "${LH_BOOTLOADER}" != "yaboot" ]
27
 
then
28
 
        exit 0
29
 
fi
30
 
 
31
 
Echo_message "Begin installing yaboot..."
32
 
 
33
 
# Requiring stage file
34
 
Require_stagefile .stage/config .stage/bootstrap
35
 
 
36
 
# Checking stage file
37
 
Check_stagefile .stage/binary_yaboot
38
 
 
39
 
# Checking yaboot templates
40
 
Check_templates yaboot
41
 
 
42
 
# Checking lock file
43
 
Check_lockfile .lock
44
 
 
45
 
# Creating lock file
46
 
Create_lockfile .lock
47
 
 
48
 
# Check architecture
49
 
Check_architecture powerpc ppc64
50
 
Check_crossarchitecture
51
 
 
52
 
# Checking depends
53
 
Check_package chroot/usr/lib/yaboot/yaboot yaboot
54
 
 
55
 
# Restoring cache
56
 
Restore_cache cache/packages_binary
57
 
 
58
 
# Installing depends
59
 
Install_package
60
 
 
61
 
# Local functions
62
 
Yaboot_live_entry ()
63
 
{
64
 
        LABEL="${1}"
65
 
        KERNEL="${2}"
66
 
        INITRD="${3}"
67
 
        APPEND="${4}"
68
 
 
69
 
        DIRECTORY="/$(basename ${DESTDIR_LIVE})"
70
 
 
71
 
        LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
72
 
        LINUX_LIVE="${LINUX_LIVE}\tlabel=${LABEL}\n"
73
 
        LINUX_LIVE="${LINUX_LIVE}\tinitrd=${DIRECTORY}/${INITRD}\n"
74
 
        LINUX_LIVE="${LINUX_LIVE}\tappend=\"boot=${INITFS} live-config LH_BOOTAPPEND_LIVE ${APPEND}\"\n"
75
 
        LINUX_LIVE="${LINUX_LIVE}\tinitrd-size=10240\n"
76
 
}
77
 
 
78
 
Yaboot_install_entry ()
79
 
{
80
 
        LABEL="${1}"
81
 
        KERNEL="${2}"
82
 
        INITRD="${3}"
83
 
        APPEND="${4}"
84
 
 
85
 
        DIRECTORY="/$(basename ${DESTDIR_INSTALL})"
86
 
 
87
 
        QAPPEND="quiet"
88
 
 
89
 
        for TYPE in Install Expert Rescue Auto
90
 
        do
91
 
                case "${TYPE}" in
92
 
                        Install)
93
 
                                TAPPEND="${APPEND} ${QAPPEND}"
94
 
                                ;;
95
 
 
96
 
                        Expert)
97
 
                                TAPPEND="priority=low ${APPEND}"
98
 
                                ;;
99
 
 
100
 
                        Rescue)
101
 
                                TAPPEND="rescue/enable=true ${APPEND} ${QAPPEND}"
102
 
                                ;;
103
 
 
104
 
                        Auto)
105
 
                                TAPPEND="auto=true priority=critical ${APPEND} ${QAPPEND}"
106
 
                                ;;
107
 
                esac
108
 
 
109
 
                case "${LABEL}" in
110
 
                        Text)
111
 
                                TYPE_SUFFIX=""
112
 
                                ;;
113
 
                        GUI)
114
 
                                TYPE_SUFFIX="gui"
115
 
                                ;;
116
 
                esac
117
 
 
118
 
                LINUX_INSTALL="${LINUX_INSTALL}\nimage=${DIRECTORY}/${KERNEL}\n"
119
 
                LINUX_INSTALL="${LINUX_INSTALL}\tlabel=${TYPE}${TYPE_SUFFIX}\n"
120
 
                LINUX_INSTALL="${LINUX_INSTALL}\tinitrd=${DIRECTORY}/${INITRD}\n"
121
 
                LINUX_INSTALL="${LINUX_INSTALL}\tappend=\"${TAPPEND} ${LH_BOOTAPPEND_INSTALL}\"\n"
122
 
                LINUX_INSTALL="${LINUX_INSTALL}\tinitrd-size=10240\n"
123
 
        done
124
 
}
125
 
 
126
 
case "${LH_INITRAMFS}" in
127
 
        casper)
128
 
                INITFS="casper"
129
 
                ;;
130
 
 
131
 
        live-initramfs)
132
 
                INITFS="live"
133
 
                ;;
134
 
esac
135
 
 
136
 
# Setting destination directory
137
 
case "${LH_BINARY_IMAGES}" in
138
 
        iso*)
139
 
                case "${LH_INITRAMFS}" in
140
 
                        casper)
141
 
                                DESTDIR_LIVE="binary/casper"
142
 
                                ;;
143
 
 
144
 
                        live-initramfs)
145
 
                                DESTDIR_LIVE="binary/live"
146
 
                                ;;
147
 
                esac
148
 
 
149
 
                DESTDIR_INSTALL="binary/install"
150
 
                ;;
151
 
 
152
 
        usb*|net|tar)
153
 
                Echo_error "not yet supported, aborting (FIXME)."
154
 
                exit 1
155
 
        ;;
156
 
esac
157
 
 
158
 
Check_multiarchitecture
159
 
 
160
 
# Creating directory
161
 
mkdir -p "${DESTDIR_LIVE}"
162
 
 
163
 
# Setting boot parameters
164
 
case "${LH_ENCRYPTION}" in
165
 
        ""|false)
166
 
                ;;
167
 
        *)
168
 
                LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} encryption=${LH_ENCRYPTION}"
169
 
                ;;
170
 
esac
171
 
 
172
 
if [ -n "${LH_USERNAME}" ]
173
 
then
174
 
        case "${LH_INITRAMFS}" in
175
 
                casper)
176
 
                        LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} username=${LH_USERNAME}"
177
 
                        ;;
178
 
 
179
 
                live-initramfs)
180
 
                        if [ "${LH_USERNAME}" != "user" ]
181
 
                        then
182
 
                                LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} username=${LH_USERNAME}"
183
 
                        fi
184
 
                        ;;
185
 
        esac
186
 
fi
187
 
 
188
 
if [ -n "${LH_HOSTNAME}" ]
189
 
then
190
 
        case "${LH_INITRAMFS}" in
191
 
                casper)
192
 
                        LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} hostname=${LH_HOSTNAME}"
193
 
                        ;;
194
 
 
195
 
                live-initramfs)
196
 
                        if [ "${LH_HOSTNAME}" != "debian" ]
197
 
                        then
198
 
                                LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} hostname=${LH_HOSTNAME}"
199
 
                        fi
200
 
                        ;;
201
 
        esac
202
 
fi
203
 
 
204
 
if [ "${LH_UNION_FILESYSTEM}" != "aufs" ]
205
 
then
206
 
        LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} union=${LH_UNION_FILESYSTEM}"
207
 
fi
208
 
 
209
 
if [ -n "${LH_NET_COW_PATH}" ]
210
 
then
211
 
        Echo_error "Net cow not yet supported on yaboot"
212
 
        exit 1
213
 
fi
214
 
 
215
 
if [ "${LH_EXPOSED_ROOT}" != "false" ]
216
 
then
217
 
        LH_BOOTAPPEND_LIVE="${LH_BOOTAPPEND_LIVE} exposedroot"
218
 
fi
219
 
 
220
 
LH_BOOTAPPEND_LIVE="$(echo ${LH_BOOTAPPEND_LIVE} | sed -e 's|  ||')"
221
 
 
222
 
# Parameters are listed at: linux/Documentation/kernel-parameters.txt
223
 
FAILSAFE="noapic noapm nodma nomce nolapic nomodeset nosmp vga=ofonly"
224
 
 
225
 
# Assembling kernel configuration
226
 
 
227
 
# Default entries
228
 
DEFAULT_FLAVOUR="$(echo ${LH_LINUX_FLAVOURS} | awk '{ print $1 }')"
229
 
DEFAULT_KERNEL="$(basename chroot/boot/vmlinux-*${DEFAULT_FLAVOUR})"
230
 
DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinux-||')"
231
 
 
232
 
Yaboot_live_entry "live" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}"
233
 
Yaboot_live_entry "live-failsafe" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}" "${FAILSAFE}"
234
 
 
235
 
if [ "$(echo ${LH_LINUX_FLAVOURS} | wc -w)" -gt "1" ]
236
 
then
237
 
        for KERNEL in chroot/boot/vmlinux-*
238
 
        do
239
 
                KERNEL_IMAGE="$(basename ${KERNEL})"
240
 
                KERNEL_VERSION="$(echo ${KERNEL_IMAGE} | sed -e 's|vmlinux-||')"
241
 
                INITRD="initrd.img-${KERNEL_VERSION}"
242
 
 
243
 
                Yaboot_live_entry "live-${KERNEL_VERSION}" "${KERNEL_IMAGE}" "${INITRD}"
244
 
                Yaboot_live_entry "live-${KERNEL_VERSION}-failsafe" "${KERNEL_IMAGE}" "${INITRD}" "${FAILSAFE}"
245
 
        done
246
 
fi
247
 
 
248
 
LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
249
 
 
250
 
# Assembling debian-installer configuration
251
 
if [ "${LH_DEBIAN_INSTALLER}" != "false" ]
252
 
then
253
 
        VMLINUZ_DI="vmlinuz"
254
 
        INITRD_DI="initrd.gz"
255
 
        APPEND_DI="vga=normal"
256
 
 
257
 
        VMLINUZ_GI="gtk/vmlinuz"
258
 
        INITRD_GI="gtk/initrd.gz"
259
 
        APPEND_GI="video=vesa:ywrap,mtrr vga=788"
260
 
 
261
 
        if [ -f "binary/${DESTDIR_INSTALL}/${VMLINUZ_DI}" ] && [ -f "binary/${DESTDIR_INSTALL}/${INITRD_DI}" ]
262
 
        then
263
 
                Yaboot_install_entry "Text" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
264
 
        fi
265
 
 
266
 
        if [ -f "binary/${DESTDIR_INSTALL}/${VMLINUZ_GI}" ] && [ -f "binary/${DESTDIR_INSTALL}/${INITRD_GI}" ]
267
 
        then
268
 
                Yaboot_install_entry "GUI" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
269
 
        fi
270
 
fi
271
 
 
272
 
LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
273
 
 
274
 
case "${LH_BINARY_IMAGES}" in
275
 
        iso*|usb*)
276
 
                # Copying yaboot
277
 
                mkdir -p binary/yaboot
278
 
 
279
 
                case "${LH_BUILD_WITH_CHROOT}" in
280
 
                        true)
281
 
                                cp chroot/usr/lib/yaboot/yaboot binary/yaboot
282
 
                                ;;
283
 
 
284
 
                        false)
285
 
                                cp /usr/lib/yaboot/yaboot binary/yaboot
286
 
                                ;;
287
 
                esac
288
 
 
289
 
                cp -r "${TEMPLATES}"/* binary/yaboot
290
 
 
291
 
                case "${LH_BINARY_IMAGES}" in
292
 
                        usb*)
293
 
                                mv binary/yaboot/yaboot.conf binary/yaboot/yaboot.conf.tmp
294
 
                                echo "root=/dev/ram" > binary/yaboot/yaboot.conf
295
 
                                cat binary/yaboot/yaboot.conf.tmp >> binary/yaboot/yaboot.conf
296
 
                                rm -f binary/yaboot/yaboot.conf.tmp
297
 
                                ;;
298
 
                esac
299
 
 
300
 
                # Configure yaboot templates
301
 
                sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" binary/yaboot/yaboot.conf
302
 
                sed -i -e "s|LH_BOOTAPPEND_INSTALL|${LH_BOOTAPPEND_INSTALL}|" -e "s|LH_BOOTAPPEND_LIVE|${LH_BOOTAPPEND_LIVE}|" binary/yaboot/yaboot.conf
303
 
                sed -i -e "s|LH_DATE|$(date +%Y%m%d)|" -e "s|LH_VERSION|${VERSION}|" binary/yaboot/boot.msg
304
 
                ;;
305
 
esac
306
 
 
307
 
# Saving cache
308
 
Save_cache cache/packages_binary
309
 
 
310
 
# Removing depends
311
 
Remove_package
312
 
 
313
 
# Creating stage file
314
 
Create_stagefile .stage/binary_yaboot