/[gli]/trunk/src/GLIArchitectureTemplate.py
Gentoo

Diff of /trunk/src/GLIArchitectureTemplate.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 390 Revision 391
1""" 1"""
2Gentoo Linux Installer 2Gentoo Linux Installer
3 3
4$Id: GLIArchitectureTemplate.py,v 1.57 2005/03/20 08:52:26 agaffney Exp $ 4$Id: GLIArchitectureTemplate.py,v 1.58 2005/03/22 02:41:14 agaffney Exp $
5Copyright 2004 Gentoo Technologies Inc. 5Copyright 2004 Gentoo Technologies Inc.
6 6
7 7
8The ArchitectureTemplate is largely meant to be an abstract class and an 8The ArchitectureTemplate is largely meant to be an abstract class and an
9interface (yes, it is both at the same time!). The purpose of this is to create 9interface (yes, it is both at the same time!). The purpose of this is to create
12 12
13""" 13"""
14 14
15import GLIUtility, GLILogger, os, string, sys, shutil, re 15import GLIUtility, GLILogger, os, string, sys, shutil, re
16from GLIException import * 16from GLIException import *
17# Until I switch my partition code to GLIUtility.spawn()
18import commands
19 17
20class ArchitectureTemplate: 18class ArchitectureTemplate:
21 def __init__(self,configuration=None, install_profile=None, client_controller=None): 19 def __init__(self,configuration=None, install_profile=None, client_controller=None):
22 self._client_configuration = configuration 20 self._client_configuration = configuration
23 self._install_profile = install_profile 21 self._install_profile = install_profile
76 74
77 def _add_to_runlevel(self, script_name, runlevel="default"): 75 def _add_to_runlevel(self, script_name, runlevel="default"):
78 "Adds the script named 'script_name' to the runlevel 'runlevel' in the chroot environement" 76 "Adds the script named 'script_name' to the runlevel 'runlevel' in the chroot environement"
79 77
80 # Do it 78 # Do it
81 status = GLIUtility.spawn("rc-update add " + script_name + " " + runlevel, display_on_tty8=True, chroot=self._chroot_dir) 79 status = GLIUtility.spawn("rc-update add " + script_name + " " + runlevel, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile)
82 if not GLIUtility.exitsuccess(status): 80 if not GLIUtility.exitsuccess(status):
83 raise GLIException("RunlevelAddError", 'fatal', '_add_to_runlevel', "Failure adding " + script_name + " to runlevel " + runlevel + "!") 81 raise GLIException("RunlevelAddError", 'fatal', '_add_to_runlevel', "Failure adding " + script_name + " to runlevel " + runlevel + "!")
84 self._logger.log("Added "+script_name+" to runlevel "+runlevel) 82 self._logger.log("Added "+script_name+" to runlevel "+runlevel)
85 83
86 def _quickpkg_deps(self, package): 84 def _quickpkg_deps(self, package):
101 99
102 def _emerge(self, package, binary=False, binary_only=False): 100 def _emerge(self, package, binary=False, binary_only=False):
103 #Error checking of this function is to be handled by the parent function. 101 #Error checking of this function is to be handled by the parent function.
104 if self._install_profile.get_grp_install(): 102 if self._install_profile.get_grp_install():
105 self._quickpkg_deps(package) 103 self._quickpkg_deps(package)
106 return GLIUtility.spawn("emerge -k " + package, display_on_tty8=True, chroot=self._chroot_dir) 104 return GLIUtility.spawn("emerge -k " + package, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile)
107 else: 105 else:
108 if binary_only: 106 if binary_only:
109 return GLIUtility.spawn("emerge -K " + package, display_on_tty8=True, chroot=self._chroot_dir) 107 return GLIUtility.spawn("emerge -K " + package, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile)
110 elif binary: 108 elif binary:
111 return GLIUtility.spawn("emerge -k " + package, display_on_tty8=True, chroot=self._chroot_dir) 109 return GLIUtility.spawn("emerge -k " + package, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile)
112 else: 110 else:
113 return GLIUtility.spawn("emerge " + package, display_on_tty8=True, chroot=self._chroot_dir) 111 return GLIUtility.spawn("emerge " + package, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile)
114 112
115 def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True): 113 def _edit_config(self, filename, newvalues, delimeter='=', quotes_around_value=True):
116 """ 114 """
117 filename = file to be editted 115 filename = file to be editted
118 newvlaues = a dictionary of VARIABLE:VALUE pairs 116 newvlaues = a dictionary of VARIABLE:VALUE pairs
151 # If we are doing a stage 1 install, then bootstrap 149 # If we are doing a stage 1 install, then bootstrap
152 if self._install_profile.get_install_stage() == 1: 150 if self._install_profile.get_install_stage() == 1:
153 self._logger.mark() 151 self._logger.mark()
154 self._logger.log("Starting bootstrap.") 152 self._logger.log("Starting bootstrap.")
155 pkgs = self._get_packages_to_emerge("/usr/portage/scripts/bootstrap.sh --pretend") 153 pkgs = self._get_packages_to_emerge("/usr/portage/scripts/bootstrap.sh --pretend")
156 exitstatus = GLIUtility.spawn("/usr/portage/scripts/bootstrap.sh", chroot=self._chroot_dir, display_on_tty8=True) 154 exitstatus = GLIUtility.spawn("/usr/portage/scripts/bootstrap.sh", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile)
157 if not GLIUtility.exitsuccess(exitstatus): 155 if not GLIUtility.exitsuccess(exitstatus):
158 raise GLIException("Stage1Error", 'fatal','stage1', "Bootstrapping failed!") 156 raise GLIException("Stage1Error", 'fatal','stage1', "Bootstrapping failed!")
159 self._logger.log("Bootstrap complete.") 157 self._logger.log("Bootstrap complete.")
160 158
161 def stage2(self): 159 def stage2(self):
255 minor = parts_to_mount[mountpoint][2] 253 minor = parts_to_mount[mountpoint][2]
256 if not GLIUtility.is_file(self._chroot_dir+mountpoint): 254 if not GLIUtility.is_file(self._chroot_dir+mountpoint):
257 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint) 255 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint)
258 if exitstatus != 0: 256 if exitstatus != 0:
259 raise GLIException("MkdirError", 'fatal','mount_local_partitions', "Making the mount point failed!") 257 raise GLIException("MkdirError", 'fatal','mount_local_partitions', "Making the mount point failed!")
260 ret = GLIUtility.spawn("mount "+partition_type+mountopts+device+minor+" "+self._chroot_dir+mountpoint, display_on_tty8=True) 258 ret = GLIUtility.spawn("mount "+partition_type+mountopts+device+minor+" "+self._chroot_dir+mountpoint, display_on_tty8=True, logfile=self._compile_logfile)
261 if not GLIUtility.exitsuccess(ret): 259 if not GLIUtility.exitsuccess(ret):
262 raise GLIException("MountError", 'fatal','mount_local_partitions','Could not mount a partition') 260 raise GLIException("MountError", 'fatal','mount_local_partitions','Could not mount a partition')
263 self._logger.log("Mounted mountpoint:"+mountpoint) 261 self._logger.log("Mounted mountpoint:"+mountpoint)
264 def mount_network_shares(self): 262 def mount_network_shares(self):
265 "Mounts all network shares to the local machine" 263 "Mounts all network shares to the local machine"
279 mountpoint = netmount['mountpoint'] 277 mountpoint = netmount['mountpoint']
280 if not GLIUtility.is_file(self._chroot_dir+mountpoint): 278 if not GLIUtility.is_file(self._chroot_dir+mountpoint):
281 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint) 279 exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint)
282 if exitstatus != 0: 280 if exitstatus != 0:
283 raise GLIException("MkdirError", 'fatal','mount_network_shares', "Making the mount point failed!") 281 raise GLIException("MkdirError", 'fatal','mount_network_shares', "Making the mount point failed!")
284 ret = GLIUtility.spawn("mount -t nfs "+mountopts+" "+host+":"+export+" "+self._chroot_dir+mountpoint, display_on_tty8=True) 282 ret = GLIUtility.spawn("mount -t nfs "+mountopts+" "+host+":"+export+" "+self._chroot_dir+mountpoint, display_on_tty8=True, logfile=self._compile_logfile)
285 if not GLIUtility.exitsuccess(ret): 283 if not GLIUtility.exitsuccess(ret):
286 raise GLIException("MountError", 'fatal','mount_network_shares','Could not mount an NFS partition') 284 raise GLIException("MountError", 'fatal','mount_network_shares','Could not mount an NFS partition')
287 self._logger.log("Mounted netmount at mountpoint:"+mountpoint) 285 self._logger.log("Mounted netmount at mountpoint:"+mountpoint)
288 286
289 def fetch_sources_from_cd(self): 287 def fetch_sources_from_cd(self):
291 #WARNING: There will no longer be sources on the future livecds. this will have to change! 289 #WARNING: There will no longer be sources on the future livecds. this will have to change!
292 if not GLIUtility.is_file(self._chroot_dir+"/usr/portage/distfiles"): 290 if not GLIUtility.is_file(self._chroot_dir+"/usr/portage/distfiles"):
293 exitstatus = GLIUtility.spawn("mkdir -p /usr/portage/distfiles",chroot=self._chroot_dir) 291 exitstatus = GLIUtility.spawn("mkdir -p /usr/portage/distfiles",chroot=self._chroot_dir)
294 if exitstatus != 0: 292 if exitstatus != 0:
295 raise GLIException("MkdirError", 'fatal','install_portage_tree',"Making the distfiles directory failed.") 293 raise GLIException("MkdirError", 'fatal','install_portage_tree',"Making the distfiles directory failed.")
296 exitstatus = GLIUtility.spawn("cp /mnt/cdrom/distfiles/* "+self._chroot_dir+"/usr/portage/distfiles/", display_on_tty8=True) 294 exitstatus = GLIUtility.spawn("cp /mnt/cdrom/distfiles/* "+self._chroot_dir+"/usr/portage/distfiles/", display_on_tty8=True, logfile=self._compile_logfile)
297 if exitstatus != 0: 295 if exitstatus != 0:
298 raise GLIException("PortageError", 'fatal','install_portage_tree',"Failed to copy the distfiles to the new system") 296 raise GLIException("PortageError", 'fatal','install_portage_tree',"Failed to copy the distfiles to the new system")
299 self._logger.log("Distfiles copied from cd.") 297 self._logger.log("Distfiles copied from cd.")
300 298
301 def fetch_grp_from_cd(self): 299 def fetch_grp_from_cd(self):
331 # FIXME TEMPORARY FIX FOR NON-GRP SETTING 329 # FIXME TEMPORARY FIX FOR NON-GRP SETTING
332 self.fetch_sources_from_cd() 330 self.fetch_sources_from_cd()
333 self._logger.log("Portage tree install was custom.") 331 self._logger.log("Portage tree install was custom.")
334 # If the type is webrsync, then run emerge-webrsync 332 # If the type is webrsync, then run emerge-webrsync
335 elif self._install_profile.get_portage_tree_sync_type() == "webrsync": 333 elif self._install_profile.get_portage_tree_sync_type() == "webrsync":
336 exitstatus = GLIUtility.spawn("emerge-webrsync", chroot=self._chroot_dir, display_on_tty8=True) 334 exitstatus = GLIUtility.spawn("emerge-webrsync", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile)
337 if exitstatus != 0: 335 if exitstatus != 0:
338 raise GLIException("EmergeWebRsyncError", 'fatal','install_portage_tre', "Failed to retrieve portage tree!") 336 raise GLIException("EmergeWebRsyncError", 'fatal','install_portage_tre', "Failed to retrieve portage tree!")
339 self._logger.log("Portage tree sync'd using webrsync") 337 self._logger.log("Portage tree sync'd using webrsync")
340 # Otherwise, just run emerge sync 338 # Otherwise, just run emerge sync
341 else: 339 else:
447 genkernel_options = genkernel_options + " --bootsplash" 445 genkernel_options = genkernel_options + " --bootsplash"
448 else: 446 else:
449 genkernel_options = genkernel_options + " --no-bootsplash" 447 genkernel_options = genkernel_options + " --no-bootsplash"
450 # Run genkernel in chroot 448 # Run genkernel in chroot
451 print "genkernel all " + genkernel_options 449 print "genkernel all " + genkernel_options
452 exitstatus = GLIUtility.spawn("genkernel all " + genkernel_options, chroot=self._chroot_dir, display_on_tty8=True) 450 exitstatus = GLIUtility.spawn("genkernel all " + genkernel_options, chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile)
453 if exitstatus != 0: 451 if exitstatus != 0:
454 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build kernel!") 452 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build kernel!")
455 self._add_to_runlevel("hotplug") 453 self._add_to_runlevel("hotplug")
456 self._add_to_runlevel("coldplug", runlevel="boot") 454 self._add_to_runlevel("coldplug", runlevel="boot")
457 self._logger.log("Genkernel complete.") 455 self._logger.log("Genkernel complete.")
473 f = open(self._chroot_dir+"/root/kernel_script", 'w') 471 f = open(self._chroot_dir+"/root/kernel_script", 'w')
474 f.writelines(kernel_compile_script) 472 f.writelines(kernel_compile_script)
475 f.close() 473 f.close()
476 #Build the kernel 474 #Build the kernel
477 exitstatus1 = GLIUtility.spawn("chmod u+x "+self._chroot_dir+"/root/kernel_script") 475 exitstatus1 = GLIUtility.spawn("chmod u+x "+self._chroot_dir+"/root/kernel_script")
478 exitstatus2 = GLIUtility.spawn("/root/kernel_script", chroot=self._chroot_dir, display_on_tty8=True) 476 exitstatus2 = GLIUtility.spawn("/root/kernel_script", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile)
479 if (exitstatus1 != 0) or (exitstatus2 != 0): 477 if (exitstatus1 != 0) or (exitstatus2 != 0):
480 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build custom kernel!") 478 raise GLIException("KernelBuildError", 'fatal', 'build_kernel', "Could not build custom kernel!")
481 479
482 #i'm sure i'm forgetting something here. 480 #i'm sure i'm forgetting something here.
483 #cleanup 481 #cleanup
800 # If a comment is specified 798 # If a comment is specified
801 if comment: 799 if comment:
802 options.append('-c "' + comment + '"') 800 options.append('-c "' + comment + '"')
803 801
804 # Add the user 802 # Add the user
805 exitstatus = GLIUtility.spawn('useradd ' + string.join(options) + ' ' + username, chroot=self._chroot_dir, quiet=True) 803 exitstatus = GLIUtility.spawn('useradd ' + string.join(options) + ' ' + username, chroot=self._chroot_dir, logfile=self._compile_logfile, display_on_tty8=True)
806 if not GLIUtility.exitsuccess(exitstatus): 804 if not GLIUtility.exitsuccess(exitstatus):
807 self._logger.log("ERROR! : Failure to add user " + username) 805 self._logger.log("ERROR! : Failure to add user " + username)
808 # raise GLIException("AddUserError", 'warning', 'set_users', "Failure to add user " + username) 806 # raise GLIException("AddUserError", 'warning', 'set_users', "Failure to add user " + username)
809 else: 807 else:
810 self._logger.log("User "+username+"was added.") 808 self._logger.log("User "+username+"was added.")

Legend:
Removed from v.390  
changed lines
  Added in v.391

  ViewVC Help
Powered by ViewVC 1.1.20