Install dependencies automatically
Install system packages needed to build manila-image-elements. Change-Id: Ia1fef024f9188869a1993604dcfbd09499700515 Closes-Bug: #1504530
This commit is contained in:
parent
da3139c28c
commit
cc1a8ba6b9
@ -16,5 +16,3 @@ Script for creating Ubuntu based image with our elements and default parameters.
|
|||||||
.. sourcecode:: bash
|
.. sourcecode:: bash
|
||||||
|
|
||||||
tox -e buildimage
|
tox -e buildimage
|
||||||
|
|
||||||
Note: Make sure you have qemu-img (qemu-utils package on Ubuntu/Debian, qemu on Fedora/RHEL/openSUSE) and kpartx installed.
|
|
||||||
|
@ -16,6 +16,7 @@ export ELEMENTS_PATH=$_PREFIX/elements
|
|||||||
# Collect configuration
|
# Collect configuration
|
||||||
# --------------------
|
# --------------------
|
||||||
# Development options:
|
# Development options:
|
||||||
|
DIB_UPDATE_REQUESTED=${DIB_UPDATE_REQUESTED:-true}
|
||||||
USE_OFFLINE_MODE=${USE_OFFLINE_MODE:-"yes"}
|
USE_OFFLINE_MODE=${USE_OFFLINE_MODE:-"yes"}
|
||||||
ENABLE_DEBUG_MODE=${ENABLE_DEBUG_MODE:-"no"}
|
ENABLE_DEBUG_MODE=${ENABLE_DEBUG_MODE:-"no"}
|
||||||
DISABLE_IMG_COMPRESSION=${DISABLE_IMG_COMPRESSION:-"no"}
|
DISABLE_IMG_COMPRESSION=${DISABLE_IMG_COMPRESSION:-"no"}
|
||||||
@ -42,7 +43,7 @@ REQUIRED_ELEMENTS="manila-ssh vm $MANILA_IMG_OS dhcp-all-interfaces cleanup-kern
|
|||||||
OPTIONAL_ELEMENTS=
|
OPTIONAL_ELEMENTS=
|
||||||
OPTIONAL_DIB_ARGS=
|
OPTIONAL_DIB_ARGS=
|
||||||
|
|
||||||
if [ "$MANILA_ENABLE_CIFS_SUPPORT" != "yes" && "$MANILA_ENABLE_NFS_SUPPORT" != "yes" ]; then
|
if [ "$MANILA_ENABLE_CIFS_SUPPORT" != "yes" ] && [ "$MANILA_ENABLE_NFS_SUPPORT" != "yes" ]; then
|
||||||
echo "You should enable NFS or CIFS support for manila image."
|
echo "You should enable NFS or CIFS support for manila image."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -67,11 +68,103 @@ if [ "$DISABLE_IMG_COMPRESSION" = "yes" ]; then
|
|||||||
OPTIONAL_DIB_ARGS="$OPTIONAL_DIB_ARGS -u"
|
OPTIONAL_DIB_ARGS="$OPTIONAL_DIB_ARGS -u"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$MANILA_IMG_OS" = "manila-ubuntu-core" && "$MANILA_IMG_OS_VER" != "trusty" ]; then
|
if [ "$MANILA_IMG_OS" = "manila-ubuntu-core" ] && [ "$MANILA_IMG_OS_VER" != "trusty" ]; then
|
||||||
echo "manila-ubuntu-core doesn't support '$MANILA_IMG_OS_VER' release."
|
echo "manila-ubuntu-core doesn't support '$MANILA_IMG_OS_VER' release."
|
||||||
echo "Change MANILA_IMG_OS to 'ubuntu' if you need another release."
|
echo "Change MANILA_IMG_OS to 'ubuntu' if you need another release."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Verify dependencies
|
||||||
|
# -------------------
|
||||||
|
if [ -e /etc/os-release ]; then
|
||||||
|
platform=$(cat /etc/os-release | awk -F= '/^ID=/ {print tolower($2);}')
|
||||||
|
# remove eventual quotes around ID=...
|
||||||
|
platform=$(echo $platform | sed -e 's,^",,;s,"$,,')
|
||||||
|
elif [ -e /etc/system-release ]; then
|
||||||
|
case "$(head -1 /etc/system-release)" in
|
||||||
|
"Red Hat Enterprise Linux Server"*)
|
||||||
|
platform=rhel
|
||||||
|
;;
|
||||||
|
"CentOS"*)
|
||||||
|
platform=centos
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "Unknown value in /etc/system-release. Impossible to build images.\nAborting"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo -e "Unknown host OS. Impossible to build images.\nAborting"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_installed() {
|
||||||
|
if [ "$platform" = 'ubuntu' ]; then
|
||||||
|
dpkg -s "$1" &> /dev/null
|
||||||
|
else
|
||||||
|
# centos, fedora, opensuse, or rhel
|
||||||
|
if ! rpm -q "$1" &> /dev/null; then
|
||||||
|
rpm -q "$(rpm -q --whatprovides "$1")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
need_required_packages() {
|
||||||
|
case "$platform" in
|
||||||
|
"ubuntu")
|
||||||
|
package_list="qemu kpartx"
|
||||||
|
;;
|
||||||
|
"fedora")
|
||||||
|
package_list="qemu-img kpartx"
|
||||||
|
;;
|
||||||
|
"opensuse")
|
||||||
|
package_list="qemu kpartx"
|
||||||
|
;;
|
||||||
|
"rhel" | "centos")
|
||||||
|
package_list="qemu-kvm qemu-img kpartx"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "Unknown platform '$platform' for the package list.\nAborting"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
for p in `echo $package_list`; do
|
||||||
|
if ! is_installed $p; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if need_required_packages; then
|
||||||
|
# install required packages if requested
|
||||||
|
if [ -n "$DIB_UPDATE_REQUESTED" ]; then
|
||||||
|
case "$platform" in
|
||||||
|
"ubuntu")
|
||||||
|
sudo apt-get install $package_list -y
|
||||||
|
;;
|
||||||
|
"opensuse")
|
||||||
|
sudo zypper --non-interactive --gpg-auto-import-keys in $package_list
|
||||||
|
;;
|
||||||
|
"fedora" | "rhel" | "centos")
|
||||||
|
if [ ${platform} = "centos" ]; then
|
||||||
|
# install EPEL repo, in order to install argparse
|
||||||
|
sudo rpm -Uvh --force http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
|
||||||
|
fi
|
||||||
|
sudo yum install $package_list -y
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e "Unknown platform '$platform' for installing packages.\nAborting"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "Missing one of the following packages: $package_list"
|
||||||
|
echo "Please install manually or rerun with the update option (-u)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Export diskimage-builder settings
|
# Export diskimage-builder settings
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
export DIB_DEFAULT_INSTALLTYPE=package
|
export DIB_DEFAULT_INSTALLTYPE=package
|
||||||
|
7
tools/gate/build_images
Normal file
7
tools/gate/build_images
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash -xe
|
||||||
|
|
||||||
|
IMAGE=$1
|
||||||
|
|
||||||
|
if [ "$IMAGE" = "generic" ]; then
|
||||||
|
tox -e buildimage
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user