Merge "Add option --min-tmpfs <size> to disk-image-create"

This commit is contained in:
Jenkins
2013-08-28 15:40:31 +00:00
committed by Gerrit Code Review
4 changed files with 10 additions and 3 deletions

View File

@@ -48,6 +48,7 @@ function show_options () {
echo " -x -- turn on tracing" echo " -x -- turn on tracing"
echo " -u -- uncompressed; do not compress the image - larger but faster" echo " -u -- uncompressed; do not compress the image - larger but faster"
echo " -c -- clear environment before starting work" echo " -c -- clear environment before starting work"
echo " --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image"
echo " --no-tmpfs -- do not use tmpfs to speed image build" echo " --no-tmpfs -- do not use tmpfs to speed image build"
echo " --offline -- do not update cached resources" echo " --offline -- do not update cached resources"
if [ "$IS_RAMDISK" == "0" ]; then if [ "$IS_RAMDISK" == "0" ]; then
@@ -61,7 +62,7 @@ function show_options () {
INSTALL_PACKAGES="" INSTALL_PACKAGES=""
COMPRESS_IMAGE="true" COMPRESS_IMAGE="true"
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline -n $SCRIPTNAME -- "$@"` TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline,min-tmpfs: -n $SCRIPTNAME -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential! # Note the quotes around `$TEMP': they are essential!
@@ -77,6 +78,7 @@ while true ; do
-c) shift ; export CLEAR_ENV=1;; -c) shift ; export CLEAR_ENV=1;;
-n) shift; export SKIP_BASE="1";; -n) shift; export SKIP_BASE="1";;
-p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;; -p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;;
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
--no-tmpfs) shift; export DIB_NO_TMPFS=1;; --no-tmpfs) shift; export DIB_NO_TMPFS=1;;
--offline) shift; export DIB_OFFLINE=1;; --offline) shift; export DIB_OFFLINE=1;;
--) shift ; break ;; --) shift ; break ;;

View File

@@ -34,6 +34,7 @@ ARCH=${ARCH:-$_ARCH}
export ARCH export ARCH
export DIB_NO_TMPFS=${DIB_NO_TMPFS:-0} export DIB_NO_TMPFS=${DIB_NO_TMPFS:-0}
export DIB_MIN_TMPFS=${DIB_MIN_TMPFS:-2}
# Set via the CLI normally. # Set via the CLI normally.
# IMAGE_ELEMENT= # IMAGE_ELEMENT=
_BASE_ELEMENT_DIR=$_PREFIX/elements _BASE_ELEMENT_DIR=$_PREFIX/elements

View File

@@ -18,8 +18,11 @@ function tmpfs_check() {
[ "$DIB_NO_TMPFS" == "0" ] || return 1 [ "$DIB_NO_TMPFS" == "0" ] || return 1
[ -r /proc/meminfo ] || return 1 [ -r /proc/meminfo ] || return 1
total_kB=$(awk '/^MemTotal/ { print $2 }' /proc/meminfo) total_kB=$(awk '/^MemTotal/ { print $2 }' /proc/meminfo)
[ $total_kB -lt $((4*1024*1024)) ] || return 0 # tmpfs uses by default 50% of the available RAM, so the RAM should be at least
echo "Not enough RAM to use tmpfs for build. ($total_kB < 4G)" # the double of the minimum tmpfs size required
RAM_NEEDED=$[ $DIB_MIN_TMPFS * 2 ]
[ $total_kB -lt $(($RAM_NEEDED*1024*1024)) ] || return 0
echo "Not enough RAM to use tmpfs for build. ($total_kB < ${RAM_NEEDED}G)"
return 1 return 1
} }

View File

@@ -17,6 +17,7 @@
# options for ramdisk-image-create # options for ramdisk-image-create
export DIB_NO_TMPFS=${DIB_NO_TMPFS:-1} export DIB_NO_TMPFS=${DIB_NO_TMPFS:-1}
export DIB_MIN_TMPFS=${DIB_MIN_TMPFS:-1}
source $_LIB/common-defaults source $_LIB/common-defaults
MODULE_ROOT=${DIB_MODULE_ROOT:-""} MODULE_ROOT=${DIB_MODULE_ROOT:-""}
LIB_UDEV_ROOT=${DIB_LIB_UDEV_ROOT:-""} LIB_UDEV_ROOT=${DIB_LIB_UDEV_ROOT:-""}