diff --git a/contrib/mkimage-yum.sh b/contrib/mkimage-yum.sh index b764588363..919160c844 100755 --- a/contrib/mkimage-yum.sh +++ b/contrib/mkimage-yum.sh @@ -10,8 +10,12 @@ usage() { cat < OPTIONS: - -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 + -p "" The list of packages to install in the container. + The default is blank. + -g "" The groups of packages to install in the container. + The default is "Core". + -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 EOOPTS exit 1 } @@ -21,8 +25,9 @@ yum_config=/etc/yum.conf if [ -f /etc/dnf/dnf.conf ] && command -v dnf &> /dev/null; then yum_config=/etc/dnf/dnf.conf alias yum=dnf -fi -while getopts ":y:h" opt; do +fi +install_groups="Core" +while getopts ":y:p:g:h" opt; do case $opt in y) yum_config=$OPTARG @@ -30,6 +35,12 @@ while getopts ":y:h" opt; do h) usage ;; + p) + install_packages="$OPTARG" + ;; + g) + install_groups="$OPTARG" + ;; \?) echo "Invalid option: -$OPTARG" usage @@ -65,8 +76,18 @@ if [ -d /etc/yum/vars ]; then cp -a /etc/yum/vars "$target"/etc/yum/ fi -yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \ - --setopt=group_package_types=mandatory -y groupinstall Core +if [[ -n "$install_groups" ]]; +then + yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \ + --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 +fi + yum -c "$yum_config" --installroot="$target" -y clean all cat > "$target"/etc/sysconfig/network <