package uninstall & install - different classes

Matteo Guglielmi Matteo.Guglielmi at dalco.ch
Mon May 6 21:17:43 CEST 2019


This is how I solved my needs to handle or adjust the

order of classes in FAI.



In my case, I always wanted to define the "essential"

classes in:


50-host-classes


and leaving the job of filing up the voids (or even

remove or change the order of classes) to a secondary

script (in my case '60-expand-classes').



If you find this useful, you are welcome to use it.




###



cat /srv/fai/config/hooks/subroutines




prependClass() {
  sed -ri "/^$2$/i $1" /tmp/fai/FAI_CLASSES
}

appendClass() {
  sed -ri "/^$2$/a $1" /tmp/fai/FAI_CLASSES
}

deleteClass() {
  sed -ri "/^$1$/d" /tmp/fai/FAI_CLASSES
}

replaceClass() {
  sed -ri "/^$2$/c $1" /tmp/fai/FAI_CLASSES
}

listClasses() {
  cat /tmp/fai/FAI_CLASSES
}

assertUfbiClasses() {
  grep -q '^UFBI' /tmp/fai/FAI_CLASSES || return 1
}




cat /srv/fai/config/class/50-host-classes




case $HOSTNAME in
  node01)
    echo CENTOS75 MLKERNEL UFBIMONITOR UFBIOFED UFBISLURM
  ;;
  node02)
    echo CENTOS76 LTKERNEL UFBIMONITOR UFBIOFED UFBISLURM
  ;;
  node03)
    echo CENTOS75 MLKERNEL UFBIMONITOR UFBIOFED UFBISLURM
  ;;
  node04)
    echo CENTOS76 LTKERNEL UFBIMONITOR UFBIOFED UFBISLURM
  ;;
  *)
    echo CENTOS76
  ;;
esac




cat /srv/fai/config/class/60-expand-classes



if ifclass AMD64 ; then
  appendClass FAIBASE AMD64
else
  exit 700 # we don't support 32-bit OSes
fi

if ifclass -o CENTOS75 CENTOS76 ; then
  prependClass CENTOS 'CENTOS7[5-6]'

  if ifclass -o LTKERNEL MLKERNEL ; then
    if ifclass UFBIOFED ; then
      replaceClass UFBIIB UFBIOFED
    fi
  fi
fi

if ifclass -o SLES150 SLES151 ; then
  prependClass SLES 'SLES15[0,1]'
fi

if ifclass UBUNTU18 ; then
  prependClass UBUNTU UBUNTU18
fi

if ifclass DEBIAN9 ; then
  prependClass DEBIAN DEBIAN9
fi

if assertUfbiClasses ; then
  ifclass UFBI || echo UFBI
fi


[ -d /sys/firmware/efi ] && echo EFI || echo BIOS



________________________________
From: linux-fai <linux-fai-bounces at uni-koeln.de> on behalf of Thomas Lange <lange at informatik.uni-koeln.de>
Sent: Monday, May 6, 2019 10:34:40 AM
To: fully automatic installation for Linux
Subject: Re: package uninstall & install - different classes

Your observation is correct. The order of classes are important when
selecting configuration files, but do not matter inside a
package_config file itself. The script install_packages reads the files in
subdirectory package_config in the order given by the classes. But each
file is read from the beginning to the end. If a line
PACKAGE install CLASSA
is found it justs checks if CLASSA is also defined, otherwise skips
this part. So inside thise config the class is more like a true/false flag.

It's not easy to change this, because you can list multiple classes
after the PACKAGE install marker which forms a logical OR
function. It's then hard to decide to which class the packages listed
should be assigned to.

In your case, is it possible to change your config by creating two
files named CLASS1 and CLASS2 which each include a section PACKAGES
install STRETCH64? Would that help you?

--
regards Thomas


More information about the linux-fai mailing list