def setTheme(self):
     self.toggleGuiElements(True)
     if self.selectedTheme != self.noPlymouth:
         if self.selectedResolution is None:
             self.selectedResolution = self.tv2Handler.getValue(self.tv2Handler.getRowCount() - 1)
     else:
         self.selectedTheme = None
         self.selectedResolution = None
     self.log.write(_("Save setting: %(theme)s (%(res)s)") % { "theme": self.selectedTheme, "res": self.selectedResolution }, 'dpm.setTheme', 'info')
     # Start saving in a separate thread
     t = PlymouthSave(self.log, self.selectedTheme, self.selectedResolution)
     t.start()
     GObject.timeout_add(250, self.checkSaveThread)
Exemple #2
0
 def setTheme(self):
     self.toggleGuiElements(True)
     if self.selectedTheme != self.noPlymouth:
         if self.selectedResolution is None:
             self.selectedResolution = self.tv2Handler.getValue(
                 self.tv2Handler.getRowCount() - 1)
     else:
         self.selectedTheme = None
         self.selectedResolution = None
     self.log.write(
         _("Save setting: %(theme)s (%(res)s)") % {
             "theme": self.selectedTheme,
             "res": self.selectedResolution
         }, 'dpm.setTheme', 'info')
     # Start saving in a separate thread
     t = PlymouthSave(self.log, self.selectedTheme, self.selectedResolution)
     t.start()
     GObject.timeout_add(250, self.checkSaveThread)
Exemple #3
0
    def finish_install(self, setup):
        # Steps:
        our_total = 11
        our_current = 4

        # write host+hostname infos
        print " --> Writing hostname"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Setting hostname"))
        hostnamefh = open("/target/etc/hostname", "w")
        hostnamefh.write("%s\n" % setup.hostname)
        hostnamefh.close()
        hostsfh = open("/target/etc/hosts", "w")
        hostsfh.write("127.0.0.1\tlocalhost\n")
        hostsfh.write("127.0.1.1\t%s\n" % setup.hostname)
        hostsfh.write("# The following lines are desirable for IPv6 capable hosts\n")
        hostsfh.write("::1     localhost ip6-localhost ip6-loopback\n")
        hostsfh.write("fe00::0 ip6-localnet\n")
        hostsfh.write("ff00::0 ip6-mcastprefix\n")
        hostsfh.write("ff02::1 ip6-allnodes\n")
        hostsfh.write("ff02::2 ip6-allrouters\n")
        hostsfh.write("ff02::3 ip6-allhosts\n")
        hostsfh.close()

        # set the locale
        print " --> Setting the locale"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Setting locale"))
        shell_exec("echo \"%s.UTF-8 UTF-8\" >> /target/etc/locale.gen" % setup.language)
        chroot_exec("locale-gen")
        shell_exec("echo \"\" > /target/etc/default/locale")
        chroot_exec("update-locale LANG=\"%s.UTF-8\"" % setup.language)
        chroot_exec("update-locale LANG=%s.UTF-8" % setup.language)

        # set the timezone
        print " --> Setting the timezone"
        shell_exec("echo \"%s\" > /target/etc/timezone" % setup.timezone)
        shell_exec("cp /target/usr/share/zoneinfo/%s /target/etc/localtime" % setup.timezone)

        # localizing
        if setup.language != "en_US":
            if os.path.exists("/lib/live/mount/medium/pool"):
                print " --> Localizing packages"
                our_current += 1
                self.update_progress(total=our_total, current=our_current, message=_("Localizing packages"))
                shell_exec("mkdir -p /target/debs")
                language_code = setup.language
                if "_" in setup.language:
                    language_code = setup.language.split("_")[0]
                l10ns = getoutput("find /lib/live/mount/medium/pool | grep 'l10n-%s\\|hunspell-%s'" % (language_code, language_code))
                for l10n in l10ns.split("\n"):
                    shell_exec("cp %s /target/debs/" % l10n)
                chroot_exec("dpkg -i /debs/*")
                shell_exec("rm -rf /target/debs")
            if hasInternetConnection:
                # [XK] Localize when not LMDE
                loc = Localize(setup.language, our_total, our_current)
                loc.set_progress_hook(self.update_progress)
                loc.start()
                our_current = loc.our_current

        # [XK] Configure Plymouth
        our_current += 1
        if os.path.exists('/target/bin/plymouth'):
            print " --> Configuring Plymouth"
            self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Configuring Plymouth"))
            plymouth = PlymouthSave()
            plymouth.save(setup.plymouth_enable)

        # [XK] Install multimedia
        our_current += 1
        if setup.multimedia_enable:
            if hasInternetConnection:
                print " --> Install multimedia"
                self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Install multimedia"))
                packages = "libdvdcss2"
                if isAmd64:
                    packages += " w64codecs"
                else:
                    packages += " w32codecs"
                chroot_exec("apt-get install --assume-yes -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold --force-yes %s" % packages)

        # [XK] Configure sensors
        our_current += 1
        if os.path.exists('/target/usr/sbin/sensors-detect'):
            print " --> Configuring sensors"
            self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Configuring sensors"))
            chroot_exec('/usr/bin/yes YES | /usr/sbin/sensors-detect')

        # [XK] Remove VirtualBox when not installing to VirtualBox
        if not runningInVirtualBox():
            print " --> Remove VirtualBox"
            self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Removing VirtualBox"))
            chroot_exec("apt-get purge --assume-yes -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold --force-yes virtualbox*")

        # set the keyboard options..
        print " --> Setting the keyboard"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Setting keyboard options"))
        consolefh = open("/target/etc/default/console-setup", "r")
        newconsolefh = open("/target/etc/default/console-setup.new", "w")
        for line in consolefh:
            line = line.rstrip("\r\n")
            if(line.startswith("XKBMODEL=")):
                newconsolefh.write("XKBMODEL=\"%s\"\n" % setup.keyboard_model)
            elif(line.startswith("XKBLAYOUT=")):
                newconsolefh.write("XKBLAYOUT=\"%s\"\n" % setup.keyboard_layout)
            elif(line.startswith("XKBVARIANT=") and setup.keyboard_variant is not None):
                newconsolefh.write("XKBVARIANT=\"%s\"\n" % setup.keyboard_variant)
            else:
                newconsolefh.write("%s\n" % line)
        consolefh.close()
        newconsolefh.close()
        chroot_exec("rm /etc/default/console-setup")
        chroot_exec("mv /etc/default/console-setup.new /etc/default/console-setup")

        consolefh = open("/target/etc/default/keyboard", "r")
        newconsolefh = open("/target/etc/default/keyboard.new", "w")
        for line in consolefh:
            line = line.rstrip("\r\n")
            if(line.startswith("XKBMODEL=")):
                newconsolefh.write("XKBMODEL=\"%s\"\n" % setup.keyboard_model)
            elif(line.startswith("XKBLAYOUT=")):
                newconsolefh.write("XKBLAYOUT=\"%s\"\n" % setup.keyboard_layout)
            elif(line.startswith("XKBVARIANT=") and setup.keyboard_variant is not None):
                newconsolefh.write("XKBVARIANT=\"%s\"\n" % setup.keyboard_variant)
            else:
                newconsolefh.write("%s\n" % line)
        consolefh.close()
        newconsolefh.close()
        chroot_exec("rm /etc/default/keyboard")
        chroot_exec("mv /etc/default/keyboard.new /etc/default/keyboard")

        # write MBR (grub)
        print " --> Configuring Grub"
        our_current += 1
        if(setup.grub_device is not None):
            self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Installing bootloader"))
            print " --> Running grub-install"
            chroot_exec("grub-install --force %s" % setup.grub_device)
            self.do_configure_grub(our_total, our_current)
            grub_retries = 0
            while (not self.do_check_grub(our_total, our_current)):
                self.do_configure_grub(our_total, our_current)
                grub_retries = grub_retries + 1
                if grub_retries >= 5:
                    self.error_message(message=_("WARNING: The grub bootloader was not configured properly! You need to configure it manually."))
                    break

        # recreate initramfs (needed in case of skip_mount also, to include things like mdadm/dm-crypt/etc in case its needed to boot a custom install)
        print " --> Configuring Initramfs"
        our_current += 1
        # [XK] Running update-initramfs takes a long time: check if it is necessary
        initrd = "/boot/initrd.img-".format(getoutput("uname -r"))
        update = os.path.getmtime(initrd) < time.time() - 86400 if os.path.isfile(initrd) else True
        if update:
            self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Configuring initramfs"))
            chroot_exec("/usr/sbin/update-initramfs -t -u -k all")
            kernelversion = getoutput("uname -r")
            chroot_exec("/usr/bin/sha1sum /boot/initrd.img-%s > /var/lib/initramfs-tools/%s" % (kernelversion,kernelversion))

        # Clean APT
        print " --> Cleaning APT"
        our_current += 1
        self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Cleaning APT"))
        shell_exec("chroot /target/ /bin/sh -c \"dpkg --configure -a\"")
        chroot_exec("sed -i 's/^deb cdrom/#deb cdrom/' /etc/apt/sources.list")
        chroot_exec("apt-get -y --force-yes autoremove")

        # now unmount it
        print " --> Unmounting partitions"
        shell_exec("umount --force /target/dev/shm")
        shell_exec("umount --force /target/dev/pts")
        if setup.gptonefi:
            shell_exec("umount --force /target/boot/efi")
            shell_exec("umount --force /target/media/cdrom")
        shell_exec("umount --force /target/dev/")
        shell_exec("umount --force /target/sys/")
        shell_exec("umount --force /target/proc/")
        shell_exec("rm -f /target/etc/resolv.conf")
        shell_exec("mv /target/etc/resolv.conf.bk /target/etc/resolv.conf")
        if(not setup.skip_mount):
            for partition in setup.partitions:
                if(partition.mount_as is not None and partition.mount_as != "" and partition.mount_as != "/" and partition.mount_as != "swap"):
                    self.do_unmount("/target" + partition.mount_as)
            self.do_unmount("/target")
        self.do_unmount("/source")

        self.update_progress(done=True, message=_("Installation finished"))
        print " --> All done"