Beispiel #1
0
 def install(self):
   """
   Assuming that last configuration editing didn't modified mount point.
   """
   if self._mbrDevice:
     self._bootsMounted = []
     mp = None
     mpList = None
     try:
       mp = self._mountBootPartition()
       if not mp:
         raise Exception("Cannot mount the main boot partition.")
       self.__debug("mp = " + unicode(mp))
       mpList = {}
       self._mountPartitions(mpList)
       self.__debug("mount point lists: " + unicode(mpList))
       # copy the configuration to the boot_partition
       try:
         self.__debug("create etc/bootsetup directory in " + mp)
         os.makedirs(os.path.join(mp, 'etc/bootsetup'))
       except os.error:
         pass
       self.__debug("copy lilo.conf to etc/bootsetup")
       shutil.copyfile(self.getConfigurationPath(), os.path.join(mp, '/etc/bootsetup/lilo.conf'))
       # run lilo
       if self.isTest:
         self.__debug('/sbin/lilo -t -v -C {mp}/etc/bootsetup/lilo.conf'.format(mp = mp))
         sltl.execCall('/sbin/lilo -t -v -C {mp}/etc/bootsetup/lilo.conf'.format(mp = mp))
       else:
         sltl.execCall('/sbin/lilo -C {mp}/etc/bootsetup/lilo.conf'.format(mp = mp))
     finally:
       self._umountAll(mp, mpList)
 def _install_services(self):
   if self._cfg.is_test:
     sleep(1)
   else:
     rootmp = sltl.getMountPoint("/dev/{0}".format(self._cfg.main_partition))
     f = 'var/log/setup/setup.services'
     p = "{0}/{1}".format(rootmp, f)
     if os.path.exists(p):
       os.chmod(p, 0755)
       sltl.execCall("{0}/{1} {0}".format(rootmp, f))
Beispiel #3
0
 def _umountAll(self, mountPoint):
   self.__debug("umountAll")
   if mountPoint:
     self.__debug("umounting main mount point " + mountPoint)
     self._unbindProcSysDev(mountPoint)
     if self._bootInBootMounted:
       self.__debut("/boot mounted in " + mountPoint + ", so umount it")
       sltl.execCall("chroot {mp} /sbin/umount /boot".format(mp = mountPoint))
     if mountPoint != '/':
       self.__debug("umain mount point ≠ '/' → umount " + mountPoint)
       sltl.umountDevice(mountPoint)
   self._bootInBootMounted = False
   self._procInBootMounted = False
Beispiel #4
0
 def _installGrub2Config(self, mountPoint):
   if os.path.exists(os.path.join(mountPoint, 'etc/default/grub')) and os.path.exists(os.path.join(mountPoint, 'usr/sbin/update-grub')):
     self.__debug("grub2 package is installed on the target partition, so it will be used to generate the grub.cfg file")
     # assume everything is installed on the target partition, grub2 package included.
     if self.isTest:
       self.__debug("chroot {mp} /usr/sbin/update-grub".format(mp = mountPoint))
     else:
       sltl.execCall("chroot {mp} /usr/sbin/update-grub".format(mp = mountPoint))
   else:
     self.__debug("grub2 not installed on the target partition, so grub_mkconfig will directly be used to generate the grub.cfg file")
     # tiny OS installed on that mount point, so we cannot chroot on it to install grub2 config.
     if self.isTest:
       self.__debug("/usr/sbin/grub-mkconfig -o {cfg}".format(cfg = os.path.join(mountPoint, "boot/grub/grub.cfg")))
     else:
       sltl.execCall("/usr/sbin/grub-mkconfig -o {cfg}".format(cfg = os.path.join(mountpoint, "boot/grub/grub.cfg")))
Beispiel #5
0
 def _mountBootInBootPartition(self, mountPoint):
   # assume that if the mount_point is /, any /boot directory is already accessible/mounted
   if mountPoint != '/' and os.path.exists(os.path.join(mountPoint, 'etc/fstab')):
     self.__debug("mp != / and etc/fstab exists, will try to mount /boot by chrooting")
     try:
       self.__debug("grep -q /boot {mp}/etc/fstab && chroot {mp} /sbin/mount /boot".format(mp = mountPoint))
       if sltl.execCall("grep -q /boot {mp}/etc/fstab && chroot {mp} /sbin/mount /boot".format(mp = mount_point)):
         self.__debug("/boot mounted in " + mp)
         self._bootInBootMounted = True
     except:
       pass
Beispiel #6
0
 def _unbindProcSysDev(self, mountPoint):
   """
   unbind /proc /sys and /dev into the boot partition
   """
   if self._procInBootMounted:
     self.__debug("mount point ≠ / so umount /dev, /proc and /sys in " + mountPoint)
     sltl.execCall('umount {mp}/dev'.format(mp = mountPoint))
     sltl.execCall('umount {mp}/proc'.format(mp = mountPoint))
     sltl.execCall('umount {mp}/sys'.format(mp = mountPoint))
Beispiel #7
0
 def _bindProcSysDev(self, mountPoint):
   """
   bind /proc /sys and /dev into the boot partition
   """
   if mountPoint != "/":
     self.__debug("mount point ≠ / so mount /dev, /proc and /sys in " + mountPoint)
     self._procInBootMounted = True
     sltl.execCall('mount -o bind /dev {mp}/dev'.format(mp = mountPoint))
     sltl.execCall('mount -o bind /proc {mp}/proc'.format(mp = mountPoint))
     sltl.execCall('mount -o bind /sys {mp}/sys'.format(mp = mountPoint))
 def _thread_install_salix(self):
   """
   Thread to install Salix.
   This works like a generator.
   It should yield fraction of the completion
   """
   print "Installing…"
   # format main partition (and mount it)
   # format linux partitions (and mount them)
   # copying modules (one step per module, so we need to count them before starting the installation)
   # create fstab
   # set date and time
   # set keyboard
   # set locale
   # set users
   # set services
   # update system things:
   # - pango, gtk, fonts, …
   # - adjusting configuration for liveclone
   if self._cfg.is_test:
     if self._cfg.is_test_clone:
       modules = ('01-clone',)
     else:
       modules = ('01-core', '02-basic', '03-full', '04-common', '05-kernel', '06-live')
   else:
     modules = sltl.listSaLTModules()
   if self._cfg.is_liveclone:
     install_modules = modules
   else:
     install_modules = []
     for m in modules:
       if 'core' in m:
         install_modules.append(m)
       elif 'basic' in m:
         if self._cfg.install_mode in ('Basic', 'Full'):
           install_modules.append(m)
       elif 'full' in m:
         if self._cfg.install_mode == 'Full':
           install_modules.append(m)
       elif not 'live' in m:
         install_modules.append(m)
   if self._cfg.linux_partitions == None:
     self._cfg.linux_partitions = []
   if self._cfg.win_partitions == None:
     self._cfg.win_partitions = []
   weight_partition = 3
   if self._cfg.is_liveclone:
     weight_module = 15
   else:
     weight_module = 5
   weights = {
       'checks': 1,
       'main_partition': weight_partition,
       'linux_partitions': dict([(p[0], weight_partition) for p in self._cfg.linux_partitions]),
       'modules': dict([(m, weight_module) for m in install_modules]),
       'fstab': 1,
       'datetime': 1,
       'keyboard': 1,
       'locale': 1,
       'users': 1,
       'services': 1,
       'system_config': 1
       }
   steps = 0
   for w in weights.values():
     if isinstance(w, dict):
       for w2 in w.values():
         steps += w2
     else:
       steps += w
   step = 0
   self._installation = 'installing'
   def installion_cancelled():
     return self._installation == 'cancelled'
   # sanity checks
   modules_size = {}
   if self._cfg.is_test:
     for m in install_modules:
       modules_size[m] = 1
   else:
     main_sizes = sltl.getSizes("/dev/{0}".format(self._cfg.main_partition))
     main_size = main_sizes['size']
     main_block_size = sltl.getBlockSize("/dev/{0}".format(self._cfg.main_partition))
     module_total_size = 0
     for m in install_modules:
       size = sltl.getUsedSize("/mnt/salt/mnt/modules/{0}".format(m), main_block_size, False)['size']
       modules_size[m] = size
       module_total_size += size
     minimum_free_size = 50 * 1024 * 1024 # 50 M
     if module_total_size + minimum_free_size > main_size:
       self._gui.install_set_progress_window_above(False)
       error_dialog(_("Cannot install!\nNot enougth space on main partition ({size} needed)").format(size = sltl.getHumanSize(module_total_size + minimum_free_size)))
       self._installation = 'error'
       return
     sltl.execCall(['rm', '-rf', sltl.getTempMountDir()])
   if installion_cancelled(): return
   step += weights['checks']
   msg = _("Formatting and mounting the main partition...")
   self._update_progressbar(msg, step, steps)
   self._install_main_partition()
   if installion_cancelled(): return
   step += weights['main_partition']
   msg = _("Formatting and mounting the Linux partitions...")
   self._update_progressbar(msg, step, steps)
   step = self._install_linux_partitions(msg, step, steps, weights['linux_partitions'])
   if installion_cancelled(): return
   msg = _("Installing the {mode} mode packages...").format(mode = _(self._cfg.install_mode))
   self._update_progressbar(msg, step, steps)
   step = self._install_modules(install_modules, modules_size, msg, step, steps, weights['modules'])
   if installion_cancelled(): return
   msg = _("Creating /etc/fstab...")
   self._update_progressbar(msg, step, steps)
   self._install_fstab()
   if installion_cancelled(): return
   step += weights['fstab']
   msg = _("Date and time configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_datetime()
   if installion_cancelled(): return
   step += weights['datetime']
   msg = _("Keyboard configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_keyboard()
   if installion_cancelled(): return
   step += weights['keyboard']
   msg = _("Locale configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_locale()
   if installion_cancelled(): return
   step += weights['locale']
   msg = _("Users configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_users()
   if installion_cancelled(): return
   step += weights['users']
   msg = _("Services configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_services()
   if installion_cancelled(): return
   step += weights['services']
   msg = _("System configuration...")
   self._update_progressbar(msg, step, steps)
   self._install_config()
   if installion_cancelled(): return
   step += weights['system_config']
   self._update_progressbar(None, step, steps)
  def _install_config(self):
    if self._cfg.is_test:
      sleep(1)
    else:
      rootmp = sltl.getMountPoint("/dev/{0}".format(self._cfg.main_partition))
      rcfont_file = open('{0}/etc/rc.d/rc.font'.format(rootmp), 'w')
      rcfont_file.write("""
#!/bin/sh
#
#This selects your default screen font from among the ones in
# /usr/share/kbd/consolefonts.
#
#setfont -v ter-v16n
unicode_start ter-v16n""")
      rcfont_file.close()
      os.chmod('{0}/etc/rc.d/rc.font'.format(rootmp), 0755)
      for f in ('var/log/setup/setup.04.mkfontdir', 'var/log/setup/setup.07.update-desktop-database', 'var/log/setup/setup.07.update-mime-database', 'var/log/setup/setup.08.gtk-update-icon-cache', 'var/log/setup/setup.htmlview'):
        p = "{0}/{1}".format(rootmp, f)
        if os.path.exists(p):
          os.chmod(p, 0755)
          sltl.execCall("cd {0}; ./{1}".format(rootmp, f))
      for f in ('/usr/bin/update-gtk-immodules', '/usr/bin/update-gdk-pixbuf-loaders', '/usr/bin/update-pango-querymodules'):
        p = "{0}/{1}".format(rootmp, f)
        if os.path.exists(p):
          sltl.execChroot(rootmp, f)
      if self._cfg.is_liveclone:
        # Remove some specific live stuff
        sltl.execCall("spkg -d liveclone --root={0}".format(rootmp))
        sltl.execCall("spkg -d salix-live-installer --root={0}".format(rootmp))
        sltl.execCall("spkg -d salix-persistence-wizard --root={0}".format(rootmp))
        sltl.execCall("rm -f {0}/etc/ssh/ssh_host_*".format(rootmp))
        sltl.execCall("rm -f {0}/home/*/Desktop/*startup-guide*desktop".format(rootmp))
        sltl.execCall("rm -f {0}/user/share/applications/*startup-guide*desktop".format(rootmp))
        os.remove("{0}/hooks.salt".format(rootmp))
Beispiel #10
0
 def _copyAndInstallGrub2(self, mountPoint, device):
   if self.isTest:
     self.__debug("/usr/sbin/grub-install --boot-directory {bootdir} --no-floppy {dev}".format(bootdir = os.path.join(mountPoint, "boot"), dev = device))
     return True
   else:
     return sltl.execCall("/usr/sbin/grub-install --boot-directory {bootdir} --no-floppy {dev}".format(bootdir = os.path.join(mountPoint, "boot"), dev = device))