Code improvements to live-installer and mintConstructor

Contribute code & patches
Forum rules
No support questions here please

Code improvements to live-installer and mintConstructor

Postby Schoelje on Thu Jun 28, 2012 8:26 am

1. Make live-installer more flexible

At the moment live-installer won't work in a KDE environment.
The code hangs when trying to edit the MDM or GDM config file which doesn't exist in KDE.

Check if the file exists so that live-installer works when no MDM is present:

file: installer.py

Code: Select all
            if os.path.exists("/target/etc/gdm3/daemon.conf"):
                # gdm overwrite (specific to Debian/live-initramfs)
                print " --> Configuring GDM"
                gdmconffh = open("/target/etc/gdm3/daemon.conf", "w")
                gdmconffh.write("# GDM configuration storage\n")
                gdmconffh.write("\n[daemon]\n")
                gdmconffh.write("\n[security]\n")
                gdmconffh.write("\n[xdmcp]\n")
                gdmconffh.write("\n[greeter]\n")
                gdmconffh.write("\n[chooser]\n")
                gdmconffh.write("\n[debug]\n")
                gdmconffh.close()
            elif os.path.exists("/target/etc/mdm/mdm.conf"):
                # MDM overwrite (specific to Debian/live-initramfs)
                print " --> Configuring MDM"
                mdmconffh = open("/target/etc/mdm/mdm.conf", "w")
                mdmconffh.write("# MDM configuration\n")
                mdmconffh.write("\n[daemon]\n")
                mdmconffh.write("\n[security]\n")
                mdmconffh.write("\n[xdmcp]\n")
                mdmconffh.write("\n[greeter]\n")
                mdmconffh.write("\n[chooser]\n")
                mdmconffh.write("\n[debug]\n")
                mdmconffh.close()


Live installer localizes Firefox and Thunderbird but not LibreOffice and KDE:
Code: Select all
            # localize KDE, LibreOffice, Firefox and Thunderbird
            if setup.language != "en_US":
                print " --> Localizing KDE, LibreOffice, Firefox and Thunderbird"
                os.system("apt-get update")
                self.do_run_in_chroot("apt-get update")
                locale = setup.language.replace("_", "-").lower()               

                # KDE
                self.update_progress(total=our_total, current=our_current, message=_("Localizing KDE"))
                num_res = commands.getoutput("aptitude search kde-l10n-%s | grep kde-l10n-%s | wc -l" % (locale, locale))
                if num_res != "0":                   
                    self.do_run_in_chroot("apt-get install --yes --force-yes kde-l10n-" + locale)
                else:
                    if "_" in setup.language:
                        language_code = setup.language.split("_")[0]
                        num_res = commands.getoutput("aptitude search kde-l10n-%s | grep kde-l10n-%s | wc -l" % (language_code, language_code))
                        if num_res != "0":                           
                            self.do_run_in_chroot("apt-get install --yes --force-yes kde-l10n-" + language_code)
               
                # LibreOffice
                self.update_progress(total=our_total, current=our_current, message=_("Localizing LibreOffice"))
                num_res = commands.getoutput("aptitude search libreoffice-l10n-%s | grep libreoffice-l10n-%s | wc -l" % (locale, locale))
                if num_res != "0":                   
                    self.do_run_in_chroot("apt-get install --yes --force-yes libreoffice-l10n-" + locale)
                else:
                    if "_" in setup.language:
                        language_code = setup.language.split("_")[0]
                        num_res = commands.getoutput("aptitude search libreoffice-l10n-%s | grep libreoffice-l10n-%s | wc -l" % (language_code, language_code))
                        if num_res != "0":                           
                            self.do_run_in_chroot("apt-get install --yes --force-yes libreoffice-l10n-" + language_code)
                            self.do_run_in_chroot("apt-get install --yes --force-yes aspell-" + language_code)
               
                # Firefox
                self.update_progress(total=our_total, current=our_current, message=_("Localizing Firefox"))
                num_res = commands.getoutput("aptitude search firefox-l10n-%s | grep firefox-l10n-%s | wc -l" % (locale, locale))
                if num_res != "0":                   
                    self.do_run_in_chroot("apt-get install --yes --force-yes firefox-l10n-" + locale)
                else:
                    if "_" in setup.language:
                        language_code = setup.language.split("_")[0]
                        num_res = commands.getoutput("aptitude search firefox-l10n-%s | grep firefox-l10n-%s | wc -l" % (language_code, language_code))
                        if num_res != "0":                           
                            self.do_run_in_chroot("apt-get install --yes --force-yes firefox-l10n-" + language_code)
               
                # Thunderbird
                self.update_progress(total=our_total, current=our_current, message=_("Localizing Thunderbird"))
                num_res = commands.getoutput("aptitude search thunderbird-l10n-%s | grep thunderbird-l10n-%s | wc -l" % (locale, locale))
                if num_res != "0":
                    self.do_run_in_chroot("apt-get install --yes --force-yes thunderbird-l10n-" + locale)
                else:
                    if "_" in setup.language:
                        language_code = setup.language.split("_")[0]
                        num_res = commands.getoutput("aptitude search thunderbird-l10n-%s | grep thunderbird-l10n-%s | wc -l" % (language_code, language_code))
                        if num_res != "0":
                            self.do_run_in_chroot("apt-get install --yes --force-yes thunderbird-l10n-" + language_code)


Unfortunately, after install the system is left with a startpar error on logout (wich prevents sgxi to successfully install the Nvidia drivers):

startpar: services(s) returned failure: live-installer failed

This was caused by residual symbolic links in the rc*.d directories wich you can remove by the following code:
Code: Select all
update-rc.d -f live-installer remove

Add this line in the remove live-initramfs part of installer.py:
Code: Select all
            # remove live-initramfs (or w/e)
            print " --> Removing live-initramfs"
            our_current += 1
            self.update_progress(total=our_total, current=our_current, message=_("Removing live configuration (packages)"))
            self.do_run_in_chroot("apt-get remove --purge --yes --force-yes live-boot live-boot-initramfs-tools live-initramfs live-installer live-config live-config-sysvinit")
            # Original leaves symbolic links pointing to the live-installer script in /etc/init.d resulting in a startpar error
            self.do_run_in_chroot("update-rc.d -f live-installer remove")


2. Minor mintconstructor improvent

When launching the chroot terminal, I encountered several mount related issues.
Only /proc is mounted but not /dev and /dev/pts.

file: mintConstructor.py

Mounting
Code: Select all
    # launch chroot terminal
    def launchTerminal(self):
        try:
            # setup environment
            # copy dns info
            print _("Copying DNS info...")
            os.popen('cp -f /etc/resolv.conf ' + os.path.join(self.customDir, "root/etc/resolv.conf"))
            # mount /proc /dev /dev/pts
            print _("Mounting /proc /dev /dev/pts filesystems...")
            os.popen('mount --bind /proc \"' + os.path.join(self.customDir, "root/proc") + '\"')
            os.popen('mount --bind /dev \"' + os.path.join(self.customDir, "root/dev") + '\"')
            os.popen('mount --bind /dev/pts \"' + os.path.join(self.customDir, "root/dev/pts") + '\"')


Unmounting
Code: Select all
            # umount /proc /dev /dev/pts
            print _("Umounting /proc  /dev /dev/pts ...")
            os.popen('umount \"' + os.path.join(self.customDir, "root/proc/") + '\"')
            os.popen('umount \"' + os.path.join(self.customDir, "root/dev/") + '\"')
            os.popen('umount \"' + os.path.join(self.customDir, "root/dev/pts/") + '\"')
Last edited by Schoelje on Fri Jul 27, 2012 10:19 am, edited 10 times in total.
User avatar
Schoelje
Level 5
Level 5
 
Posts: 791
Joined: Wed Jan 18, 2012 6:25 am
Location: Netherlands

Linux Mint is funded by ads and donations.
 

Re: Code improvements to live-installer and mintConstructor

Postby Schoelje on Sat Jul 21, 2012 6:04 pm

Added localization and group permissions for initial user for live-installer (see above).
User avatar
Schoelje
Level 5
Level 5
 
Posts: 791
Joined: Wed Jan 18, 2012 6:25 am
Location: Netherlands

Re: Code improvements to live-installer and mintConstructor

Postby clem on Thu Jul 26, 2012 4:31 pm

Hi there,

Thanks for bringing this up. We don't use live-installer with KDE ourselves but we'd be happy to add that in for other projects if you could send your changes via a github pull request. Our code is hosted at https://github.com/linuxmint/live-installer

We're also at #linuxmint-dev on the IRC (irc.spotchat.org) if you're interested in chatting with the devs.

Many thanks,
Clem.
Image
User avatar
clem
Level 15
Level 15
 
Posts: 5548
Joined: Wed Nov 15, 2006 8:34 am

Re: Code improvements to live-installer and mintConstructor

Postby Schoelje on Thu Jul 26, 2012 5:50 pm

I wish I could...
I don't know anything about GitHub or how to submit my changes there: I just changed the installer.py script in kate to get it working for the "unofficial LMDE KDE" (viewtopic.php?f=61&t=106426). I'm afraid I'm just good at creatively copying and pasting in kate but I hope you can use what I've learned from creating the unofficial LMDE KDE (of which I hope you already have taken a look at).
So again, apologies for the lack of knowledge in this regard.
User avatar
Schoelje
Level 5
Level 5
 
Posts: 791
Joined: Wed Jan 18, 2012 6:25 am
Location: Netherlands

Re: Code improvements to live-installer and mintConstructor

Postby clem on Fri Jul 27, 2012 5:07 am

Don't worry about it. You don't need to know much to learn a little :)

Don't hesitate to come and join us on the IRC chat. We're there most of the time and always happy to help. Git is both easy and fun and working with github is a real treat. We'll guide you through it and show you the basics if you have the time.

For now, I'm keeping track of this with a github issue on the live-installer project: https://github.com/linuxmint/live-installer/issues/3
Image
User avatar
clem
Level 15
Level 15
 
Posts: 5548
Joined: Wed Nov 15, 2006 8:34 am

Re: Code improvements to live-installer and mintConstructor

Postby xenopeek on Fri Jul 27, 2012 7:48 am

GitHub also has a very nice interactive online tutorial, where you can learn how to use it in 15 minutes :wink: http://try.github.com/

To join #linuxmint-dev, just open XChat (or Quassel) from the menu to be automatically connected to #linuxmint-debian channel and then type in there:
Code: Select all
/join #linuxmint-dev

You can also edit your preferences to automatically connect to this channel upon starting XChat (or Quassel).
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14816
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Code improvements to live-installer and mintConstructor

Postby Schoelje on Fri Jul 27, 2012 7:57 am

Thanks for the tip on the tutorial.
Just now Clem gave me a git/github crash course, but I'm going to watch the tutorial anyway...maybe then I understand what Clem told me to do ;)
User avatar
Schoelje
Level 5
Level 5
 
Posts: 791
Joined: Wed Jan 18, 2012 6:25 am
Location: Netherlands

Linux Mint is funded by ads and donations.
 

Return to Code & Patches

Who is online

Users browsing this forum: No registered users and 2 guests