示例#1
0
	def revert(self):
		""" Umounts TARGET. """
		
		# Ensure that is mounted
		if not os.path.ismount(self.main_settings["target"]):
			# Umounted. pass.
			pass
		
		# See if "used" was... used :)
		if "partdisks.inst" in self.modules_settings and "used" in self.modules_settings["partdisks.inst"]:
			_used = self.modules_settings["partdisks.inst"]["used"]
			_used.reverse()
			if _used:
				for part in _used:
					if lib.is_mounted(part):
						try:
							lib.umount(path=part, tries=5)
						except:
							pass
		
		# Umount target, finally.
		try:
			lib.umount(path=self.main_settings["target"], tries=5)
		except:
			pass
示例#2
0
	def disable(self):
		""" Disables the LogicalVolume. """
		
		if os.path.exists(self.path):
			
			# Ensure it is umounted...
			if is_mounted(self.mapper_path): umount(path=self.mapper_path)
			
			m.sexec("lvchange -a n %s" % self.path)
示例#3
0
文件: crypt.py 项目: g7/linstaller
	def close(self):
		""" Closes the device. """
		
		# Bugfix
		if not self.path: return
		
		# Ensure we have it unmounted...
		if lib.is_mounted(self.path): lib.umount(path=self.path)
		
		# Then close...
		m.sexec("cryptsetup luksClose %s" % self.path)
示例#4
0
    def freespace(self, partition):
        """ Calculates freespace on partition. """

        # Rapid-mount
        mounted = lib.mount_partition(path=partition)

        info = os.statvfs(mounted)

        free = info.f_frsize * info.f_bavail

        # Umount
        lib.umount(path=mounted)

        return free
示例#5
0
	def start(self):
		""" Do things. """
		
		used = []

		# Bind-mount /dev, /sys and /proc (if no_virtual_partitions is not True):
		if not self.settings["skip"]:
			for point in ("/dev","/sys","/proc"):
				fullpath = os.path.join(self.main_settings["target"],os.path.basename(point))
				if lib.is_mounted(fullpath):
					lib.umount(path=fullpath)
				
				# We can go?
				lib.mount_partition(path=point, opts="bind", target=fullpath, check=False)
				used.append(fullpath)
				
		# Store used
		self.settings["used"] = used
示例#6
0
	def revert(self):
		""" Umounts virtual partitions, if any. """
		
		# Ensure that we didn't skip
		if not "virtualpartitions.inst" in self.modules_settings or ("skip" in self.modules_settings["virtualpartitions.inst"] and
			self.modules_settings["virtualpartitions.inst"]["skip"]):

			return
			
		# See if "used" was... used :)
		if "used" in self.modules_settings["virtualpartitions.inst"]:
			_used = self.modules_settings["virtualpartitions.inst"]["used"]
			_used.reverse()
			if _used:
				for part in _used:
					if lib.is_mounted(part):
						try:
							lib.umount(path=part, tries=5)
						except:
							pass
示例#7
0
	def configure(self):
		""" Configures the previously formatted persistent filesystem. """
		
		path = self.main_settings["target"] + self.settings["path"] # os.path.join doesn't work if second argument begins with /
		image = os.path.join(path, "persistence-%s" % (self.settings["suffix"]))
		
		# Mount
		mpoint = lib.mount_partition(path=image, opts="loop")
		
		if self.settings["type"] in ("root", "home"):
			# Write
			with open(os.path.join(mpoint, "persistence.conf"), "w") as f:
				if self.settings["type"] == "root":
					# root persistence
					f.write("/ union\n")
				elif self.settings["type"] == "home":
					# home persistence
					f.write("/ bind\n")
		else:
			# We need to copy the path specified in type as the persistence.conf in the mountpoint
			shutil.copy2(self.settings["type"], os.path.join(mpoint, "persistence.conf"))
		
		# Umount!
		lib.umount(path=mpoint)
示例#8
0
	def start(self):
		""" Start override to unsquash. """
				
		if "partdisks" in self.modules_settings:
			settings = self.modules_settings["partdisks"]
		else:
			settings = self.settings
		
		# Mount root partition.
		root = settings["root"]

		# Ensure that is unmounted
		if os.path.ismount(self.main_settings["target"]):
			# Target mounted. Unmount
			lib.umount(path=self.main_settings["target"])
		if lib.is_mounted(root):
			# Partition mounted. Unmount
			lib.umount(path=root)
				
		# Then mount at TARGET
		lib.mount_partition(path=root, target=self.main_settings["target"])

		used = []
				
		# Mount every partition which has "useas" on it
		# Get changed.
		try:
			changed = self.modules_settings["partdisks"]["changed"]
		except:
			# Pass
			changed = {}
		
		mountpo = []
		changeslist = {}
				
		# Regenerate changed to sort it sanely
		for key, value in changed.items():
			if not "useas" in value["changes"]:
				# There isn't "useas" in changes; skipping this item
				continue

			mountpo.append(value["changes"]["useas"])
			changeslist[value["changes"]["useas"]] = key
		
		mountpo.sort()
				
		for point in mountpo:
						
			# Get correct partition
			key = changeslist[point]
			# Get value
			value = changed[key]
									
			# Get useas
			useas = value["changes"]["useas"]
			
			if useas in ("/","swap"):
				# Root or swap, do not use it
				continue
						
			# Mount key to mountpoint
			if lib.is_mounted(key):
				# Umount
				lib.umount(path=key)
			if useas == "/boot/efi":
				# If this is going to be the /boot/efi partition
				# we should make sure that it's going to have the
				# proper partition type set to EFI System Partition
				lib.prepareforEFI(lib.return_partition(key))
							
			# If we mount_on_install, simply set drop to False, as we should use it anyway
			if ("mount_on_install" in value["changes"] and value["changes"]["mount_on_install"]) or useas in ("/boot","/boot/efi"):
				# Create mountpoint
				mountpoint = self.main_settings["target"] + useas # useas begins with a /, so os.path.join doesn't work
				if not os.path.exists(mountpoint): os.makedirs(mountpoint)

				lib.mount_partition(path=key, target=mountpoint)
				# Partition will be used during unsquash, we should remember when linstaller will execute revert
				used.append(key)
				
		# Store used
		self.settings["used"] = used