Commit ab54cadc authored by OPNA2608's avatar OPNA2608
Browse files

ubports-click: Modernise

- Reorder function arguments in lexicographical order, derivation attributes in more common order
- Add changelog, mainProgram, pkgConfigModules + test
- Adjust maintainers, heavily related to Lomiri so pulling in that team
parent 1077e452
Loading
Loading
Loading
Loading
+78 −67
Original line number Diff line number Diff line
{
  lib,
  buildPythonApplication,
  fetchFromGitLab,
  fetchpatch,
  lib,
  stdenv,
  buildPythonApplication,
  testers,
  ubports-click,
  autoreconfHook,
  dbus,
  dbus-test-runner,
  dpkg,
  getopt,
  glib,
  python-debian,
  python-apt,
  gobject-introspection,
  json-glib,
  libgee,
  perl,
  vala,
  pkg-config,
  libgee,
  json-glib,
  properties-cpp,
  gobject-introspection,
  getopt,
  pygobject3,
  python-apt,
  python-debian,
  setuptools,
  six,
  pygobject3,
  unittestCheckHook,
  vala,
  wrapGAppsHook3,
}:

@@ -38,6 +40,22 @@ buildPythonApplication rec {
    hash = "sha256-AV3n6tghvpV/6Ew6Lokf8QAGBIMbHFAnp6G4pefVn+8=";
  };

  patches = [
    # Remove when version > 0.5.2
    (fetchpatch {
      name = "0001-click-fix-Wimplicit-function-declaration.patch";
      url = "https://gitlab.com/ubports/development/core/click/-/commit/8f654978a12e6f9a0b6ff64296ec5565e3ff5cd0.patch";
      hash = "sha256-kio+DdtuagUNYEosyQY3q3H+dJM3cLQRW9wUKUcpUTY=";
    })

    # Remove when version > 0.5.2
    (fetchpatch {
      name = "0002-click-Add-uid_t-and-gid_t-to-the-ctypes-_typemap.patch";
      url = "https://gitlab.com/ubports/development/core/click/-/commit/cbcd23b08b02fa122434e1edd69c2b3dcb6a8793.patch";
      hash = "sha256-QaWRhxO61wAzULVqPLdJrLuBCr3+NhKmQlEPuYq843I=";
    })
  ];

  postPatch = ''
    # These should be proper Requires, using the header needs their headers
    substituteInPlace lib/click/click-*.pc.in \
@@ -50,22 +68,6 @@ buildPythonApplication rec {
    patchShebangs bin/click
  '';

  configureFlags = [
    "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
    "--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user"
  ];

  preFixup = ''
    makeWrapperArgs+=(
      --prefix LD_LIBRARY_PATH : "$out/lib"
    )
  '';

  preConfigure = ''
    export click_cv_perl_vendorlib=$out/${perl.libPrefix}
    export PYTHON_INSTALL_FLAGS="--prefix=$out"
  '';

  strictDeps = true;

  pkgsBuildBuild = [
@@ -75,14 +77,27 @@ buildPythonApplication rec {
  nativeBuildInputs = [
    autoreconfHook
    dbus-test-runner # Always checking for this
    getopt
    gobject-introspection
    perl
    pkg-config
    gobject-introspection
    vala
    getopt
    wrapGAppsHook3
  ];

  buildInputs = [
    glib
    json-glib
    libgee
    properties-cpp
  ];

  propagatedBuildInputs = [
    python-debian
    pygobject3
    setuptools
  ];

  nativeCheckInputs = [
    dbus
    dpkg
@@ -94,19 +109,19 @@ buildPythonApplication rec {
    six
  ];

  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
  preConfigure = ''
    export click_cv_perl_vendorlib=$out/${perl.libPrefix}
    export PYTHON_INSTALL_FLAGS="--prefix=$out"
  '';

  preCheck = ''
    export HOME=$TMP
  configureFlags = [
    "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
    "--with-systemduserunitdir=${placeholder "out"}/lib/systemd/user"
  ];

    # tests recompile some files for loaded predefines, doesn't use any optimisation level for it
    # makes test output harder to read, so make the warning go away
    export NIX_CFLAGS_COMPILE+=" -U_FORTIFY_SOURCE"
  enableParallelBuilding = true;

    for path in $disabledTestPaths; do
      rm -v $path
    done
  '';
  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

  disabledTestPaths = [
    # From apt: Unable to determine a suitable packaging system type
@@ -116,45 +131,41 @@ buildPythonApplication rec {
    "click_package/tests/test_scripts.py"
  ];

  enableParallelBuilding = true;
  preCheck = ''
    export HOME=$TMP

  patches = [
    # Remove when version > 0.5.2
    (fetchpatch {
      name = "0001-click-fix-Wimplicit-function-declaration.patch";
      url = "https://gitlab.com/ubports/development/core/click/-/commit/8f654978a12e6f9a0b6ff64296ec5565e3ff5cd0.patch";
      hash = "sha256-kio+DdtuagUNYEosyQY3q3H+dJM3cLQRW9wUKUcpUTY=";
    })
    # tests recompile some files for loaded predefines, doesn't use any optimisation level for it
    # makes test output harder to read, so make the warning go away
    export NIX_CFLAGS_COMPILE+=" -U_FORTIFY_SOURCE"

    # Remove when version > 0.5.2
    (fetchpatch {
      name = "0002-click-Add-uid_t-and-gid_t-to-the-ctypes-_typemap.patch";
      url = "https://gitlab.com/ubports/development/core/click/-/commit/cbcd23b08b02fa122434e1edd69c2b3dcb6a8793.patch";
      hash = "sha256-QaWRhxO61wAzULVqPLdJrLuBCr3+NhKmQlEPuYq843I=";
    })
  ];
    # Haven'tbeen able to get them excluded via disabledTest{s,Paths}, just deleting them
    for path in $disabledTestPaths; do
      rm -v $path
    done
  '';

  buildInputs = [
    glib
    libgee
    json-glib
    properties-cpp
  ];
  preFixup = ''
    makeWrapperArgs+=(
      --prefix LD_LIBRARY_PATH : "$out/lib"
    )
  '';

  propagatedBuildInputs = [
    python-debian
    pygobject3
    setuptools
  ];
  passthru.tests.pkg-config = testers.hasPkgConfigModules {
    package = ubports-click;
  };

  meta = {
    description = "Tool to build click packages. Mainly used for Ubuntu Touch";
    description = "Tool to build click packages, mainly used for Ubuntu Touch";
    homepage = "https://gitlab.com/ubports/development/core/click";
    changelog = "https://gitlab.com/ubports/development/core/click/-/blob/${version}/ChangeLog";
    license = lib.licenses.gpl3Only;
    mainProgram = "click";
    maintainers = with lib.maintainers; [
      ilyakooo0
      OPNA2608
    ];
    ] ++ lib.teams.lomiri.members;
    platforms = lib.platforms.linux;
    pkgConfigModules = [
      "click-0.4"
    ];
  };
}