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

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

add original source

  • Property svn:executable set to *
File size: 5.7 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 silo 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}" != "silo" ]
28then
29        exit 0
30fi
31
32# Check image type
33case "${LB_BINARY_IMAGES}" in
34        iso*|hdd*|tar)
35                ;;
36
37        netboot)
38                # silo not required for sparc netbooting
39                exit 0
40                ;;
41esac
42
43Echo_message "Begin installing silo..."
44
45# Requiring stage file
46Require_stagefile .build/config .build/bootstrap
47
48# Checking stage file
49Check_stagefile .build/binary_silo
50
51# Checking silo templates
52Check_templates silo
53
54# Checking lock file
55Check_lockfile .lock
56
57# Creating lock file
58Create_lockfile .lock
59
60# Check architecture
61Check_architectures sparc
62
63# Checking depends
64Check_package chroot/usr/sbin/silo silo
65
66# Restoring cache
67Restore_cache cache/packages.binary
68
69# Installing depends
70Install_package
71
72# Local functions
73Silo_live_entry ()
74{
75        LABEL="${1}"
76        KERNEL="${2}"
77        INITRD="${3}"
78        APPEND="${4}"
79
80        DIRECTORY="/$(basename ${DESTDIR_LIVE})"
81
82        LINUX_LIVE="${LINUX_LIVE}\nimage=${DIRECTORY}/${KERNEL}\n"
83        LINUX_LIVE="${LINUX_LIVE}\t  label=${LABEL}\n"
84        LINUX_LIVE="${LINUX_LIVE}\t  initrd=${DIRECTORY}/${INITRD}\n"
85        LINUX_LIVE="${LINUX_LIVE}\t  append=\"${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}\"\n"
86}
87
88Silo_install_entry ()
89{
90        LABEL="${1}"
91        KERNEL="${2}"
92        INITRD="${3}"
93        APPEND="${4}"
94
95        DIRECTORY="/$(basename ${DESTDIR_INSTALL})"
96
97        if [ "${LABEL}" != "rescue" ] && [ "${LABEL}" != "rescuegui" ]
98        then
99                APPEND="${APPEND} quiet"
100        fi
101
102        LINUX_INSTALL="${LINUX_INSTALL}\nimage=${DIRECTORY}/${KERNEL}\n"
103        LINUX_INSTALL="${LINUX_INSTALL}\t  label=${LABEL}\n"
104        LINUX_INSTALL="${LINUX_INSTALL}\t  initrd=${DIRECTORY}/${INITRD}\n"
105        LINUX_INSTALL="${LINUX_INSTALL}\t  append=\"LB_BOOTAPPEND_LIVE ${APPEND} LB_BOOTAPPEND_INSTALL\"\n"
106}
107
108# Setting destination directories
109DESTDIR_INSTALL="binary/install"
110case "${LB_INITRAMFS}" in
111        casper)
112                INITFS="casper"
113                DESTDIR_LIVE="binary/casper"
114                ;;
115
116        live-boot)
117                INITFS="live"
118                DESTDIR_LIVE="binary/live"
119                ;;
120
121        *)
122                INITFS=""
123                DESTDIR_LIVE="binary/boot"
124                ;;
125esac
126
127# Creating directory
128mkdir -p "${DESTDIR_LIVE}"
129
130# Setting boot parameters
131if [ "${LB_UNION_FILESYSTEM}" != "aufs" ]
132then
133        LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} union=${LB_UNION_FILESYSTEM}"
134fi
135
136if [ -n "${LB_NET_COW_PATH}" ]
137then
138        Echo_error "Net cow not supported on silo"
139        exit 1
140fi
141
142if [ "${LB_EXPOSED_ROOT}" != "false" ]
143then
144        LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE} exposedroot"
145fi
146
147LB_BOOTAPPEND_LIVE="$(echo ${LB_BOOTAPPEND_LIVE} | sed -e 's|  ||')"
148
149# Assembling kernel configuration
150
151# Default entries
152DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
153DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
154DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
155
156Silo_live_entry "live" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}"
157
158if [ "${LB_BOOTAPPEND_FAILSAFE}" != "none" ]
159then
160        Silo_live_entry "live-failsafe" "${DEFAULT_KERNEL}" "${DEFAULT_INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
161fi
162
163if [ "$(echo ${LB_LINUX_FLAVOURS} | wc -w)" -gt "1" ]
164then
165        for KERNEL in chroot/boot/vmlinuz-*
166        do
167                KERNEL_IMAGE="$(basename ${KERNEL})"
168                KERNEL_VERSION="$(echo ${KERNEL_IMAGE} | sed -e 's|vmlinuz-||')"
169                INITRD="initrd.img-${KERNEL_VERSION}"
170
171                Silo_live_entry "live-${KERNEL_VERSION}" "${KERNEL_IMAGE}" "${INITRD}"
172                Silo_live_entry "live-${KERNEL_VERSION}-failsafe" "${KERNEL_IMAGE}" "${INITRD}" "${LB_BOOTAPPEND_FAILSAFE}"
173        done
174fi
175
176LINUX_LIVE="$(/bin/echo ${LINUX_LIVE} | sed -e 's|binary||g' -e 's|//|/|g')"
177
178# Assembling debian-installer configuration
179if [ "${LB_DEBIAN_INSTALLER}" != "false" ]
180then
181        VMLINUZ_DI="vmlinuz"
182        INITRD_DI="initrd.gz"
183        APPEND_DI="vga=normal"
184
185        Silo_install_entry "linux" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
186        Silo_install_entry "install" "${VMLINUZ_DI}" "${INITRD_DI}" "${APPEND_DI}"
187        Silo_install_entry "expert" "${VMLINUZ_DI}" "${INITRD_DI}" "priority=low ${APPEND_DI}"
188        Silo_install_entry "rescue" "${VMLINUZ_DI}" "${INITRD_DI}" "rescue/enable=true ${APPEND_DI}"
189        Silo_install_entry "auto" "${VMLINUZ_DI}" "${INITRD_DI}" "auto=true priority=critical ${APPEND_DI}"
190fi
191
192LINUX_INSTALL="$(/bin/echo ${LINUX_INSTALL} | sed -e 's|binary||g' -e 's|//|/|g')"
193
194case "${LB_BINARY_IMAGES}" in
195        iso*|hdd*)
196                # Copying silo
197                mkdir -p binary/boot
198
199                case "${LB_BUILD_WITH_CHROOT}" in
200                        true)
201                                cp chroot/boot/second.b binary/boot
202                                ;;
203
204                        false)
205                                cp /boot/second.b binary/boot
206                                ;;
207                esac
208
209                cp -r "${TEMPLATES}"/* binary/boot
210
211                if [ "${LB_DEBIAN_INSTALLER}" = "false" ]
212                then
213                        rm -f binary/boot/debian.txt.install
214                else
215                        mv binary/boot/debian.txt.install binary/boot/debian.txt
216                fi
217
218                # Configure silo templates
219                sed -i -e "s|LINUX_LIVE|${LINUX_LIVE}|" \
220                       -e "s|LINUX_INSTALL|${LINUX_INSTALL}|" \
221                       binary/boot/silo.conf
222                sed -i -e "s|LB_BOOTAPPEND_INSTALL|${LB_BOOTAPPEND_INSTALL}|" \
223                       -e "s|LB_BOOTAPPEND_LIVE|${LB_BOOTAPPEND_LIVE}|" \
224                       binary/boot/silo.conf
225                sed -i -e "s|LB_DATE|$(date +%Y%m%d)|" \
226                       -e "s|LB_VERSION|${VERSION}|" \
227                       -e "s|LB_DISTRIBUTION|${LB_DISTRIBUTION}|" \
228                       binary/boot/debian.txt
229                ;;
230esac
231
232# Saving cache
233Save_cache cache/packages.binary
234
235# Removing depends
236Remove_package
237
238# Creating stage file
239Create_stagefile .build/binary_silo
Note: See TracBrowser for help on using the repository browser.