[Windows Mobile Software Development] Da_G:
Let's see if I can give a quick rundown (no sleep, been up all night playing with this, and i leave for vacation in 2 hours, haha :P)

very first thing checked is .cab.pkg signature, against BLOB of signatures in \SYS\Metadata\DefaultCerts.dat, signature match passes,

then update agent enumerates all .dsm on device, noting Package GUID, versioning info, and Interface GUID.. then notes all files belonging to each package.

now new .dsm is examined, dependencies checked against packages on device

there are 2 types of dependencies in .dsm:

Package GUID dependency, which is a simple "package a requires package b"

also an Interface GUID dependancy, which is, "package a requires all packages of matching interface to be present, and matching version" - this is important, for example all packages of a language have interface dependency on each other, trying to install one package without the rest results in a dependency failure, must include all interface dependent packages in a super package, to be updated at once

this is the biggest part, dependencies must be met exactly, any mismatch and .cab.pkg upgrade will fail.

once dependencies are passed, files are checked for conflicts, no 2 packages on device can share the same filename - if package has a duplicate, results in failure.

only way to update a file is to update the entire package associated with that file, can't just drop in a new package, containing the file, update will fail due to file conflict (2 or more packages sharing same filename) - only package with matching GUID, higher version, can replace a file, by replacing entire package

if signature, package/interface dependency pass, and file conflicts pass, system is rebooted into ULDR

ULDR grabs package, again validates (here is where you will get a failure if ROM is cooked with platform rebuilder, as relocs are stripped and ULDR cannot reloc new packages - failure will result in system reboot and auto-deletion of package)

if package passes validation, now is when it gets added to the IMGFS, process takes a good amount of time (in my testing, 10 minutes for a 25mb package)

so far every time ive tried a custom .cab.pkg, got an error extracting, out of space error, maybe problem with way cabarc is storing, or .dsm created with dsm analyzer

working scenario was:

dump stock rom, replace \SYS\Metadata\DefaultCerts.dat with certs i have .pvk .spc for (private keys so can sign .cab.pkg) - tested single .cab.pkg generated from dump of 21725 sys - failed with dependency error

copied log from /release folder (must create this folder for updatevalidator.log to appear)

noted failing guid from log, added corresponding .cab.pkg to super package - again sign with certs and timestamping

stepped through until all dependencies were met - total packages required on this test run was 9 to meet all dependencies (base_lang_0409, base_lang_0409_dpi_192, base_lang_0409_dpi_192_resh_480_resv_640, baseapps, baseappsfiles, msxipkernel, os, shell, smime

system was updated successfully, verified by start - settings - about (new ce os version showing from msxipkernel.cab.pkg)

however received error 0x80004005, unspecified failure

error returned in updateapp.log was:

Error during update: Function: RegistryUpdate::CopyFileToIMGFS, Line: 135, Hr: 0x80070070, GetLastError: 112

updatevalidator shows 2 base_lang_dpi packages did not need to be updated, maybe cause of error

but it worked!

now i need to get a coffee.. :)