Added --oem_pkg oem override option to image_to_vm.sh

This sets the IMG_FORCE_OEM_PACKAGE variable to the supplied string.  If a
':' is present, what follows it gets put in the IMG_FORCE_OEM_USE variable
and what precedes in the former.

_get_vm_opt() has been modified to generally support forced overrides such
as this one, simply set variables named IMG_FORCE_$opt.

Now you can do things like:

for fmt in cloudstack \
		digitalocean \
		ec2-compat:ec2 \
		ec2-compat:openstack \
		ec2-compat:brightbox \
		exoscale \
		gce \
		hyperv \
		rackspace \
		rackspace-onmetal; do
	./image_to_vm.sh --format=qemu --oem_pkg=$fmt
	../build/images/amd64-usr/latest/coreos_developer_qemu.sh -curses
done

rather than having to modify build_library/vm_image_util.sh to test oem
builds in qemu.
This commit is contained in:
Vito Caputo 2014-09-23 17:58:05 -04:00
parent 782a7fd9ca
commit 454e4c1ad4
2 changed files with 43 additions and 1 deletions

View File

@ -31,6 +31,21 @@ VALID_IMG_TYPES=(
hyperv
)
#list of oem package names, minus the oem- prefix
VALID_OEM_PACKAGES=(
azure
cloudstack
digitalocean
ec2-compat
exoscale
gce
hyperv
rackspace
rackspace-onmetal
vagrant
vagrant-key
)
# Set at runtime to one of the above types
VM_IMG_TYPE=DEFAULT
@ -57,9 +72,15 @@ IMG_DEFAULT_BOOT_KERNEL=1
# If set install the given package name to the OEM partition
IMG_DEFAULT_OEM_PACKAGE=
# Forced OEM package name overriding what may be in the format
IMG_FORCE_OEM_PACKAGE=
# USE flags for the OEM package
IMG_DEFAULT_OEM_USE=
# Forced USE flags for the OEM package
IMG_FORCE_OEM_USE=
# Hook to do any final tweaks or grab data while fs is mounted.
IMG_DEFAULT_FS_HOOK=
@ -210,6 +231,20 @@ set_vm_type() {
return 1
}
# Validate and set the oem package, colon delimited USE optional
set_vm_oem_pkg() {
local oem_pkg="${1%:*}" oem_use="${1##*:}"
local valid_pkg
for valid_pkg in "${VALID_OEM_PACKAGES[@]}"; do
if [[ "${oem_pkg}" == "${valid_pkg}" ]]; then
IMG_FORCE_OEM_PACKAGE="oem-${oem_pkg}"
IMG_FORCE_OEM_USE="${oem_use}"
return 0
fi
done
return 1
}
# Validate and set source vm image path
set_vm_paths() {
local src_dir="$1"
@ -238,7 +273,8 @@ _get_vm_opt() {
local opt="$1"
local type_opt="IMG_${VM_IMG_TYPE}_${opt}"
local default_opt="IMG_DEFAULT_${opt}"
echo "${!type_opt:-${!default_opt}}"
local force_opt="IMG_FORCE_${opt}"
echo "${!force_opt:-${!type_opt:-${!default_opt}}}"
}
# Translate source image names to output names.

View File

@ -40,6 +40,8 @@ DEFINE_boolean prod_image "${FLAGS_FALSE}" \
"Use the production image instead of the default developer image."
DEFINE_string to "" \
"Destination folder for VM output file(s)"
DEFINE_string oem_pkg "" \
"OEM package to install"
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
@ -57,6 +59,10 @@ if ! set_vm_type "${FLAGS_format}"; then
die_notrace "Invalid format: ${FLAGS_format}"
fi
if [ ! -z "${FLAGS_oem_pkg}" ] && ! set_vm_oem_pkg "${FLAGS_oem_pkg}"; then
die_notrace "Invalid oem : ${FLAGS_oem_pkg}"
fi
if [ -z "${FLAGS_board}" ] ; then
die_notrace "--board is required."
fi