diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | src/GLIArchitectureTemplate.py | 57 | ||||
-rw-r--r-- | src/GLIInstallProfile.py | 37 | ||||
-rw-r--r-- | src/GLIUtility.py | 3 | ||||
-rw-r--r-- | src/SimpleXMLParser.py | 7 | ||||
-rwxr-xr-x | src/tests/install.py | 10 |
7 files changed, 94 insertions, 28 deletions
@@ -1,9 +1,14 @@ # ChangeLog for Gentoo Linux Installer # Copyright 2004 Gentoo Technologies, Inc. -# $Header: /var/cvsroot/gentoo/src/installer/ChangeLog,v 1.166 2005/05/07 05:00:15 agaffney Exp $ +# $Header: /var/cvsroot/gentoo/src/installer/ChangeLog,v 1.167 2005/05/10 04:11:28 codeman Exp $ *GLI-0.1_alpha (4 Apr 2005) + 9 May 2005; Preston Cody <codeman@gentoo.org> + Added the function for set_etc_portage to ArchTemplate. no step for it yet. + Updated _edit_config in ArchTemplate, make_config, and various other fixes + from bug #89683, mostly touchups. + 6 May 2005; Andrew Gaffney <agaffney@gentoo.org> GLIStorageDevice cleanup patch from bug #91761 @@ -15,6 +15,7 @@ Things still needing to be done for the BETA release: support for /etc/portage/* partitioning error checking. add distcc support + add r_pppoe configuration stuff. DialogFE: gtkFE: diff --git a/src/GLIArchitectureTemplate.py b/src/GLIArchitectureTemplate.py index d31f565..ac249b7 100644 --- a/src/GLIArchitectureTemplate.py +++ b/src/GLIArchitectureTemplate.py @@ -1,7 +1,7 @@ """ Gentoo Linux Installer -$Id: GLIArchitectureTemplate.py,v 1.106 2005/05/03 17:12:37 agaffney Exp $ +$Id: GLIArchitectureTemplate.py,v 1.107 2005/05/10 04:11:28 codeman Exp $ Copyright 2004 Gentoo Technologies Inc. The ArchitectureTemplate is largely meant to be an abstract class and an @@ -143,11 +143,12 @@ class ArchitectureTemplate: ## # Private Function. Will edit a config file and insert a value or two overwriting the previous value # (actually it only just comments out the old one) - # @param filename file to be edited - # @param newvalues a dictionary of VARIABLE:VALUE pairs - # @param delimeter='=' what is between the key and the value - # @param quotes_around_value=True whether there are quotes around the value or not (ex. "local" vs. localhost) - def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True): + # @param filename file to be edited + # @param newvalues a dictionary of VARIABLE:VALUE pairs + # @param delimeter='=' what is between the key and the value + # @param quotes_around_value=True whether there are quotes around the value or not (ex. "local" vs. localhost) + # @param only_value=False Ignore the keys and output only a value. + def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True, only_value=False): if not GLIUtility.is_file(filename): raise GLIException("NoSuchFileError", 'notice','_edit_config',filename + ' does not exist!') @@ -166,12 +167,18 @@ class ArchitectureTemplate: file.append('\n# Added by GLI\n') commentprefix = "" - if newvalues[key] == "COMMENT" or newvalues[key] == "##comment##" or newvalues[key] == "##commented##": - commentprefix = "#" - if quotes_around_value: - file.append(commentprefix + key + delimeter + '"' + newvalues[key] + '"\n') + if key == "SPACER": + file.append('\n') + elif key == "COMMENT" or key == "##comment##" or key == "##commented##": + file.append('# ' + newvalues[key] + '\n') else: - file.append(commentprefix + key + delimeter + newvalues[key]+'\n') + if quotes_around_value: + newvalues[key] = '"' + newvalues[key] + '"' + #Only the printing of values is required. + if only_value: + file.append(newvalues[key] + '\n') + else: + file.append(key + delimeter + newvalues[key]+'\n') f = open(filename,'w') f.writelines(file) @@ -237,12 +244,13 @@ class ArchitectureTemplate: def install_packages(self): installpackages = self._install_profile.get_install_packages() for package in installpackages: + self._logger.log("Starting emerge " + package) status = self._emerge(package) if not GLIUtility.exitsuccess(status): self._logger.log("Could not emerge " + package + "!") # raise GLIException("InstallPackagesError", 'warning', 'install_packages', "Could not emerge " + package + "!") else: - self._logger.log("Emerged package: "+package) + self._logger.log("Emerged package: " + package) ## # Will set the list of services to runlevel default. This is a temporary solution! @@ -451,7 +459,7 @@ class ArchitectureTemplate: ## # Fetches desired kernel sources, unless you're using a livecd-kernel in which case it does freaky stuff. def emerge_kernel_sources(self): - + self._logger.log("Starting emerge_kernel") kernel_pkg = self._install_profile.get_kernel_source_pkg() # if kernel_pkg: if kernel_pkg == "livecd-kernel": @@ -976,3 +984,26 @@ class ArchitectureTemplate: GLIUtility.spawn("chmod a+x /tmp/post-install && /tmp/post-install", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True) except: raise GLIException("RunPostInstallScriptError", 'fatal', 'run_post_install_script', "Failed to retrieve and/or execute post-install script") + + # FIXME: UNKNOWN PURPOSE + # + ## + def set_etc_portage(self): + etc_portage = self._install_profile.get_etc_portage() + + # Loop through the required files. + for file in etc_portage: + contents = enumerate(etc_portage[file]) + self._logger.log("Configuring /etc/portage/" + file) + self._edit_config(self._chroot_dir + "/etc/portage/" + file, {"COMMENT": "GLI additions ===>"}) + + # Set up the contents hash to pass to the config writer. + contents = {} + for key,value in enumerate(etc_portage[file]): + contents[str(key)] = string.strip(value) + + # Write out the contents in one go. + self._edit_config(self._chroot_dir + "/etc/portage/" + file, contents, "", False, True) + + self._edit_config(self._chroot_dir + "/etc/make.conf", {"COMMENT": "<=== End GLI additions"}) + self._logger.log("Finished configuring /etc/portage/" + file) diff --git a/src/GLIInstallProfile.py b/src/GLIInstallProfile.py index 7c5a44c..f12ed4c 100644 --- a/src/GLIInstallProfile.py +++ b/src/GLIInstallProfile.py @@ -1,7 +1,7 @@ """ Gentoo Linux Installer -$Id: GLIInstallProfile.py,v 1.46 2005/04/29 06:25:14 agaffney Exp $ +$Id: GLIInstallProfile.py,v 1.47 2005/05/10 04:11:28 codeman Exp $ Copyright 2004 Gentoo Technologies Inc. The GLI module contains all classes used in the Gentoo Linux Installer (or GLI). @@ -59,6 +59,7 @@ class InstallProfile: parser.addHandler('gli-profile/make-conf/variable', self.make_conf_add_var) parser.addHandler('gli-profile/rc-conf/variable', self.rc_conf_add_var) parser.addHandler('gli-profile/network-interfaces/device', self.add_network_interface) + parser.addHandler('gli-profile/etc-portage/file', self.set_etc_portage) parser.addHandler('gli-profile/install-packages', self.set_install_packages) parser.addHandler('gli-profile/fstab/partition', self.add_fstab_partition) parser.addHandler('gli-profile/partitions/device', self.add_partitions_device, call_on_null=True) @@ -107,6 +108,7 @@ class InstallProfile: self._dns_servers = () self._default_gateway = () self._fstab = {} + self._etc_portage = {} self._install_packages = () self._services = () self._mta = "" @@ -1284,10 +1286,34 @@ class InstallProfile: """ return self._fstab + # Sets a list of files in /etc/portage to configure. + # @param xml_path Used internally by the XML parser. Should be + # None when calling directly + # @param install_packages The packages to install. + # @param xml_attr Parameter description + def set_etc_portage(self, xml_path, file_entries, xml_attr): + + if type(file_entries) == str: + file_entries = string.split(file_entries, "\n") + else: + raise GLIException("EtcPortageError", 'fatal', 'set_etc_portage', "Invalid input!") + + for entry in file_entries: + if not GLIUtility.is_realstring(entry): + raise GLIException("EtcPortageError", 'fatal', 'set_etc_packages', entry + " must be a valid string!") + + self._etc_portage[xml_attr['name']] = file_entries + ## - # Brief description of function + # Returns a hash/array of /etc/portage files to configure. + def get_etc_portage(self): + return self._etc_portage + + + ## + # Sets up the list of packages to be installed. # @param xml_path Used internally by the XML parser. Should be None when calling directly - # @param install_packages Parameter description + # @param install_packages The space-separated list of packages to install. # @param xml_attr Parameter description def set_install_packages(self, xml_path, install_packages, xml_attr): """ @@ -1306,11 +1332,8 @@ class InstallProfile: self._install_packages = install_packages ## - # Brief description of function + # This returns a list of the packages def get_install_packages(self): - """ - This returns a list of the packages: - """ return self._install_packages ## diff --git a/src/GLIUtility.py b/src/GLIUtility.py index 9e5b539..54e5fb2 100644 --- a/src/GLIUtility.py +++ b/src/GLIUtility.py @@ -441,7 +441,8 @@ def fetch_and_unpack_tarball(tarball_uri, target_directory, temp_directory="/tmp tarball_filename = tarball_uri.split("/")[-1] # Get the tarball - get_uri(tarball_uri, temp_directory + "/" + tarball_filename) + if not get_uri(tarball_uri, temp_directory + "/" + tarball_filename): + return False # Reset tar options tar_options = "xv" diff --git a/src/SimpleXMLParser.py b/src/SimpleXMLParser.py index 531c0a1..7e5ae4f 100644 --- a/src/SimpleXMLParser.py +++ b/src/SimpleXMLParser.py @@ -1,7 +1,7 @@ """ Gentoo Linux Installer -$Id: SimpleXMLParser.py,v 1.3 2005/04/14 15:44:03 agaffney Exp $ +$Id: SimpleXMLParser.py,v 1.4 2005/05/10 04:11:28 codeman Exp $ Copyright 2004 Gentoo """ @@ -68,8 +68,7 @@ class SimpleXMLParser(xml.sax.ContentHandler): if path in self._fntable.keys(): for fn in self._fntable[path]: if self._xml_current_data != "" or fn[1]: - fn[0](path, self._xml_current_data, self._xml_attrs[-1]) - + fn[0](path, string.strip(self._xml_current_data), self._xml_attrs[-1]) # Keep the XML state self._xml_current_data = "" self._xml_attrs.pop() @@ -88,7 +87,7 @@ class SimpleXMLParser(xml.sax.ContentHandler): # This converts data to a string instead of being Unicode # Maybe we should use Unicode strings instead of normal strings? - self._xml_current_data += string.strip(str(data)) + self._xml_current_data += str(data) ## # Brief description of function diff --git a/src/tests/install.py b/src/tests/install.py index ff3162e..605052c 100755 --- a/src/tests/install.py +++ b/src/tests/install.py @@ -28,6 +28,9 @@ def usage(): print "\tbootloader install and configure bootloader" print "\tconfig_files update config files" print "\tupdate_rc_conf update rc.conf" + print "\tset_users set up the users" + print "\tetc_portage set up the files in /etc/portage" + print "\tinstall_packages install required packages" print "\tunmount unmount all filesystems" def not_working(): @@ -75,8 +78,11 @@ operations = { 'bootloader': archtemplate.install_bootloader, 'config_files': archtemplate.update_config_files, 'update_rc_conf': archtemplate.configure_rc_conf, - 'unmount': not_working - } + 'set_users': archtemplate.set_users, + 'etc_portage': archtemplate.set_etc_portage, + 'install_packages': archtemplate.install_packages, + 'unmount': not_working + } for action in sys.argv: if operations.has_key(action): |