def _partition_format_step(self, parted_disk, device, newparts):
		for part in newparts:
			newpart = newparts[part]
			devnode = newpart['devnode']
			# This little hack is necessary because parted sucks goat nuts
			if newparts.get_disklabel() == "mac" and newpart['type'] == "free":
				self._delete_partition(parted_disk, newpart)
				continue
			if newpart['format'] and newpart['type'] not in ('extended', 'free'):
#				devnode = device + str(int(part))
				if self._debug: self._logger.log("_partition_format_step(): devnode is %s in formatting code" % devnode)
				# if you need a special command and
				# some base options, place it here.
				format_cmds = { 'linux-swap': "mkswap", 'fat16': "mkfs.vfat -F 16", 'fat32': "mkfs.vfat -F 32",
				                'ntfs': "mkntfs", 'xfs': "mkfs.xfs -f", 'jfs': "mkfs.jfs -f",
				                'reiserfs': "mkfs.reiserfs -f", 'ext2': "mkfs.ext2", 'ext3': "mkfs.ext3"
				              }
				if newpart['type'] in format_cmds:
					cmdname = format_cmds[newpart['type']]
				else: # this should catch everything else
					raise GLIException("PartitionFormatError", 'fatal', '_partition_format_step', "Unknown partition type " + newpart['type'])
				# sleep a bit first
				time.sleep(1)
				for tries in range(10):
					cmd = "%s %s %s" % (cmdname, newpart['mkfsopts'], devnode)
					self._logger.log("  Formatting partition %s as %s with: %s" % (str(part),newpart['type'],cmd))
					ret = GLIUtility.spawn(cmd, logfile=self._compile_logfile, append_log=True)
					if not GLIUtility.exitsuccess(ret):
						self._logger.log("Try %d failed formatting partition %s...waiting 5 seconds" % (tries+1, devnode))
						time.sleep(5)
					else:
						break
				else:
					raise GLIException("PartitionFormatError", 'fatal', '_partition_format_step', "Could not create %s filesystem on %s" % (newpart['type'], devnode))
	def activate(self):
		self.controller.SHOW_BUTTON_EXIT    = True
		self.controller.SHOW_BUTTON_HELP    = True
		self.controller.SHOW_BUTTON_BACK    = True
		self.controller.SHOW_BUTTON_FORWARD = True
		self.controller.SHOW_BUTTON_FINISH  = False
		if self.controller.install_profile.get_dynamic_stage3():
			self.entry_portage_snapshot_uri.set_text(GLIUtility.get_cd_snapshot_uri())
			self.radio_syncs["snapshot"].set_active(True)
			self.active_selection = "snapshot"
			for radio in self.radio_syncs:
				self.radio_syncs[radio].set_sensitive(False)
			self.entry_portage_snapshot_uri.set_sensitive(False)
			self.browse_uri.set_sensitive(False)
		else:
			for radio in self.radio_syncs:
				self.radio_syncs[radio].set_sensitive(True)
			self.entry_portage_snapshot_uri.set_sensitive(True)
			self.browse_uri.set_sensitive(True)
			self.active_selection = self.controller.install_profile.get_portage_tree_sync_type() or "sync"
			self.radio_syncs[self.active_selection].set_active(True)
			self.stage_selected(self.radio_syncs[self.active_selection], self.active_selection)
			self.entry_portage_snapshot_uri.set_text(self.controller.install_profile.get_portage_tree_snapshot_uri())
			if not self.entry_portage_snapshot_uri.get_text():
				self.entry_portage_snapshot_uri.set_text(GLIUtility.get_cd_snapshot_uri())
Beispiel #3
0
	def get_deps(self, pkgs):
		pkglist = []
		if isinstance(pkgs, str):
			pkgs = pkgs.split()
		for pkg in pkgs:
			if not pkg: continue
			if self._debug: self._logger.log("get_deps(): pkg is " + pkg)
			if not self._grp_install or not self.get_best_version_vdb(pkg):
				if self._debug: self._logger.log("get_deps(): grabbing compile deps")
				tmppkglist = GLIUtility.spawn("emerge -p " + pkg + r" 2>/dev/null | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n")
			else:
				if self._debug: self._logger.log("get_deps(): grabbing binary deps")
				# The runtimedeps.py script generates a package install order that is *very* different from emerge itself
#				tmppkglist = GLIUtility.spawn("python ../../runtimedeps.py " + self._chroot_dir + " " + pkg, return_output=True)[1].strip().split("\n")
				tmppkglist = []
				for tmppkg in GLIUtility.spawn("emerge -p " + pkg + r" 2>/dev/null | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n"):
					if self._debug: self._logger.log("get_deps(): looking at " + tmppkg)
					if self.get_best_version_vdb("=" + tmppkg):
						if self._debug: self._logger.log("get_deps(): package " + tmppkg + " in host vdb...adding to tmppkglist")
						tmppkglist.append(tmppkg)
			if self._debug: self._logger.log("get_deps(): deplist for " + pkg + ": " + str(tmppkglist))
			for tmppkg in tmppkglist:
				if self._debug: self._logger.log("get_deps(): checking to see if " + tmppkg + " is already in pkglist")
				if not tmppkg in pkglist and not self.get_best_version_vdb_chroot("=" + tmppkg):
					if self._debug: self._logger.log("get_deps(): adding " + tmppkg + " to pkglist")
					pkglist.append(tmppkg)
		if self._debug: self._logger.log("get_deps(): pkglist is " + str(pkglist))
		return pkglist
Beispiel #4
0
	def host_browse_clicked(self, button):
		hostdlg = gtk.Dialog("Browse mirror list", self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
		hbox = gtk.HBox(False)
		hbox.set_border_width(10)
		hbox.pack_start(gtk.Label("Mirror:"), expand=False, fill=False, padding=0)
		host_combo = gtk.combo_box_new_text()
		if self.uritypes[self.uritype.get_active()] == "http":
			mirrors = GLIUtility.list_mirrors(http=True, ftp=False, rsync=False)
		elif self.uritypes[self.uritype.get_active()] == "ftp":
			mirrors = GLIUtility.list_mirrors(http=False, ftp=True, rsync=False)
		else:
			msgdlg = gtk.MessageDialog(parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("There are no known mirrors for this URI type."))
			msgdlg.run()
			msgdlg.destroy()
			return
		for mirror in mirrors:
			host_combo.append_text(mirror[1])
			host_combo.set_active(0)
		hbox.pack_start(host_combo, expand=False, fill=True, padding=15)
		hbox.show_all()
		hostdlg.vbox.pack_start(hbox)
		resp = hostdlg.run()
		if resp == gtk.RESPONSE_ACCEPT:
			mirror = mirrors[host_combo.get_active()][0]
			if not mirror.endswith("/"):
				mirror += "/"
			self.uri = mirror
			self.update_from_uri()
		hostdlg.destroy()
Beispiel #5
0
	def add_pkg_to_world(self, package):
		if package.find("/") == -1:
			package = self.get_best_version_vdb_chroot(package)
		if not package: return False
		expr = re.compile('^=?(.+?/.+?)(-\d.+)?$')
		res = expr.match(package)
		if res:
			GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world")
	def start_portmap(self):
		if self._configuration.get_verbose(): self._logger.log("DEBUG: beginning of start_portmap()")
		status = GLIUtility.spawn('/etc/init.d/portmap start') #, display_on_tty8=True)
		if not GLIUtility.exitsuccess(status):
			self._logger.log("ERROR! : Could not start the portmap service!")
		#	raise GLIException("PortmapError", 'warning', 'start_portmap', "Could not start the portmap service!")
		else:
			self._logger.log("Portmap started.")
	def _configure_lilo(self):
		self.build_mode = self._install_profile.get_kernel_build_method()
		self._gather_lilo_drive_info()
		root = self._chroot_dir
		file_name3 = root + "/boot/kernel_name"
		root = self._chroot_dir
		exitstatus0 = GLIUtility.spawn("ls "+root+"/boot/kernel-* > "+file_name3)
		if (exitstatus0 != 0):
			raise GLIException("BootloaderError", 'fatal', '_configure_lilo', "Could not list kernels in /boot or no kernels found.")
		if self.build_mode == "genkernel" or self._install_profile.get_kernel_source_pkg() == "livecd-kernel":
			exitstatus1 = GLIUtility.spawn("ls "+root+"/boot/init* >> "+file_name3)
			if (exitstatus1 != 0):
				raise GLIException("BootloaderError", 'fatal', '_configure_lilo', "Could not list initrds in /boot")
		g = open(file_name3)
		kernel_name = g.readlines()
		g.close()
		if not kernel_name[0]:
			raise GLIException("BootloaderError", 'fatal', '_configure_lilo',"Error: We have no kernel in /boot to put in the grub.conf file!")
		kernel_name = map(string.strip, kernel_name)
		kernel_name[0] = kernel_name[0].split(root)[1]
		kernel_name[1] = kernel_name[1].split(root)[1]
		if self._install_profile.get_bootloader_kernel_args(): bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args()
		else: bootloader_kernel_args = ""
		#-------------------------------------------------------------
		#time to build the lilo.conf
		newliloconf = ""
		if self._install_profile.get_boot_loader_mbr():
			newliloconf += "boot="+self.mbr_device+"   # Install LILO in the MBR \n"
		else:
			newliloconf += "boot="+self.boot_device+self.boot_minor+"   # Install LILO in the MBR \n"
		newliloconf += "prompt                    # Give the user the chance to select another section\n"
		newliloconf += "timeout=50                # Wait 5 (five) seconds before booting the default section\n"
		newliloconf += "default=gentoo            # When the timeout has passed, boot the \"gentoo\" section\n"
		newliloconf += "# Only if you use framebuffer. Otherwise remove the following line:\n"
		if not self._install_profile.get_kernel_bootsplash():
			newliloconf += "#"
		newliloconf += "vga=788                   # Framebuffer setting. Adjust to your own will\n"
		newliloconf += "image=/boot"+kernel_name[0][5:]+" \n"
		newliloconf += "  label=gentoo \n  read-only \n"
		if self.build_mode != "genkernel" and self._install_profile.get_kernel_source_pkg() != "livecd-kernel": 
			newliloconf += "  root="+self.root_device+self.root_minor+" \n"
			if bootloader_kernel_args:
				newliloconf += "  append=\""+bootloader_kernel_args+"\" \n"
		else:
			newliloconf += "  root=/dev/ram0 \n"
			newliloconf += "  append=\"init=/linuxrc ramdisk=8192 real_root="+self.root_device+self.root_minor + " " + bootloader_kernel_args + "\" \n"
			newliloconf += "  initrd=/boot"+kernel_name[1][5:] + "\n\n"
		newliloconf = self._lilo_add_windows(newliloconf)
		#now make the lilo.conf file
		file_name = root + "/etc/lilo.conf"	
		try:
			shutil.move(file_name, file_name + ".OLDdefault")
		except:
			pass
		f = open(file_name, 'w')
		f.writelines(newliloconf)
		f.close()
		self._logger.log("Lilo installed and configured.  Not run yet.")
	def enable_ssh(self):
		if self._configuration.get_verbose(): self._logger.log("DEBUG: beginning of enable_ssh()")
		if self._configuration.get_enable_ssh():
			status = GLIUtility.spawn("/etc/init.d/sshd start")
			if not GLIUtility.exitsuccess(status):
				self._logger.log("ERROR! : Could not start the SSH daemon!")
			#	raise GLIException("SSHError", 'warning','enable_ssh',"Could not start SSH daemon!")
			else:
				self._logger.log("SSH Started.")
Beispiel #9
0
	def get_best_version_vdb_chroot(self, package):
		if package.startswith('='):
			package = package[1:]
			if GLIUtility.is_file(self._chroot_dir + "/var/db/pkg/" + package):
				return package
			else:
				return ""
		else:
			return GLIUtility.spawn("portageq best_version / " + package, chroot=self._chroot_dir, return_output=True)[1].strip()
	def set_root_passwd(self):
		self._logger.log("Setting root password.")
		if self._configuration.get_root_passwd() != "":
			# The password specified in the configuration is encrypted.
			status = GLIUtility.spawn("echo 'root:" + self._configuration.get_root_passwd() + "' | chpasswd -e")
	
			if not GLIUtility.exitsuccess(status):
				self._logger.log("ERROR! : Could not set the root password on the livecd environment!")
			#	raise GLIException("PasswordError", 'warning', 'set_root_passwd', "Could not set the root password!")
			else:
				self._logger.log("Livecd root password set.")
	def _partition_resize_step(self, parted_disk, device, oldparts, newparts):
		for oldpart in oldparts:
			tmppart_old = oldparts[oldpart]
			devnode = tmppart_old['devnode']
			newminor = self._find_existing_in_new(oldpart, newparts)
			if not newminor or not newparts[newminor]['resized']:
				continue
			tmppart_new = newparts[newminor]
			type = tmppart_new['type']
			start = tmppart_new['start']
			end = start + (long(tmppart['mb']) * MEGABYTE / 512) - 1
			total_sectors = end - start + 1
			total_bytes = long(total_sectors) * 512
			# Make sure calculated end sector doesn't overlap start sector of next partition
			nextminor = self._find_next_partition(newminor, newparts)
			if nextminor:
				if newparts[nextminor]['start'] and end >= newparts[nextminor]['start']:
					self._logger.log("  End sector for growing partition overlaps with start of next partition...fixing")
					end = newparts[nextminor]['start'] - 1
			# sleep a bit first
			time.sleep(3)
			# now sleep until it exists
			while not GLIUtility.is_file(device + str(minor)):
				self._logger.log("Waiting for device node " + devnode + " to exist before resizing")
				time.sleep(1)
			# one bit of extra sleep is needed, as there is a blip still
			time.sleep(3)
			if type in ("ext2", "ext3"):
				ret = GLIUtility.spawn("resize2fs " + devnode + " " + str(total_sectors) + "s", logfile=self._compile_logfile, append_log=True)
				if not GLIUtility.exitsuccess(ret): # Resize error
					raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize ext2/3 filesystem on " + devnode)
			elif type == "ntfs":
				ret = GLIUtility.spawn("yes | ntfsresize -v --size " + str(total_bytes) + " " + devnode, logfile=self._compile_logfile, append_log=True)
				if not GLIUtility.exitsuccess(ret): # Resize error
					raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize NTFS filesystem on " + devnode)
			elif type in ("linux-swap", "fat32", "fat16"):
				parted_fs = parted_disk.get_partition(part).geom.file_system_open()
				resize_constraint = parted_fs.get_resize_constraint()
				if total_sectors < resize_constraint.min_size or start != resize_constraint.start_range.start:
					raise GLIException("PartitionError", 'fatal', 'partition', "New size specified for " + device + str(minor) + " is not within allowed boundaries (blame parted)")
				new_geom = resize_constraint.start_range.duplicate()
				new_geom.set_start(start)
				new_geom.set_end(end)
				try:
					parted_fs.resize(new_geom)
				except:
					raise GLIException("PartitionResizeError", 'fatal', 'partition', "could not resize " + device + str(minor))
			self._logger.log("  Deleting old minor " + str(oldpart) + " to be recreated in 3rd pass")
			self._delete_partition(parted_disk, oldpart)
		parted_disk.delete_all()
		parted_disk.commit()
Beispiel #12
0
	def deactivate(self):
		temp_use = ""
		sorted_use = self.use_flags.keys()
		sorted_use.sort()
		for flag in sorted_use:
			if self.use_flags[flag]:
				temp_use += " " + flag
			else:
				temp_use += " -" + flag
		self.make_conf_values['USE'] = temp_use
		self.make_conf_values['CFLAGS'] = "-march=" + self.arch_procs['x86'][self.proc_combo.get_active()] + " " + self.optimizations[self.optimizations_combo.get_active()] + " " + self.custom_cflags_entry.get_text()
		if self.unstable_packages_check.get_active():
			self.make_conf_values['ACCEPT_KEYWORDS'] = "~x86"
		else:
			self.make_conf_values['ACCEPT_KEYWORDS'] = ""
		temp_features = ""
		if self.build_binary_check.get_active():
			temp_features += "buildpkg "
		if self.use_distcc_check.get_active():
			temp_features += "distcc "
		if self.use_ccache_check.get_active():
			temp_features += "ccache "
		self.make_conf_values['FEATURES'] = temp_features.strip()
		if self.controller.install_profile.get_install_stage() > 1:
			if 'CHOST' in self.make_conf_values:
				del self.make_conf_values['CHOST']
		else:
			self.make_conf_values['CHOST'] = GLIUtility.get_chosts(self.controller.client_profile.get_architecture_template())[self.chost_combo.get_active()]
		self.make_conf_values['MAKEOPTS'] = self.makeopts_entry.get_text()
		self.etc_files['make.conf'] = self.make_conf_values
		self.controller.install_profile.set_etc_files(self.etc_files)
		return True
Beispiel #13
0
	def get_treeview_data(self):
		data = []
		treeiter = self.treedata.get_iter_first()
		
		while treeiter !=None:
			user = self.treedata.get_value(treeiter,1)
			passwd = self.treedata.get_value(treeiter,0)
			
			# if the user was loaded from a profile, do NOT
			# hash the password, but carry it through
			if user not in self.users_from_profile:
				pass_hash = GLIUtility.hash_password(passwd)
			else:
				pass_hash = passwd
				
			groups = self.treedata.get_value(treeiter,2)
			shell = self.treedata.get_value(treeiter,3)
			homedir = self.treedata.get_value(treeiter,4)
			userid = self.treedata.get_value(treeiter,5)
			comment = self.treedata.get_value(treeiter,6)
			try:
				group_tuple = tuple(groups.split(","))
			except:
				# must be only 1 group
				group_tuple = (groups)
			
			data.append([user,pass_hash,group_tuple,shell,homedir,userid,comment])
			treeiter = self.treedata.iter_next(treeiter)
			
		return data
	def _setup_lilo(self):
		#-------------------------------------------------------------
		#OK, now that the file is built.  Install lilo.
		exitstatus = GLIUtility.spawn("/sbin/lilo",chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)
		if exitstatus != 0:
			raise GLIException("LiloInstallError", 'fatal', '_setup_lilo', "Running lilo failed!")
		self._logger.log("Bootloader: lilo has been run/installed!")
	def set_partitions_from_disk(self):
		parted_part = self._parted_disk.next_partition()
		while parted_part:
			part_mb = long((parted_part.geom.end - parted_part.geom.start + 1) * self._sector_bytes / MEGABYTE)
			# Ignore metadata "partitions"...this will need to be changed for non-x86
			if parted_part.num >= 1:
				fs_type = ""
				if parted_part.fs_type != None: fs_type = parted_part.fs_type.name
				if parted_part.type == 2: fs_type = "extended"
				part_name = ""
				if self._parted_disk.type.check_feature(parted.DISK_TYPE_PARTITION_NAME):
					part_name = parted_part.get_name()
				self._partitions.append(Partition(self, parted_part.num, part_mb, parted_part.geom.start, parted_part.geom.end, fs_type, format=False, existing=True, name=part_name))
			elif parted_part.type_name == "free":
				if self._disklabel == "mac":
					free_minor = int(GLIUtility.spawn("mac-fdisk -l %s | grep '@ %s' | cut -d ' ' -f 1" % (self._device, str(parted_part.geom.start)), return_output=True)[1].strip()[-1])
				elif self.get_extended_partition() and parted_part.geom.start >= self.get_partition(self.get_extended_partition()).get_start() and parted_part.geom.end <= self.get_partition(self.get_extended_partition()).get_end():
					if self._partitions[-1].get_minor() > 4:
						free_minor = self._partitions[-1].get_minor() + FREE_MINOR_FRAC_LOG
					else:
						free_minor = 4 + FREE_MINOR_FRAC_LOG
				else:
					try:
						free_minor = self._partitions[-1].get_minor() + FREE_MINOR_FRAC_PRI
					except IndexError:
						free_minor = FREE_MINOR_FRAC_PRI
				self._partitions.append(Partition(self, free_minor, part_mb, parted_part.geom.start, parted_part.geom.end, "free", format=False, existing=False))
			parted_part = self._parted_disk.next_partition(parted_part)
		# Juggle minor numbers so they match physical disk order. People may complain, but we're actually doing them a favor
		self.reorder_minors()
Beispiel #16
0
	def deactivate(self):
		if not self.check_dynamic.get_active():
			if not self.entry_stage_tarball_uri.get_text():
				msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="You did not enter a stage tarball URI. You cannot complete an installation until you set this value. Continue?")
				resp = msgdlg.run()
				msgdlg.destroy()
				if resp == gtk.RESPONSE_NO:
					return False
			elif not GLIUtility.validate_uri(self.entry_stage_tarball_uri.get_text()):
				msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="The stage tarball URI you entered does not exist. You cannot complete an installation until this value is a valid. Continue?")
				resp = msgdlg.run()
				msgdlg.destroy()
				if resp == gtk.RESPONSE_NO:
					return False
			elif self.active_selection == 3 and self.check_grp.get_active() and self.has_systempkgs:
				msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="When doing a GRP install, it is recommended to use the Dynamic option instead of selecting your own tarball. Continue?")
				resp = msgdlg.run()
				msgdlg.destroy()
				if resp == gtk.RESPONSE_NO:
					return False
		self.controller.install_profile.set_install_stage(None, self.active_selection, None)
		if self.active_selection == 3:
			self.controller.install_profile.set_grp_install(None, self.check_grp.get_active(), None)
			self.controller.install_profile.set_dynamic_stage3(None, self.check_dynamic.get_active(), None)
		else:
			self.controller.install_profile.set_grp_install(None, False, None)
		try: self.controller.install_profile.set_stage_tarball_uri(None, self.entry_stage_tarball_uri.get_text(), None)
		except: pass
		return True
	def load_kernel_modules(self):
		if self._configuration.get_verbose(): self._logger.log("DEBUG: beginning of load_kernel_modules()")
		modules = self._configuration.get_kernel_modules()
		if self._configuration.get_verbose(): self._logger.log("DEBUG: load_kernel_modules(): modules are " + str(modules))
		for module in modules:
			try:
				if self._configuration.get_verbose(): self._logger.log("DEBUG: load_kernel_modules(): trying to load module " + module)
				ret = GLIUtility.spawn('modprobe ' + module)
				if not GLIUtility.exitsuccess(ret):
					self._logger.log("ERROR! : Could not load module: "+module)
				#	raise GLIException("KernelModuleError", 'warning', 'load_kernel_modules', 'Could not load module: ' + module)
				else:
					self._logger.log('kernel module: ' + module + ' loaded.')
			except KernelModuleError, error:
				self.output(error)
				self._logger.log(error.get_error_level() + '! ' + error.get_error_msg())
	def set_network_netmask(self, xml_path, netmask, xml_attr=None):
		if not GLIUtility.is_ip(netmask):
			raise GLIException("IPAddressError", 'fatal','set_network_netmask', 'The specified netmask is not a valid IP Address!')
		else:
			# Need to guess the netmask... just in case (probably need the gateway..)
			pass
			
		self._network_netmask = netmask
Beispiel #19
0
 def update_mount(self, button, data=None):
     if not GLIUtility.is_ip(self.mount_info_host.get_text()) and not GLIUtility.is_hostname(
         self.mount_info_host.get_text()
     ):
         msgdialog = Widgets.Widgets().error_Box(
             "Invalid Host or IP", "You must specify a valid hostname or IP address"
         )
         result = msgdialog.run()
         if result == gtk.RESPONSE_ACCEPT:
             msgdialog.destroy()
         return
     if self.mount_info_export.get_child().get_text() == "":
         msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a value for the export field")
         result = msgdialog.run()
         if result == gtk.RESPONSE_ACCEPT:
             msgdialog.destroy()
         return
     if self.mount_info_mountpoint.get_text() == "":
         msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a mountpoint")
         result = msgdialog.run()
         if result == gtk.RESPONSE_ACCEPT:
             msgdialog.destroy()
         return
     if self.active_entry == -1:
         self.netmounts.append(
             {
                 "host": self.mount_info_host.get_text(),
                 "export": self.mount_info_export.get_child().get_text(),
                 "type": self.mount_types[self.mount_info_type.get_active()],
                 "mountpoint": self.mount_info_mountpoint.get_text(),
                 "mountopts": self.mount_info_mountopts.get_text(),
             }
         )
         self.active_entry = -1
         self.mount_button_update.set_sensitive(False)
         self.mount_button_delete.set_sensitive(False)
         self.mount_button_populate.set_sensitive(False)
     else:
         self.netmounts[self.active_entry]["host"] = self.mount_info_host.get_text()
         self.netmounts[self.active_entry]["export"] = self.mount_info_export.get_child().get_text()
         self.netmounts[self.active_entry]["type"] = self.mount_info_type.get_text()
         self.netmounts[self.active_entry]["mountpoint"] = self.mount_info_mountpoint.get_text()
         self.netmounts[self.active_entry]["mountopts"] = self.mount_info_mountopts.get_text()
     self.refresh_list_at_top()
     self.disable_all_fields()
	def _setup_grub(self):
		#-------------------------------------------------------------
		#OK, now that the file is built.  Install grub.
		#cp /proc/mounts /etc/mtab
		#grub-install --root-directory=/boot /dev/hda
		#shutil.copy("/proc/mounts",root +"/etc/mtab")
		self._gather_grub_drive_info()
		grubinstallstring = "echo -en 'root ("+self.grub_boot_drive + "," + self.grub_boot_minor + ")\n"
		if not self._install_profile.get_boot_loader_mbr():
			grubinstallstring +="setup ("+self.grub_boot_drive + "," + self.grub_boot_minor + ")\n"
		else:
			grubinstallstring +="setup ("+self.grub_mbr_drive+")\n"
		grubinstallstring += "quit\n' | "+self._chroot_dir+"/sbin/grub --batch --no-floppy"
		if self._debug: self._logger.log("DEBUG: _configure_grub(): Grub install string: " + grubinstallstring)
		exitstatus = GLIUtility.spawn(grubinstallstring, logfile=self._compile_logfile, append_log=True)
		if not GLIUtility.exitsuccess(exitstatus):
			raise GLIException("GrubInstallError", 'fatal', '_setup_grub', "Could not install grub!")
		self._logger.log("Bootloader: grub has been installed!")
Beispiel #21
0
	def populate_consolefont_combo(self, default="default8x16"):
		# Adds all the consolefonts
		consolefonts = GLIUtility.generate_consolefont_list()
		for i in range(len(consolefonts)):
			consolefont = consolefonts[i]
			self.consolefont.append_text(consolefont)
			
			# select the default
			if consolefont == default:
				self.consolefont.set_active(i)
Beispiel #22
0
	def populate_consoletranslation_combo(self, default=0):
		self.consoletranslation.append_text("commented out")
		
		consoletranslations = GLIUtility.generate_consoletranslation_list()
		
		for i in range(len(consoletranslations)):
			consoletran = consoletranslations[i]
			self.consoletranslation.append_text(consoletran)
			
		self.consoletranslation.set_active(default)
Beispiel #23
0
	def populate_keymap_combo(self, default="us"):
		# Adds all the keymaps to the dropdown
		keymaps = GLIUtility.generate_keymap_list()
		
		for i in range(len(keymaps)):
			keymap = keymaps[i]
			self.keymap.append_text(keymap)
			
			# select the default
			if keymap == default:
				self.keymap.set_active(i)
Beispiel #24
0
	def refresh_file_list(self):
		if not self.uri.endswith("/"):
			self.uri = self.uri[:self.uri.rfind("/")+1]
		try:
			filelist = GLIUtility.get_directory_listing_from_uri(self.uri)
		except GLIException, e:
			if e.get_error_name() == "IncorrectPassword":
				msgdlg = gtk.MessageDialog(parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("Your password is incorrect."))
				msgdlg.run()
				msgdlg.destroy()
			return
Beispiel #25
0
	def update_from_uri(self):
		if self.uri:
			self.uriparts = GLIUtility.parse_uri(self.uri)
			if not self.uriparts:
				msgdlg = gtk.MessageDialog(parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format=_("The URI you had previously entered was malformed and couldn't be parsed."))
				msgdlg.run()
				msgdlg.destroy()
				self.uri = "file:///"
				self.uriparts = GLIUtility.parse_uri(self.uri)
			else:
				for i, tmpuritype in enumerate(self.uritypes):
					if self.uriparts[0] == tmpuritype:
						self.uritype.set_active(i)
				if self.uriparts[3]: self.host_entry.set_text(self.uriparts[3])
				if self.uriparts[1]: self.username_entry.set_text(self.uriparts[1])
				if self.uriparts[2]: self.password_entry.set_text(self.uriparts[2])
				if self.uriparts[4]: self.port_entry.set_text(self.uriparts[4])
		else:
			self.uri = "file:///"
			self.uriparts = GLIUtility.parse_uri(self.uri)
		self.refresh_file_list()
	def load_install_profile(self):
		install_profile=None
		if self._install_profile == None:
			if self._configuration != None:
				success = GLIUtility.get_uri(self._configuration.get_profile_uri(),'/tmp/install_profile.xml')
				if success:
					self._logger.log("Profile downloaded succesfully, loading it now.")
					self.output("Profile downloaded... loading it now...")
					install_profile = GLIInstallProfile.InstallProfile()
					install_profile.parse('/tmp/install_profile.xml')
				else:
					raise GLIException("InstallProfileError", 'fatal', 'get_install_profile', 'Could not download/copy the install profile from: ' + self._configuration.get_profile_uri())

		self._install_profile = install_profile
	def _map_device_to_grub_device(self, device):
		file_name = self._chroot_dir + "/boot/grub/glidevice.map"
		#If we can't find it, make it.  If we STILL can't find it. die.
		if not GLIUtility.is_file(file_name):
			exitstatus1 = GLIUtility.spawn("echo quit | "+ self._chroot_dir+"/sbin/grub --batch --no-floppy --device-map="+file_name, logfile=self._compile_logfile, append_log=True)
		if not GLIUtility.is_file(file_name):
			raise GLIException("BootloaderError", 'fatal', '_configure_grub', "Error making the new device map.")
		"""
		read the device map.  sample looks like this:
		(fd0)   /dev/floppy/0
		(hd0)   /dev/sda
		(hd1)   /dev/hda
		(hd2)   /dev/hdb
		"""
		
		# Search for the key
		f = open(file_name)  #open the device map
		file = f.readlines()
		f.close()	
		for i in range(len(file)):
			if file[i][6:-1] == device:
				return file[i][1:4]
		raise GLIException("BootloaderError", 'fatal', '_map_device_to_grub_device', "ERROR, could not map"+device+" to anything in the device map")
Beispiel #28
0
 def populate_exports(self, button, data=None):
     host = self.mount_info_host.get_text()
     oldtext = self.mount_info_export.get_child().get_text()
     if GLIUtility.is_ip(host) or GLIUtility.is_hostname(host):
         remotemounts = commands.getoutput(
             "/usr/sbin/showmount -e " + host + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo"
         )
         mountlist = gtk.ListStore(gobject.TYPE_STRING)
         self.mount_info_export.set_model(mountlist)
         while remotemounts.find("\n") != -1:
             index = remotemounts.find("\n") + 1
             remotemount = remotemounts[:index]
             remotemounts = remotemounts[index:]
             remotemount = string.strip(remotemount)
             mountlist.append([remotemount])
         self.mount_info_export.get_child().set_text(oldtext)
     else:
         msgdialog = Widgets.Widgets().error_Box(
             "Invalid Host or IP", "You must specify a valid hostname or IP address to scan for exports"
         )
         result = msgdialog.run()
         if result == gtk.RESPONSE_ACCEPT:
             msgdialog.destroy()
Beispiel #29
0
	def deactivate(self):
		if self.active_selection == "snapshot":
			if not self.entry_portage_snapshot_uri.get_text():
				msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="You did not enter a portage snapshot URI. Continue?")
				resp = msgdlg.run()
				msgdlg.destroy()
				if resp == gtk.RESPONSE_NO:
					return False
			elif not GLIUtility.validate_uri(self.entry_portage_snapshot_uri.get_text()):
				msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format="The portage snapshot URI you entered does not exist. Continue?")
				resp = msgdlg.run()
				msgdlg.destroy()
				if resp == gtk.RESPONSE_NO:
					return False
		self.controller.install_profile.set_portage_tree_sync_type(None, self.active_selection, None)
		try: self.controller.install_profile.set_portage_tree_snapshot_uri(None, self.entry_portage_snapshot_uri.get_text(), None)
		except: pass
		return True
Beispiel #30
0
	def refresh_clicked(self, button):
		if self.uritype.get_active() == 0:
			self.uri = "file://"
		else:
			self.host_entry.set_sensitive(True)
			self.port_entry.set_sensitive(True)
			self.username_entry.set_sensitive(True)
			self.password_entry.set_sensitive(True)
			self.uri = self.uritypes[self.uritype.get_active()] + "://"
			if self.username_entry.get_text():
				self.uri += self.username_entry.get_text()
				if self.password_entry.get_text():
					self.uri += ":" + self.password_entry.get_text()
				self.uri += "@"
			self.uri += self.host_entry.get_text()
			if self.port_entry.get_text():
				self.uri += ":" + self.port_entry.get_text()
		self.uri += (self.path_entry.get_text() or "/")
		self.uriparts = GLIUtility.parse_uri(self.uri)
		self.refresh_file_list()
Beispiel #31
0
	def copy_pkg_to_chroot(self, package, use_root=False, ignore_missing=False):
		symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/', 
		             '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '******',
		             '/etc/gconf': '/usr/livecd/gconf/' }

		tmpdir = "/var/tmp/portage"
		image_dir = tmpdir + "/" + package.split("/")[1] + "/image"
		root_cmd = ""
		tmp_chroot_dir = self._chroot_dir
		portage_tmpdir = "/var/tmp/portage"
		vdb_dir = "/var/db/pkg/"
		if use_root:
			root_cmd = "ROOT=" + self._chroot_dir
			tmp_chroot_dir = ""
			portage_tmpdir = self._chroot_dir + "/var/tmp/portage"
			vdb_dir = self._chroot_dir + "/var/db/pkg/"

		# Create /tmp, /var/tmp, and /var/lib/portage with proper permissions
		oldumask = os.umask(0)
		if not os.path.exists(self._chroot_dir + "/tmp"):
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /tmp doesn't exist in chroot...creating with proper permissions")
			try:
				os.mkdir(self._chroot_dir + "/tmp", 01777)
			except:
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /tmp in chroot")
		if not os.path.exists(self._chroot_dir + "/var/tmp"):
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /var/tmp doesn't exist in chroot...creating with proper permissions")
			try:
				os.mkdir(self._chroot_dir + "/var", 0755)
			except:
				pass
			try:
				os.mkdir(self._chroot_dir + "/var/tmp", 01777)
			except:
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /var/tmp in chroot")
		if not os.path.exists(self._chroot_dir + "/var/lib/portage"):
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): /var/lib/portage doesn't exist in chroot...creating with proper permissions")
			try:
				os.mkdir(self._chroot_dir + "/var/lib", 0755)
			except:
				pass
			try:
				os.mkdir(self._chroot_dir + "/var/lib/portage", 02750)
			except:
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Failed to create /var/lib/portage in chroot")
		os.umask(oldumask)

		# Check to see if package is actually in vdb
		if not GLIUtility.is_file("/var/db/pkg/" + package):
			if ignore_missing:
				if self._debug:
					self._logger.log("DEBUG: copy_pkg_to_chroot(): package " + package + " does not have a vdb entry but ignore_missing=True...ignoring error")
				return
			else:
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "There is no vdb entry for " + package)

		# Copy the vdb entry for the package from the LiveCD to the chroot
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): copying vdb entry for " + package)
		if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + "/var/db/pkg/" + package + " && cp -a /var/db/pkg/" + package + "/* " + self._chroot_dir + "/var/db/pkg/" + package, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy vdb entry for " + package)

		# Create the image dir in the chroot
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'mkdir -p " + self._chroot_dir + image_dir + "'")
		if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create image dir for " + package)

		# Create list of files for tar to work with from CONTENTS file in vdb entry
		entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS")
		if not entries:
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup")
		else:
#			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries))
			try:
				tarfiles = open("/tmp/tarfilelist", "w")
				for entry in entries:
					parts = entry.split(" ")
#					# Hack for symlink crappiness
#					for symlink in symlinks:
#						if parts[0].startswith(symlink):
#							parts[0] = symlinks[symlink] + parts[0][len(symlink):]
					tarfiles.write(parts[0] + "\n")
				tarfiles.close()
			except:
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create filelist for " + package)

			# Use tar to transfer files into IMAGE directory
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp'")
			if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp", logfile=self._compile_logfile, append_log=True)):
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package)

			# Fix mode, uid, and gid of directories
#			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'")
#			dirlist = GLIUtility.spawn("find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'", return_output=True)[1].strip().split("\n")
#			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): found the following directories: " + str(dirlist))
#			if not dirlist or dirlist[0] == "":
#				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "directory list entry for " + package + "...this shouldn't happen!")
#			for dir in dirlist:
#				dirstat = os.stat(dir)
#				if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): setting mode " + str(dirstat[0]) + " and uid/gid " + str(dirstat[4]) + "/" + str(dirstat[5]) + " for directory " + self._chroot_dir + image_dir + dir)
#				os.chown(self._chroot_dir + image_dir + dir, dirstat[4], dirstat[5])
#				os.chmod(self._chroot_dir + image_dir + dir, dirstat[0])

#			# More symlink crappiness hacks
#			for symlink in symlinks:
##				if GLIUtility.is_file(self._chroot_dir + image_dir + symlinks[symlink]):
#				if os.path.islink(self._chroot_dir + image_dir + symlink):
#					if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): fixing " + symlink + " symlink ickiness stuff in " + image_dir + " for " + package)
#					GLIUtility.spawn("rm " + self._chroot_dir + image_dir + symlink)
#					if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)):
#						raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package)

		# Run pkg_setup
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package)
		if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild setup", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package)

		# Run pkg_preinst
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running preinst for " + package)
		if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild preinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute preinst for " + package)

		# Copy files from image_dir to chroot
		if not entries:
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping copy from image dir to /")
		else:
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): copying files from " + image_dir + " to / for " + package)
#			if not GLIUtility.exitsuccess(GLIUtility.spawn("cp -a " + self._chroot_dir + image_dir + "/* " + self._chroot_dir)):
			if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -C " + self._chroot_dir + image_dir + "/ -cp . | tar -C " + self._chroot_dir + "/ -xp", logfile=self._compile_logfile, append_log=True)):
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy files from " + image_dir + " to / for " + package)

		# Run pkg_postinst
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running postinst for " + package)
		if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild postinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute postinst for " + package)

		# Remove image_dir
		if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): removing " + image_dir + " for " + package)
		if not GLIUtility.exitsuccess(GLIUtility.spawn("rm -rf " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)):
			raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not remove + " + image_dir + " for " + package)

		# Run env-update
		if not use_root:
			if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running env-update inside chroot")
			if not GLIUtility.exitsuccess(GLIUtility.spawn("env-update", chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)):
				raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not run env-update for " + package)
Beispiel #32
0
	def __init__(self, controller):
		GLIScreen.GLIScreen.__init__(self, controller)

		self.has_systempkgs = GLIUtility.is_file("/usr/livecd/systempkgs.txt")

		vert = gtk.VBox(False, 0)
		vert.set_border_width(10)

		content_str = """Here, you will select which stage you would like to start your install from.
Each option has a brief description beside it.
"""
		content_label = gtk.Label(content_str)
		vert.pack_start(content_label, expand=False, fill=False, padding=0)            
		self.radio_stages[1] = gtk.RadioButton(None, "Stage 1")
		self.radio_stages[1].set_name("1")
		self.radio_stages[1].connect("toggled", self.stage_selected, "1")
		self.radio_stages[1].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[1], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The entire system will be compiled from scratch with your CHOST and CFLAGS settings")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)
		self.radio_stages[2] = gtk.RadioButton(self.radio_stages[1], "Stage 2")
		self.radio_stages[2].set_name("2")
		self.radio_stages[2].connect("toggled", self.stage_selected, "2")
		self.radio_stages[2].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[2], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("Most of the system will be compiled with your CHOST and CFLAGS settings. Don't use this option unless you have a good reason")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.radio_stages[3] = gtk.RadioButton(self.radio_stages[1], "Stage 3")
		self.radio_stages[3].set_name("3")
		self.radio_stages[3].connect("toggled", self.stage_selected, "3")
		self.radio_stages[3].set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.radio_stages[3], expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The base system will be installed using precompiled packages. You can recompile later with your custom settings if you choose. This is the fastest option")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.check_grp = gtk.CheckButton("GRP Install")
		self.check_grp.set_sensitive(False)
		self.check_grp.set_size_request(100, -1)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.check_grp, expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("Any extra packages installed (beyond the stage3) will be installed using binaries from the LiveCD that you are installing from")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		self.check_dynamic = gtk.CheckButton("Dynamic")
		self.check_dynamic.set_sensitive(False)
		self.check_dynamic.connect("toggled", self.dynamic_checked)
		self.check_dynamic.set_size_request(100, -1)
		if not self.has_systempkgs:
			self.check_dynamic.set_sensitive(False)
		hbox = gtk.HBox(False, 0)
		hbox.pack_start(self.check_dynamic, expand=False, fill=False, padding=5)
		tmplabel = gtk.Label("The stage3 will be generated from the packages on the LiveCD")
		tmplabel.set_line_wrap(True)
		hbox.pack_start(tmplabel, expand=False, fill=False, padding=20)
		vert.pack_start(hbox, expand=False, fill=False, padding=10)

		hbox = gtk.HBox(False, 0)
		hbox.pack_start(gtk.Label("Stage tarball URI:"), expand=False, fill=False, padding=5)
		self.entry_stage_tarball_uri = gtk.Entry()
		self.entry_stage_tarball_uri.set_width_chars(50)
		hbox.pack_start(self.entry_stage_tarball_uri, expand=False, fill=False, padding=10)
		self.browse_uri = gtk.Button(" ... ")
		self.browse_uri.connect("clicked", self.browse_uri_clicked)
		hbox.pack_start(self.browse_uri, expand=False, fill=False, padding=5)
		vert.pack_end(hbox, expand=False, fill=False, padding=0)

		self.add_content(vert)
	def _configure_yaboot(self):
		build_mode = self._install_profile.get_kernel_build_method()
		root_device = ""
		root_minor = ""
		parts = self._install_profile.get_partition_tables()
		for device in parts:
			tmp_partitions = parts[device]
			for partition in tmp_partitions:
				mountpoint = tmp_partitions[partition]['mountpoint']
				if mountpoint == "/":
					root_minor = str(int(tmp_partitions[partition]['minor']))
					root_device = device
		if self._install_profile.get_bootloader_kernel_args(): bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args()
		else: bootloader_kernel_args = ""
		#Assuming the config program works as specified, it should do the majority of the work.
		#this is the white rabbit object.  antarus: it expects a full fstab, /proc mounted, and a kernel in /boot/vmlinux.  The manaul also says /dev must be bind-mounted.
		exitstatus = GLIUtility.spawn("yabootconfig --chroot "+self._chroot_dir+" --quiet", display_on_tty8=True)
		if not GLIUtility.exitsuccess(exitstatus):
			raise GLIException("YabootError",'fatal','_configure_yaboot',"Could not successfully run the yabootconfig command.")
		#Hopefully now an /etc/yaboot.conf exists but does not have the correct kernel/Sysmap information.
		#We must gather that info like we have done for the other bootloaders.
		file_name = self._chroot_dir + "/boot/kernel_name"
		file_name2 = self._chroot_dir + "/boot/initrd_name"
		exitstatus2 = GLIUtility.spawn("ls "+root+"/boot/kernel-* > "+file_name)
		if build_mode == "genkernel":
			exitstatus3 = GLIUtility.spawn("ls "+root+"/boot/initramfs-* > "+file_name2)
		else:
			exitstatus3 = GLIUtility.spawn("touch "+file_name2)
		if (exitstatus2 != 0) or (exitstatus3 != 0):
			raise GLIException("BootloaderError", 'fatal', '_configure_yaboot', "Error in one of THE TWO run commands")
		self._logger.log("Bootloader: the three information gathering commands have been run")
		g = open(file_name)
		h = open(file_name2)
		initrd_name = h.readlines()
		kernel_name = g.readlines()
		g.close()
		h.close()
		if not kernel_name[0]:
			raise GLIException("BootloaderError", 'fatal', '_configure_yaboot',"Error: We have no kernel in /boot to put in the yaboot.conf file!")
		kernel_name = map(string.strip, kernel_name)
		initrd_name = map(string.strip, initrd_name)
		for i in range(len(kernel_name)):
			kernel_name = kernel_name[i].split(root)[1]
		for i in range(len(initrd_name)):
			initrd_name = initrd_name[i].split(root)[1]
		#Open the file and edit the right lines
		f = open(self._chroot_dir+"/etc/yaboot.conf")
		contents = f.readlines()
		f.close()
		for i in range(0, len(contents)):
			if contents[i] == "image=/boot/vmlinux":
				contents[i] = "image=/boot/"+kernel_name[5:]
				if build_mode == "genkernel":
					#insert /dev/ram0 line
					contents.insert("root=/dev/ram0",i+2)
					#insert partition line.
					contents.insert("partition="+root_minor,i+3)
					#edit append line. use root_device and root_minor.
					contents.insert("append=\"real_root="+root_device+root_minor+ " init=/linuxrc "+bootloader_kernel_args + "\" \n", i+4)
		f = open(self._chroot_dir+"/etc/yaboot.conf",'w')
		f.writelines(contents)
		f.close()
Beispiel #34
0
    def _configure_grub(self):
        self.build_mode = self._install_profile.get_kernel_build_method()
        self._gather_grub_drive_info()
        root = self._chroot_dir
        exitstatus2, kernel_names = GLIUtility.spawn("ls -1 --color=no " +
                                                     root + "/boot/pentoo",
                                                     return_output=True)
        self._logger.log("Output of Kernel Names:\n" + kernel_names)
        if not GLIUtility.exitsuccess(exitstatus2):
            raise GLIException("BootloaderError", 'fatal', '_configure_grub',
                               "Error listing the kernels in /boot")
        if self.build_mode == "genkernel" or self._install_profile.get_kernel_source_pkg(
        ) == "livecd-kernel":
            exitstatus3, initrd_names = GLIUtility.spawn(
                "ls -1 --color=no " + root + "/boot/pentoo.igz",
                return_output=True)
            self._logger.log("Output of Initrd Names:\n" + initrd_names)
        if not GLIUtility.exitsuccess(exitstatus3):
            raise GLIException("BootloaderError", 'fatal', '_configure_grub',
                               "Error listing the initrds")
        self._logger.log(
            "Bootloader: the three information gathering commands have been run"
        )

        if not kernel_names[0]:
            raise GLIException(
                "BootloaderError", 'fatal', '_configure_grub',
                "Error: We have no kernel in /boot to put in the grub.conf file!"
            )

        #-------------------------------------------------------------
        #OK, now that we have all the info, let's build that grub.conf
        newgrubconf = ""
        newgrubconf += "default 0\ntimeout 30\n"
        if self.foundboot:  #we have a /boot
            newgrubconf += "splashimage=(" + self.grub_boot_drive + "," + self.grub_boot_minor + ")/grub/splash.xpm.gz\n"
        else:  #we have / and /boot needs to be included
            newgrubconf += "splashimage=(" + self.grub_boot_drive + "," + self.grub_boot_minor + ")/boot/grub/splash.xpm.gz\n"
        if self._install_profile.get_bootloader_kernel_args():
            bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args(
            )
        else:
            bootloader_kernel_args = ""

        kernel_names = map(string.strip, kernel_names.strip().split("\n"))
        initrd_names = map(string.strip, initrd_names.strip().split("\n"))
        grub_kernel_name = kernel_names[-1].split(root)[-1]
        if initrd_names: grub_initrd_name = initrd_names[-1].split(root)[-1]
        #		for i in range(len(kernel_names)):
        #			grub_kernel_name = kernel_names[i].split(root)[-1]
        #		for i in range(len(initrd_names)):  #this should be okay if blank.
        #			grub_initrd_name = initrd_names[i].split(root)[-1]
        #i think this means take the last one it finds.. i.e. the newest.

        newgrubconf += "title=Gentoo Linux\n"
        newgrubconf += "root (" + self.grub_boot_drive + "," + self.grub_boot_minor + ")\n"
        if self.build_mode != "genkernel" and self._install_profile.get_kernel_source_pkg(
        ) != "livecd-kernel":  #using CUSTOM kernel
            if self.foundboot:
                newgrubconf += "kernel " + grub_kernel_name[
                    5:] + " root=" + self.root_device + self.root_minor + "\n"
            else:
                newgrubconf += "kernel /boot" + grub_kernel_name[
                    5:] + " root=" + self.root_device + self.root_minor + "\n"
        else:  #using genkernel so it has an initrd.
            if self.foundboot:
                newgrubconf += "kernel " + grub_kernel_name[
                    5:] + " root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root="
                newgrubconf += self.root_device + self.root_minor + " " + bootloader_kernel_args + "\n"
                newgrubconf += "initrd " + grub_initrd_name[5:] + "\n"
            else:
                newgrubconf += "kernel /boot" + grub_kernel_name[
                    5:] + " root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root="
                newgrubconf += self.root_device + self.root_minor + " " + bootloader_kernel_args + "\n"
                newgrubconf += "initrd /boot" + grub_initrd_name[5:] + "\n"
        newgrubconf = self._grub_add_windows(newgrubconf)
        #now make the grub.conf file
        file_name = root + "/boot/grub/grub.conf"
        try:
            shutil.move(file_name, file_name + ".OLDdefault")
        except:
            pass
        f = open(file_name, 'w')
        f.writelines(newgrubconf)
        f.close()
        self._logger.log(
            "Grub installed and configured. Contents of grub.conf:\n" +
            newgrubconf)
        self._logger.log(
            "Grub has not yet been run.  If a normal install, it will now be run."
        )
Beispiel #35
0
 def _partition_resize_step(self, parted_disk, device, oldparts, newparts):
     for oldpart in oldparts:
         tmppart_old = oldparts[oldpart]
         devnode = tmppart_old['devnode']
         newminor = self._find_existing_in_new(oldpart, newparts)
         if not newminor or not newparts[newminor]['resized']:
             continue
         tmppart_new = newparts[newminor]
         type = tmppart_new['type']
         start = tmppart_new['start']
         end = start + (long(tmppart['mb']) * MEGABYTE / 512) - 1
         total_sectors = end - start + 1
         total_bytes = long(total_sectors) * 512
         # Make sure calculated end sector doesn't overlap start sector of next partition
         nextminor = self._find_next_partition(newminor, newparts)
         if nextminor:
             if newparts[nextminor][
                     'start'] and end >= newparts[nextminor]['start']:
                 self._logger.log(
                     "  End sector for growing partition overlaps with start of next partition...fixing"
                 )
                 end = newparts[nextminor]['start'] - 1
         # sleep a bit first
         time.sleep(3)
         # now sleep until it exists
         while not GLIUtility.is_file(device + str(minor)):
             self._logger.log("Waiting for device node " + devnode +
                              " to exist before resizing")
             time.sleep(1)
         # one bit of extra sleep is needed, as there is a blip still
         time.sleep(3)
         if type in ("ext2", "ext3"):
             ret = GLIUtility.spawn("resize2fs " + devnode + " " +
                                    str(total_sectors) + "s",
                                    logfile=self._compile_logfile,
                                    append_log=True)
             if not GLIUtility.exitsuccess(ret):  # Resize error
                 raise GLIException(
                     "PartitionResizeError", 'fatal', 'partition',
                     "could not resize ext2/3 filesystem on " + devnode)
         elif type == "ntfs":
             ret = GLIUtility.spawn("yes | ntfsresize -v --size " +
                                    str(total_bytes) + " " + devnode,
                                    logfile=self._compile_logfile,
                                    append_log=True)
             if not GLIUtility.exitsuccess(ret):  # Resize error
                 raise GLIException(
                     "PartitionResizeError", 'fatal', 'partition',
                     "could not resize NTFS filesystem on " + devnode)
         elif type in ("linux-swap", "fat32", "fat16"):
             parted_fs = parted_disk.get_partition(
                 part).geom.file_system_open()
             resize_constraint = parted_fs.get_resize_constraint()
             if total_sectors < resize_constraint.min_size or start != resize_constraint.start_range.start:
                 raise GLIException(
                     "PartitionError", 'fatal', 'partition',
                     "New size specified for " + device + str(minor) +
                     " is not within allowed boundaries (blame parted)")
             new_geom = resize_constraint.start_range.duplicate()
             new_geom.set_start(start)
             new_geom.set_end(end)
             try:
                 parted_fs.resize(new_geom)
             except:
                 raise GLIException(
                     "PartitionResizeError", 'fatal', 'partition',
                     "could not resize " + device + str(minor))
         self._logger.log("  Deleting old minor " + str(oldpart) +
                          " to be recreated in 3rd pass")
         self._delete_partition(parted_disk, oldpart)
     parted_disk.delete_all()
     parted_disk.commit()
Beispiel #36
0
    def deactivate(self):
        self.controller.client_profile.set_network_interface(
            None,
            self.interface_combo.get_child().get_text(), None)
        if self.already_setup_check.get_active():
            self.controller.client_profile.set_network_type(None, "none", None)
        else:
            if self.basic_dhcp_radio.get_active():
                self.controller.client_profile.set_network_type(
                    None, "dhcp", None)
                self.controller.client_profile.set_network_dhcp_options(
                    None, self.dhcp_options_entry.get_text(), None)
            else:
                self.controller.client_profile.set_network_type(
                    None, "static", None)
                self.controller.client_profile.set_network_ip(
                    None, self.ip_address_entry.get_text(), None)
                self.controller.client_profile.set_network_netmask(
                    None, self.netmask_entry.get_text(), None)
                self.controller.client_profile.set_network_broadcast(
                    None, self.broadcast_entry.get_text(), None)
                self.controller.client_profile.set_network_gateway(
                    None, self.gateway_entry.get_text(), None)
                self.controller.client_profile.set_dns_servers(
                    None, self.dns_entry.get_text(), None)
        self.controller.client_profile.set_http_proxy(
            None, self.http_proxy_entry.get_text(), None)
        self.controller.client_profile.set_ftp_proxy(
            None, self.ftp_proxy_entry.get_text(), None)
        self.controller.client_profile.set_rsync_proxy(
            None, self.rsync_proxy_entry.get_text(), None)
        self.controller.client_profile.set_root_mount_point(
            None, self.chroot_dir_entry.get_text(), None)
        self.controller.client_profile.set_log_file(
            None, self.logfile_entry.get_text(), None)
        self.controller.client_profile.set_enable_ssh(
            None, self.sshd_yes_radio.get_active(), None)
        if self.root_password_entry.get_text(
        ) == self.verify_root_password_entry.get_text():
            self.controller.client_profile.set_root_passwd(
                None,
                GLIUtility.hash_password(self.root_password_entry.get_text()),
                None)
        self.controller.client_profile.set_kernel_modules(
            None, self.modules_entry.get_text(), None)
        self.controller.client_profile.set_verbose(
            None, self.verbose_yes_radio.get_active(), None)
        arch = GLIUtility.spawn(
            r"uname -m | sed -e 's:i[3-6]86:x86:' -e 's:x86_64:amd64:' -e 's:parisc:hppa:'",
            return_output=True)[1].strip()
        self.controller.client_profile.set_architecture_template(
            None, arch, None)
        self.controller.client_profile.set_install_mode(
            None,
            self._install_modes[self.install_mode_combo.get_active()].lower(),
            None)

        self.controller.cc.set_configuration(self.controller.client_profile)
        self.controller.cc.start_pre_install()

        return True
Beispiel #37
0
    def __init__(self, controller):
        GLIScreen.GLIScreen.__init__(self, controller)
        vert = gtk.VBox(False, 0)
        vert.set_border_width(10)

        content_str = _(
            """On this screen, you will set all your pre-install options such as networking,
		chroot directory, logfile location, architecture, etc.""")

        content_label = gtk.Label(content_str)
        vert.pack_start(content_label, expand=False, fill=False, padding=5)

        self.notebook = gtk.Notebook()

        basicbox = gtk.VBox(False, 0)
        basicbox.set_border_width(10)
        hbox = gtk.HBox(False, 0)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Network setup (for install only):") +
                            "</u></b>")
        hbox.pack_start(tmplabel, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=0)
        hbox = gtk.HBox(False, 0)
        self.already_setup_check = gtk.CheckButton()
        self.already_setup_check.set_active(False)
        self.already_setup_check.connect("toggled", self.already_setup_toggled)
        hbox.pack_start(self.already_setup_check,
                        expand=False,
                        fill=False,
                        padding=0)
        hbox.pack_start(gtk.Label(
            "My network is already setup and running (or no network)"),
                        expand=False,
                        fill=False,
                        padding=10)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        hbox.pack_start(gtk.Label(_("Interface:")),
                        expand=False,
                        fill=False,
                        padding=0)
        self.interface_combo = gtk.combo_box_entry_new_text()
        self.interface_combo.get_child().set_width_chars(9)
        self.interface_combo.connect("changed", self.interface_changed)
        self.interfaces = GLIUtility.get_eth_devices()
        for device in self.interfaces:
            self.interface_combo.append_text(device)
        hbox.pack_start(self.interface_combo,
                        expand=False,
                        fill=False,
                        padding=10)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=7)
        hbox = gtk.HBox(False, 0)
        self.basic_dhcp_radio = gtk.RadioButton(label=_("DHCP"))
        self.basic_dhcp_radio.connect("toggled", self.dhcp_static_toggled,
                                      "dhcp")
        hbox.pack_start(self.basic_dhcp_radio,
                        expand=False,
                        fill=False,
                        padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=0)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=1, columns=3)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmptable.attach(gtk.Label("        "), 0, 1, 0, 1)
        tmplabel = gtk.Label(_("DHCP options:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 0, 1)
        self.dhcp_options_entry = gtk.Entry()
        self.dhcp_options_entry.set_width_chars(35)
        tmptable.attach(self.dhcp_options_entry, 2, 3, 0, 1)
        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        self.basic_static_radio = gtk.RadioButton(group=self.basic_dhcp_radio,
                                                  label=_("Static"))
        self.basic_static_radio.connect("toggled", self.dhcp_static_toggled,
                                        "static")
        hbox.pack_start(self.basic_static_radio,
                        expand=False,
                        fill=False,
                        padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=5, columns=1)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmptable.attach(gtk.Label("        "), 0, 1, 0, 1)
        tmplabel = gtk.Label(_("IP address:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 0, 1)
        self.ip_address_entry = gtk.Entry()
        self.ip_address_entry.set_width_chars(20)
        tmptable.attach(self.ip_address_entry, 2, 3, 0, 1)
        tmptable.attach(gtk.Label("        "), 3, 4, 0, 1)
        tmplabel = gtk.Label(_("Netmask:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 4, 5, 0, 1)
        self.netmask_entry = gtk.Entry()
        self.netmask_entry.set_width_chars(20)
        tmptable.attach(self.netmask_entry, 5, 6, 0, 1)
        tmplabel = gtk.Label(_("Broadcast:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 1, 2)
        self.broadcast_entry = gtk.Entry()
        self.broadcast_entry.set_width_chars(20)
        tmptable.attach(self.broadcast_entry, 2, 3, 1, 2)
        tmplabel = gtk.Label(_("Gateway:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 4, 5, 1, 2)
        self.gateway_entry = gtk.Entry()
        self.gateway_entry.set_width_chars(20)
        tmptable.attach(self.gateway_entry, 5, 6, 1, 2)
        tmplabel = gtk.Label(_("DNS servers:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 1, 2, 2, 3)
        self.dns_entry = gtk.Entry()
        self.dns_entry.set_width_chars(20)
        tmptable.attach(self.dns_entry, 2, 3, 2, 3)
        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=1, columns=5)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        #		tmptable.attach(gtk.Label("   "), 0, 2, 0, 1)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Proxies:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 5, 0, 1)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("HTTP:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 2, 3)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.http_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.http_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.http_proxy_entry, 1, 2, 2, 3)
        tmptable.attach(tmpbox, 0, 1, 1, 2)
        tmptable.attach(gtk.Label("    "), 1, 2, 1, 2)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("FTP:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 3, 4)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.ftp_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.ftp_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.ftp_proxy_entry, 1, 2, 3, 4)
        tmptable.attach(tmpbox, 2, 3, 1, 2)
        tmptable.attach(gtk.Label("    "), 3, 4, 1, 2)

        tmpbox = gtk.HBox(False, 5)
        tmplabel = gtk.Label(_("Rsync:"))
        tmplabel.set_alignment(0, 0.5)
        #		tmptable.attach(tmplabel, 0, 1, 4, 5)
        tmpbox.pack_start(tmplabel, expand=False, fill=False)
        self.rsync_proxy_entry = gtk.Entry()
        tmpbox.pack_start(self.rsync_proxy_entry, expand=False, fill=False)
        #		tmptable.attach(self.rsync_proxy_entry, 1, 2, 4, 5)
        tmptable.attach(tmpbox, 4, 5, 1, 2)

        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)
        basicbox.pack_start(hbox, expand=False, fill=False, padding=3)
        self.notebook.append_page(basicbox, gtk.Label(_("Networking")))

        advbox = gtk.VBox(False, 0)
        advbox.set_border_width(10)
        hbox = gtk.HBox(False, 0)
        tmptable = gtk.Table(rows=5, columns=1)
        tmptable.set_col_spacings(6)
        tmptable.set_row_spacings(5)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("Directories and logfiles:") +
                            "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 0, 1)
        tmplabel = gtk.Label(_("Chroot directory:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 1, 2)
        self.chroot_dir_entry = gtk.Entry()
        self.chroot_dir_entry.set_width_chars(25)
        tmptable.attach(self.chroot_dir_entry, 1, 2, 1, 2)
        tmplabel = gtk.Label(_("Logfile:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 2, 3)
        self.logfile_entry = gtk.Entry()
        self.logfile_entry.set_width_chars(25)
        tmptable.attach(self.logfile_entry, 1, 2, 2, 3)
        tmplabel = gtk.Label("   ")
        tmptable.attach(tmplabel, 0, 1, 3, 4)
        tmplabel = gtk.Label()
        tmplabel.set_markup("<b><u>" + _("SSH:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 4, 5)
        tmplabel = gtk.Label(_("Start SSHd:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 5, 6)
        tmphbox = gtk.HBox(False, 0)
        self.sshd_yes_radio = gtk.RadioButton(label=_("Yes"))
        tmphbox.pack_start(self.sshd_yes_radio,
                           expand=False,
                           fill=False,
                           padding=0)
        self.sshd_no_radio = gtk.RadioButton(group=self.sshd_yes_radio,
                                             label=_("No"))
        tmphbox.pack_start(self.sshd_no_radio,
                           expand=False,
                           fill=False,
                           padding=15)
        tmptable.attach(tmphbox, 1, 2, 5, 6)
        tmplabel = gtk.Label(_("Root password:"******"Verify root password:"******"   ")
        tmptable.attach(tmplabel, 0, 1, 8, 9)
        tmplabel = gtk.Label()
        #		tmplabel.set_markup("<b><u>" + _("Kernel modules:") + "</u></b>")
        tmplabel.set_markup("<b><u>" + _("Other:") + "</u></b>")
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 2, 9, 10)
        tmplabel = gtk.Label(_("Kernel modules:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 10, 11)
        self.modules_entry = gtk.Entry()
        self.modules_entry.set_width_chars(25)
        tmptable.attach(self.modules_entry, 1, 2, 10, 11)
        #		tmplabel = gtk.Label("   ")
        #		tmptable.attach(tmplabel, 0, 1, 11, 12)
        #		tmplabel = gtk.Label()
        #		tmplabel.set_markup("<b><u>" + _("Debug:") + "</u></b>")
        #		tmplabel.set_alignment(0.0, 0.5)
        #		tmptable.attach(tmplabel, 0, 2, 12, 13)
        tmplabel = gtk.Label(_("Verbose logging:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 11, 12)
        tmphbox = gtk.HBox(False, 0)
        self.verbose_no_radio = gtk.RadioButton(label=_("No"))
        tmphbox.pack_start(self.verbose_no_radio,
                           expand=False,
                           fill=False,
                           padding=0)
        self.verbose_yes_radio = gtk.RadioButton(group=self.verbose_no_radio,
                                                 label=_("Yes"))
        tmphbox.pack_start(self.verbose_yes_radio,
                           expand=False,
                           fill=False,
                           padding=15)
        tmptable.attach(tmphbox, 1, 2, 11, 12)
        tmplabel = gtk.Label(_("Install mode:"))
        tmplabel.set_alignment(0.0, 0.5)
        tmptable.attach(tmplabel, 0, 1, 12, 13)
        self.install_mode_combo = gtk.combo_box_new_text()
        self._install_modes = ("Normal", "Chroot")
        for install_mode in self._install_modes:
            self.install_mode_combo.append_text(install_mode)
        self.install_mode_combo.set_active(0)
        tmptable.attach(self.install_mode_combo, 1, 2, 12, 13)

        hbox.pack_start(tmptable, expand=False, fill=False, padding=0)

        # Currently loaded modules
        loaded_mod_frame = gtk.Frame(label="Loaded modules")
        loaded_mod_frame.set_size_request(200, -1)
        module_list_box = gtk.VBox(False, 3)
        module_list_box.set_border_width(7)
        module_scroll = gtk.ScrolledWindow()
        module_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        module_scroll.set_shadow_type(gtk.SHADOW_NONE)
        module_viewport = gtk.Viewport()
        module_viewport.set_shadow_type(gtk.SHADOW_NONE)
        module_viewport.add(module_list_box)
        module_scroll.add(module_viewport)
        loaded_mod_frame.add(module_scroll)
        loaded_modules = GLIUtility.spawn(
            r"lsmod | grep -v ^Module | cut -d ' ' -f 1",
            return_output=True)[1].strip().split("\n")
        for module in loaded_modules:
            tmplabel = gtk.Label(module)
            tmplabel.set_alignment(0.0, 0.5)
            module_list_box.pack_start(tmplabel,
                                       expand=False,
                                       fill=False,
                                       padding=0)
        hbox.pack_end(loaded_mod_frame, expand=False, fill=False, padding=5)

        advbox.pack_start(hbox, expand=False, fill=False, padding=0)
        self.notebook.append_page(advbox, gtk.Label(_("Misc.")))

        vert.pack_start(self.notebook, expand=True, fill=True, padding=0)

        self.add_content(vert)
    def configure_networking(self):
        if self._configuration.get_verbose():
            self._logger.log("DEBUG: beginning of configure_networking()")
        # Do networking setup right here.
        if self._configuration.get_network_type() != None:
            type = self._configuration.get_network_type()
            if type == "null" or type == "none":
                # don't do anything, it's not our problem if the user specifies this.
                return
            elif type == "dhcp":
                if self._configuration.get_verbose():
                    self._logger.log(
                        "DEBUG: configure_networking(): DHCP selected")
                # Run dhcpcd.
                try:
                    interface = self._configuration.get_network_interface()
                    dhcp_options = self._configuration.get_network_dhcp_options(
                    )
                except:
                    self._logger.log(
                        "No interface found.. defaulting to eth0.")
                    interface = "eth0"
                    dhcp_options = ""

                if interface and not dhcp_options:
                    if self._configuration.get_verbose():
                        self._logger.log(
                            "DEBUG: configure_networking(): running '/sbin/dhcpcd -n "
                            + interface + "'")
                    status = GLIUtility.spawn("/sbin/dhcpcd -t 15 -n " +
                                              interface)
                elif interface and dhcp_options:
                    if self._configuration.get_verbose():
                        self._logger.log(
                            "DEBUG: configure_networking(): running '/sbin/dhcpcd "
                            + dhcp_options + " " + interface + "'")
                    status = GLIUtility.spawn("/sbin/dhcpcd -t 15 " +
                                              dhcp_options + " " + interface)
                else:
                    if self._configuration.get_verbose():
                        self._logger.log(
                            "DEBUG: configure_networking(): running '/sbin/dhcpcd -n'"
                        )
                    status = GLIUtility.spawn("/sbin/dhcpcd -t 15 -n")
                if self._configuration.get_verbose():
                    self._logger.log(
                        "DEBUG: configure_networking(): call to /sbin/dhcpcd complete"
                    )

                if not GLIUtility.exitsuccess(status):
                    raise GLIException(
                        "DHCPError", 'fatal', 'configure_networking',
                        "Failed to get a dhcp address for " + interface + ".")

            elif type == "manual" and self._configuration.get_interactive():
                # Drop to bash shell and let them configure it themselves
                print "Please configure & test your network device."
                GLIUtility.spawn_bash()
            elif type == "manual" and not self._interactive.get_interactive():
                print "You cannot manually configure the network in non-interactive mode!"
                print "Please fix either the network settings or the interactive mode!"
                sys.exit(1)
            elif type == "static":
                if self._configuration.get_verbose():
                    self._logger.log(
                        "DEBUG: configure_networking(): setting static IP")
                # Configure the network from the settings they gave.
                net_interface = self._configuration.get_network_interface()
                net_ip = self._configuration.get_network_ip()
                net_broadcast = self._configuration.get_network_broadcast()
                net_netmask = self._configuration.get_network_netmask()
                if not GLIUtility.set_ip(net_interface, net_ip, net_broadcast,
                                         net_netmask):
                    raise GLIException("SetIPError", 'fatal',
                                       'configure_networking',
                                       "Could not set the IP address!")

                route = self._configuration.get_network_gateway()
                if not GLIUtility.set_default_route(route):
                    raise GLIException("DefaultRouteError", 'fatal',
                                       'configure_networking',
                                       "Could not set the default route!")

                dns_servers = self._configuration.get_dns_servers()
                if dns_servers:
                    try:
                        resolv_conf = open("/etc/resolv.conf", "w")
                        for dns_server in dns_servers:
                            resolv_conf.write("nameserver " + dns_server +
                                              "\n")
                        resolv_conf.close()
                    except:
                        raise GLIException("DNSServerError", 'fatal',
                                           'configure_networking',
                                           "Could not set the DNS servers!")

                if self._configuration.get_verbose():
                    self._logger.log(
                        "DEBUG: configure_networking(): done setting static IP"
                    )
Beispiel #39
0
 def activate(self):
     self.controller.SHOW_BUTTON_EXIT = True
     self.controller.SHOW_BUTTON_HELP = True
     self.controller.SHOW_BUTTON_BACK = True
     self.controller.SHOW_BUTTON_FORWARD = True
     self.controller.SHOW_BUTTON_FINISH = False
     self.etc_files = self.controller.install_profile.get_etc_files()
     if not "make.conf" in self.etc_files:
         self.etc_files['make.conf'] = {}
     self.make_conf_values = self.etc_files['make.conf']
     # Parsing USE
     self.use_flags = {}
     if not self.make_conf_values.has_key(
             'USE') or not self.make_conf_values['USE']:
         self.make_conf_values['USE'] = self.system_use_flags
     for flag in self.make_conf_values['USE'].split(" "):
         if flag.startswith("-"):
             flag = flag[1:]
             self.use_flags[flag] = 0
         else:
             self.use_flags[flag] = 1
     sorted_use = self.use_desc.keys()
     sorted_use.sort()
     self.treedata = gtk.ListStore(gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING)
     for flag in sorted_use:
         if flag in self.use_flags and self.use_flags[flag] == 1:
             self.treedata.append([True, flag, self.use_desc[flag]])
         else:
             self.treedata.append([False, flag, self.use_desc[flag]])
     self.treeview.set_model(self.treedata)
     if self.controller.install_profile.get_grp_install():
         self.treeview.set_sensitive(False)
         self.unstable_packages_check.set_sensitive(False)
         self.unstable_packages_check.set_active(False)
     else:
         self.treeview.set_sensitive(True)
         self.unstable_packages_check.set_sensitive(True)
     # Parsing CFLAGS
     if not self.make_conf_values.has_key(
             'CFLAGS') or not self.make_conf_values['CFLAGS']:
         self.make_conf_values['CFLAGS'] = self.system_cflags
     custom_cflags = ""
     for flag in self.make_conf_values['CFLAGS'].split(" "):
         flag = flag.strip()
         if flag.startswith("-march="):
             equal_pos = flag.find("=")
             arch = flag[equal_pos + 1:]
             i = 0
             for proc in self.arch_procs['x86']:
                 if proc == arch:
                     self.proc_combo.set_active(i)
                     break
                 i += 1
         elif flag.startswith("-O"):
             i = 0
             for opt in self.optimizations:
                 if flag == opt:
                     self.optimizations_combo.set_active(i)
                     break
                 i += 1
         else:
             custom_cflags = custom_cflags + " " + flag
     self.custom_cflags_entry.set_text(custom_cflags.strip())
     # Parsing ACCEPT_KEYWORDS
     if not self.make_conf_values.has_key(
             'ACCEPT_KEYWORDS'
     ) or not self.make_conf_values['ACCEPT_KEYWORDS']:
         self.make_conf_values[
             'ACCEPT_KEYWORDS'] = self.system_accept_keywords
     if self.make_conf_values['ACCEPT_KEYWORDS'].find("~x86") != -1:
         self.unstable_packages_check.set_active(True)
     else:
         self.unstable_packages_check.set_active(False)
     # Parsing FEATURES
     if not self.make_conf_values.has_key(
             'FEATURES') or not self.make_conf_values['FEATURES']:
         self.make_conf_values['FEATURES'] = self.system_features
     self.use_distcc_check.set_active(False)
     self.use_ccache_check.set_active(False)
     self.build_binary_check.set_active(False)
     for feature in self.make_conf_values['FEATURES'].split(" "):
         feature = feature.strip()
         if feature == "distcc":
             self.use_distcc_check.set_active(True)
         elif feature == "ccache":
             self.use_ccache_check.set_active(True)
         elif feature == "buildpkg":
             self.build_binary_check.set_active(True)
     # Parsing CHOST
     if not self.make_conf_values.has_key(
             'CHOST') or not self.make_conf_values['CHOST']:
         self.make_conf_values['CHOST'] = self.system_chost
     self.chost_combo.get_model().clear()
     for i, chost in enumerate(
             GLIUtility.get_chosts(self.controller.client_profile.
                                   get_architecture_template())):
         self.chost_combo.append_text(chost)
         if chost == self.make_conf_values['CHOST'] or i == 0:
             self.chost_combo.set_active(i)
     if self.controller.install_profile.get_install_stage() > 1:
         self.chost_combo.set_sensitive(False)
     else:
         self.chost_combo.set_sensitive(True)
     # Parsing MAKEOPTS
     if not self.make_conf_values.has_key(
             'MAKEOPTS') or not self.make_conf_values['MAKEOPTS']:
         self.make_conf_values['MAKEOPTS'] = self.system_makeopts
     self.makeopts_entry.set_text(self.make_conf_values['MAKEOPTS'])
Beispiel #40
0
    def draw_screen(self):
        content_str = """
This is where you emerge extra packages that your system may need. Packages that
are fetch-restricted (e.g. sun-jdk) or require you to accept licenses (e.g. many
big games) will cause your install to fail. Add additional packages with
caution. These trouble packages can be installed manually after you reboot.
"""

        # pack the description
        self.vert.pack_start(gtk.Label(content_str),
                             expand=False,
                             fill=False,
                             padding=5)

        scrolled_window = gtk.ScrolledWindow(hadjustment=None,
                                             vadjustment=None)
        scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)

        # store the objects for later ( when loading )
        self.category_objects = {}
        self.package_objects = {}

        self.categories = self.controller.install_profile.get_install_package_list(
        )
        self.group_packages = GLIUtility.get_grp_pkgs_from_cd()

        # first load the category
        for category in self.categories:
            categ = self.Category(category)
            self.category_objects[category] = categ
            hbox = categ.Generate_GTK()
            self.vert2.pack_start(hbox, expand=False, fill=False, padding=0)

            # then load the packages in that category
            packages = self.categories[category][1]
            for package in packages:
                # group_packages may be in the format category/package or just package
                if "/" in package:
                    displayname = package[package.index("/") + 1:]
                else:
                    displayname = package

                # if its a grp install, append (GRP) to the name
                if self.controller.install_profile.get_grp_install():
                    if package in self.group_packages:
                        displayname = displayname + " (GRP)"

                pack = self.Package(self, package, packages[package],
                                    displayname)
                self.package_objects[package] = pack
                hbox = pack.Generate_GTK()
                self.vert2.pack_start(hbox,
                                      expand=False,
                                      fill=False,
                                      padding=0)

        # add the custom space-seperated list bar
        entry_description = gtk.Label(
            "Enter a space seperated list of extra packages to install on the system ( in addition to those checked above ):"
        )
        self.entry = gtk.Entry()

        scrolled_window.add_with_viewport(self.vert2)
        viewport = scrolled_window.get_children()[0]
        viewport.set_shadow_type(gtk.SHADOW_IN)
        viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))

        self.vert.pack_start(scrolled_window,
                             expand=True,
                             fill=True,
                             padding=0)
        self.vert.pack_start(entry_description,
                             expand=False,
                             fill=False,
                             padding=0)
        self.vert.pack_start(self.entry, expand=False, fill=False, padding=0)
        self.vert.show_all()
        self.add_content(self.vert)
Beispiel #41
0
    def partition(self):
        """
		TODO:
		before step 3, wipe drive and use the default disklabel for arch
		skip fixed partitions in all passes (in GLISD maybe?)
		"""
        parts_old = {}
        parts_new = self._install_profile.get_partition_tables()
        for device in GLIStorageDevice.detect_devices():
            parts_old[device] = GLIStorageDevice.Device(
                device,
                arch=self._client_configuration.get_architecture_template())
            parts_old[device].set_partitions_from_disk()

        self.notify_frontend("progress", (0, "Examining partitioning data"))
        total_steps = float(len(parts_new) *
                            4)  # 4 for the number of passes over each device
        cur_progress = 0
        for device in parts_new:
            # Skip this device in parts_new if device isn't detected on current system
            if not device in parts_old:
                self._logger.log(
                    "There is no physical device " + device +
                    " detected to match the entry in the install profile...skipping"
                )
                continue

            # This just makes things simpler in the code
            newparts = parts_new[device]
            oldparts = parts_old[device]

            # Check to see if the old and new partition table structures are the same...skip if they are
            if not self._check_table_changed(oldparts, newparts):
                self._logger.log("Partition table for " + device +
                                 " is unchanged...skipping")
                continue

            self._logger.log("partition(): Processing " + device + "...")

            # Commit ritual sepuku if there are any mounted filesystems on this device
            if GLIUtility.spawn("mount | grep '^" + device + "'",
                                return_output=True)[1].strip():
                raise GLIException(
                    "PartitionsMountedError", 'fatal', 'partition',
                    "Cannot partition " + device +
                    " due to filesystems being mounted")

            # We also can't handle "unknown" partitions
            for part in newparts:
                if newparts[part]['type'] == "unknown":
                    raise GLIException(
                        "UnknownPartitionTypeError", 'fatal', 'partition',
                        "Refusing to partition this drive due to the presence of an unknown type of partition"
                    )

            # Create pyparted objects for this device
            parted_dev = parted.PedDevice.get(device)
            try:
                parted_disk = parted.PedDisk.new(parted_dev)
            except:
                if self._debug:
                    self._logger.log(
                        "partition(): could not load existing disklabel...creating new one"
                    )
                parted_disk = parted_dev.disk_new_fresh(
                    parted.disk_type_get(
                        (newparts.get_disklabel() or
                         GLIStorageDevice.archinfo[self._architecture_name])))

            # Iterate through new partitions and check for 'origminor' and 'format' == False
            for part in newparts:
                tmppart_new = newparts[part]
                if not tmppart_new['origminor'] or tmppart_new['format']:
                    continue
                if not tmppart_new['origminor'] in oldparts:
                    raise GLIException(
                        "MissingPartitionsError", 'fatal', 'partition',
                        "Cannot find the existing partition that a new one refers to. This is not a bug. This is in fact your (the user's) fault. You should not reuse the installprofile.xml from a previous install that started the partitioning step."
                    )
                tmppart_old = oldparts[tmppart_new['origminor']]
                if parted_disk.type.check_feature(
                        parted.DISK_TYPE_PARTITION_NAME):
                    tmppart_new['name'] = tmppart_old['name']
                tmppart_new['flags'] = tmppart_old['flags']
                if tmppart_new['resized']:
                    # Partition is being resized in the new layout
                    self._logger.log(
                        "  Partition " + str(part) + " has origminor " +
                        str(tmppart_new['origminor']) +
                        " and it being resized...saving start sector " +
                        str(tmppart_old['start']))
                    tmppart_new['start'] = tmppart_old['start']
                    tmppart_new['end'] = 0
                else:
                    # Partition is untouched in the new layout
                    self._logger.log("  Partition " + str(part) +
                                     " has origminor " +
                                     str(tmppart_new['origminor']) +
                                     "...saving start sector " +
                                     str(tmppart_old['start']) +
                                     " and end sector " +
                                     str(tmppart_old['end']))
                    tmppart_new['start'] = tmppart_old['start']
                    tmppart_new['end'] = tmppart_old['end']

            if self._check_table_layout_changed(parts_old[device],
                                                parts_new[device]):
                # First pass to delete old partitions that aren't resized
                self.notify_frontend(
                    "progress",
                    (cur_progress / total_steps,
                     "Deleting partitioning that aren't being resized for " +
                     device))
                cur_progress += 1
                self._partition_delete_step(parted_disk, oldparts, newparts)

                # Second pass to resize old partitions that need to be resized
                self._logger.log("Partitioning: Second pass...")
                self.notify_frontend(
                    "progress",
                    (cur_progress / total_steps,
                     "Resizing remaining partitions for " + device))
                cur_progress += 1
                self._partition_resize_step(parted_disk, device, oldparts,
                                            newparts)

                # Wiping disk and creating blank disklabel
                try:
                    parted_disk = parted_dev.disk_new_fresh(
                        parted.disk_type_get(newparts.get_disklabel()))
                    parted_disk.commit()
                except:
                    raise GLIException("DiskLabelCreationError", 'fatal',
                                       'partition',
                                       "Could not create a blank disklabel!")

                # Third pass to create new partition table
                self._logger.log(
                    "Partitioning: Third pass....creating partitions")
                self.notify_frontend(
                    "progress", (cur_progress / total_steps,
                                 "Recreating partition table for " + device))
                cur_progress += 1
                self._partition_recreate_step(parted_disk, newparts)
            else:
                cur_progress += 3

            # Fourth pass to format partitions
            self._logger.log("Partitioning: formatting partitions")
            self.notify_frontend("progress",
                                 (cur_progress / total_steps,
                                  "Formatting partitions for " + device))
            cur_progress += 1
            self._partition_format_step(parted_disk, device, newparts)

            # All done for this device
            self.notify_frontend("progress",
                                 (cur_progress / total_steps,
                                  "Done with partitioning for " + device))
            cur_progress += 1
Beispiel #42
0
		elif arg == "-g" or arg == "--grp":
			mode = "grp"
		elif arg == "-s" or arg == "--stage3":
			mode = "stage3"
		elif arg == "-h" or arg == "--help":
			usage(progname)
			sys.exit(0)
		elif arg[0] == "-":
			usage(progname)
			sys.exit(1)
		else:
			grp_packages.append(arg)

	gliportage = GLIPortage(chroot_dir, True, None, False, None, None)
	if mode == "stage3":
		if not GLIUtility.is_file("/usr/livecd/systempkgs.txt"):
			print "Required file /usr/livecd/systempkgs.txt does not exist!"
			sys.exit(1)
		try:
			syspkgs = open("/usr/livecd/systempkgs.txt", "r")
			systempkgs = syspkgs.readlines()
			syspkgs.close()
		except:
			print "Could not open /usr/livecd/systempkgs.txt!"
			sys.exit(1)

		# Pre-create /lib (and possible /lib32 and /lib64)
		if os.path.islink("/lib") and os.readlink("/lib") == "lib64":
			if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir " + chroot_dir + "/lib64 && ln -s lib64 " + chroot_dir + "/lib")):
				print "Could not precreate /lib64 dir and /lib -> /lib64 symlink"
				sys.exit(1)
Beispiel #43
0
 def _configure_lilo(self):
     self.build_mode = self._install_profile.get_kernel_build_method()
     self._gather_lilo_drive_info()
     root = self._chroot_dir
     file_name3 = root + "/boot/kernel_name"
     root = self._chroot_dir
     exitstatus0 = GLIUtility.spawn("ls " + root + "/boot/kernel-* > " +
                                    file_name3)
     if (exitstatus0 != 0):
         raise GLIException(
             "BootloaderError", 'fatal', '_configure_lilo',
             "Could not list kernels in /boot or no kernels found.")
     if self.build_mode == "genkernel" or self._install_profile.get_kernel_source_pkg(
     ) == "livecd-kernel":
         exitstatus1 = GLIUtility.spawn("ls " + root + "/boot/init* >> " +
                                        file_name3)
         if (exitstatus1 != 0):
             raise GLIException("BootloaderError", 'fatal',
                                '_configure_lilo',
                                "Could not list initrds in /boot")
     g = open(file_name3)
     kernel_name = g.readlines()
     g.close()
     if not kernel_name[0]:
         raise GLIException(
             "BootloaderError", 'fatal', '_configure_lilo',
             "Error: We have no kernel in /boot to put in the grub.conf file!"
         )
     kernel_name = map(string.strip, kernel_name)
     kernel_name[0] = kernel_name[0].split(root)[1]
     kernel_name[1] = kernel_name[1].split(root)[1]
     if self._install_profile.get_bootloader_kernel_args():
         bootloader_kernel_args = self._install_profile.get_bootloader_kernel_args(
         )
     else:
         bootloader_kernel_args = ""
     #-------------------------------------------------------------
     #time to build the lilo.conf
     newliloconf = ""
     if self._install_profile.get_boot_loader_mbr():
         newliloconf += "boot=" + self.mbr_device + "   # Install LILO in the MBR \n"
     else:
         newliloconf += "boot=" + self.boot_device + self.boot_minor + "   # Install LILO in the MBR \n"
     newliloconf += "prompt                    # Give the user the chance to select another section\n"
     newliloconf += "timeout=50                # Wait 5 (five) seconds before booting the default section\n"
     newliloconf += "default=gentoo            # When the timeout has passed, boot the \"gentoo\" section\n"
     newliloconf += "# Only if you use framebuffer. Otherwise remove the following line:\n"
     if not self._install_profile.get_kernel_bootsplash():
         newliloconf += "#"
     newliloconf += "vga=788                   # Framebuffer setting. Adjust to your own will\n"
     newliloconf += "image=/boot" + kernel_name[0][5:] + " \n"
     newliloconf += "  label=gentoo \n  read-only \n"
     if self.build_mode != "genkernel" and self._install_profile.get_kernel_source_pkg(
     ) != "livecd-kernel":
         newliloconf += "  root=" + self.root_device + self.root_minor + " \n"
         if bootloader_kernel_args:
             newliloconf += "  append=\"" + bootloader_kernel_args + "\" \n"
     else:
         newliloconf += "  root=/dev/ram0 \n"
         newliloconf += "  append=\"init=/linuxrc ramdisk=8192 real_root=" + self.root_device + self.root_minor + " " + bootloader_kernel_args + "\" \n"
         newliloconf += "  initrd=/boot" + kernel_name[1][5:] + "\n\n"
     newliloconf = self._lilo_add_windows(newliloconf)
     #now make the lilo.conf file
     file_name = root + "/etc/lilo.conf"
     try:
         shutil.move(file_name, file_name + ".OLDdefault")
     except:
         pass
     f = open(file_name, 'w')
     f.writelines(newliloconf)
     f.close()
     self._logger.log("Lilo installed and configured.  Not run yet.")
Beispiel #44
0
class URIBrowser(gtk.Window):

    uritypes = ("file", "http", "ftp", "scp")

    def __init__(self, controller, entry):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)

        self.controller = controller
        self.entry = entry
        self.uri = None
        self.old_uri = None
        self.uriparts = None
        self.mirrors = None

        self.set_title(_("URI Browser"))
        self.connect("delete_event", self.delete_event)
        self.connect("destroy", self.destroy_event)

        self.globalbox = gtk.VBox(False, 0)
        self.globalbox.set_border_width(10)

        self.table = gtk.Table(5, 3, False)
        self.table.set_col_spacings(5)
        self.table.set_row_spacings(3)

        tmplabel = gtk.Label("URI type:")
        tmplabel.set_alignment(0.0, 0.5)
        self.table.attach(tmplabel, 0, 1, 0, 1)
        self.uritype = gtk.combo_box_new_text()
        self.uritype.connect("changed", self.uritype_changed)
        for tmpuritype in self.uritypes:
            self.uritype.append_text(tmpuritype)
        self.table.attach(self.uritype, 1, 3, 0, 1)

        tmplabel = gtk.Label("Host:")
        tmplabel.set_alignment(0.0, 0.5)
        self.table.attach(tmplabel, 0, 1, 1, 2)
        self.host_entry = gtk.Entry()
        self.table.attach(self.host_entry, 1, 2, 1, 2)
        self.host_browse = gtk.Button(" ... ")
        self.host_browse.connect("clicked", self.host_browse_clicked)
        self.table.attach(self.host_browse, 2, 3, 1, 2)

        tmplabel = gtk.Label("Username:"******"Password:"******"Port:")
        tmplabel.set_alignment(0.0, 0.5)
        self.table.attach(tmplabel, 0, 1, 4, 5)
        self.port_entry = gtk.Entry()
        self.table.attach(self.port_entry, 1, 3, 4, 5)

        tmplabel = gtk.Label("Path:")
        tmplabel.set_alignment(0.0, 0.5)
        self.table.attach(tmplabel, 0, 1, 5, 6)
        self.path_entry = gtk.Entry()
        self.table.attach(self.path_entry, 1, 3, 5, 6)

        self.treedata = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.treeview = gtk.TreeView(self.treedata)
        self.treeview.connect("row-activated", self.row_activated)
        column = gtk.TreeViewColumn()
        cell_renderer = gtk.CellRendererPixbuf()
        column.pack_start(cell_renderer, False)
        column.set_attributes(cell_renderer, stock_id=0)
        cell_renderer = gtk.CellRendererText()
        column.pack_start(cell_renderer, True)
        column.set_attributes(cell_renderer, text=1)
        self.treeview.append_column(column)
        self.treeview.set_headers_visible(False)
        self.treewindow = gtk.ScrolledWindow()
        self.treewindow.set_size_request(-1, 130)
        self.treewindow.set_shadow_type(gtk.SHADOW_IN)
        self.treewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.treewindow.add(self.treeview)
        self.treewindow.set_size_request(300, 200)
        self.table.attach(self.treewindow, 0, 3, 6, 7)

        hbox = gtk.HBox(True)
        self.ok_button = gtk.Button("OK")
        self.ok_button.connect("clicked", self.ok_clicked)
        hbox.pack_start(self.ok_button, expand=False, fill=True, padding=10)
        self.cancel_button = gtk.Button("Cancel")
        self.cancel_button.connect("clicked", self.cancel_clicked)
        hbox.pack_start(self.cancel_button,
                        expand=False,
                        fill=True,
                        padding=10)
        self.refresh_button = gtk.Button("Refresh")
        self.refresh_button.connect("clicked", self.refresh_clicked)
        hbox.pack_start(self.refresh_button,
                        expand=False,
                        fill=True,
                        padding=10)
        self.table.attach(hbox, 0, 3, 7, 8)

        self.globalbox.pack_start(self.table, expand=False, fill=False)
        self.add(self.globalbox)
        self.set_modal(True)
        self.set_transient_for(self.controller.controller.window)
        self.uritype.set_active(0)

    def update_from_uri(self):
        if self.uri:
            self.uriparts = GLIUtility.parse_uri(self.uri)
            if not self.uriparts:
                msgdlg = gtk.MessageDialog(
                    parent=self,
                    type=gtk.MESSAGE_ERROR,
                    buttons=gtk.BUTTONS_OK,
                    message_format=
                    _("The URI you had previously entered was malformed and couldn't be parsed."
                      ))
                msgdlg.run()
                msgdlg.destroy()
                self.uri = "file:///"
                self.uriparts = GLIUtility.parse_uri(self.uri)
            else:
                for i, tmpuritype in enumerate(self.uritypes):
                    if self.uriparts[0] == tmpuritype:
                        self.uritype.set_active(i)
                if self.uriparts[3]: self.host_entry.set_text(self.uriparts[3])
                if self.uriparts[1]:
                    self.username_entry.set_text(self.uriparts[1])
                if self.uriparts[2]:
                    self.password_entry.set_text(self.uriparts[2])
                if self.uriparts[4]: self.port_entry.set_text(self.uriparts[4])
        else:
            self.uri = "file:///"
            self.uriparts = GLIUtility.parse_uri(self.uri)
        self.refresh_file_list()

    def run(self, uri=None):
        self.uri = uri
        self.update_from_uri()
        self.make_visible()

    def make_visible(self):
        self.show_all()
        self.present()

    def make_invisible(self):
        self.hide_all()

    def refresh_file_list(self):
        if not self.uri.endswith("/"):
            self.uri = self.uri[:self.uri.rfind("/") + 1]
        try:
            filelist = GLIUtility.get_directory_listing_from_uri(self.uri)
        except GLIException, e:
            if e.get_error_name() == "IncorrectPassword":
                msgdlg = gtk.MessageDialog(
                    parent=self,
                    type=gtk.MESSAGE_ERROR,
                    buttons=gtk.BUTTONS_OK,
                    message_format=_("Your password is incorrect."))
                msgdlg.run()
                msgdlg.destroy()
            return
        if not filelist:
            msgdlg = gtk.MessageDialog(
                parent=self,
                type=gtk.MESSAGE_ERROR,
                buttons=gtk.BUTTONS_OK,
                message_format=_("The information you entered is invalid."))
            msgdlg.run()
            msgdlg.destroy()
            self.uri = self.old_uri
            filelist = GLIUtility.get_directory_listing_from_uri(self.uri)
        self.uriparts = GLIUtility.parse_uri(self.uri)
        self.treedata.clear()
        for file in filelist:
            #			print "adding " + file + " to self.treedata"
            if file.endswith('/'):
                self.treedata.append(None, ("gtk-directory", file[:-1]))
            else:
                self.treedata.append(None, ("", file))
        self.treewindow.get_vadjustment().set_value(0)
        self.path_entry.set_text(self.uriparts[5])
Beispiel #45
0
def detect_devices():
    devices = []

    # Make sure sysfs exists
    # TODO: rewrite for 2.4 support
    if not os.path.exists("/sys/bus"):
        raise GLIException("GLIStorageDeviceError", 'fatal', 'detect_devices',
                           "no sysfs found (you MUST use a kernel >2.6)")
    # Make sure /proc/partitions exists
    if not os.path.exists("/proc/partitions"):
        raise GLIException(
            "GLIStorageDeviceError", 'fatal', 'detect_devices',
            "/proc/partitions does not exist! Please make sure procfs is in your kernel and mounted!"
        )

    # Load /proc/partitions into the variable 'partitions'
    partitions = []
    for line in open("/proc/partitions"):
        tmpparts = line.split()
        if len(tmpparts) < 4 or not tmpparts[0].isdigit(
        ) or not tmpparts[1].isdigit():
            continue

        # Get the major, minor and device name
        major = int(tmpparts[0])
        minor = int(tmpparts[1])
        device = "/dev/" + tmpparts[3]

        # If there is no /dev/'device_name', then scan
        # all the devices in /dev to try and find a
        # devices with the same major and minor
        if not os.path.exists(device):
            device = None
            for path, dirs, files in os.walk("/dev"):
                for d_file in files:
                    full_file = os.path.join(path, d_file)
                    if not os.path.exists(full_file):
                        continue
                    statres = os.stat(full_file)
                    fmaj = os.major(statres.st_rdev)
                    fmin = os.minor(statres.st_rdev)
                    if fmaj == major and fmin == minor:
                        device = full_file
                        break
            if not device:
                continue

        partitions.append((major, minor, device))

    # Scan sysfs for the devices of type 'x'
    # 'x' being a member of the list below:
    # Compaq cards.../sys/block/{cciss,ida}!cXdX/dev
    for dev_glob in ("/sys/bus/ide/devices/*/block*/dev",
                     "/sys/bus/scsi/devices/*/block*/dev",
                     "/sys/block/cciss*/dev", "/sys/block/ida*/dev"):
        sysfs_devices = glob(dev_glob)
        if not sysfs_devices: continue
        for sysfs_device in sysfs_devices:
            # Get the major and minor info
            try:
                major, minor = open(sysfs_device).read().split(":")
                major = int(major)
                minor = int(minor)
            except:
                raise GLIException("GLIStorageDeviceError", 'fatal',
                                   'detect_devices',
                                   "invalid major/minor in " + sysfs_device)

            # Find a device listed in /proc/partitions
            # that has the same minor and major as our
            # current block device.
            for record in partitions:
                if major == record[0] and minor == record[1]:
                    devices.append(record[2])

    # For testing the partitioning code
    if GLIUtility.is_file("/tmp/disk.img"):
        devices.append("/tmp/disk.img")

    # We have assembled the list of devices, so return it
    return devices
Beispiel #46
0
    def __init__(self, controller):
        GLIScreen.GLIScreen.__init__(self, controller)

        vert = gtk.VBox(
            False, 10
        )  # This box is content so it should fill space to force title to top
        horiz = gtk.HBox(False, 0)
        horiz2 = gtk.HBox(False, 0)
        horiz3 = gtk.HBox(False, 0)

        addme_to_vert = []

        # this code could be reduced, but would it make things any clearer?

        # create the CLOCK object
        self.clock = self.Option("Clock")
        self.clock.HelpText = "Should CLOCK be set to UTC or local? Unless you set your timezone to UTC you will want to choose local."
        self.clock.Options = ["UTC", "local"]
        self.clock.Type = self.Option.OptionType.COMBO
        clock_gtk = self.clock.Generate_GTK()
        addme_to_vert.append(clock_gtk)

        # create the Windowkeys object
        self.windowkeys = self.Option("Windowkeys")
        self.windowkeys.HelpText = "Should we first load the 'windowkeys' console keymap?"
        self.windowkeys.Options = ["Yes", "No"]
        self.windowkeys.Type = self.Option.OptionType.COMBO
        clock_gtk = self.windowkeys.Generate_GTK()
        addme_to_vert.append(clock_gtk)

        # create the Display Manager object
        self.displaymanager = self.Option("Display Manager")
        self.displaymanager.HelpText = "Choose your display manager for Xorg-x11 (note you must make sure that package also gets installed for it to work)"
        self.displaymanager.Options = ["xdm", "kdm", "gdm"]
        self.displaymanager.Type = self.Option.OptionType.COMBO_ENTRY
        clock_gtk = self.displaymanager.Generate_GTK()
        addme_to_vert.append(clock_gtk)

        # create the Default Editor object
        self.editor = self.Option("Default Editor")
        self.editor.HelpText = "Choose your default editor"
        self.editor.Options = ["/bin/nano", "/usr/bin/vim", "/usr/bin/emacs"]
        self.editor.Type = self.Option.OptionType.COMBO
        editor_gtk = self.editor.Generate_GTK()
        addme_to_vert.append(editor_gtk)

        # create the Keymap object
        self.keymap = self.Option("Keymap")
        self.keymap.HelpText = "Choose your desired keymap"
        self.keymap.Options = [""] + GLIUtility.generate_keymap_list()
        self.keymap.Type = self.Option.OptionType.COMBO
        editor_gtk = self.keymap.Generate_GTK()
        addme_to_vert.append(editor_gtk)

        # create the Console Font object
        self.font = self.Option("Console Font")
        self.font.HelpText = "Choose your default console font"
        self.font.Options = [""] + GLIUtility.generate_consolefont_list()
        self.font.Type = self.Option.OptionType.COMBO
        editor_gtk = self.font.Generate_GTK()
        addme_to_vert.append(editor_gtk)

        # create a last bogus one to make it look pretty.
        bogus = self.Option("")
        bogus.HelpText = ""
        bogus.Type = self.Option.OptionType.NONE
        bogus = bogus.Generate_GTK()
        addme_to_vert.append(bogus)

        # create the XSession object
        self.xsession = self.Option("XSession")
        self.xsession.HelpText = "Choose what window manager you want to start default with X if run with xdm, startx, or xinit. (common options are Gnome or Xsession)"
        self.xsession.Options = ["Gnome", "Xsession", "fluxbox"]
        self.xsession.Type = self.Option.OptionType.COMBO_ENTRY
        editor_gtk = self.xsession.Generate_GTK()
        addme_to_vert.append(editor_gtk)

        # create the Extended Keymaps object
        self.extkeymap = self.Option("Extended Keymaps")
        self.extkeymap.HelpText = "This sets the maps to load for extended keyboards. Most users will leave this as is."
        self.extkeymap.Type = self.Option.OptionType.TEXT
        editor_gtk = self.extkeymap.Generate_GTK()
        addme_to_vert.append(editor_gtk)

        addme_to_vert.reverse()
        for i, item in enumerate(addme_to_vert):
            if i < 3:
                horiz.pack_start(item, expand=True, fill=True, padding=10)
            elif i < 6:
                horiz2.pack_start(item, expand=True, fill=True, padding=10)
            else:
                horiz3.pack_start(item, expand=True, fill=True, padding=10)

        self.add_content(horiz)
        self.add_content(horiz2)
        self.add_content(horiz3)