Unverified Commit 605b8e28 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

firewalld: repackage (#389437)

parents ec5ec924 afd5a4bf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
--- a/src/firewall/config/__init__.py.in
+++ b/src/firewall/config/__init__.py.in
@@ -80,7 +80,8 @@
     FIREWALLD_POLICIES = path + "/policies"
 
 
-set_default_config_paths("/usr/lib/firewalld")
+import os
+set_default_config_paths(os.environ.get("NIX_FIREWALLD_CONFIG_PATH", "/usr/lib/firewalld"))
 
 FIREWALLD_LOGFILE = "/var/log/firewalld"
 
+74 −25
Original line number Diff line number Diff line
@@ -2,20 +2,27 @@
  lib,
  stdenv,
  fetchFromGitHub,
  autoreconfHook,
  bash,
  autoconf,
  automake,
  docbook_xml_dtd_42,
  docbook-xsl-nons,
  glib,
  gobject-introspection,
  gtk3,
  intltool,
  ipset,
  iptables,
  kdePackages,
  kmod,
  libnotify,
  libxml2,
  libxslt,
  networkmanager,
  networkmanagerapplet,
  pkg-config,
  python3,
  qt6,
  sysctl,
  wrapGAppsNoGuiHook,
  withGui ? false,
}:
@@ -30,8 +37,7 @@ let
      pygobject3
    ]
    ++ lib.optionals withGui [
      pyqt5
      pyqt5-sip
      pyqt6
    ]
  );
in
@@ -47,27 +53,32 @@ stdenv.mkDerivation rec {
  };

  patches = [
    ./add-config-path-env-var.patch
    ./respect-xml-catalog-files-var.patch
    ./specify-localedir.patch
  ];

  postPatch =
    ''
      substituteInPlace src/firewall/config/__init__.py.in \
        --replace "/usr/share" "$out/share"
      substituteInPlace config/xmlschema/check.sh \
        --replace-fail /usr/bin/ ""

      for file in config/firewall-{applet,config}.desktop.in; do
      for file in src/{firewall-offline-cmd.in,firewall/config/__init__.py.in} \
        config/firewall-{applet,config}.desktop.in; do
          substituteInPlace $file \
          --replace "/usr/bin/" "$out/bin/"
            --replace-fail /usr "$out"
      done
    ''
    + lib.optionalString withGui ''
      substituteInPlace src/firewall-applet.in \
        --replace "/usr/bin/nm-connection-editor" "${networkmanagerapplet}/bin/nm-connection-editor"
        --replace-fail "/usr/bin/systemsettings" "${kdePackages.systemsettings}/bin/systemsettings" \
        --replace-fail "/usr/bin/nm-connection-editor" "${networkmanagerapplet}/bin/nm-connection-editor"
    '';

  nativeBuildInputs =
    [
      autoreconfHook
      autoconf
      automake
      docbook_xml_dtd_42
      docbook-xsl-nons
      glib
@@ -77,40 +88,78 @@ stdenv.mkDerivation rec {
      pkg-config
      python3
      python3.pkgs.wrapPython
      wrapGAppsNoGuiHook
    ]
    ++ lib.optionals withGui [
      gobject-introspection
      wrapGAppsNoGuiHook
      qt6.wrapQtAppsHook
    ];

  buildInputs =
    [
      bash
      glib
      gobject-introspection
      ipset
      iptables
      kmod
      networkmanager
      pythonPath
      sysctl
    ]
    ++ lib.optionals withGui [
      gtk3
      libnotify
      pythonPath
      qt6.qtbase
    ];

  preConfigure = ''
    ./autogen.sh
  '';

  ac_cv_path_MODPROBE = lib.getExe' kmod "modprobe";
  ac_cv_path_RMMOD = lib.getExe' kmod "rmmod";
  ac_cv_path_SYSCTL = lib.getExe' sysctl "sysctl";

  configureFlags = [
    "--with-iptables=${lib.getExe' iptables "iptables"}"
    "--with-iptables-restore=${lib.getExe' iptables "iptables-restore"}"
    "--with-ip6tables=${lib.getExe' iptables "ip6tables"}"
    "--with-ip6tables-restore=${lib.getExe' iptables "ip6tables-restore"}"
    "--with-ebtables=${lib.getExe' iptables "ebtables"}"
    "--with-ebtables-restore=${lib.getExe' iptables "ebtables-restore"}"
    "--with-ipset=${lib.getExe' ipset "ipset"}"
  ];

  postInstall =
    ''
      rm -r $out/share/firewalld/testsuite
    ''
    + lib.optionalString (!withGui) ''
      rm $out/bin/firewall-{applet,config}
    '';

  dontWrapGApps = true;
  dontWrapQtApps = true;

  preFixup = lib.optionalString withGui ''
  preFixup =
    ''
      makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
    ''
    + lib.optionalString withGui ''
      makeWrapperArgs+=("''${qtWrapperArgs[@]}")
    '';

  postFixup = ''
    chmod +x $out/share/firewalld/*.py $out/share/firewalld/testsuite/python/*.py $out/share/firewalld/testsuite/{,integration/}testsuite
    patchShebangs --host $out/share/firewalld/testsuite/{,integration/}testsuite $out/share/firewalld/*.py
    chmod +x $out/share/firewalld/*.py
    patchShebangs --host $out/share/firewalld/*.py
    wrapPythonProgramsIn "$out/bin" "$out ${pythonPath}"
    wrapPythonProgramsIn "$out/share/firewalld/testsuite/python" "$out ${pythonPath}"
  '';

  meta = with lib; {
  meta = {
    description = "Firewall daemon with D-Bus interface";
    homepage = "https://github.com/firewalld/firewalld";
    license = licenses.gpl2Plus;
    maintainers = [ ];
    homepage = "https://firewalld.org";
    downloadPage = "https://github.com/firewalld/firewalld/releases";
    license = lib.licenses.gpl2Plus;
    maintainers = with lib.maintainers; [ prince213 ];
    platforms = lib.platforms.linux;
  };
}
+12 −0
Original line number Diff line number Diff line
--- a/src/firewall/config/__init__.py.in
+++ b/src/firewall/config/__init__.py.in
@@ -19,6 +19,9 @@
 DOMAIN = "firewalld"
 import gettext
 
+locale.bindtextdomain(DOMAIN, "/usr/share/locale")
+gettext.bindtextdomain(DOMAIN, "/usr/share/locale")
+
 gettext.install(domain=DOMAIN)
 
 from . import dbus  # noqa: F401