[Nexus S General] qorron:
Solution (well maybe...)

So.. from what I read in this thread I derive some more or less useful observations:

It works and fails on slightly modified roms.

It works and fails on unmodified roms.

It tends to fail more often with the stock recovery.

Here is my story: 9023, cwm5023, manually flashed 4.0.3 in december, rooted, rom slightly modified (hosts file, some extra ogg files in the notifications dir, root, rootkeeper, and deleted recovery-overwrite-script).

What I did: put the file from the first post in /sdcard/, reboot, recovery, apply update.zip, first the 404, then root (just to be sure), fix permissions (don't know if necessary), reboot, got 404.

But the reports of failed updates made me curios.

(at this point this analysis may get a little bit above the level of understanding of a regular Joe android user)

So, I had a look at the source.

(extract the zip, searched for something that looks like an update script)

got this one:

/META-INF/com/google/android/updater-script

And right here at the end of this little code block in line 652:

assert(apply_patch_check("/system/vendor/lib/libwvm.so", "6f03d4b266d99f2e79a617786d4ba4981a2bc4e5", "aa466817fc702b7764ac442452aea2c4593503e3"));
set_progress(0.983189);
assert(apply_patch_check("MTD:boot:3526656:40d819a22242be448d36e61b1ad42501e88838cb:3526656:877503a77928e449c8bff451ea7a3e783a4b607f"));
set_progress(1.000000);
assert(apply_patch_space(15916988));

Here is the feared apply_patch_space call.

Still no real clue what it does.

So, I googled and found:

http://www.freeyourandroid.com/guide/introdution_to_edify

The interesting part:

Ok.. so, the problem is not a modified file (files are checked too, you can see which ones by reading the script) but more a lack of free space on a 'cache' (who's location is yet to be determined).

So, thats about 15MB of free space required.

Looking at /cache with root explorer: 466MB free

Found a lead to the source files here:

http://tjworld.net/wiki/Android/UpdaterScriptEdifyFunctions

Again, use the source Luke!

I had the android source lying around somewhere from the time I wrote this (completely unrelated) post: http://xdaforums.com/showthread.php?p=20017514#post20017514

I had to jump through quite a bunch of C-source files (I'll spare you the story) until i got the answer:

size_t free_now = FreeSpaceForFile("/cache");

So, it really is /cache

There may be many reasons why this fails:

There is not enough space left on /cache (obvious)

/cache is not mounted but it should be (it failed to mount somehow? maybe a prior wipe or backup unmounted it?)

It is mounted read only and it should be mounted rw.

To be sure, I had a quick look at the situation right after the device enters the (cwm) recovery:

~ # mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/block/mtdblock4 on /cache type yaffs2 (rw,nodev,noatime,nodiratime)
~ #

if you are there, you can check the free space with the df command:

~ # df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 176532 32 176500 0% /dev
/dev/block/mtdblock4 480768 2588 478180 1% /cache
~ #

The expected situation right before the update should be:

/cache is mounted read/write and has plenty of free space.

(note: df displays capacities in numbers of 1k blocks)

I have no idea what all you guys did before the update, but this may help if you have this 'apply_patch_space' error:

Ensure a working 4.0.3 is on the device.

After entering the recovery, immediately apply the update.

If you have the urge to backup, wipe, whatever, do it and then reboot once more for the update to ensure all effects of that actions on the /cache are gone.

Again: I have no idea if this solves your case, but it is my best guess and I think it has a good chance of success.