source: live-build/trunk/fuentes/scripts/build/lb_binary_yaboot @ 900

Last change on this file since 900 was 900, checked in by kbut, 3 years ago

add original source

  • Property svn:executable set to *
File size: 6.4 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program 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
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16# Setting static variables
17DESCRIPTION="$(Echo 'installs yaboot into binary')"
18HELP=""
19USAGE="${PROGRAM} [--force]"
20
21Arguments "${@}"
22
23# Reading configuration files
24Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25Set_defaults
26
27if [ "${LB_BOOTLOADER}" != "yaboot" ]
28then
29        exit 0
30fi
31
32Echo_message "Begin installing yaboot..."
33
34# Requiring stage file
35Require_stagefile .build/config .build/bootstrap
36
37# Checking stage file
38Check_stagefile .build/binary_yaboot
39
40# Checking yaboot templates
41Check_templates yaboot
42
43# Checking lock file
44Check_lockfile .lock
45
46# Creating lock file
47Create_lockfile .lock
48
49# Check architecture
50Check_architectures powerpc ppc64
51Check_crossarchitectures
52
53# Checking depends
54Check_package chroot/usr/lib/yaboot/yaboot yaboot
55
56# Restoring cache
57Restore_cache cache/packages.binary
58
59# Installing depends
60Install_package
61
62# Local functions
63Yaboot_live_entry ()
64{
65        LABEL="${1}"
66        KERNEL="${2}"
67        INITRD="${3}"
68        APPEND="${4}"
69
70        DIRECTORY="/$(basename ${DESTDIR_LIVE})"
71
72        LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
73        LINUX_LIVE="${LINUX_LIVE}\tlabel=${LABEL}\n"
74        LINUX_LIVE="${LINUX_LIVE}\tinitrd=${DIRECTORY}/${INITRD}\n"
75        LINUX_LIVE="${LINUX_LIVE}\tappend=\"${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
76        LINUX_LIVE="${LINUX_LIVE}\tinitrd-size=10240\n"
77}
78
79Yaboot_install_entry ()
80{
81        LABEL="${1}"
82        KERNEL="${2}"
83        INITRD="${3}"
84        APPEND="${4}"
85
86        DIRECTORY="/$(basename ${DESTDIR_INSTALL})"
87
88        QAPPEND="quiet"
89
90        for TYPE in Install Expert Rescue Auto
91        do
92                case "${TYPE}" in
93                        Install)
94                                TAPPEND="${APPEND} ${QAPPEND}"
95                                ;;
96
97                        Expert)
98                                TAPPEND="priority=low ${APPEND}"
99                                ;;
100
101                        Rescue)
102                                TAPPEND="rescue/enable=true ${APPEND} ${QAPPEND}"
103                                ;;
104
105                        Auto)
106                                TAPPEND="auto=true priority=critical ${APPEND} ${QAPPEND}"
107                                ;;
108                esac
109
110                case "${LABEL}" in
111                        Text)
112                                TYPE_SUFFIX=""
113                                ;;
114                        GUI)
115                                TYPE_SUFFIX="gui"
116                                ;;
117                esac
118
119                LINUX_INSTALL="${LINUX_INSTALL}\nimage=${DIRECTORY}/${KERNEL}\n"
120                LINUX_INSTALL="${LINUX_INSTALL}\tlabel=${TYPE}${TYPE_SUFFIX}\n"
121                LINUX_INSTALL="${LINUX_INSTALL}\tinitrd=${DIRECTORY}/${INITRD}\n"
122                LINUX_INSTALL="${LINUX_INSTALL}\tappend=\"${TAPPEND} ${LB_BOOTAPPEND_INSTALL}\"\n"
123                LINUX_INSTALL="${LINUX_INSTALL}\tinitrd-size=10240\n"
124        done
125}
126
127case "${LB_INITRAMFS}" in
128        casper)
129                INITFS="casper"
130                ;;
131
132        live-boot)
133                INITFS="live"
134                ;;
135
136        *)
137                INITFS=""
138                ;;
139esac
140
141# Setting destination directory
142case "${LB_BINARY_IMAGES}" in
143        iso*)
144                case "${LB_INITRAMFS}" in
145                        casper)
146                                DESTDIR_LIVE="binary/casper"
147                                ;;
148
149                        live-boot)
150                                DESTDIR_LIVE="binary/live"
151                                ;;
152
153                        *)
154                                DESTDIR_LIVE="binary/boot"
155                                ;;
156                esac
157
158                DESTDIR_INSTALL="binary/install"
159                ;;
160
161        hdd*|netboot|tar)
162                Echo_error "not yet supported, aborting (FIXME)."
163                exit 1
164        ;;
165esac
166
167Check_multiarchitectures
168
169# Creating directory
170mkdir -p "${DESTDIR_LIVE}"
171
172# Setting boot parameters
173if [ "${LB_UNION_FILESYSTEM}" != "aufs" ]
174then
175        LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}"
176fi
177
178if [ -n "${LB_NET_COW_PATH}" ]
179then
180        Echo_error "Net cow not yet supported on yaboot"
181        exit 1
182fi
183
184if [ "${LB_EXPOSED_ROOT}" != "false" ]
185then
186        LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} exposedroot"
187fi
188
189LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's|  ||')"
190
191# Assembling kernel configuration
192
193# Default entries
194DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
195DEFAULT_KERNEL="$(basename chroot/boot/vmlinux-*${DEFAULT_FLAVOUR})"
196DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinux-||')"
197
198Yaboot_live_entry "live" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}"
199
200if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]
201then
202        Yaboot_live_entry "live-failsafe" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
203fi
204
205if [ "$(echo ${LB_LINUX_FLAVOURS} | wc -w)" -gt "1" ]
206then
207        for KERNEL in chroot/boot/vmlinux-*
208        do
209                KERNEL_IMAGE="$(basename ${KERNEL})"
210                KERNEL_VERSION="$(echo ${KERNEL_IMAGE} | sed -e 's|vmlinux-||')"
211                INITRD="initrd.img-${KERNEL_VERSION}"
212
213                Yaboot_live_entry "live-${KERNEL_VERSION}" "${KERNEL_IMAGE}" "${INITRD}"
214                Yaboot_live_entry "live-${KERNEL_VERSION}-failsafe" "${KERNEL_IMAGE}" "${INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
215        done
216fi
217
218LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
219
220# Assembling debian-installer configuration
221if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
222then
223        VMLINUZ_DI="vmlinuz"
224        INITRD_DI="initrd.gz"
225        APPEND_DI="vga=normal"
226
227        VMLINUZ_GI="gtk/vmlinuz"
228        INITRD_GI="gtk/initrd.gz"
229        APPEND_GI="video=vesa:ywrap,mtrr vga=788"
230
231        if [ -f "binary/${DESTDIR_INSTALL}/${VMLINUZ_DI}" ] && [ -f "binary/${DESTDIR_INSTALL}/${INITRD_DI}" ]
232        then
233                Yaboot_install_entry "Text" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
234        fi
235
236        if [ -f "binary/${DESTDIR_INSTALL}/${VMLINUZ_GI}" ] && [ -f "binary/${DESTDIR_INSTALL}/${INITRD_GI}" ]
237        then
238                Yaboot_install_entry "GUI" "${VMLINUZ_GI}" "${INITRD_GI}" "${APPEND_GI}"
239        fi
240fi
241
242LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
243
244case "${LB_BINARY_IMAGES}" in
245        iso*|hdd*)
246                # Copying yaboot
247                mkdir -p binary/yaboot
248
249                case "${LB_BUILD_WITH_CHROOT}" in
250                        true)
251                                cp chroot/usr/lib/yaboot/yaboot binary/yaboot
252                                ;;
253
254                        false)
255                                cp /usr/lib/yaboot/yaboot binary/yaboot
256                                ;;
257                esac
258
259                cp -r "${TEMPLATES}"/* binary/yaboot
260
261                case "${LB_BINARY_IMAGES}" in
262                        hdd*)
263                                mv binary/yaboot/yaboot.conf binary/yaboot/yaboot.conf.tmp
264                                echo "root=/dev/ram" > binary/yaboot/yaboot.conf
265                                cat binary/yaboot/yaboot.conf.tmp >> binary/yaboot/yaboot.conf
266                                rm -f binary/yaboot/yaboot.conf.tmp
267                                ;;
268                esac
269
270                # Configure yaboot templates
271                sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" binary/yaboot/yaboot.conf
272                sed -i -e "s|LB_BOOTAPPEND_INSTALL|${LB_BOOTAPPEND_INSTALL}|" -e "s|LB_BOOTAPPEND_LIVE|${LB_BOOTAPPEND_LIVE}|" binary/yaboot/yaboot.conf
273                sed -i -e "s|LB_DATE|$(date +%Y%m%d)|" -e "s|LB_VERSION|${VERSION}|" binary/yaboot/boot.msg
274                ;;
275esac
276
277# Saving cache
278Save_cache cache/packages.binary
279
280# Removing depends
281Remove_package
282
283# Creating stage file
284Create_stagefile .build/binary_yaboot
Note: See TracBrowser for help on using the repository browser.