[Milestone XT720 Android Development] Mioze7Ae:
The way odexed builds in CM work is:

All system.img dependencies are built deodex

A deodex system.img is created

Deodexed system.img is booted into the simulator and creates odex

Odex is extracted and packaged into the the initial update.zip

The releasetools/squisher repackages and processes the initial update.zip to produce the final update.zip

So, you *always* build a deodexed version first. The squisher* is a generic script that can do anything that you would do manually to a ROM after it was installed. nadlabak added commands to his version of the CM6 vendor/cyanogen/releasetools/squisher to use baksmali/smali to inject and modify the framework. This doesn't work well in odex'd ROMs because baksmali/smali of odex framework files is not as easy as deodexed. It also adds a lot of overhead when you try to do odexed builds because the commands need to work for both deodex or odex in the update.zip that's being squished.

A simpler approach is to do this sort of tweaking before odexing (i.e. between steps 1. and 2. above). I did that by adding a "tweaker" in addition to the "squisher" to the core makefiles:

https://github.com/CyanogenModXT720/android_build/commit/788f95727a83f7602bebcd6264088d9d4a87fe6b

This adds an opportunity for the device to define TARGET_CUSTOM_SYSTEMIMAGE_TWEAKER to run a shell script before the system.img is generated for the simulator. Conveniently, the Makefile modification passes the directory of the files that are going to be stuffed into system.img to the tweaker ;) (I haven't looked at CM7, but I assume the same principle applies)

This is the latest tweaker I'm using now in CM6 (the device squisher is also in the same directory):

https://github.com/CyanogenModXT720/android_device_motorola_sholest/blob/froyo/releasetools/tweaker

This tweaker injects smali into framework.jar and services.jar from vendor/motorola/sholest/smali. The framework injection support implemented there is fairly generic based on the idea that e.g. all files in vendor/motorola/sholest/smali/framework get injected into framework.jar and all files in vendor/motorola/sholest/smali/services get injected into services.jar. There's also a sed script inherited from nadlabak's CM6 that adds something related to google location services to services.jar. The tweaker also modifies system/etc/permissions/platform.xml to add the motorola jar permissions. So this is now what happens on CM6:

All system.img dependencies are built deodex

tweaker is run to modify the built dependencies and basically do-whatever-the-hell-I-want-goddamnit(TM)

A deodex system.img is created using the modified files

Deodexed system.img is booted into the simulator and creates odex

Odex is extracted and packaged into the the initial update.zip

The releasetools/squisher repackages and processes the initial update.zip to produce the final update.zip

*CM6 originally only had the generic one-script-fits-all-devices vendor/cyanogen/releasetools/squisher -- epsylon3 added support in CM7 to allow each device to substitute its own squisher via TARGET_CUSTOM_RELEASETOOL in e.g. BoardConfig.mk -- I backported that to CM6. That's where we do things like remove boot.img and replace the updater-script etc (because no matter how many times you tell the build system NOT to include boot.img in the update it insists on doing it anyway).