Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 57383 Details for
Bug 89683
patch to improve make.conf marking, and add an option to install a precompiled kernel
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
more additions
gli.patch (text/plain), 17.99 KB, created by
Marko Djukic
on 2005-04-27 05:44:02 UTC
(
hide
)
Description:
more additions
Filename:
MIME Type:
Creator:
Marko Djukic
Created:
2005-04-27 05:44:02 UTC
Size:
17.99 KB
patch
obsolete
>Index: GLIArchitectureTemplate.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/GLIArchitectureTemplate.py,v >retrieving revision 1.97 >diff -u -r1.97 GLIArchitectureTemplate.py >--- GLIArchitectureTemplate.py 17 Apr 2005 05:57:11 -0000 1.97 >+++ GLIArchitectureTemplate.py 27 Apr 2005 12:39:43 -0000 >@@ -55,6 +55,7 @@ > (self.set_timezone, "Setting timezone"), > (self.emerge_kernel_sources, "Emerge kernel sources"), > (self.build_kernel, "Building kernel"), >+ (self.install_kernel, "Installing a kernel"), > (self.install_logging_daemon, "Logger"), > (self.install_cron_daemon, "Cron daemon"), > (self.install_filesystem_tools, "Installing filesystem tools"), >@@ -140,20 +141,28 @@ > return GLIUtility.spawn("emerge " + package, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True) > > ## >- # 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): >- if not GLIUtility.is_file(filename): >- raise GLIException("NoSuchFileError", 'notice','_edit_config',filename + ' does not exist!') >- >- f = open(filename) >- file = f.readlines() >- f.close() >- >+ # Private Function. Will edit a config file and insert a value or two >+ # overridding the previous value (comments out the old values). >+ # >+ # @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. >+ # @param create=True Create the file if it doesn't exist. >+ def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True, only_value=False, create=True): >+ if GLIUtility.is_file(filename): >+ f = open(filename) >+ file = f.readlines() >+ f.close() >+ else: >+ # File does not exist, check if creation is not allowed. >+ if not create: >+ raise GLIException("NoSuchFileError", 'notice','_edit_config',filename + ' does not exist!') >+ else: >+ file = [] >+ > for key in newvalues.keys(): > regexpr = '^\s*#?\s*' + key + '\s*' + delimeter + '.*$' > regexpr = re.compile(regexpr) >@@ -162,17 +171,22 @@ > if regexpr.match(file[i]): > if not file[i][0] == '#': > file[i] = '#' + file[i] >- >- file.append('\n# Added by GLI\n') >- commentprefix = "" >- if newvalues[key] == "COMMENT" or newvalues[key] == "##comment##": >- 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##": >+ 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 = open(filename, 'w') > f.writelines(file) > f.flush() > f.close() >@@ -231,17 +245,42 @@ > self._logger.log("Chroot environment ready.") > > ## >- # Installs a list of packages specified in the profile. Will install any extra software! >- # In the future this function will lead to better things. It may even wipe your ass for you. >+ # Installs a list of packages specified in the profile. Will install also >+ # any dependencies. >+ ## >+ 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) >+ >+ # Installs a list of packages specified in the profile. Will install also >+ # any dependencies. > 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! >@@ -349,7 +388,11 @@ > def configure_make_conf(self): > # Get make.conf options > options = self._install_profile.get_make_conf() >- >+ >+ if options.keys(): >+ self._edit_config(self._chroot_dir + "/etc/make.conf", {"SPACER": ""}) >+ self._edit_config(self._chroot_dir + "/etc/make.conf", {"COMMENT": "GLI additions ===>"}) >+ > # For each configuration option... > for key in options.keys(): > >@@ -357,6 +400,9 @@ > self._edit_config(self._chroot_dir + "/etc/make.conf", {key: options[key]}) > self._logger.log("Make.conf configured") > >+ if options.keys(): >+ self._edit_config(self._chroot_dir + "/etc/make.conf", {"COMMENT": "<=== End GLI additions"}) >+ > ## > # This will get/update the portage tree. If you want to snapshot or mount /usr/portage use "custom". > def install_portage_tree(self): >@@ -446,6 +492,7 @@ > ## > # 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: >@@ -509,12 +556,7 @@ > self._logger.log("Genkernel emerged. Beginning kernel compile.") > # Null the genkernel_options > genkernel_options = "" >- >- # If the uri for the kernel config is not null, then >- if kernel_config_uri != "": >- GLIUtility.get_uri(kernel_config_uri, self._chroot_dir + "/root/kernel_config") >- genkernel_options = genkernel_options + " --kernel-config=/root/kernel_config" >- >+ > # Decide whether to use bootsplash or not > if self._install_profile.get_kernel_bootsplash(): > genkernel_options = genkernel_options + " --bootsplash" >@@ -567,9 +609,34 @@ > exitstatus = GLIUtility.spawn("rm "+self._chroot_dir+"/root/kernel_script") > #it's not important if this fails. > self._logger.log("Custom kernel complete") >- >+ >+ >+ ## >+ # Installs the kernels as defined in the install profile. >+ def install_kernel(self): >+ self._logger.log("Checking for kernels to install.") >+ >+ # Get the kernels to install. >+ kernels = self._install_profile.get_kernels() >+ >+ # Install each kernel. >+ for kernel in kernels: >+ if (kernel['type'] == 'precompiled'): >+ self._install_kernel_precompiled(kernel['kernel']); >+ elif (kernel['type'] == 'emerge'): >+ self._install_kernel_emerge; >+ >+ ## >+ # Function to install a precompiled kernel. >+ def _install_kernel_precompiled(self, kernel): >+ self._logger.log("Installing precompiled kernel " + kernel) >+ if (GLIUtility.spawn("emerge -K " + kernel, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)): >+ raise GLIException("KernelInstallError", 'fatal', 'install_kernel', "Could not install precompiled kernel!") >+ self._logger.log("Kernel install finished.") >+ > ## >- # Installs and sets up logging daemon on the new system. adds to runlevel too. >+ # Installs and sets up logging daemon on the new system. Adds to runlevel >+ # too. > def install_logging_daemon(self): > > # Get loggin daemon info >Index: GLIInstallProfile.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/GLIInstallProfile.py,v >retrieving revision 1.43 >diff -u -r1.43 GLIInstallProfile.py >--- GLIInstallProfile.py 14 Apr 2005 18:35:38 -0000 1.43 >+++ GLIInstallProfile.py 27 Apr 2005 12:39:43 -0000 >@@ -40,6 +40,7 @@ > parser.addHandler('gli-profile/cron-daemon', self.set_cron_daemon_pkg) > parser.addHandler('gli-profile/root-pass-hash', self.set_root_pass_hash) > parser.addHandler('gli-profile/kernel-config', self.set_kernel_config_uri) >+ parser.addHandler('gli-profile/kernels/kernel', self.set_kernel) > parser.addHandler('gli-profile/domainname', self.set_domainname) > parser.addHandler('gli-profile/portage-snapshot', self.set_portage_tree_snapshot_uri) > parser.addHandler('gli-profile/time-zone', self.set_time_zone) >@@ -56,6 +57,7 @@ > 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) >@@ -74,6 +76,7 @@ > self._boot_loader_pkg = "" > self._kernel_modules = [] > self._kernel_config_uri = "" >+ self._kernels = [] > self._bootloader_kernel_args = "" > self._kernel_initrd = True > self._kernel_bootsplash = False >@@ -100,6 +103,7 @@ > self._dns_servers = () > self._default_gateway = () > self._fstab = {} >+ self._etc_portage = {} > self._install_packages = () > self._services = () > self._mta = "" >@@ -254,6 +258,31 @@ > self._kernel_config_uri = kernel_config_uri > > ## >+ # Returns the kernels that need to be installed and how. >+ def get_kernels(self): >+ "returns kernels" >+ return self._kernels >+ >+ ## >+ # Brief description of function >+ # @param xml_path Used internally by the XML parser. Should be None when calling directly >+ # @param kernels Parameter description >+ # @param xml_attr Parameter description >+ def set_kernel(self, xml_path, kernel, attr=None): >+ """ >+ kernels is a hash containing all the kernels to be installed, the >+ method to install them and where to fetch from if so required. >+ """ >+ >+ kernel_type = str(attr.getValue('type')) >+ >+ # Check type >+ if type(kernel) != str: >+ raise GLIException("KernelError", 'fatal', 'set_kernel', "Must be a string!") >+ >+ self._kernels.append({'type': kernel_type, 'kernel': kernel}) >+ >+ ## > # Brief description of function > def get_bootloader_kernel_args(self): > "returns kernel arguments" >@@ -1007,8 +1036,8 @@ > """ > make_conf is a dictionary that will be set to _make_conf > >- There is no checking that needs to be done, so please sure sure that the make_conf dictionary >- that is passed in is valid. >+ There is no checking that needs to be done, so please sure sure that >+ the make_conf dictionary that is passed in is valid. > """ > > self._make_conf = make_conf >@@ -1212,17 +1241,42 @@ > return self._fstab > > ## >- # Brief description of function >- # @param xml_path Used internally by the XML parser. Should be None when calling directly >- # @param install_packages Parameter description >- # @param xml_attr Parameter description >+ # 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 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 >+ >+ ## >+ # 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 The packages to install. >+ # @param xml_attr Parameter description > def set_install_packages(self, xml_path, install_packages, xml_attr): > """ > Set the packages to be installed for the post-installed system. > """ > > if type(install_packages) == str: >- install_packages = string.split(install_packages) >+ install_packages = string.split(install_packages, "\n") > else: > raise GLIException("InstallPackagesError", 'fatal', 'set_install_packages', "Invalid input!") > >Index: GLIUtility.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/GLIUtility.py,v >retrieving revision 1.48 >diff -u -r1.48 GLIUtility.py >--- GLIUtility.py 14 Apr 2005 15:44:03 -0000 1.48 >+++ GLIUtility.py 27 Apr 2005 12:39:43 -0000 >@@ -441,7 +441,8 @@ > tarball_filename = tarball_uri.split("/")[-1] > > # Get the tarball >- get_uri(tarball_uri, temp_directory + "/" + tarball_filename) >+ if (get_uri(tarball_uri, temp_directory + "/" + tarball_filename)) == 0: >+ return False > > # Reset tar options > tar_options = "xv" >@@ -462,7 +463,7 @@ > exitstatus = spawn("tar -" + tar_options + " -f " + temp_directory + "/" + tarball_filename + " -C " + target_directory, display_on_tty8=True, logfile="/tmp/compile_output.log", append_log=True) # change this to the logfile variable > > if not exitsuccess(exitstatus): >- raise GLIException("UnpackTarballError", 'fatal', 'fetch_and_unpack_tarball',"Could not unpack tarball!") >+ raise GLIException("UnpackTarballError", 'fatal', 'fetch_and_unpack_tarball', "Could not unpack tarball!") > > > def generate_random_password(): >Index: SimpleXMLParser.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/SimpleXMLParser.py,v >retrieving revision 1.3 >diff -u -r1.3 SimpleXMLParser.py >--- SimpleXMLParser.py 14 Apr 2005 15:44:03 -0000 1.3 >+++ SimpleXMLParser.py 27 Apr 2005 12:39:43 -0000 >@@ -68,7 +68,7 @@ > 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 = "" >@@ -85,10 +85,10 @@ > > Called when the SAX parser encounters character data. > """ >- >+ > # 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 >Index: tests/install.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/tests/install.py,v >retrieving revision 1.5 >diff -u -r1.5 install.py >--- tests/install.py 8 Jan 2005 09:35:01 -0000 1.5 >+++ tests/install.py 27 Apr 2005 12:39:43 -0000 >@@ -21,6 +21,7 @@ > print "\ttimezone set timezone" > print "\temerge_kernel install the kernel sources" > print "\tbuild_kernel build the kernel" >+ print "\tinstall_kernel install just the kernel" > print "\tlogger install logger" > print "\tcrond install cron daemon" > print "\tfstools install filesystem tools" >@@ -28,6 +29,9 @@ > 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(): >@@ -68,6 +72,7 @@ > 'timezone': archtemplate.set_timezone, > 'emerge_kernel': archtemplate.emerge_kernel_sources, > 'build_kernel': archtemplate.build_kernel, >+ 'install_kernel': archtemplate.install_kernel, > 'logger': archtemplate.install_logging_daemon, > 'crond': archtemplate.install_cron_daemon, > 'fstools': archtemplate.install_filesystem_tools, >@@ -75,6 +80,9 @@ > 'bootloader': archtemplate.install_bootloader, > 'config_files': archtemplate.update_config_files, > 'update_rc_conf': archtemplate.configure_rc_conf, >+ 'set_users': archtemplate.set_users, >+ 'etc_portage': archtemplate.set_etc_portage, >+ 'install_packages': archtemplate.install_packages, > 'unmount': not_working > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 89683
:
56686
|
56855
|
57287
| 57383