Unverified Commit 88c5c5a0 authored by Paul Haerle's avatar Paul Haerle Committed by GitHub
Browse files

openbgpd: 6.8p0 -> 9.0 (+ refactorings) (#509502)

parents 8b7dc1f6 054e2748
Loading
Loading
Loading
Loading
+15 −51
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  autoconf,
  automake,
  libtool,
  m4,
  bison,
  clangStdenv,
  fetchurl,
  libevent,
}:
# Use clang instead of gcc because that issues way less warnings.
# Besides, OpenBSD devs generally prefer clang over gcc, so it is more likely
# that the entire compilation is more tested using clang from an upstream POV.
clangStdenv.mkDerivation (finalAttrs: {
  pname = "openbgpd";
  version = "9.0";

let
  openbsd_version = "OPENBSD_6_8"; # This has to be equal to ${src}/OPENBSD_BRANCH
  openbsd = fetchFromGitHub {
    name = "portable";
    owner = "openbgpd-portable";
    repo = "openbgpd-openbsd";
    rev = openbsd_version;
    sha256 = "sha256-vCVK5k4g6aW2z2fg7Kv0uvkX7f34aRc8K2myb3jjl6w=";
  src = fetchurl {
    url = "https://cdn.openbsd.org/pub/OpenBSD/OpenBGPD/openbgpd-${finalAttrs.version}.tar.gz";
    hash = "sha256-4JfE81Gibx3lM5IS2eENTPWrxLgQXk8cSI7wZakD9hU=";
  };
in
stdenv.mkDerivation rec {
  pname = "opengpd";
  version = "6.8p0";

  src = fetchFromGitHub {
    owner = "openbgpd-portable";
    repo = "openbgpd-portable";
    rev = version;
    sha256 = "sha256-TKs6tt/SCWes6kYAGIrSShZgOLf7xKh26xG3Zk7wCCw=";
  };

  nativeBuildInputs = [
    autoconf
    automake
    libtool
    m4
    bison
  buildInputs = [
    libevent
  ];

  preConfigure = ''
    mkdir ./openbsd
    cp -r ${openbsd}/* ./openbsd/
    chmod -R +w ./openbsd
    openbsd_version=$(cat ./OPENBSD_BRANCH)
    if [ "$openbsd_version" != "${openbsd_version}" ]; then
      echo "OPENBSD VERSION does not match"
      exit 1
    fi
    ./autogen.sh
  '';

  # Workaround build failure on -fno-common toolchains like upstream
  # gcc-10. Otherwise build fails as:
  #   ld: bgpd-rde_peer.o:/build/source/src/bgpd/bgpd.h:133: multiple definition of `bgpd_process';
  #     bgpd-bgpd.o:/build/source/src/bgpd/bgpd.h:133: first defined here
  env.NIX_CFLAGS_COMPILE = "-fcommon";

  meta = {
    description = "Free implementation of the Border Gateway Protocol, Version 4. It allows ordinary machines to be used as routers exchanging routes with other systems speaking the BGP protocol";
    license = lib.licenses.isc;
@@ -63,4 +27,4 @@ stdenv.mkDerivation rec {
    maintainers = with lib.maintainers; [ cvengler ];
    platforms = lib.platforms.linux;
  };
}
})