2012-11-09 18:18:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# XXX: Only portions of this are the NTT original, much is now HP work
|
|
|
|
|
|
|
|
# Copyright (c) 2012 NTT DOCOMO, INC.
|
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
SCRIPTNAME=$(basename $0)
|
2013-01-22 01:35:31 +00:00
|
|
|
SCRIPT_HOME=$(dirname $0)
|
2012-11-09 18:18:08 +00:00
|
|
|
export _DIR=$(dirname $0)
|
|
|
|
export _LIB=${_DIR}/../lib
|
|
|
|
source $_LIB/die
|
|
|
|
|
|
|
|
function show_options () {
|
|
|
|
echo "Options:"
|
|
|
|
echo " -m PATH -- Path to find lib/modules. Default /"
|
|
|
|
echo " -k VERSION -- Kernel version. Default $(uname -r)"
|
|
|
|
echo " -h -- This help"
|
|
|
|
echo " -o FILENAME -- Output file"
|
|
|
|
echo " -x -- turn on tracing"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
TEMP=$(getopt -o m:k:ho:x -n $SCRIPTNAME -- "$@")
|
|
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
|
|
eval set -- "$TEMP"
|
|
|
|
|
|
|
|
while true ; do
|
|
|
|
case "$1" in
|
|
|
|
-m) export MODULE_ROOT=$2; shift 2 ;;
|
|
|
|
-k) export KERNEL_VERSION=$2; shift 2 ;;
|
|
|
|
-o) export IMAGE_NAME=$2; shift 2 ;;
|
|
|
|
-h) show_options;;
|
|
|
|
-x) shift; set -x;;
|
|
|
|
--) shift ; break ;;
|
|
|
|
*) echo "Internal error!" ; exit 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
2012-11-30 20:47:57 +00:00
|
|
|
for arg do RAMDISK_ELEMENT="$RAMDISK_ELEMENT $arg" ; done
|
2012-11-09 18:18:08 +00:00
|
|
|
|
|
|
|
source $_LIB/ramdisk-defaults
|
|
|
|
source $_LIB/common-functions
|
|
|
|
source $_LIB/ramdisk-functions
|
|
|
|
|
2013-01-22 01:35:31 +00:00
|
|
|
RAMDISK_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $RAMDISK_ELEMENT)
|
|
|
|
|
2012-11-30 20:47:57 +00:00
|
|
|
echo "Building element(s): ${RAMDISK_ELEMENT}"
|
2012-11-09 18:18:08 +00:00
|
|
|
|
|
|
|
echo "Discovering binary dependencies"
|
|
|
|
ensure_binaries
|
|
|
|
|
|
|
|
mk_build_dir
|
|
|
|
|
|
|
|
INIT="$_DIR/../scripts/init"
|
|
|
|
FUNCTIONS_D="$_DIR/../scripts/d"
|
|
|
|
|
|
|
|
MODULE_DIR=$MODULE_ROOT/lib/modules/$KERNEL_VERSION
|
|
|
|
FIRMWARE_DIR=$MODULE_ROOT/lib/firmware
|
|
|
|
|
|
|
|
if [ ! -d "$MODULE_DIR" ]; then
|
|
|
|
echo "ERROR: kernel module directory not found at $MODULE_DIR"
|
2013-02-12 08:43:35 +00:00
|
|
|
exit 1
|
2012-11-09 18:18:08 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-29 03:28:14 +00:00
|
|
|
LIB_UDEV=$LIB_UDEV_ROOT/lib/udev
|
|
|
|
|
|
|
|
if [ ! -d "$LIB_UDEV" ]; then
|
|
|
|
echo "ERROR: udev directory not found at $LIB_UDEV"
|
2013-02-12 08:43:35 +00:00
|
|
|
exit 1
|
2012-11-29 03:28:14 +00:00
|
|
|
fi
|
|
|
|
|
2012-11-09 18:18:08 +00:00
|
|
|
mk_build_dir
|
|
|
|
mkdir -p $TMP_BUILD_DIR/mnt
|
|
|
|
TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
|
|
|
|
|
|
|
|
echo "working in $TMP_MOUNT_PATH"
|
|
|
|
|
|
|
|
create_base
|
|
|
|
populate_lib
|
|
|
|
populate_busybox
|
|
|
|
populate_init
|
2012-11-12 16:56:08 +00:00
|
|
|
populate_udev
|
2012-11-09 18:18:08 +00:00
|
|
|
finalise_image
|
|
|
|
save_image $IMAGE_NAME
|
|
|
|
|