source: live-build/trunk/fuentes/scripts/build/lb_binary_netboot

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

add original source

  • Property svn:executable set to *
File size: 3.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 'build netboot binary image')"
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 ! In_list netboot "${LB_BINARY_IMAGES}"
28then
29        exit 0
30fi
31
32if [ "${LB_NET_TARBALL}" = "false" ]
33then
34        exit 0
35fi
36
37Echo_message "Begin building binary netboot image..."
38
39# Requiring stage file
40Require_stagefile .build/config .build/bootstrap
41
42# Checking stage file
43Check_stagefile .build/binary_netboot
44
45# Checking lock file
46Check_lockfile .lock
47
48# Creating lock file
49Create_lockfile .lock
50
51if [ "${LB_ARCHITECTURES}" = "sparc" ]
52then
53        # Checking depends
54        Check_package chroot/usr/bin/elftoaout sparc-utils
55
56        # Restoring cache
57        Restore_cache cache/packages.binary
58
59        # Installing depends
60        Install_package
61
62        # Set target and source directories
63        DESTDIR="tftpboot"
64        case "${LB_INITRAMFS}" in
65                casper)
66                        ORIGDIR="binary/casper"
67                        ;;
68
69                live-boot)
70                        ORIGDIR="binary/live"
71                        ;;
72
73                *)
74                        ORIGDIR="binary/boot"
75                        ;;
76        esac
77
78        # Find defaults
79        DEFAULT_FLAVOUR="$(echo ${LB_LINUX_FLAVOURS} | awk '{ print $1 }')"
80        DEFAULT_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
81        DEFAULT_INITRD="initrd.img-$(echo ${DEFAULT_KERNEL} | sed -e 's|vmlinuz-||')"
82        DEFAULT_MAP="$(echo chroot/boot/System.map-*${DEFAULT_FLAVOUR})"
83
84        gzip -cd ${ORIGDIR}/${DEFAULT_KERNEL} > kernel.tmp
85
86        mkdir -p ${DESTDIR}
87        rm -f ${DESTDIR}/boot.img
88        elftoaout -o ${DESTDIR}/boot.img kernel.tmp
89
90        case "${DEFAULT_FLAVOUR}" in
91                sparc32)
92                        piggyback ${DESTDIR}/boot.img ${DEFAULT_MAP} ${ORIGDIR}/${DEFAULT_INITRD}
93                        ;;
94                sparc64)
95                        piggyback64 ${DESTDIR}/boot.img ${DEFAULT_MAP} ${ORIGDIR}/${DEFAULT_INITRD}
96                        ;;
97                *)
98                        Echo_error "Invalid default kernel flavour for sparc \"%s\"" "${DEFAULT_FLAVOUR}"
99                        exit 1;
100                        ;;
101        esac
102
103        # Pad boot.img
104        REMAINDER=$((( 4 - $(stat -c %s ${DESTDIR}/boot.img) % 4 ) % 4))
105        dd if=/dev/zero bs=1 count=${REMAINDER} >> ${DESTDIR}/boot.img
106
107        # No need for kernel and initrd images in the binary
108        rm -f ${ORIGDIR}/vmlinuz-*
109        rm -f ${ORIGDIR}/initrd.img-*
110
111        # Clean temporaries
112        rm -f kernel.tmp
113
114        # Saving cache
115        Save_cache cache/packages.binary
116
117        # Removing depends
118        Remove_package
119fi
120
121# Remove old binary
122rm -f binary.netboot.tar binary.netboot.tar.gz binary.netboot.tar.bz2 binary.netboot.tar.xz binary.netboot.tar.xz
123
124# Creating image file
125ROOT_DIR=$(basename ${LB_NET_ROOT_PATH})
126
127if [ "${ROOT_DIR}" = "chroot" ]
128then
129        mv chroot chroot.tmp
130fi
131
132if [ "${ROOT_DIR}" != "binary" ]
133then
134        mv binary ${ROOT_DIR}
135fi
136
137mkdir binary.tmp
138mv ${ROOT_DIR} tftpboot binary.tmp
139cd binary.tmp
140
141# Moving kernel and initrd image arround
142mkdir tftpboot/live
143mv */live/vmlinuz* */live/initrd* tftpboot/live
144
145tar cf ../binary.netboot.tar *
146
147case "${LB_COMPRESSION}" in
148        bzip2)
149                bzip2 ${BZIP2_OPTIONS} ../binary.netboot.tar
150                ;;
151
152        gzip)
153                gzip ${GZIP_OPTIONS} ../binary.netboot.tar
154                ;;
155
156        lzip)
157                lzip ${LZIP_OPTIONS} ../binary.netboot.tar
158                ;;
159
160        xz)
161                xz ${XZ_OPTIONS} ../binary.netboot.tar
162                ;;
163
164        none)
165                ;;
166esac
167
168mv * ../
169cd "${OLDPWD}"
170rmdir binary.tmp
171
172if [ "${ROOT_DIR}" != "binary" ]
173then
174        mv ${ROOT_DIR} binary
175fi
176
177if [ "${ROOT_DIR}" = "chroot" ]
178then
179        mv chroot.tmp chroot
180fi
181
182# Creating stage file
183Create_stagefile .build/binary_netboot
Note: See TracBrowser for help on using the repository browser.