From 823391050346b0cb88a3fd8fc114490233a6adaa Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 27 Mar 2019 21:21:17 +0530 Subject: [PATCH 1/2] mkimage-yum.sh: handle spaces properly & allow mutiple packages & groups Signed-off-by: Ankit Jain --- contrib/mkimage-yum.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/contrib/mkimage-yum.sh b/contrib/mkimage-yum.sh index 49eeacc0cb..eff604a89b 100755 --- a/contrib/mkimage-yum.sh +++ b/contrib/mkimage-yum.sh @@ -13,9 +13,9 @@ usage() { $(basename $0) [OPTIONS] OPTIONS: -p "" The list of packages to install in the container. - The default is blank. + The default is blank. Can use multiple times. -g "" The groups of packages to install in the container. - The default is "Core". + The default is "Core". Can use multiple times. -y The path to the yum config to install packages from. The default is /etc/yum.conf for Centos/RHEL and /etc/dnf/dnf.conf for Fedora -t Specify Tag information. @@ -30,7 +30,9 @@ if [ -f /etc/dnf/dnf.conf ] && command -v dnf &> /dev/null; then yum_config=/etc/dnf/dnf.conf alias yum=dnf fi -install_groups="Core" +install_groups=('Core') +# for names with spaces, use double quotes (") as install_groups=('Core' '"Compute Node"') +install_packages=('') version= while getopts ":y:p:g:t:h" opt; do case $opt in @@ -41,10 +43,10 @@ while getopts ":y:p:g:t:h" opt; do usage ;; p) - install_packages="$OPTARG" + install_packages+=("\"$OPTARG\"") ;; g) - install_groups="$OPTARG" + install_groups+=("\"$OPTARG\"") ;; t) version="$OPTARG" @@ -87,13 +89,13 @@ fi if [[ -n "$install_groups" ]]; then yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \ - --setopt=group_package_types=mandatory -y groupinstall "$install_groups" + --setopt=group_package_types=mandatory -y groupinstall "${install_groups[*]}" fi if [[ -n "$install_packages" ]]; then yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \ - --setopt=group_package_types=mandatory -y install "$install_packages" + --setopt=group_package_types=mandatory -y install "${install_packages[*]}" fi yum -c "$yum_config" --installroot="$target" -y clean all From eb137580576dfd9e3279fe0ef47f82c5d8d144ac Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 29 Mar 2019 20:21:33 +0530 Subject: [PATCH 2/2] Default to Core group only if no groups specified Signed-off-by: Ankit Jain --- contrib/mkimage-yum.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/mkimage-yum.sh b/contrib/mkimage-yum.sh index eff604a89b..b4471a94f6 100755 --- a/contrib/mkimage-yum.sh +++ b/contrib/mkimage-yum.sh @@ -30,9 +30,9 @@ if [ -f /etc/dnf/dnf.conf ] && command -v dnf &> /dev/null; then yum_config=/etc/dnf/dnf.conf alias yum=dnf fi -install_groups=('Core') # for names with spaces, use double quotes (") as install_groups=('Core' '"Compute Node"') -install_packages=('') +install_groups=() +install_packages=() version= while getopts ":y:p:g:t:h" opt; do case $opt in @@ -64,6 +64,11 @@ if [[ -z $name ]]; then usage fi +# default to Core group if not specified otherwise +if [ ${#install_groups[*]} -eq 0 ]; then + install_groups=('Core') +fi + target=$(mktemp -d --tmpdir $(basename $0).XXXXXX) set -x