[Atrix 4G Android Development] Sogarth:
Archived notes:

The below steps are performed by the script in the first post, but in case you really wanted to know what's going on behind the scenes.... ;)

----- The setup script takes care of steps starting here. -----

From here on until noted otherwise,

all commands are assumed to be run as root

(so you either are root, or you're calling every command via sudo).

First, we should make sure that there's enough free space on the device:

/bin/df -h /data

There should be at least 1.0G under the Used column. If not, you won't have enough to create a decent disk. If so, then you can keep going:

/bin/dd if=/dev/zero of=/data/ubuntu.disk bs=1024 count=1048576

/sbin/losetup /dev/block/loop7 /data/ubuntu.disk

/sbin/mkfs -t ext3 -m 1 -b 2048 /dev/block/loop7

mkdir /tmp/osh

/bin/mount -t ext3 /dev/block/loop7 /tmp/osh

At this point, we've created a 1 GB disk file (1,024×1,024=1,048,576), formatted it as ext3, and mounted it in /tmp/osh. The next step is that we need to grab a copy of rsync so that we can perform our copy. I'll assume that rync is in /mnt/sdcard-ext for now:

mkdir /tmp/deb

/usr/bin/dpkg-deb -x /mnt/sdcard-ext/rsync* /tmp/deb

/tmp/deb/usr/bin/rsync -avx /osh/ /tmp/osh/

And now we have a duplicate of our /osh partition, but with more space this time (1 GB instead of 756 MB, which isn't great, but is a hell of a lot better). And, we know how to intercept the point in init.rc where /osh is mounted so that we can redirect it. Put the following into a file named mountosh.new, then copy it to /mnt/sdcard-ext. Here's the file:

#!/system/bin/sh

# Run mountosh.orig
/system/bin/mountosh.orig "$@"

# Then, mount the filesystem file over the existing /osh
# partition.
/sbin/losetup /dev/block/loop7 /data/ubuntu.disk
/system/bin/mount -t ext3 /dev/block/loop7 /osh

After that:

mv /system/bin/mountosh /system/bin/mountosh.orig

cp /mnt/sdcard-ext/mountosh.new /system/bin/mountosh

chmod 0755 /system/bin/mountosh

chown 0 /system/bin/mountosh

chgrp 2000 /system/bin/mountosh

You can now reboot your device, and you should now boot into the new partition we've just created.

----- The 0.5 version of the setup script performs up through here. -----

Here, an interesting question pops up: do you want mandatory access control (MAC) in place? In my case, I don't have a problem with it, so I can provide updated TOMOYO configuration files that reflect that. If you would prefer to disable it completely, run the following commands:

rm osh/etc/tomoyo/exception_policy.conf

touch osh/etc/tomoyo/exception_policy.conf

rm osh/etc/tomoyo/domain_policy.conf

touch osh/etc/tomoyo/domain_policy.conf

and then reboot your device again. This configures TOMOYO so that it monitors nothing.

Next, we go through and install a series of packages which are either loaded in a broken state (because Motorola force-installed conflicting packages afterward) or packages which are expected to be present. Some of these packages have specific paths listed afterward; if there are, then those files need to be backed up before package reinstallation, then restored afterward.

This is important

.

coreutils

cpio

dbus

/etc/init.d/dbus

dbus-x11

/etc/X11/Xsession.d/75dbus_dbus-launch

dhcp3-client

findutils

gpgv

pulseaudio

/etc/pulse/daemon.conf

/etc/pulse/default.pa

udev

/etc/init.d/udev

xserver-xorg-core

/usr/bin/Xorg

You'll need to install each package with:

dpkg -i --root=/osh --force-overwrite <package>

At this point, we can now update the list of APT sources so that we can start querying the public Ubuntu depots. Edit your /etc/apt/sources.list to have these entries:

deb http://ports.ubuntu.com jaunty main universe multiverse restricted
deb http://ports.ubuntu.com jaunty-security main universe multiverse restricted
deb http://ports.ubuntu.com jaunty-updates main universe multiverse restricted

I would also recommend that you add this line to the bottom of your /etc/apt/apt.conf.d/05aptitude file, since the reality of the situation is that we still don't have much space (it'll turn off auto-installing packages that aren't necessary but are recommended):

Apt::Install-Recommends "false";

At this point, you should be able to run the following with no problems:

apt-get update

----- The 0.7 version of the setup script performs up through here. -----

If this succeeds, we can move on to running aptitude:

aptitude

It will complain that a number of package installations are broken. This is expected, as that's how Motorola built out the distribution. The current script executes the "default" solution, which at the time of writing is four uninstallations, one downgrade, and ten installs. Also make sure that no "unnecessary" packages are uninstalled, since some of them are actually necessary.

We can then install gksu and aptitude so that we have graphical access to the package repositories from aptitude.

----- The 1.0 version of the setup script performs up through here. -----