Blob Blame History Raw
name: keepalived
adopt-info: keepalived
summary: High availability VRRP and load-balancing for Linux
description: |
  Keepalived provides simple and robust loadbalancing and high-availability
  to Linux based infrastructures using VRRP and the well-known Linux Virtual
  Server (IPVS) kernel module.

grade: stable
confinement: classic

# linux-libc-dev for 5.0, 4.18 and 3.10 are no longer available via
#    http://security.ubuntu.com/ubuntu/pool/main/l/linux/
# or
#    http://ports.ubuntu.com/pool/main/l/linux/
# and will disappear for other versions is due course.
#
# To find the relevant files, go to launchpad.net/ubuntu/CODENAME/ARCH/linux-libc-dev
#   where CODENAME is, for example cosmic for Ubuntu 18.10, and ARCH is each of amd64,
#   i386, ppc64el, arm64, armhf and s390x.
# Select the most recent version, and click on link under Version column (RHS). Under
#   Downloadable files is a link to the .deb file. That is what we need in DEB_URL.
#
# We should probably update the locations of the files to use this more difficult way
#   of finding them once the Ubuntu version that provides them goes EOL.

apps:
  daemon:
    daemon: forking
    command: bin/keepalived-wrapper
  keepalived:
    command: bin/keepalived-wrapper
  "504":        # Ubuntu 20.04 and Fedora 31
    command: usr/sbin/keepalived-504
  "503":        # Ubuntu 19.10 and Fedora 31
    command: usr/sbin/keepalived-503
  "500":        # Fedora 30
    command: usr/sbin/keepalived-500
  "418":        # Ubuntu 18.10 and RHEL 8 and Fedora 29
    command: usr/sbin/keepalived-418
  "415":        # Ubuntu 18.04
    command: usr/sbin/keepalived-415
  "404":        # Ubuntu 16.04
    command: usr/sbin/keepalived-404
  "310":        # RHEL 7
    command: usr/sbin/keepalived-310
  genhash:
    command: usr/bin/genhash

parts:
  keepalived:
    plugin: autotools
    source: .
    source-type: git
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    override-build: |
      snapcraftctl build
      VER=$(grep GIT_COMMIT lib/git-commit.h | cut -d'"' -f2)
      if [ -z $VER ]; then
        VER=`grep "^AC_INIT" configure.ac | tr '[' ']' | cut -d']' -f4`
      fi
      snapcraftctl set-version $VER
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    build-packages:
      - iptables-dev
      - libipset-dev
      - libglib2.0-dev
      - libmagic-dev
      - libmnl-dev
      - libnftnl-dev
      - libnl-3-dev
      - libnl-genl-3-dev
      - libnfnetlink-dev
      - libpcre2-dev
      - libsnmp-dev
      - libssl-dev
    stage-packages:
      - libnfnetlink0
      - libipset3
      - libglib2.0-0
      - libmagic1
      - libmnl0
      - libnftnl4
      - libnl-3-200
      - libnl-genl-3-200
      - libpcre2-8-0
      - libsnmp30
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-404

  linux-headers-504:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived
    override-pull: |
      KERNEL_VER="5.4.0"
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ] || [ $ARCH = i386 ]; then
        ARCHIVE_URL="http://security.ubuntu.com/ubuntu/pool/main/l/linux/"
      else
        ARCHIVE_URL="http://ports.ubuntu.com/pool/main/l/linux/"
      fi
      DEB_SUFFIX=$(wget ${ARCHIVE_URL} -O - | grep linux-libc-dev | cut -d'_' -f2-3 | cut -d'"' -f1 | grep ${ARCH} | grep ${KERNEL_VER} | tail -n1)
      wget --quiet ${ARCHIVE_URL}/linux-libc-dev_${DEB_SUFFIX} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      echo -n "Unpacking kernel headers..."
      dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
      rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
    override-build: |
      snapcraftctl build
      # Move header from the part to the host
      ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
      for d in linux asm-generic $ARCH_DIR/asm; do
        dest=/usr/include/$d
        rm -rf $dest
        mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
      done
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-504:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-504
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-504
      'usr/etc/dbus-1/system.d/org.keepalived.Vrrp1.conf': etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
    stage:
      - usr/sbin/keepalived-504
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml
    prime:
      - usr/sbin/keepalived-504
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml

  linux-headers-503:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived-504
    override-pull: |
      KERNEL_VER="5.3.0"
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ] || [ $ARCH = i386 ]; then
        ARCHIVE_URL="http://security.ubuntu.com/ubuntu/pool/main/l/linux/"
      else
        ARCHIVE_URL="http://ports.ubuntu.com/pool/main/l/linux/"
      fi
      DEB_SUFFIX=$(wget ${ARCHIVE_URL} -O - | grep linux-libc-dev | cut -d'_' -f2-3 | cut -d'"' -f1 | grep ${ARCH} | grep ${KERNEL_VER} | tail -n1)
      wget --quiet ${ARCHIVE_URL}/linux-libc-dev_${DEB_SUFFIX} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      echo -n "Unpacking kernel headers..."
      dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
      rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
    override-build: |
      snapcraftctl build
      # Move header from the part to the host
      ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
      for d in linux asm-generic $ARCH_DIR/asm; do
        dest=/usr/include/$d
        rm -rf $dest
        mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
      done
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-503:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-503
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-503
      'usr/etc/dbus-1/system.d/org.keepalived.Vrrp1.conf': etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
    stage:
      - usr/sbin/keepalived-503
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml
    prime:
      - usr/sbin/keepalived-503
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml

  linux-headers-500:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived-503
    override-pull: |
      KERNEL_VER="5.0.0"
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ]; then
        DEB_URL="http://launchpadlibrarian.net/460650013/linux-libc-dev_5.0.0-40.44_amd64.deb"
      elif [ $ARCH = ppc64el ]; then
        DEB_URL="http://launchpadlibrarian.net/460651527/linux-libc-dev_5.0.0-40.44_ppc64el.deb"
      elif [ $ARCH = arm64 ]; then
        DEB_URL="http://launchpadlibrarian.net/460676453/linux-libc-dev_5.0.0-40.44_arm64.deb"
      elif [ $ARCH = i386 ]; then
        DEB_URL="http://launchpadlibrarian.net/460681467/linux-libc-dev_5.0.0-40.44_i386.deb"
      elif [ $ARCH = armhf ]; then
        DEB_URL="http://launchpadlibrarian.net/460683805/linux-libc-dev_5.0.0-40.44_armhf.deb"
      elif [ $ARCH = s390x ]; then
        DEB_URL="http://launchpadlibrarian.net/460646235/linux-libc-dev_5.0.0-40.44_s390x.deb"
      fi
      wget --quiet ${DEB_URL} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      echo -n "Unpacking kernel headers..."
      dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
      rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
    override-build: |
      snapcraftctl build
      # Move header from the part to the host
      ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
      for d in linux asm-generic $ARCH_DIR/asm; do
        dest=/usr/include/$d
        rm -rf $dest
        mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
      done
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-500:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-500
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-500
      'usr/etc/dbus-1/system.d/org.keepalived.Vrrp1.conf': etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
    stage:
      - usr/sbin/keepalived-500
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml
    prime:
      - usr/sbin/keepalived-500
      - etc/dbus-1/system.d/org.keepalived.Vrrp1.conf
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Instance.xml
      - usr/share/dbus-1/interfaces/org.keepalived.Vrrp1.Vrrp.xml

  linux-headers-418:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived-500
    override-pull: |
      KERNEL_VER="4.18.0"
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ] || [ $ARCH = ppc64el ] ||  [ $ARCH = arm64 ]; then
        DEB_URL="http://launchpadlibrarian.net/431512728/linux-libc-dev_4.18.0-26.27_amd64.deb"
      elif [ $ARCH = i386 ]; then
        DEB_URL="http://launchpadlibrarian.net/431500961/linux-libc-dev_4.18.0-26.27_i386.deb"
      elif [ $ARCH = armhf ]; then
        DEB_URL="http://launchpadlibrarian.net/431525966/linux-libc-dev_4.18.0-26.27_armhf.deb"
      elif [ $ARCH = s390x ]; then
        DEB_URL="http://launchpadlibrarian.net/431485536/linux-libc-dev_4.18.0-26.27_s390x.deb"
      fi
      wget --quiet ${DEB_URL} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      echo -n "Unpacking kernel headers..."
      dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
      rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
    override-build: |
      snapcraftctl build
      # Move header from the part to the host
      ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
      for d in linux asm-generic $ARCH_DIR/asm; do
        dest=/usr/include/$d
        rm -rf $dest
        mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
      done
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-418:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-418
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-418
    stage:
      - usr/sbin/keepalived-418
    prime:
      - usr/sbin/keepalived-418

  linux-headers-415:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived-418
    override-pull: |
      KERNEL_VER="4.15.0"
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ] || [ $ARCH = i386 ]; then
        ARCHIVE_URL="http://security.ubuntu.com/ubuntu/pool/main/l/linux/"
      else
        ARCHIVE_URL="http://ports.ubuntu.com/pool/main/l/linux/"
      fi
      DEB_SUFFIX=$(wget ${ARCHIVE_URL} -O - | grep linux-libc-dev | cut -d'_' -f2-3 | cut -d'"' -f1 | grep ${ARCH} | grep ${KERNEL_VER} | tail -n1)
      wget --quiet ${ARCHIVE_URL}/linux-libc-dev_${DEB_SUFFIX} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      echo -n "Unpacking kernel headers..."
      dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
      rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
    override-build: |
      snapcraftctl build
      # Move header from the part to the host
      ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
      for d in linux asm-generic $ARCH_DIR/asm; do
        dest=/usr/include/$d
        rm -rf $dest
        mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
      done
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-415:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-415
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-415
    stage:
      - usr/sbin/keepalived-415
    prime:
      - usr/sbin/keepalived-415

  linux-headers-310:
    plugin: nil
    build-packages:
      - dpkg
      - dpkg-dev
      - wget
    after:
      - keepalived-415
    override-pull: |
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH = amd64 ] || [ $ARCH = ppc64el ] ||  [ $ARCH = arm64 ]; then
        DEB_URL="http://launchpadlibrarian.net/144719237/linux-libc-dev_3.10.0-2.11_amd64.deb"
      elif [ $ARCH = i386 ]; then
        DEB_URL="http://launchpadlibrarian.net/144720155/linux-libc-dev_3.10.0-2.11_i386.deb"
      elif [ $ARCH = armhf ]; then
        DEB_URL="http://launchpadlibrarian.net/144753483/linux-libc-dev_3.10.0-2.11_armhf.deb"
      fi
      if [ $ARCH != s390x ]; then
        # s390x was not supported on Trusty, so there are no kernel headers for it.
        # Just let it build with the previous headers.
        wget --quiet ${DEB_URL} -O ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
        echo -n "Unpacking kernel headers..."
        dpkg -x ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb ${SNAPCRAFT_PART_INSTALL}
        printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_PART_INSTALL}/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
        rm -f ${SNAPCRAFT_PART_INSTALL}/linux-libc-dev.deb
      fi
    override-build: |
      snapcraftctl build
      ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
      if [ $ARCH != s390x ]; then
        # Move header from the part to the host
        ARCH_DIR=$(ls -d ${SNAPCRAFT_PART_INSTALL}/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
        for d in linux asm-generic $ARCH_DIR/asm; do
          dest=/usr/include/$d
          rm -rf $dest
          mv ${SNAPCRAFT_PART_INSTALL}/usr/include/$d ${dest%/*}
        done
      fi
      echo -n "Build kernel:"
      printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
    stage:
      - -*
    prime:
      - -*

  keepalived-310:
    plugin: autotools
    source: .
    source-type: git
    after:
      - linux-headers-310
    configflags:
      - --prefix=/usr
      - --enable-bfd
      - --enable-dbus
      - --enable-json
      - --enable-regex
      - --enable-snmp
      - --enable-snmp-rfc
      - --disable-libipset-dynamic
    organize:
      'usr/sbin/keepalived': usr/sbin/keepalived-310
    stage:
      - usr/sbin/keepalived-310
    prime:
      - usr/sbin/keepalived-310

  keepalived-wrapper:
    plugin: dump
    source: snap-tools
    organize:
      'keepalived-wrapper': bin/