Adding new update option to diskimage-create.sh
This change removes the global system updates in favor of only updating the required packages for diskimage creation. Additionally the script will not automatically install the updates but will warn the user if the packages are not installed. A switch is provided to allow the script to install the updates. Changes * adding function to detect an installed package * adding function to check for a list of installed packages * adding command line switch for updating (-u) * removing global update commands * refactoring update logic to fail gracefully or accept switch * adding -u switch to build-images gate tool * adding note in documentation about update command line switch Closes-Bug: 1375843 Change-Id: Iba5e676fa8ef7a852b71acd9e4c19d32f848285a
This commit is contained in:
parent
e315186c93
commit
4bf342a48c
|
@ -41,6 +41,8 @@ NOTE: Do not create all images for all plugins with the same mirrors. Different
|
|||
|
||||
sudo bash sahara-image-elements/diskimage-create/diskimage-create.sh -i [ubuntu|fedora|centos]
|
||||
|
||||
7. If the host system is missing packages required for diskimage-create.sh, the '-u' commandline option will instruct the script to install them without prompt.
|
||||
|
||||
NOTE for 4, 5, 6:
|
||||
|
||||
For Vanilla you can create ubuntu, fedora and centos cloud image with hadoop 1.x.x and 2.x.x versions. Use environment variables 'DIB_HADOOP_VERSION_1' and 'DIB_HADOOP_VERSION_2' to change defaults.
|
||||
|
|
|
@ -27,12 +27,14 @@ usage() {
|
|||
echo " [-r 3.1.1|4.0.1]"
|
||||
echo " [-d]"
|
||||
echo " [-m]"
|
||||
echo " [-u]"
|
||||
echo " '-p' is plugin version (default: all plugins)"
|
||||
echo " '-i' is operating system of the base image (default: all supported by plugin)"
|
||||
echo " '-v' is hadoop version (default: all supported by plugin)"
|
||||
echo " '-r' is MapR Version (default: ${DIB_DEFAULT_MAPR_VERSION})"
|
||||
echo " '-d' enable debug mode, root account will have password 'hadoop'"
|
||||
echo " '-m' set the diskimage-builder repo to the master branch (default: $DEFAULT_DIB_REPO_BRANCH)"
|
||||
echo " '-u' install missing packages necessary for building"
|
||||
echo
|
||||
echo "You shouldn't specify hadoop version and image type for spark plugin"
|
||||
echo "You shouldn't specify image type for hdp plugin"
|
||||
|
@ -43,7 +45,7 @@ usage() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
while getopts "p:i:v:dmr:" opt; do
|
||||
while getopts "p:i:v:dmur:" opt; do
|
||||
case $opt in
|
||||
p)
|
||||
PLUGIN=$OPTARG
|
||||
|
@ -68,6 +70,9 @@ while getopts "p:i:v:dmr:" opt; do
|
|||
r)
|
||||
DIB_MAPR_VERSION=$OPTARG
|
||||
;;
|
||||
u)
|
||||
DIB_UPDATE_REQUESTED=true
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
|
@ -153,23 +158,56 @@ fi
|
|||
|
||||
#################
|
||||
|
||||
is_installed() {
|
||||
if [ "$platform" = 'NAME="Ubuntu"' ]; then
|
||||
apt-get update -y
|
||||
apt-get install qemu kpartx git -y
|
||||
elif [ "$platform" = 'NAME=Fedora' ]; then
|
||||
yum update -y
|
||||
yum install qemu kpartx git -y
|
||||
dpkg -s "$1" &> /dev/null
|
||||
else
|
||||
# centos, fedora, opensuse, or rhel
|
||||
rpm -q "$1" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
need_required_packages() {
|
||||
if [[ "$platform" == 'NAME="Ubuntu"' || "$platform" == 'NAME=Fedora' ]]; then
|
||||
package_list="qemu kpartx git"
|
||||
elif [ "$platform" = 'NAME=openSUSE' ]; then
|
||||
zypper --non-interactive --gpg-auto-import-keys in kpartx qemu git-core
|
||||
package_list="qemu kpartx git-core"
|
||||
else
|
||||
# centos or rhel
|
||||
yum update -y
|
||||
yum install qemu-kvm qemu-img kpartx git -y
|
||||
package_list="qemu-kvm qemu-img kpartx git"
|
||||
if [ ${platform:0:6} = "CentOS" ]; then
|
||||
# CentOS requires the python-argparse package be installed separately
|
||||
package_list="$package_list python-argparse"
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
if [ "$platform" = 'NAME="Ubuntu"' ]; then
|
||||
apt-get install $package_list -y
|
||||
elif [ "$platform" = 'NAME=openSUSE' ]; then
|
||||
zypper --non-interactive --gpg-auto-import-keys in $package_list
|
||||
else
|
||||
# fedora, centos, and rhel share an install command
|
||||
if [ ${platform:0:6} = "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
|
||||
# CentOS requires the python-argparse package be installed separately
|
||||
yum install python-argparse -y
|
||||
rpm -Uvh --force http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
|
||||
fi
|
||||
yum install $package_list -y
|
||||
fi
|
||||
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
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
PLUGIN=$1
|
||||
export SIM_REPO_PATH=$(pwd)
|
||||
|
||||
sudo -E ./diskimage-create/diskimage-create.sh -p $PLUGIN
|
||||
sudo -E ./diskimage-create/diskimage-create.sh -u -p $PLUGIN
|
||||
|
|
Loading…
Reference in New Issue