From 3bf3d1975922b8956565e10ccc5f4caea0fdbcf6 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 21 Oct 2015 16:43:34 +0200 Subject: [PATCH] nixpart0: Don't search for libudev using SO major. The SO major is going to change in the upcoming update of the Hetzner rescue system, which will cause NixOps to break because it's statically using the SO major 0 while the new rescue system will have the major number 1. I'm still keeping the udevSoMajor attribute to retain backwards- compatibility with older NixOps versions. Signed-off-by: aszlig --- pkgs/tools/filesystems/nixpart/0.4/blivet.nix | 13 ++----- .../filesystems/nixpart/0.4/blivet.patch | 39 +++++++++++++++++++ .../tools/filesystems/nixpart/0.4/default.nix | 6 ++- 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 pkgs/tools/filesystems/nixpart/0.4/blivet.patch diff --git a/pkgs/tools/filesystems/nixpart/0.4/blivet.nix b/pkgs/tools/filesystems/nixpart/0.4/blivet.nix index fd7d59774b2..d4129f4d390 100644 --- a/pkgs/tools/filesystems/nixpart/0.4/blivet.nix +++ b/pkgs/tools/filesystems/nixpart/0.4/blivet.nix @@ -1,8 +1,6 @@ { stdenv, fetchurl, buildPythonPackage, pykickstart, pyparted, pyblock , libselinux, cryptsetup, multipath_tools, lsof, utillinux , useNixUdev ? true, udev ? null -# This is only used when useNixUdev is false -, udevSoMajor ? 1 }: assert useNixUdev -> udev != null; @@ -17,6 +15,8 @@ buildPythonPackage rec { sha256 = "1k3mws2q0ryb7422mml6idmaasz2i2v6ngyvg6d976dx090qnmci"; }; + patches = [ ./blivet.patch ]; + postPatch = '' sed -i -e 's|"multipath"|"${multipath_tools}/sbin/multipath"|' \ blivet/devicelibs/mpath.py blivet/devices.py @@ -27,16 +27,11 @@ buildPythonPackage rec { sed -i -e 's|"lsof"|"${lsof}/bin/lsof"|' blivet/formats/fs.py sed -i -r -e 's|"(u?mount)"|"${utillinux}/bin/\1"|' blivet/util.py sed -i '/pvscan/s/, *"--cache"//' blivet/devicelibs/lvm.py - '' + (if useNixUdev then '' + '' + stdenv.lib.optionalString useNixUdev '' sed -i -e '/find_library/,/find_library/ { c libudev = "${udev}/lib/libudev.so.1" }' blivet/pyudev.py - '' else '' - sed -i \ - -e '/^somajor *=/s/=.*/= ${toString udevSoMajor}/p' \ - -e 's|common =.*|& + ["/lib/x86_64-linux-gnu", "/lib/i686-linux-gnu"]|' \ - blivet/pyudev.py - ''); + ''; propagatedBuildInputs = [ pykickstart pyparted pyblock libselinux cryptsetup diff --git a/pkgs/tools/filesystems/nixpart/0.4/blivet.patch b/pkgs/tools/filesystems/nixpart/0.4/blivet.patch new file mode 100644 index 00000000000..1758d18442d --- /dev/null +++ b/pkgs/tools/filesystems/nixpart/0.4/blivet.patch @@ -0,0 +1,39 @@ +diff --git a/blivet/pyudev.py b/blivet/pyudev.py +index 705b93d..7268d71 100644 +--- a/blivet/pyudev.py ++++ b/blivet/pyudev.py +@@ -7,9 +7,9 @@ from ctypes import * + + + # XXX this one may need some tweaking... +-def find_library(name, somajor=0): ++def find_library(name): + env = os.environ.get("LD_LIBRARY_PATH") +- common = ["/lib64", "/lib"] ++ common = ["/lib64", "/lib", "/lib/x86_64-linux-gnu", "/lib/i686-linux-gnu"] + + if env: + libdirs = env.split(":") + common +@@ -19,7 +19,7 @@ def find_library(name, somajor=0): + libdirs = filter(os.path.isdir, libdirs) + + for dir in libdirs: +- files = fnmatch.filter(os.listdir(dir), "lib%s.so.%d" % (name, somajor)) ++ files = fnmatch.filter(os.listdir(dir), "lib%s.so.*" % name) + files = [os.path.join(dir, file) for file in files] + + if files: +@@ -32,11 +32,10 @@ def find_library(name, somajor=0): + + # find the udev library + name = "udev" +-somajor = 1 +-libudev = find_library(name=name, somajor=somajor) ++libudev = find_library(name) + + if not libudev or not os.path.exists(libudev): +- raise ImportError, "No library named %s.%d" % (name, somajor) ++ raise ImportError, "No library named lib%s.so" % name + + # load the udev library + libudev = CDLL(libudev) diff --git a/pkgs/tools/filesystems/nixpart/0.4/default.nix b/pkgs/tools/filesystems/nixpart/0.4/default.nix index 9ea2f9bfdc7..01a3caafc5d 100644 --- a/pkgs/tools/filesystems/nixpart/0.4/default.nix +++ b/pkgs/tools/filesystems/nixpart/0.4/default.nix @@ -1,6 +1,8 @@ { stdenv, fetchurl, python, buildPythonPackage # Propagated to blivet -, useNixUdev ? true, udevSoMajor ? null +, useNixUdev ? true +# No longer needed, but kept for backwards-compatibility with older NixOps. +, udevSoMajor ? null # Propagated dependencies , pkgs, urlgrabber }: @@ -9,7 +11,7 @@ let blivet = import ./blivet.nix { inherit stdenv fetchurl buildPythonPackage; inherit pykickstart pyparted pyblock cryptsetup multipath_tools; - inherit useNixUdev udevSoMajor; + inherit useNixUdev; inherit (pkgs) lsof utillinux udev; libselinux = pkgs.libselinux.override { enablePython = true; }; };