[Desire HD Android Development] Dude360:
Pretty much yeah.

The benefits are that if the cleaner script is run before the rom has booted for the first time, the apps arent able to run.

So not only are they removed from the system, they dont have chance to put down any data on it, leaving it just that little bit cleaner.

Its also a lot faster and has the ability to add stuff to the device as well ;)

Also, more importantly , you arent editing the ROM zip directly! This helps to make sure it is kept in tact and also makes it easier to troubleshoot errors with the rom.

If you open the zip with WinZip or 7zip youll see a folder structure like so:

data\
META-INF\com\google\android\
system\

Head into the android folder and you will find 2 files: updater-binary & updater-script (notice they do not have file extensions like .txt)

updater-script is the script we are referring to throughout this post ;)

Drag the updater-script out of the zip and to somewhere on your PC.

Open Notepad++ and then drag the script into Notepad++, you see that its just a plain text file.

Quick Breakdown:

ui_print(" ");

Anything placed within the " " is displayed on your screen in CWM

The above denotes a blank line.

This section is the header section youll see when first running the script.

It basically mounts all your partitions so the script can read and write to it.

ui_print(" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
ui_print("| * * * * * * * * * * * * * * * |");
ui_print("| ROM Cleaner v1.2 by Patrics83 |");
ui_print("|_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_|");
ui_print(" ");
ui_print(" ");
run_program("/sbin/sleep", "1");
ui_print("Mounting partitions");
run_program("/sbin/busybox", "mount", "/system");
run_program("/sbin/busybox", "mount", "/data");
delete_recursive("/data/dalvik-cache");

These commands will delete the entire folder:

delete_recursive("/sdcard/.adobe");
delete_recursive("/sdcard/.adobe-digital-editions");

These commands will delete a specific file:

delete("/data/app/apps.txt");
delete("/data/app/com.htc.rosiewidgets.note.apk");

To stop the script form removing something you add a # in front of the command like so:

#delete("/data/app/apps.txt");
delete("/data/app/com.htc.rosiewidgets.note.apk");

So all you have to do is look through the script and see if theres any apps you dont want deleted and add a # in front of the command.

If theres any apps, files or folders that you want to add then you can just copy a line and change it:

delete("/data/add/file/here.txt");
delete_recursive("/add/folderhere");

When you hit the bottom of the script you will see the closer:

ui_print(" ");
ui_print("Writing Data From Data Folder In Zip");
package_extract_dir("data", "/data");
ui_print("Writing Data From System Folder In Zip");
package_extract_dir("system", "/system");

ui_print("Unmounting partitions");
run_program("/sbin/busybox", "umount", "/system");
run_program("/sbin/busybox", "umount", "/data");
ui_print(" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");

The first set of commands will copy anything located in the zip folders data & system to the relevant folders on your device

The second set will unmount your partitions to allow other CMW stuff to happen.

Once you are happy with your script, open up the zip file, head to the /android directory and copy the script back into the zip.

Thats it, its done. Now just flash straight after flashing a rom to have everything removed (and added if you want) all before first boot :D

You can get really creative with what you do with the zips.

For example, I copy all my apps from my device to my Cleaner .zip so they are all preinstalled. This save time and bandwidth as I dont have to redownload them from the market. I also have all my mods in another :D

Hope that was some help to ya'll :)