Merge "Support installing packages by default"

This commit is contained in:
Jenkins 2014-11-13 10:27:56 +00:00 committed by Gerrit Code Review
commit ce67ce87ea
4 changed files with 24 additions and 12 deletions

View File

@ -124,7 +124,14 @@ Install Types
------------- -------------
Install types permit elements to be installed from different sources, such as Install types permit elements to be installed from different sources, such as
git repositories, distribution packages, or pip. git repositories, distribution packages, or pip. The default install type
is 'source' but it can be modified on the disk-image-create command line
via the --install-type option. For example you can set:
--install-type=package
to enable package installs by default. Alternately, you can also
set DIB\_DEFAULT\_INSTALLTYPE.
Many elements expose different install types. The different implementations Many elements expose different install types. The different implementations
live under `<install-dir-prefix>-<install-type>-install` directories under an live under `<install-dir-prefix>-<install-type>-install` directories under an

View File

@ -65,6 +65,7 @@ function show_options () {
echo " Options need to be comma separated, and follow the key=value pattern." echo " Options need to be comma separated, and follow the key=value pattern."
echo " --root-label label -- label for the root filesystem. Defaults to 'cloudimg-rootfs'." echo " --root-label label -- label for the root filesystem. Defaults to 'cloudimg-rootfs'."
echo " --ramdisk-element -- specify the main element to be used for building ramdisks." echo " --ramdisk-element -- specify the main element to be used for building ramdisks."
echo " --install-type -- specify the default installation type. Defaults to 'source'. Set to 'package' to use package based installations by default."
if [ "$IS_RAMDISK" == "0" ]; then if [ "$IS_RAMDISK" == "0" ]; then
echo " -n skip the default inclusion of the 'base' element" echo " -n skip the default inclusion of the 'base' element"
echo " -p package[,package,package] -- list of packages to install in the image" echo " -p package[,package,package] -- list of packages to install in the image"
@ -90,7 +91,8 @@ INSTALL_PACKAGES=""
IMAGE_TYPES=("qcow2") IMAGE_TYPES=("qcow2")
COMPRESS_IMAGE="true" COMPRESS_IMAGE="true"
export DIB_ROOT_LABEL="" export DIB_ROOT_LABEL=""
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,qemu-img-options:,ramdisk-element:,root-label: -n $SCRIPTNAME -- "$@"` DIB_DEFAULT_INSTALLTYPE=${DIB_DEFAULT_INSTALLTYPE:-"source"}
TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,qemu-img-options:,ramdisk-element:,root-label:,install-type: -n $SCRIPTNAME -- "$@"`
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential! # Note the quotes around `$TEMP': they are essential!
@ -116,6 +118,7 @@ while true ; do
--qemu-img-options) QEMU_IMG_OPTIONS=$2; shift 2;; --qemu-img-options) QEMU_IMG_OPTIONS=$2; shift 2;;
--root-label) export DIB_ROOT_LABEL=$2; shift 2;; --root-label) export DIB_ROOT_LABEL=$2; shift 2;;
--ramdisk-element) RAMDISK_ELEMENT=$2; shift 2;; --ramdisk-element) RAMDISK_ELEMENT=$2; shift 2;;
--install-type) DIB_DEFAULT_INSTALLTYPE=$2; shift 2;;
--) shift ; break ;; --) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;; *) echo "Internal error!" ; exit 1 ;;
esac esac
@ -162,6 +165,8 @@ fi
mk_build_dir mk_build_dir
create_base create_base
# This variable needs to be propagated into the chroot
echo "export DIB_DEFAULT_INSTALLTYPE=\"${DIB_DEFAULT_INSTALLTYPE}\"" > $TMP_HOOKS_PATH/environment.d/11-dib-install-type.bash
run_d extra-data run_d extra-data
# Run pre-install scripts. These do things that prepare the chroot for package installs # Run pre-install scripts. These do things that prepare the chroot for package installs
run_d_in_target pre-install run_d_in_target pre-install

View File

@ -45,14 +45,14 @@ for _install_type_var in $INSTALL_TYPE_VARS; do
done done
# For any existing *-source-install directory under install.d, if an # For any existing *-<default_install_dir>-install directory under install.d,
# environment variable setting a different install type was not seen, enable # if an environment variable setting a different install type was not seen,
# the source install type. # enable the default (set via --install-type).
source_install_dirs=$(ls -d $TMP_HOOKS_PATH/install.d/*-source-install || true) default_install_type_dirs=$(ls -d $TMP_HOOKS_PATH/install.d/*-${DIB_DEFAULT_INSTALLTYPE}-install || true)
for _source_install_dir in $source_install_dirs; do for _install_dir in $default_install_type_dirs; do
SUFFIX="-source-install" SUFFIX="-${DIB_DEFAULT_INSTALLTYPE}-install"
_source_install_dir=$(basename $_source_install_dir) _install_dir=$(basename $_install_dir)
INSTALLDIRPREFIX=${_source_install_dir%$SUFFIX} INSTALLDIRPREFIX=${_install_dir%$SUFFIX}
found=0 found=0
for specified in ${SPECIFIED_ELEMS[@]}; do for specified in ${SPECIFIED_ELEMS[@]}; do
@ -65,7 +65,7 @@ for _source_install_dir in $source_install_dirs; do
# install type not specified, assume source # install type not specified, assume source
if [ "$found" = "0" ]; then if [ "$found" = "0" ]; then
pushd $TMP_HOOKS_PATH/install.d pushd $TMP_HOOKS_PATH/install.d
ln -sf $_source_install_dir/* . ln -sf $_install_dir/* .
popd popd
fi fi
done done

View File

@ -89,7 +89,7 @@ function get_repos_for_element(){
# Return if install type is not source # Return if install type is not source
local INSTALL_TYPE_VAR=DIB_INSTALLTYPE_${REPONAME//[^A-Za-z0-9]/_} local INSTALL_TYPE_VAR=DIB_INSTALLTYPE_${REPONAME//[^A-Za-z0-9]/_}
local INSTALL_TYPE=${!INSTALL_TYPE_VAR:-source} local INSTALL_TYPE=${!INSTALL_TYPE_VAR:-$DIB_DEFAULT_INSTALLTYPE}
if [ ! $INSTALL_TYPE = "source" ]; then if [ ! $INSTALL_TYPE = "source" ]; then
echo "$REPONAME install type not set to source" echo "$REPONAME install type not set to source"
continue continue