Unverified Commit 7cb7b7f9 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

Merge pull request #266635 from katexochen/dnf4-init

dnf4: init at 4.18.1
parents fae7198d 0465f280
Loading
Loading
Loading
Loading
+83 −0
Original line number Diff line number Diff line
{ lib
, buildPythonPackage
, cmake
, fetchFromGitHub
, gettext
, libcomps
, libdnf
, python
, rpm
, sphinx
}:

buildPythonPackage rec {
  pname = "dnf4";
  version = "4.18.1";
  format = "other";

  outputs = [ "out" "man" ];

  src = fetchFromGitHub {
    owner = "rpm-software-management";
    repo = "dnf";
    rev = version;
    hash = "sha256-pgS4y87HbFiaS+fftdhKHOZAl2hYTUds3XVXUuQN6tU=";
  };

  patches = [
    ./fix-python-install-dir.patch
  ];

  postPatch = ''
    substituteInPlace CMakeLists.txt \
      --replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}" \
      --replace "SYSCONFDIR /etc" "SYSCONFDIR $out/etc" \
      --replace "SYSTEMD_DIR /usr/lib/systemd/system" "SYSTEMD_DIR $out/lib/systemd/system"
    substituteInPlace etc/tmpfiles.d/CMakeLists.txt \
      --replace "DESTINATION /usr/lib/tmpfiles.d" "DESTINATION $out/usr/lib/tmpfiles.d"
    substituteInPlace dnf/const.py.in \
      --replace "/etc" "$out/etc"
    substituteInPlace doc/CMakeLists.txt \
      --replace 'SPHINX_BUILD_NAME "sphinx-build-3"' 'SPHINX_BUILD_NAME "${sphinx}/bin/sphinx-build"'
  '';

  nativeBuildInputs = [
    cmake
    gettext
    sphinx
  ];

  propagatedBuildInputs = [
    libcomps
    libdnf
    rpm
  ];

  cmakeFlags = [
    "-DPYTHON_DESIRED=${lib.head (lib.splitString ["."] python.version)}"
  ];

  postBuild = ''
    make doc-man
  '';

  postInstall = ''
    # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L218-L220
    ln -s dnf-3 $out/bin/dnf
    ln -s dnf-3 $out/bin/dnf4
    mv $out/bin/dnf-automatic-3 $out/bin/dnf-automatic
    # See https://github.com/rpm-software-management/dnf/blob/41a287e2bd60b4d1100c329a274776ff32ba8740/dnf.spec#L231-L232
    ln -s $out/etc/dnf/dnf.conf $out/etc/yum.conf
    ln -s dnf-3 $out/bin/yum
  '';

  meta = with lib; {
    description = "Package manager based on libdnf and libsolv. Replaces YUM";
    homepage = "https://github.com/rpm-software-management/dnf";
    changelog = "https://github.com/rpm-software-management/dnf/releases/tag/${version}";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ katexochen ];
    mainProgram = "dnf";
    platforms = platforms.unix;
  };
}
+13 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4aee99fb..0bb28897 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ ELSE ()
     MESSAGE (FATAL_ERROR "Invalid PYTHON_DESIRED value: " ${PYTHON_DESIRED})
 ENDIF()

-EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from sysconfig import get_path; stdout.write(get_path('purelib'))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR)
+SET(PYTHON_INSTALL_DIR "@PYTHON_INSTALL_DIR@")
 MESSAGE(STATUS "Python install dir is ${PYTHON_INSTALL_DIR}")

 ADD_SUBDIRECTORY (dnf)
+65 −0
Original line number Diff line number Diff line
{ lib
, check
, cmake
, doxygen
, expat
, fetchFromGitHub
, libxml2
, python
, sphinx
, stdenv
, zlib
}:

stdenv.mkDerivation rec {
  pname = "libcomps";
  version = "0.1.20";

  outputs = [ "out" "dev" "py" ];

  src = fetchFromGitHub {
    owner = "rpm-software-management";
    repo = "libcomps";
    rev = version;
    hash = "sha256-IX4du1+G7lwWrGnllydnBDap2aqK5pzos1Mdyu4MzOU=";
  };

  patches = [
    ./fix-python-install-dir.patch
  ];

  postPatch = ''
    substituteInPlace libcomps/src/python/src/CMakeLists.txt \
      --replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}"
  '';

  nativeBuildInputs = [
    check
    cmake
    doxygen
    python
    sphinx
  ];

  buildInputs = [
    expat
    libxml2
    zlib
  ];

  dontUseCmakeBuildDir = true;
  cmakeDir = "libcomps";

  postFixup = ''
    ls $out/lib
    moveToOutput "lib/${python.libPrefix}" "$py"
  '';

  meta = with lib; {
    description = "Comps XML file manipulation library";
    homepage = "https://github.com/rpm-software-management/libcomps";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ katexochen ];
    platforms = platforms.unix;
  };
}
+13 −0
Original line number Diff line number Diff line
diff --git a/libcomps/src/python/src/CMakeLists.txt b/libcomps/src/python/src/CMakeLists.txt
index d22b84e..57bd1c2 100644
--- a/libcomps/src/python/src/CMakeLists.txt
+++ b/libcomps/src/python/src/CMakeLists.txt
@@ -85,7 +85,7 @@ IF (SKBUILD)
     INSTALL(FILES libcomps/__init__.py DESTINATION libcomps/src/python/src/libcomps)
     INSTALL(TARGETS pycomps LIBRARY DESTINATION libcomps/src/python/src/libcomps)
 ELSE ()
-    EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from sysconfig import get_path; stdout.write(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR)
+    SET(PYTHON_INSTALL_DIR "@PYTHON_INSTALL_DIR@")

     INSTALL(FILES ${pycomps_SRCDIR}/libcomps/__init__.py DESTINATION ${PYTHON_INSTALL_DIR}/libcomps)
     #INSTALL(FILES ${pycomps_SRCDIR}/tests/__test.py DESTINATION
+27 −7
Original line number Diff line number Diff line
@@ -15,12 +15,19 @@
, libyaml
, rpm
, zchunk
, cppunit
, python
, swig
, glib
, sphinx
}:

stdenv.mkDerivation rec {
  pname = "libdnf";
  version = "0.72.0";

  outputs = [ "out" "dev" "py" ];

  src = fetchFromGitHub {
    owner = "rpm-software-management";
    repo = pname;
@@ -36,12 +43,16 @@ stdenv.mkDerivation rec {

  buildInputs = [
    check
    cppunit
    openssl
    json_c
    libsmartcols
    libyaml
    libmodulemd
    zchunk
    python
    swig
    sphinx
  ];

  propagatedBuildInputs = [
@@ -56,29 +67,38 @@ stdenv.mkDerivation rec {
    cp ${libsolv}/share/cmake/Modules/FindLibSolv.cmake cmake/modules/
  '';

  postPatch = ''
    # See https://github.com/NixOS/nixpkgs/issues/107428
    substituteInPlace CMakeLists.txt \
      --replace "enable_testing()" "" \
      --replace "add_subdirectory(tests)" ""
  patches = [
    ./fix-python-install-dir.patch
  ];

  postPatch = ''
    # https://github.com/rpm-software-management/libdnf/issues/1518
    substituteInPlace libdnf/libdnf.pc.in \
      --replace '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
    substituteInPlace cmake/modules/FindPythonInstDir.cmake \
      --replace "@PYTHON_INSTALL_DIR@" "$out/${python.sitePackages}"
  '';

  cmakeFlags = [
    "-DWITH_GTKDOC=OFF"
    "-DWITH_HTML=OFF"
    "-DWITH_BINDINGS=OFF"
    "-DPYTHON_DESIRED=${lib.head (lib.splitString ["."] python.version)}"
  ];

  postInstall = ''
    rm -r $out/${python.sitePackages}/hawkey/test
  '';

  postFixup = ''
    moveToOutput "lib/${python.libPrefix}" "$py"
  '';

  meta = with lib; {
    description = "Package management library";
    homepage = "https://github.com/rpm-software-management/libdnf";
    changelog = "https://github.com/rpm-software-management/libdnf/releases/tag/${version}";
    license = licenses.gpl2Plus;
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ rb2k ];
    maintainers = with maintainers; [ rb2k katexochen ];
  };
}
Loading