From dc3777645d9fa1a5d74f37c99ba8ae160c22e548 Mon Sep 17 00:00:00 2001 From: Mike khiretskiy Date: Wed, 21 May 2014 10:40:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=20udev-209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install/variables/net.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/install/variables/net.py b/install/variables/net.py index 01b0032..a07cfe3 100644 --- a/install/variables/net.py +++ b/install/variables/net.py @@ -34,6 +34,7 @@ from calculate.lib.utils import ip from calculate.lib.utils.portage import isPkgInstalled from operator import itemgetter from itertools import * +from functools import partial import hashlib from calculate.install.distr import DistributiveError @@ -92,18 +93,24 @@ class VariableOsInstallNetInterfacesOrig(NetHelper,ReadonlyVariable): """ type = "list" + def is_classic_interface_name(self): + hashsum = lambda x: hashlib.md5(readFile(x)).digest() + chroot_path = self.Get('cl_chroot_path') + etc_path_join = partial(path.join, + chroot_path, 'etc/udev/rules.d') + lib_path_join = partial(path.join, + chroot_path, 'lib/udev/rules.d') + udev_files = ('70-persistent-net.rules', + '80-net-name-slot.rules', + '80-net-setup-link.rules') + for etc_file, lib_file in izip(map(etc_path_join,udev_files), + map(lib_path_join,udev_files)): + if path.exists(etc_file) and hashsum(etc_file) != hashsum(lib_file): + return True + return False + def get(self): - chrootPath = self.Get('cl_chroot_path') - pathOldUdevNet = path.join(chrootPath, - 'etc/udev/rules.d/70-persistent-net.rules') - pathNewUdevNet = path.join(chrootPath, - 'etc/udev/rules.d/80-net-name-slot.rules') - pathOrigUdevNet = path.join(chrootPath, - 'lib/udev/rules.d/80-net-name-slot.rules') - if path.exists(pathOldUdevNet) or \ - (path.exists(pathNewUdevNet) and - hashlib.md5(readFile(pathNewUdevNet)).digest() != \ - hashlib.md5(readFile(pathOrigUdevNet)).digest()): + if self.is_classic_interface_name(): return self.Get('os_install_net_interfaces') def getOrig(x): try: