]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add blivet3 repackaging (work in progress)
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Oct 2020 08:43:29 +0000 (10:43 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Oct 2020 08:43:29 +0000 (10:43 +0200)
overlays/python-packages/default.nix
pkgs/python-packages/blivet/default.nix [new file with mode: 0644]
pkgs/python-packages/blivet/fix_path.patch [new file with mode: 0644]
pkgs/python-packages/blivet/poetry.lock [new file with mode: 0644]
pkgs/python-packages/blivet/pyproject.toml [new file with mode: 0644]
pkgs/python-packages/default.nix

index 901cd7266cc8c5e43f095755bb34d7b74fe5abee..11dea09602b616df8a68ae8ce963b334df951a7f 100644 (file)
@@ -23,6 +23,7 @@ in
 
 
   apprise = fromMyPythonPackages "apprise";
+  blivet3 = fromMyPythonPackages "blivet3";
   buildbot = import ./buildbot.nix;
   wokkel = fromMyPythonPackages "wokkel";
   pymilter = fromMyPythonPackages "pymilter";
diff --git a/pkgs/python-packages/blivet/default.nix b/pkgs/python-packages/blivet/default.nix
new file mode 100644 (file)
index 0000000..108d548
--- /dev/null
@@ -0,0 +1,118 @@
+{ lib, writeText, poetry2nix, python, pythonPackages,
+  gobject-introspection, libblockdev, libbytesize, fetchFromGitHub,
+  pkg-config, parted, systemd,
+  with_dmraid ? false,
+  with_fs_btrfs ? false,
+  with_fs_fat ? false,
+  with_fs_f2fs ? false,
+  with_fs_hfs_plus ? false,
+  with_fs_jfs ? false,
+  with_fs_nfs ? false,
+  with_fs_nfsv4 ? false,
+  with_fs_ntfs ? false,
+  with_fs_reiserfs ? false,
+  with_fs_xfs ? false,
+  with_luks ? false,
+  with_lvm ? false,
+  with_mdadm ? false,
+  with_multipath ? false,
+  with_optical ? false,
+  with_iscsi ? false,
+  dmraid, multipath_tools, lvm2, eject, kmod, utillinux, lsof,
+  openiscsi, coreutils, dosfstools, e2fsprogs, jfsutils, btrfs-progs,
+  xfsprogs, f2fs-tools, hfsprogs, nfs-utils, ntfs3g, ntfsprogs,
+  reiserfsprogs, devicemapper, cryptsetup, mdadm
+}@args:
+let
+  # FIXME: blivet/tasks/fsmount.py links to /sbin
+  additionalPackages =
+      lib.optionals with_dmraid [ dmraid ]
+   ++ lib.optionals with_fs_btrfs [ btrfs-progs ]
+   ++ lib.optionals with_fs_fat [ dosfstools ]
+   ++ lib.optionals with_fs_f2fs [ f2fs-tools ]
+   ++ lib.optionals with_fs_hfs_plus [ hfsprogs ]
+   ++ lib.optionals with_fs_jfs [ jfsutils ]
+   ++ lib.optionals with_fs_nfs [ nfs-utils ]
+   ++ lib.optionals with_fs_ntfs [ ntfs3g ntfsprogs ]
+   ++ lib.optionals with_fs_reiserfs [ reiserfsprogs ]
+   ++ lib.optionals with_fs_xfs [ xfsprogs.bin ]
+   ++ lib.optionals with_luks [ devicemapper cryptsetup ]
+   ++ lib.optionals with_lvm [ lvm2 ]
+   ++ lib.optionals with_mdadm [ mdadm ]
+   ++ lib.optionals with_multipath [ multipath_tools ]
+   ++ lib.optionals with_optical [ eject ]
+   ++ lib.optionals with_iscsi [ openiscsi ];
+in
+# nix-shell -E "with import <nixpkgs> {}; pkgs.mkShell { buildInputs = [ python3 python3Packages.blivet3 ]; }"
+# nix-shell -E "with import <nixpkgs> {}; pkgs.mkShell { buildInputs = [ (python3.withPackages(p: [ p.blivet3 ])) ]; }"
+poetry2nix.mkPoetryApplication {
+  inherit python;
+  propagatedBuildInputs = [
+    gobject-introspection
+    (pythonPackages.toPythonModule libblockdev)
+    (pythonPackages.toPythonModule libbytesize)
+  ];
+  src = fetchFromGitHub {
+    owner = "storaged-project";
+    repo = "blivet";
+    rev = "blivet-3.3.0";
+    sha256 = "0ynxm37cxxr2sf2hj18hrdxs1qfw6dgdagkvv5f6g4fmp51m7c3c";
+  };
+  overrides = poetry2nix.overrides.withDefaults (self: super: {
+    pyparted = super.pyparted.overridePythonAttrs (old: {
+      buildInputs = old.buildInputs ++ [ parted ];
+      nativeBuildInputs = old.nativeBuildInputs ++ [ pkg-config ];
+    });
+    selinux = super.selinux.overridePythonAttrs (old: {
+      buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
+      nativeBuildInputs = old.nativeBuildInputs ++ [ pkg-config ];
+    });
+  });
+  patches = [ ./fix_path.patch ];
+  postPatch = let
+    runtimePaths = lib.makeBinPath ([
+      systemd utillinux kmod e2fsprogs mdadm lsof coreutils
+    ] ++ additionalPackages);
+    libraryPath = builtins.concatStringsSep " " (map (v: "-rpath ${v}/lib -L ${v}/lib") [ systemd.lib ]);
+    giLibraryPath = lib.makeSearchPath "lib/girepository-1.0" [libblockdev gobject-introspection];
+    addGiPath = writeText "add-gi-path" ''
+      import os
+      newGiPath = "${giLibraryPath}"
+      if newGiPath not in os.environ.get("GI_TYPELIB_PATH", ""):
+          os.environ["GI_TYPELIB_PATH"] = os.environ.get("GI_TYPELIB_PATH", "") + ":" + newGiPath
+    '';
+    addPath = writeText "add-path" ''
+      import os
+      newPath = "${runtimePaths}"
+      newLibraryPath = "${libraryPath}"
+      if newPath not in os.environ.get("PATH", ""):
+          os.environ["PATH"] = os.environ.get("PATH", "") + ":" + newPath
+          os.environ["NIX_LDFLAGS"] = os.environ.get("NIX_LDFLAGS", "") + " " + newLibraryPath
+    '';
+  in
+  ''
+      prepend() {
+        mv "$1" "$1.bak"
+        cat ${addPath} "$1.bak" > $1
+        rm -f "$1.bak"
+      }
+      prepend "blivet/__init__.py"
+      prepend "blivet/iscsi.py"
+      prepend "blivet/tasks/availability.py"
+      prepend "blivet/util.py"
+      prepend "blivet/udev.py"
+      prependGi() {
+        mv "$1" "$1.bak"
+        cat ${addGiPath} "$1.bak" > $1
+        rm -f "$1.bak"
+      }
+      grep -rl require_version blivet/ | while read i; do prependGi "$i"; done
+      sed -i -e "s@/lib/modules@/run/booted-system/kernel-modules/lib/modules/@" blivet/tasks/fsmount.py
+    '';
+  postInstall = let
+  in ''
+    rm -rf $out/lib/python*/site-packages/{etc,usr}
+    '';
+  pyproject = ./pyproject.toml;
+  poetrylock = ./poetry.lock;
+}
diff --git a/pkgs/python-packages/blivet/fix_path.patch b/pkgs/python-packages/blivet/fix_path.patch
new file mode 100644 (file)
index 0000000..29c4052
--- /dev/null
@@ -0,0 +1,21 @@
+diff --git a/blivet/tasks/fsmount.py b/blivet/tasks/fsmount.py
+index 15f79a3e..bb3fe873 100644
+--- a/blivet/tasks/fsmount.py
++++ b/blivet/tasks/fsmount.py
+@@ -19,6 +19,7 @@
+ #
+ # Red Hat Author(s): Anne Mulhern <amulhern@redhat.com>
++from distutils.spawn import find_executable
+ import os
+ from ..errors import FSError
+@@ -58,7 +59,7 @@ class FSMount(task.BasicApplication, fstask.FSTask):
+     @property
+     def _can_mount(self):
+         return (self.mount_type in fslib.kernel_filesystems) or \
+-            (os.access("/sbin/mount.%s" % (self.mount_type,), os.X_OK)) or \
++            (find_executable("mount.%s" % (self.mount_type,)) is not None) or \
+             self._has_driver
+     @property
diff --git a/pkgs/python-packages/blivet/poetry.lock b/pkgs/python-packages/blivet/poetry.lock
new file mode 100644 (file)
index 0000000..c45011a
--- /dev/null
@@ -0,0 +1,96 @@
+[[package]]
+name = "distro"
+version = "1.5.0"
+description = "Distro - an OS platform information API"
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "pycairo"
+version = "1.19.1"
+description = "Python interface for cairo"
+category = "main"
+optional = false
+python-versions = ">=3.5, <4"
+
+[[package]]
+name = "pygobject"
+version = "3.36.1"
+description = "Python bindings for GObject Introspection"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+
+[package.dependencies]
+pycairo = ">=1.11.1"
+
+[[package]]
+name = "pyparted"
+version = "3.11.6"
+description = "Python bindings for GNU parted"
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "pyudev"
+version = "0.22.0"
+description = "A libudev binding"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+six = "*"
+
+[[package]]
+name = "selinux"
+version = "0.2.1"
+description = "shim selinux module"
+category = "main"
+optional = false
+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
+
+[package.dependencies]
+distro = ">=1.3.0"
+setuptools = ">=39.0"
+
+[[package]]
+name = "six"
+version = "1.15.0"
+description = "Python 2 and 3 compatibility utilities"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
+
+[metadata]
+lock-version = "1.0"
+python-versions = "^3.8"
+content-hash = "636edb46b1deb0f6d5db636b0bc6639205335c9915480b156a417067137548f8"
+
+[metadata.files]
+distro = [
+    {file = "distro-1.5.0-py2.py3-none-any.whl", hash = "sha256:df74eed763e18d10d0da624258524ae80486432cd17392d9c3d96f5e83cd2799"},
+    {file = "distro-1.5.0.tar.gz", hash = "sha256:0e58756ae38fbd8fc3020d54badb8eae17c5b9dcbed388b17bb55b8a5928df92"},
+]
+pycairo = [
+    {file = "pycairo-1.19.1.tar.gz", hash = "sha256:2c143183280feb67f5beb4e543fd49990c28e7df427301ede04fc550d3562e84"},
+]
+pygobject = [
+    {file = "PyGObject-3.36.1.tar.gz", hash = "sha256:012a589aec687bfa809a1ff9f5cd775dc7f6fcec1a6bc7fe88e1002a68f8ba34"},
+]
+pyparted = [
+    {file = "pyparted-3.11.6.tar.gz", hash = "sha256:727ccdf308c194069aa9797f7a6a973bc95b2e407cdf5d58d6c8bc4c9dec92dc"},
+]
+pyudev = [
+    {file = "pyudev-0.22.0.tar.gz", hash = "sha256:69bb1beb7ac52855b6d1b9fe909eefb0017f38d917cba9939602c6880035b276"},
+]
+selinux = [
+    {file = "selinux-0.2.1-py2.py3-none-any.whl", hash = "sha256:820adcf1b4451c9cc7759848797703263ba0eb6a4cad76d73548a9e0d57b7926"},
+    {file = "selinux-0.2.1.tar.gz", hash = "sha256:d435f514e834e3fdc0941f6a29d086b80b2ea51b28112aee6254bd104ee42a74"},
+]
+six = [
+    {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
+    {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
+]
diff --git a/pkgs/python-packages/blivet/pyproject.toml b/pkgs/python-packages/blivet/pyproject.toml
new file mode 100644 (file)
index 0000000..cf86aa1
--- /dev/null
@@ -0,0 +1,20 @@
+[tool.poetry]
+name = "blivet"
+version = "3.3.0"
+description = "A python module for system storage configuration"
+authors = ["David Lehman <dlehman@redhat.com>"]
+license = "GPL-2.0-or-later"
+
+[tool.poetry.dependencies]
+python = "^3.8"
+six = "^1.15.0"
+pyudev = "^0.22.0"
+pyparted = "^3.11.6"
+selinux = "^0.2.1"
+pygobject = "^3.36.1"
+
+[tool.poetry.dev-dependencies]
+
+[build-system]
+requires = ["poetry>=0.12"]
+build-backend = "poetry.masonry.api"
index 9347a067b6a6f448905c0065c768e98e6e88ad22..94bb5fec7c4ad03f76e46f15bd10c630a7c1cce2 100644 (file)
@@ -1,6 +1,7 @@
 { mylibs, callPackage, python }:
 {
   apprise = callPackage ./apprise { inherit mylibs; pythonPackages = python.pkgs; };
+  blivet3 = callPackage ./blivet { inherit python; pythonPackages = python.pkgs; };
   buildbot-plugins = callPackage ./buildbot/plugins { inherit python; };
   wokkel = callPackage ./wokkel.nix { pythonPackages = python.pkgs; };
   pymilter = callPackage ./pymilter.nix { pythonPackages = python.pkgs; };