Tuesday, October 30, 2012

Wubi development and customisation


Wubi is managed by the Ubuntu-installer team. But you can still fix bugs and submit it to them to review, approve and merge. Or if you just want to create your own version of Wubi... how do you go about it?

To start off I am using a vanilla install (so I don't miss any steps). It happens to be a Wubi install, but this doesn't matter.

1. Preparing your machine

Install some packages that you'll need to get started:
sudo apt-get install packaging-dev

2. Launchpad setup

This involves registering on launchpad.net, signing their code of conduct (which involves creation of a GnuPG key), adding an SSH key (which you'll need if you want to push your code back to launchpad). You can find help for this on launchpad itself.

3. Identifying yourself

You should now have GnuPG and SSH key setup. Identify yourself to the debian packaging tools by adding the following lines to your .bashrc:
e.g.
export DEBFULLNAME='bcbc'
export DEBEMAIL='openbcbc@gmail.com'

To make the change take effect run:

source ~/.bashrc

4. Download the code for Wubi

First identify yourself to bzr (and launchpad):
e.g.
bzr launchpad-login bcbc
bzr whoami "bcbc <openbcbc@gmail.com>"


If you're working on the development release you can download it using:
bzr branch lp:wubi

If you want a production release e.g. precise, instead use:
bzr branch lp:~ubuntu-installer/wubi/precise



This will confirm the RSA fingerprint on the server and ask you to unlock your own SSH key; then download the code. Now you should review the README and compile wubi.exe because the first time you do it, it installs and configures wine and other software you require (there is a lot to install, when prompted accept the defaults except for a few things like accepting the EULA):

make





6. Make your changes
So in this case I'm going to fix a really easy bug. This affects 12.04.1 wubi.exe (but I'm fixing it in the dev branch 13.04). It doesn't matter, it will have to go in there as well. The problem is that with long term releases, not all flavours of Ubuntu get updates. So while there is a 12.04.1 release of Ubuntu/Kubuntu/Edubuntu etc., there isn't one for Lubuntu. And the 12.04.1 version of wubi.exe won't install a 12.04 version of Lubuntu.

There is a check that allows a 12.04 version of wubi.exe to install a 12.04.1 release, but I believe that's an error - it should be the other way round.

So, let's find the bug and the affected code. Here's the bug: https://bugs.launchpad.net/wubi/+bug/1043607 and here's the relevant output:

08-29 21:38 DEBUG CommonBackend: Checking C:\ubuntu\install\lubuntu-12.04-desktop-i386.iso
08-29 21:38 DEBUG Distro: checking Lubuntu ISO C:\ubuntu\install\lubuntu-12.04-desktop-i386.iso
08-29 21:38 DEBUG Distro: wrong version: 12.04 != 12.04.1


The highlighted part shows you where to find the code: its in distro.py which happens to be in src/wubi/backends/common (search on "wrong version" since the release numbers are variables...) and then make the fix. Here's the diff after fixing.:

=== modified file 'src/wubi/backends/common/distro.py'
--- src/wubi/backends/common/distro.py 2012-04-24 15:57:38 +0000
+++ src/wubi/backends/common/distro.py 2012-10-30 21:17:02 +0000
@@ -166,7 +166,7 @@
         if self.name and name != self.name:
             log.debug('wrong name: %s != %s' % (name, self.name))
             return False
-        if self.version and not (version == self.version or version.startswith(self.version + '.')):
+        if self.version and not (version == self.version or self.version.startswith(version + '.')):
             log.debug('wrong version: %s != %s' % (version, self.version))
             return False
         if check_arch and self.arch and arch != self.arch:



7. Edit the changelog
You can use dch -i to add a changelog entry. It does some automatic stuff for you, but make sure you correct the release number or it names it 12.10ubuntu1. Otherwise just use your favourite editor. Note: I'm not really sure of the convention here - but only the Ubuntu-installer team can merge changes to the main Wubi branch, so they'll sort that out if they have the time to look at it.

So here's what mine looks like:

wubi (13.04) UNRELEASED; urgency=low

  [ bcbc ]
  * Allow Wubi to install earlier release ISOs on LTS (LP: #1043607)

 -- bcbc <openbcbc@gmail.com>  Tue, 30 Oct 2012 14:41:50 -0700




8. Commit the changes

bcbc@ubuntu:~/wubi$ bzr commit -m 'Allow Wubi to install earlier release ISOs on LTS - LP 1043607'Committing to: /home/bcbc/wubi/                                                                  
modified debian/changelog
modified src/wubi/backends/common/distro.py
Committed revision 274. 

If you messed up, run bzr uncommit and you can change and recommit. It doesn't remove your changes, just the commit.

9. Push to a new branch

bcbc@ubuntu:~/wubi$ bzr push lp:~bcbc/wubi/lp1043607
Using default stacking branch /+branch-id/30119 at chroot-74436368:///~bcbc/wubi/
Created new stacked branch referring to /+branch-id/30119.    


10. Link it to the bug
Go to the page for the branch you just pushed: https://code.launchpad.net/~bcbc/wubi/lp1043607
Now you can link the bug report and open a merge request.






11. Final comment
You probably noticed I forgot to test my patch. That's not a good idea. So once you have made you changes you should run make again to build wubi.exe. You can find it in the build directory. You can copy that to your Windows machine and test it - or view the README for other test options.

PS. If you want to build a custom Wubi for your own ISO, review the README as well. It tells you what you need to change.

Monday, October 29, 2012

Getting ready for Ringtail

With the news that the Ubuntu 13.04 Raring Ringtail repositories are in place, I decided to try a different approach this time to using the development release. Usually, at some point in the cycle, I'll try out an upgrade - and if it seems usable - I'll keep it (I always have a full backup just in case).

With 12.04 Precise Pangolin the development release was really stable so I quite happily used it actively throughout the cycle... but unfortunately it wasn't quite as good with 12.10 Quantal Quetzal and I found that I relied more on my non-wubi 12.04 Edubuntu install (although that wasn't entirely without problems either).

The down side of switching to the development release is that I lose touch with the latest production release , which is more useful in keeping track of current issues, and since I'm not upgrading my Edubuntu machine I want to keep both 12.10 and 13.04 on the same machine (with Wubi).

I already have a Wubi-resize script that will duplicate a Wubi install (and keep it in synch). I've added a custom menu entry to boot the sychronized disk to make sure it's functional. Now I need to be able to switch and run independent Wubi installs (without the tedium of booting to Windows to manually switch the root.disks).

So that led me to my latest testing approach:
1. Duplicate the up-to-date 12.10 install using the Wubi resize script and rename the new.disk to raring.disk
2. Add a custom boot entry for this raring.disk
3. Manually update /usr/share/lupin-support/grub-mkimage on the Raring install to stop it splatting /wubildr whenever there's an update to Grub (which would make the raring intall the default)
4. Turn off Ubuntu One synchronization and other automatic backups on the Raring install
5. Go nuts without worrying about breakage

Here's the custom boot entry (modify the one on root.disk only and change the highlighted bits):
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Ubuntu - Raring Ringtail' --class ubuntu --class gnu-linux --class gnu --class os {
        gfxmode $linux_gfx_mode
        insmod gzio
        insmod ntfs
        set root='(hd0,msdos3)'
        search --no-floppy --fs-uuid --set=root 18B4B7BBB4B799A8
        loopback loop1 /ubuntu/disks/raring.disk
        set root=(loop1)
        linux /vmlinuz root=UUID=18B4B7BBB4B799A8 loop=/ubuntu/disks/raring.disk ro quiet splash $vt_handoff
        initrd /initrd.img
}


Here's the diff on grub-mkimage (modify the one on raring.disk only):
--- /mnt/usr/share/lupin-support/grub-mkimage 2011-09-20 03:44:44.000000000 -0700
+++ /usr/share/lupin-support/grub-mkimage 2012-10-29 22:02:55.784517389 -0700
@@ -112,7 +112,7 @@
         exit 1
     fi
 fi
-
+exit 0 # for raring test install, bypass creation of wubildr
 wubildr_partitions="$(find_wubildr)"
 
 if [ ! -f "$target" ] && [ -z "$wubildr_partitions" ]; then


Now all I have to do is wait for something exciting to happen with Ringtail:


Friday, October 26, 2012

Tricking Wubi into installing Xubuntu 12.10

Xubuntu is no longer available on Wubi from release 12.10 and later - as I mentioned here: Xubuntu option to be removed from Wubi. However, there are some people that will want to try it out with Wubi anyway, so here's a way to do it.

Disclaimer: I don't recommend the technique I describe here, but it works fine if that's what you want to do.

It involves downloading two ISOs, one for Xubuntu and another one supported by Wubi. I'll choose lubuntu since it's the smallest.
  1. Dowload the smallest supported ISO: lubuntu-12.10-desktop-i386.iso
  2. Download xubuntu-12.10-desktop-amd64.iso (I want 64-bit, but you can use 32-bit too)
  3. Check the xubuntu md5sum (Wubi will check lubuntu, but you need to check xubuntu).
  4. Download wubi.exe for release 12.10
  5. Make sure wubi.exe and the lubuntu ISO are in the same folder. Run Wubi and select lubuntu
  6. When it tells you to reboot, select "Reboot later".
  7. Replace C:\ubuntu\install\installation.iso with the Xubuntu ISO (renaming to installation.iso)
  8. Mount the Xubuntu ISO and copy initrd.lz and vmlinuz from the /casper/ directory over the one in C:\ubuntu\install
  9. Edit the preseed.cfg file in C:\ubuntu\install\custom-installation\ so that it installs xubuntu-desktop instead of lubuntu-desktop
  10. Reboot the computer
  11. Select Lubuntu
  12. Watch Xubuntu install
  13. Reboot, select Lubuntu and boot into your new Xubuntu install.
You don't strictly need to predownload the lubuntu ISO but it's faster than letting Wubi do it. If you decide to use the Ubuntu ISO instead of lubuntu you do have to download the ISO beforehand (because Ubuntu defaults to the preinstalled diskimage and that won't work with this technique).

Notes:
I used the C: drive for clarity - if you install to a different drive then modify as required.
If it bugs you, you can rename the Lubuntu menu entry to Xubuntu using bcdedit or easyBCD. 

Here are some screenshots for selected steps:


Step 3: Check Xubuntu MD5 sum




Step 5: Run wubi.exe with lubuntu in the same folder



Step 6: Select to reboot later




Step 7a: Delete the existing installation.iso




Step 7b: copy the Xubuntu ISO and rename to installation.iso




Step 8: Mount the xubuntu ISO and copy vmlinuz and initrd.lz







Step 9: Set it to install xubuntu-desktop




Step 11: Select Lubuntu




Step 12: Watch it install Xubuntu



Credit: I got this tip from here ironically to install lubuntu prior to it being supported by Wubi.

Update:
The original post had this line: "This technique will also likely work with other unsupported flavours e.g. ubuntu-studio". It does with one caveat. Ubuntu Studio doesn't include the package required by grub to generate the menu entries that can boot a loop mounted install (lupin-support). So it will install, but you have to manually boot it the first time from the grub prompt and then install lupin-support.

 Here's how to manually boot any Wubi install:
search -s -f -n /ubuntu/disks/root.disk
probe --set=diskuuid -u $root
loopback loop0 /ubuntu/disks/root.disk
set root=(loop0)
linux /vmlinuz root=UUID=$diskuuid loop=/ubuntu/disks/root.disk ro quiet splash
initrd /initrd.img
boot


Thursday, October 11, 2012

Pass on upgrade to Quantal Quetzal 12.10

I've been following the development of Quantal Quetzal in passive mode. I need the development release to maintain the Wubi move and resize scripts, so I don't have much choice in the matter, but I haven't been as involved this time around.

The most striking difference between development on Quantal and that on Precise Pangolin 12.04 has been the quality drop-off. Precise was remarkably stable throughout the development cycle, whereas 12.10 has had some rough patches, making it barely usable at times. Most recently I've found the zombie application window problem - which is when I've closed some applications but they still appear to be active - almost like an overlay on the desktop. In fact, moving to separate workspaces shows these zombie windows and even the launcher has the active window indicator. Now normally this isn't too big a deal - in development we expect some weird stuff - but it's very close to release, and what's more, this is a recent 'development' (as it were). So that doesn't bode well.

So what's really new with Quantal? What new benefits are there?
I'm having a bit of a problem figuring this one out.

  • During development they renamed "Shut down..." to "Switch off..." on the system menu (but not the Shut down dialog pop up). Then they renamed it back to "Shut down..." a few weeks ago. 
  • They've added the "Restart..." option back to the System menu that was removed in 12.04.
  • They've combined the User and System menu into one
  • The i386 non-PAE kernel has been removed so the PAE kernel becomes default on 32-bit installs
  • They've added Amazon online search results to the main Unity search lens that ironically seems to return adult-themed toys for innocent search strings dynamically as you type. Because as everyone knows, sometimes you just randomly decide to buy things online when you're searching for documents on your computer.
  • They changed some icons on the mail envelope a lot and then removed them
  • There's no more live CD since the ISO is too big to fit on a CD. So you'll need a DVD or USB.
  • There's no more alternate CD because support and testing two images takes too much time and they figure that the text installer is not needed anymore - and for those that do they can use the netboot ISO.
  • There's a new version of Grub that supports UEFI secure boot (I believe this is on 12.04 as well)
  • For Wubi, you won't be able to install Xubuntu anymore, but they have finally fixed the links for Kubuntu so that will be available and working.
Okay that was a list of nothing. What are the benefits?

Well, I really like the new blue sky wallpaper. And there are obviously lots of other little changes that may be important to users, like updates to more recent versions of some applications.



Upgrade Recommendation
I'd say pass on the upgrade unless there's something specific that you need. But bear in mind that if you decide to upgrade to 13.04 later, you'll still need to upgrade to 12.10 along the way.
Remember that there will be some new bugs introduced with the mainly cosmetic changes, added to the unfixed bugs from 12.04.
If you do decide to upgrade please make sure you have at least 3 GB free space - see here for more upgrade tips.

Wubi default
For new Wubi users, you'll be installing 12.10 by default from here. Get the wubi.exe for 12.04 from here instead if you prefer.