1#!/bin/sh
2
3##########################################################################
4# Copyright (c) 2009, ETH Zurich.
5# All rights reserved.
6#
7# This file is distributed under the terms in the attached LICENSE file.
8# If you do not find this file, copies can be found by writing to:
9# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
10##########################################################################
11
12#
13# Create a list of modules and their arguments. We use this list
14# as the bootscript. It's a cleaned up version of menu.lst. The
15# files named here are used to create a cpio archive that are in
16# the same order as the script. This allows:
17#
18#   1) Writing script lines with 1:1 correspondance with files
19#   in archive.
20#
21#   2) Checking all the files specified actually exist rather than
22#   discovering this at boot.
23#
24# At some point the kernel should probably go into the generated
25# archive and the bootloader do just enough to open the archive
26# and setup the kernel.
27#
28
29if [ $# -ne 2 ] ; then
30   echo "Usage: $0 arm/menu.lst <cpio_file>"
31   exit 1
32fi
33
34BOOTSCRIPT=menu.lst.modules
35
36echo ${BOOTSCRIPT} > ${BOOTSCRIPT}
37
38cat $1 | \
39sed -n -e 's/#.*//' \
40 -e 's/[ \t]\+/ /g' \
41 -e 's/ $//;s/^ //' \
42 -e '/^\(module\|modulenounzip\)/ { s@ *\(module\|modulenounzip\) /?*\(.*\)@./\2@ ; p }' >>${BOOTSCRIPT}
43
44sed -e 's/ .*//' ${BOOTSCRIPT} | cpio -o -H crc > $2
45if [ $? -ne 0 ] ; then
46    cat <<EOF
47
48Failed to create $2.
49
50Check files specified in $1 are being built in symbolic_target.mk.
51
52EOF
53
54    exit 1
55fi
56