- yum)
- # --allowerasing required starting with fedora24
- dnf=$(chroot ${lxc_root} $personality type -p dnf)
- if [ -n "$dnf" ]; then
- pkg_installer="dnf -y install --allowerasing"
- grp_installer="dnf -y groupinstall --allowerasing"
- else
- pkg_installer="yum -y install"
- grp_installer="yum -y groupinstall"
- fi
- [ -n "$packages" ] && chroot ${lxc_root} $personality $pkg_installer $packages
- for group_plus in $groups; do
- group=$(echo $group_plus | sed -e "s,+++, ,g")
- chroot ${lxc_root} $personality $grp_installer "$group"
- done
- # store current rpm list in /init-lxc.rpms in case we need to check the contents
- chroot ${lxc_root} $personality rpm -aq > $lxc_root/init-lxc.rpms
- ;;
- debootstrap)
- # for ubuntu
- if grep -iq ubuntu /vservers/$lxc/etc/lsb-release 2> /dev/null; then
- # on ubuntu, at this point we end up with a single feed in /etc/apt/sources.list
- # we need at least to add the 'universe' feed for python-rpm
- ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e s,main,universe, > sources.list.d/universe.list )
- # also adding a link to updates sounds about right
- ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e 's, main,-updates main,' > sources.list.d/updates.list )
- # tell apt about the changes
- chroot /vservers/$lxc apt-get update
- fi
- for package in $packages ; do
- # container not started yet
- #virsh -c lxc:/// lxc-enter-namespace $lxc /usr/bin/$personality /bin/bash -c "apt-get install -y $package" || :
- chroot ${lxc_root} $personality apt-get install -y $package || :
- done
- ### xxx todo install groups with apt..
- ;;
- *)
- echo "unknown pkg_method $pkg_method"
- ;;
+ dnf)
+ # --allowerasing required starting with fedora24
+ #
+ local has_dnf=""
+ chroot ${lxc_root} $personality dnf --version && has_dnf=true
+ if [ -n "$has_dnf" ]; then
+ echo "container has dnf - invoking with --allowerasing"
+ local pkg_installer="dnf -y install --allowerasing"
+ local grp_installer="dnf -y groupinstall --allowerasing"
+ else
+ echo "container has only dnf"
+ local pkg_installer="dnf -y install"
+ local grp_installer="dnf -y groupinstall"
+ fi
+ [ -n "$packages" ] && chroot ${lxc_root} $personality $pkg_installer $packages
+ for group_plus in $groups; do
+ local group=$(echo $group_plus | sed -e "s,+++, ,g")
+ chroot ${lxc_root} $personality $grp_installer "$group"
+ done
+ # store current rpm list in /init-lxc.rpms in case we need to check the contents
+ chroot ${lxc_root} $personality rpm -aq > $lxc_root/init-lxc.rpms
+ ;;
+ debootstrap)
+ # for ubuntu
+ if grep -iq ubuntu /vservers/$lxc/etc/lsb-release 2> /dev/null; then
+ # on ubuntu, at this point we end up with a single feed in /etc/apt/sources.list
+ # we need at least to add the 'universe' feed for python-rpm
+ ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e s,main,universe, > sources.list.d/universe.list )
+ # also adding a link to updates sounds about right
+ ( cd /vservers/$lxc/etc/apt ; head -1 sources.list | sed -e 's, main,-updates main,' > sources.list.d/updates.list )
+ # tell apt about the changes
+ chroot /vservers/$lxc apt-get update
+ fi
+ for package in $packages ; do
+ # container not started yet
+ #virsh -c lxc:/// lxc-enter-namespace $lxc /usr/bin/$personality /bin/bash -c "apt-get install -y $package" || :
+ chroot ${lxc_root} $personality apt-get install -y $package || :
+ done
+ ### xxx todo install groups with apt..
+ ;;
+ *)
+ echo "unknown pkg_method $pkg_method"
+ ;;