Example #1
0
    def save(self, enable=True):
        if self.theme == '':
            enable = False
        try:
            if os.path.isfile(self.modulesPath) and os.path.isfile(self.boot):

                if enable:
                    # Edit grub
                    cmd = 'sed -i -e \'/GRUB_CMDLINE_LINUX_DEFAULT=/ c GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"\' %s' % self.boot
                    os.system(cmd)

                    cmd = 'sed -i -e \'/GRUB_GFXMODE=/ c GRUB_GFXMODE=%s\' %s' % (self.resolution, self.boot)
                    os.system(cmd)

                else:
                    # Edit grub
                    cmd = 'sed -i -e \'/GRUB_CMDLINE_LINUX_DEFAULT=/ c GRUB_CMDLINE_LINUX_DEFAULT="quiet"\' %s' % self.boot
                    os.system(cmd)

                # Read grub for debugging purposes
                f = open(self.boot, 'r')
                newGrub = f.read()
                f.close()
                print '\nNew grub:\n%s\n' % newGrub

                # Set the theme
                if enable:
                    chroot_exec('%s %s' % (self.setThemePath, self.theme))
                chroot_exec('update-grub')

            else:
                print 'Plymouth unconfigured - cannot find: %s or %s' % (self.modulesPath, self.boot)

        except Exception, detail:
            print detail
Example #2
0
 def do_configure_grub(self, our_total, our_current):
     self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Configuring bootloader"))
     print " --> Running grub-mkconfig"
     chroot_exec("grub-mkconfig -o /boot/grub/grub.cfg")
     grub_output = getoutput("chroot /target/ /bin/sh -c \"grub-mkconfig -o /boot/grub/grub.cfg\"")
     grubfh = open("/var/log/live-installer-grub-output.log", "w")
     grubfh.writelines(grub_output)
     grubfh.close()
Example #3
0
 def languageSpecific(self):
     self.our_current += 1
     localizeConf = os.path.join(self.scriptDir, "localize/%s" % self.language)
     if os.path.exists(localizeConf):
         try:
             print " --> Localizing %s" % self.edition
             config = get_config_dict(localizeConf)
             packages = config.get(self.edition, "").strip()
             if packages != "":
                 self.update_progress(
                     total=self.our_total,
                     current=self.our_current,
                     message=_("Install additional localized packages"),
                 )
                 chroot_exec("apt-get --yes --force-yes install %s" % packages)
         except Exception as detail:
             msg = "ERROR: %s" % detail
             print msg
             self.update_progress(total=self.our_total, current=self.our_current, message=msg)
Example #4
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"))
        os.system("echo \"%s.UTF-8 UTF-8\" >> /target/etc/locale.gen" % setup.language)
        chroot_exec("locale-gen")
        os.system("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"
        os.system("echo \"%s\" > /target/etc/timezone" % setup.timezone)
        os.system("cp /target/usr/share/zoneinfo/%s /target/etc/localtime" % setup.timezone)

        # localizing
        print " --> Localizing packages"
        self.update_progress(total=our_total, current=our_current, message=_("Localizing packages"))
        if setup.language != "en_US":
            os.system("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"):
                os.system("cp %s /target/debs/" % l10n)
            chroot_exec("dpkg -i /debs/*")
            os.system("rm -rf /target/debs")

        # 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
        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"))
        os.system("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"
        os.system("umount --force /target/dev/shm")
        os.system("umount --force /target/dev/pts")
        if setup.gptonefi:
            os.system("umount --force /target/boot/efi")
            os.system("umount --force /target/media/cdrom")
        os.system("umount --force /target/dev/")
        os.system("umount --force /target/sys/")
        os.system("umount --force /target/proc/")
        os.system("rm -f /target/etc/resolv.conf")
        os.system("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"
Example #5
0
    def init_install(self, setup):        
        # mount the media location.
        print " --> Installation started"
        if(not os.path.exists("/target")):
            if (setup.skip_mount):
                self.error_message(message=_("ERROR: You must first manually mount your target filesystem(s) at /target to do a custom install!"))
                return
            os.mkdir("/target")
        if(not os.path.exists("/source")):
            os.mkdir("/source")
        # find the squashfs..
        if(not os.path.exists(self.media)):
            print "Base filesystem does not exist! Critical error (exiting)."
            self.error_message(message=_("ERROR: Something is wrong with the installation medium! This is usually caused by burning tools which are not compatible with LMDE (YUMI or other multiboot tools). Please burn the ISO image to DVD/USB using a different tool."))
            return

        os.system("umount --force /target/dev/shm")
        os.system("umount --force /target/dev/pts")
        os.system("umount --force /target/dev/")
        os.system("umount --force /target/sys/")
        os.system("umount --force /target/proc/")

        if (not setup.skip_mount):
            self.step_format_partitions(setup)
            self.step_mount_partitions(setup)
        else:
            self.step_mount_source(setup)

        # Transfer the files
        SOURCE = "/source/"
        DEST = "/target/"
        EXCLUDE_DIRS = "home/* dev/* proc/* sys/* tmp/* run/* mnt/* media/* lost+found source".split()
        our_current = 0
        # assume: #(files to copy) ~= #(used inodes on /)
        our_total = int(getoutput("df --inodes /{src} | awk '/^.+?\/{src}$/{{ print $3 }}'".format(src=SOURCE.strip('/'))))
        print " --> Copying {} files".format(our_total)
        rsync_filter = ' '.join('--exclude=' + SOURCE + d for d in EXCLUDE_DIRS)
        rsync = shell_exec("rsync --verbose --archive --no-D --acls "
                           "--hard-links --xattrs {rsync_filter} "
                           "{src}* {dst}".format(src=SOURCE, dst=DEST, rsync_filter=rsync_filter),
                           shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        while rsync.poll() is None:
            line = rsync.stdout.readline()
            if not line: time.sleep(0.1)
            else:
                our_current = min(our_current + 1, our_total)
                self.update_progress(total=our_total, current=our_current, message=_("Copying %s" % line))
                print "Copying " + line
        print "rsync exited with returncode: " + str(rsync.poll())

        # Steps:
        our_total = 11
        our_current = 0
        # chroot
        print " --> Chrooting"
        self.update_progress(total=our_total, current=our_current, message=_("Entering the system ..."))
        os.system("mount --bind /dev/ /target/dev/")
        os.system("mount --bind /dev/shm /target/dev/shm")
        os.system("mount --bind /dev/pts /target/dev/pts")
        os.system("mount --bind /sys/ /target/sys/")
        os.system("mount --bind /proc/ /target/proc/")
        os.system("mv /target/etc/resolv.conf /target/etc/resolv.conf.bk")
        os.system("cp -f /etc/resolv.conf /target/etc/resolv.conf")

        kernelversion = getoutput("uname -r")
        os.system("cp /lib/live/mount/medium/live/vmlinuz /target/boot/vmlinuz-%s" % kernelversion)
        os.system("cp /lib/live/mount/medium/live/initrd.img /target/boot/initrd.img-%s" % kernelversion)

        if (setup.gptonefi):
            os.system("mkdir -p /target/boot/efi/EFI/linuxmint")
            os.system("cp /lib/live/mount/medium/EFI/BOOT/grubx64.efi /target/boot/efi/EFI/linuxmint")
            os.system("mkdir -p /target/debs")
            os.system("cp /lib/live/mount/medium/pool/main/g/grub2/grub-efi* /target/debs/")
            os.system("cp /lib/live/mount/medium/pool/main/e/efibootmgr/efibootmgr* /target/debs/")
            chroot_exec("dpkg -i /debs/*")
            os.system("rm -rf /target/debs")

        # Detect cdrom device
        # TODO : properly detect cdrom device
        # Mount it
        # os.system("mkdir -p /target/media/cdrom")
        # if (int(os.system("mount /dev/sr0 /target/media/cdrom"))):
        #     print " --> Failed to mount CDROM. Install will fail"
        # chroot_exec("apt-cdrom -o Acquire::cdrom::AutoDetect=false -m add")

        # remove live-packages (or w/e)
        print " --> Removing live packages"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Removing live configuration (packages)"))
        with open("/lib/live/mount/medium/live/filesystem.packages-remove", "r") as fd:
            line = fd.read().replace('\n', ' ')
        chroot_exec("apt-get remove --purge --yes --force-yes %s" % line)

        # add new user
        print " --> Adding new user"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Adding new user to the system"))
        chroot_exec('adduser --disabled-login --gecos "{real_name}" {username}'.format(real_name=setup.real_name.replace('"', r'\"'), username=setup.username))
        for group in 'adm audio bluetooth cdrom dialout dip fax floppy fuse lpadmin netdev plugdev powerdev sambashare scanner sudo tape users vboxusers video'.split():
            chroot_exec("adduser {user} {group}".format(user=setup.username, group=group))

        fp = open("/target/tmp/.passwd", "w")
        fp.write(setup.username +  ":" + setup.password1 + "\n")
        fp.write("root:" + setup.password1 + "\n")
        fp.close()
        chroot_exec("cat /tmp/.passwd | chpasswd")
        os.system("rm -f /target/tmp/.passwd")

        # Set autologin for user if they so elected
        if setup.autologin:
            # LightDM
            chroot_exec(r"sed -i -r 's/^#?(autologin-user)\s*=.*/\1={user}/' /etc/lightdm/lightdm.conf".format(user=setup.username))
            # MDM
            chroot_exec(r"sed -i -r -e '/^AutomaticLogin(Enable)?\s*=/d' -e 's/^(\[daemon\])/\1\nAutomaticLoginEnable=true\nAutomaticLogin={user}/' /etc/mdm/mdm.conf".format(user=setup.username))
            # GDM3
            chroot_exec(r"sed -i -r -e '/^(#\s*)?AutomaticLogin(Enable)?\s*=/d' -e 's/^(\[daemon\])/\1\nAutomaticLoginEnable=true\nAutomaticLogin={user}/' /etc/gdm3/daemon.conf".format(user=setup.username))
            # KDE4
            chroot_exec(r"sed -i -r -e 's/^#?(AutomaticLoginEnable)\s*=.*/\1=true/' -e 's/^#?(AutomaticLoginUser)\s*.*/\1={user}/' /etc/kde4/kdm/kdmrc".format(user=setup.username))
            # LXDM
            chroot_exec(r"sed -i -r -e 's/^#?(autologin)\s*=.*/\1={user}/' /etc/lxdm/lxdm.conf".format(user=setup.username))
            # SLiM
            chroot_exec(r"sed -i -r -e 's/^#?(default_user)\s.*/\1  {user}/' -e 's/^#?(auto_login)\s.*/\1  yes/' /etc/slim.conf".format(user=setup.username))

        # Add user's face
        os.system("cp /tmp/live-installer-face.png /target/home/%s/.face" % setup.username)
        chroot_exec("chown %s:%s /home/%s/.face" % (setup.username, setup.username, setup.username))

        # Make the new user the default user in KDM
        if os.path.exists('/target/etc/kde4/kdm/kdmrc'):
            defUsrCmd = "sed -i 's/^#DefaultUser=.*/DefaultUser="******"/g' " + kdmrcPath
            print defUsrCmd
            os.system(defUsrCmd)

        # write the /etc/fstab
        print " --> Writing fstab"
        our_current += 1
        self.update_progress(total=our_total, current=our_current, message=_("Writing filesystem mount information to /etc/fstab"))
        if not os.path.exists("/target/etc/fstab"):
            os.system("echo '#### Static Filesystem Table File' > /target/etc/fstab")
        if not setup.skip_mount:
            with open("/target/etc/fstab", "a") as fstab:
                for part in setup.partitions:
                    if not part.mount_as: continue
                    uuid = getoutput('blkid -s UUID -o value ' + part.partition.path) or part.partition.path
                    fsck = 0 if part.type in ('ntfs', 'swap') else 1 if part.mount_as == '/' else 2
                    opts = 'rw,errors=remount-ro' if 'ext' in part.type else 'defaults'
                    fs = 'vfat' if part.type.startswith('fat') else part.type
                    fstab.write('{uuid}\t{part.mount_as}\t{fs}\t{opts}\t0\t{fsck}\n'.format(**locals()))
Example #6
0
 def exec_cmd(self, command):
     if self.setup.oem_setup:
         shell_exec(command)
     else:
         chroot_exec(command, self.setup.target_dir)
Example #7
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"
Example #8
0
    def applications(self):
        if self.language != "en_US":
            # Localize KDE
            self.our_current += 1
            if self.isPackageInstalled("kde-runtime"):
                print " --> Localizing KDE"
                self.update_progress(total=self.our_total, current=self.our_current, message=_("Localizing KDE"))
                lan = "".join(self.locale)
                package = "kde-l10n-%s" % lan
                print "    > package = %s" % package
                if not self.doesPackageExist(package):
                    lan = self.locale[0]
                    package = "kde-l10n-%s" % lan
                    print "    > package = %s" % package
                    if not self.doesPackageExist(package):
                        package = ""
                if package != "":
                    chroot_exec("apt-get install --yes --force-yes %s" % package)

            # Localize LibreOffice
            self.our_current += 1
            if self.isPackageInstalled("libreoffice"):
                print " --> Localizing LibreOffice"
                self.update_progress(
                    total=self.our_total, current=self.our_current, message=_("Localizing LibreOffice")
                )
                lan = "-".join(self.locale)
                package = "libreoffice-l10n-%s" % lan
                print "    > package = %s" % package
                if not self.doesPackageExist(package):
                    lan = self.locale[0]
                    package = "libreoffice-l10n-%s" % lan
                    print "    > package = %s" % package
                    if not self.doesPackageExist(package):
                        package = ""
                if package != "":
                    chroot_exec("apt-get install --yes --force-yes %s" % package)
                    chroot_exec("apt-get install --yes --force-yes libreoffice-help-%s" % lan)
                    chroot_exec("apt-get install --yes --force-yes myspell-%s" % lan)

            # Localize AbiWord
            self.our_current += 1
            if self.isPackageInstalled("abiword"):
                print " --> Localizing AbiWord"
                self.update_progress(total=self.our_total, current=self.our_current, message=_("Localizing AbiWord"))
                chroot_exec("apt-get install --yes --force-yes aspell-%s" % self.locale[0])

            # Localize Firefox
            self.our_current += 1
            isESR = self.isPackageInstalled("firefox-esr")
            if isESR or self.isPackageInstalled("firefox"):
                esr = ""
                if isESR:
                    esr = "esr-"
                print " --> Localizing Firefox"
                self.update_progress(total=self.our_total, current=self.our_current, message=_("Localizing Firefox"))
                lan = "-".join(self.locale)
                package = "firefox-%sl10n-%s" % (esr, lan)
                print "    > package = %s" % package
                if not self.doesPackageExist(package):
                    lan = self.locale[0]
                    package = "firefox-%sl10n-%s" % (esr, lan)
                    print "    > package = %s" % package
                    if not self.doesPackageExist(package):
                        package = ""
                if package != "":
                    chroot_exec("apt-get install --yes --force-yes %s" % package)
                    self.localizePref("/etc/skel/.mozilla/firefox/mwad0hks.default/prefs.js")

            # Localize Thunderbird
            self.our_current += 1
            if self.isPackageInstalled("thunderbird"):
                print " --> Localizing Thunderbird"
                self.update_progress(
                    total=self.our_total, current=self.our_current, message=_("Localizing Thunderbird")
                )
                lan = "-".join(self.locale)
                package = "thunderbird-l10n-%s" % lan
                print "    > package = %s" % package
                if not self.doesPackageExist(package):
                    lan = self.locale[0]
                    package = "thunderbird-l10n-%s" % lan
                    print "    > package = %s" % package
                    if not self.doesPackageExist(package):
                        package = ""
                if package != "":
                    chroot_exec("apt-get install --yes --force-yes %s" % package)
                    self.localizePref("/etc/skel/.thunderbird/pjzwmea6.default/prefs.js")
Example #9
0
 def start(self):
     self.our_current += 1
     self.update_progress(total=self.our_total, current=self.our_current, message=_("Update apt cache"))
     chroot_exec("apt-get update")
     self.applications()
     self.languageSpecific()
Example #10
0
 def exec_cmd(self, command):
     if self.setup.oem_setup:
         shell_exec(command)
     else:
         chroot_exec(command, self.setup.target_dir)