diskimage-builder/bin/ramdisk-image-create
Arata Notsu aa6f5f8005 Correct misuse of return in ramdisk-image-create
Replaced return with exit.

Change-Id: Iee26177cdb58af67b6919da12456debfe5940105
2013-02-12 17:43:35 +09:00

102 lines
2.6 KiB
Bash
Executable File

#!/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)
SCRIPT_HOME=$(dirname $0)
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
for arg do RAMDISK_ELEMENT="$RAMDISK_ELEMENT $arg" ; done
source $_LIB/ramdisk-defaults
source $_LIB/common-functions
source $_LIB/ramdisk-functions
RAMDISK_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $RAMDISK_ELEMENT)
echo "Building element(s): ${RAMDISK_ELEMENT}"
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"
exit 1
fi
LIB_UDEV=$LIB_UDEV_ROOT/lib/udev
if [ ! -d "$LIB_UDEV" ]; then
echo "ERROR: udev directory not found at $LIB_UDEV"
exit 1
fi
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
populate_udev
finalise_image
save_image $IMAGE_NAME