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 <aszlig@redmoonstudios.org>

aszlig 3bf3d197 b7f3d559

+47 -11
+4 -9
pkgs/tools/filesystems/nixpart/0.4/blivet.nix
··· 1 { stdenv, fetchurl, buildPythonPackage, pykickstart, pyparted, pyblock 2 , libselinux, cryptsetup, multipath_tools, lsof, utillinux 3 , useNixUdev ? true, udev ? null 4 - # This is only used when useNixUdev is false 5 - , udevSoMajor ? 1 6 }: 7 8 assert useNixUdev -> udev != null; ··· 16 + "${name}.tar.bz2"; 17 sha256 = "1k3mws2q0ryb7422mml6idmaasz2i2v6ngyvg6d976dx090qnmci"; 18 }; 19 20 postPatch = '' 21 sed -i -e 's|"multipath"|"${multipath_tools}/sbin/multipath"|' \ ··· 27 sed -i -e 's|"lsof"|"${lsof}/bin/lsof"|' blivet/formats/fs.py 28 sed -i -r -e 's|"(u?mount)"|"${utillinux}/bin/\1"|' blivet/util.py 29 sed -i '/pvscan/s/, *"--cache"//' blivet/devicelibs/lvm.py 30 - '' + (if useNixUdev then '' 31 sed -i -e '/find_library/,/find_library/ { 32 c libudev = "${udev}/lib/libudev.so.1" 33 }' blivet/pyudev.py 34 - '' else '' 35 - sed -i \ 36 - -e '/^somajor *=/s/=.*/= ${toString udevSoMajor}/p' \ 37 - -e 's|common =.*|& + ["/lib/x86_64-linux-gnu", "/lib/i686-linux-gnu"]|' \ 38 - blivet/pyudev.py 39 - ''); 40 41 propagatedBuildInputs = [ 42 pykickstart pyparted pyblock libselinux cryptsetup
··· 1 { stdenv, fetchurl, buildPythonPackage, pykickstart, pyparted, pyblock 2 , libselinux, cryptsetup, multipath_tools, lsof, utillinux 3 , useNixUdev ? true, udev ? null 4 }: 5 6 assert useNixUdev -> udev != null; ··· 14 + "${name}.tar.bz2"; 15 sha256 = "1k3mws2q0ryb7422mml6idmaasz2i2v6ngyvg6d976dx090qnmci"; 16 }; 17 + 18 + patches = [ ./blivet.patch ]; 19 20 postPatch = '' 21 sed -i -e 's|"multipath"|"${multipath_tools}/sbin/multipath"|' \ ··· 27 sed -i -e 's|"lsof"|"${lsof}/bin/lsof"|' blivet/formats/fs.py 28 sed -i -r -e 's|"(u?mount)"|"${utillinux}/bin/\1"|' blivet/util.py 29 sed -i '/pvscan/s/, *"--cache"//' blivet/devicelibs/lvm.py 30 + '' + stdenv.lib.optionalString useNixUdev '' 31 sed -i -e '/find_library/,/find_library/ { 32 c libudev = "${udev}/lib/libudev.so.1" 33 }' blivet/pyudev.py 34 + ''; 35 36 propagatedBuildInputs = [ 37 pykickstart pyparted pyblock libselinux cryptsetup
+39
pkgs/tools/filesystems/nixpart/0.4/blivet.patch
···
··· 1 + diff --git a/blivet/pyudev.py b/blivet/pyudev.py 2 + index 705b93d..7268d71 100644 3 + --- a/blivet/pyudev.py 4 + +++ b/blivet/pyudev.py 5 + @@ -7,9 +7,9 @@ from ctypes import * 6 + 7 + 8 + # XXX this one may need some tweaking... 9 + -def find_library(name, somajor=0): 10 + +def find_library(name): 11 + env = os.environ.get("LD_LIBRARY_PATH") 12 + - common = ["/lib64", "/lib"] 13 + + common = ["/lib64", "/lib", "/lib/x86_64-linux-gnu", "/lib/i686-linux-gnu"] 14 + 15 + if env: 16 + libdirs = env.split(":") + common 17 + @@ -19,7 +19,7 @@ def find_library(name, somajor=0): 18 + libdirs = filter(os.path.isdir, libdirs) 19 + 20 + for dir in libdirs: 21 + - files = fnmatch.filter(os.listdir(dir), "lib%s.so.%d" % (name, somajor)) 22 + + files = fnmatch.filter(os.listdir(dir), "lib%s.so.*" % name) 23 + files = [os.path.join(dir, file) for file in files] 24 + 25 + if files: 26 + @@ -32,11 +32,10 @@ def find_library(name, somajor=0): 27 + 28 + # find the udev library 29 + name = "udev" 30 + -somajor = 1 31 + -libudev = find_library(name=name, somajor=somajor) 32 + +libudev = find_library(name) 33 + 34 + if not libudev or not os.path.exists(libudev): 35 + - raise ImportError, "No library named %s.%d" % (name, somajor) 36 + + raise ImportError, "No library named lib%s.so" % name 37 + 38 + # load the udev library 39 + libudev = CDLL(libudev)
+4 -2
pkgs/tools/filesystems/nixpart/0.4/default.nix
··· 1 { stdenv, fetchurl, python, buildPythonPackage 2 # Propagated to blivet 3 - , useNixUdev ? true, udevSoMajor ? null 4 # Propagated dependencies 5 , pkgs, urlgrabber 6 }: ··· 9 blivet = import ./blivet.nix { 10 inherit stdenv fetchurl buildPythonPackage; 11 inherit pykickstart pyparted pyblock cryptsetup multipath_tools; 12 - inherit useNixUdev udevSoMajor; 13 inherit (pkgs) lsof utillinux udev; 14 libselinux = pkgs.libselinux.override { enablePython = true; }; 15 };
··· 1 { stdenv, fetchurl, python, buildPythonPackage 2 # Propagated to blivet 3 + , useNixUdev ? true 4 + # No longer needed, but kept for backwards-compatibility with older NixOps. 5 + , udevSoMajor ? null 6 # Propagated dependencies 7 , pkgs, urlgrabber 8 }: ··· 11 blivet = import ./blivet.nix { 12 inherit stdenv fetchurl buildPythonPackage; 13 inherit pykickstart pyparted pyblock cryptsetup multipath_tools; 14 + inherit useNixUdev; 15 inherit (pkgs) lsof utillinux udev; 16 libselinux = pkgs.libselinux.override { enablePython = true; }; 17 };