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: