Auto-Update System Modification Technology

Introduction
Auto-Update System Modification Technology (AUSMT) is the next generation of AUPT technology that has been used in all homebrew patches in the webos-patches feed. AUSMT allows patches to be installed/removed even after faulty installs, partial or full erases, webos doctors and even OTA updates to new WebOS versions! With time, AUSMT should bring the OTA safeness to all patches including the advanced ones.

All patch installations and removals will now log to /media/internal/webos-ausmt.log and should be examined for detailed information with regards to any patch installation or removal failures.

Installation
Always install patches with Preware or webOS Quick Install v4.00 or later.

Recovery & Verification
To recover from situation when you have modified files left behind even if you have uninstalled all your patches there are 3 recovery options offered in Preware. You may also wish to verify that all of your system file modifications were indeed done with AUSMT and that there are no left-over older or incompatible modifications in the system, for this you should run the verification utility found in Preware.

AUSMT Recovery - Safe
This version leaves backup files behind in situations where its not 100% sure what to do with the backup files due to OTA for example. This makes manual recovery possible if the recovery fails to put the system into original state. If you do not wish to leave behind any backup files your should run the basic version.

AUSMT Recovery - Basic
This version makes assumptions of certain situations been caused by OTA and therefore deletes unneeded backup files. This way the system is left in clean state, but in case of something was really wrong in the system it can delete backup files you might need to do manual recovery. If you haven't fiddled with your system nor experienced any data loss due to power off etc. this should be safe to run.

AUSMT Recovery - Full
This is meant to be the last resort recovery which searches the system for backup files in the case where AUSMT has lost the track. You might want to test this before Doctoring, and this should be as safe to run as the basic, but running this can take really long.

AUSMT System Verification
Upon installation, this package will run through all known stock md5sums and check against the known safe patch technology version(s). Simply install this package and if you receive an error that means that there is some unknown or outdated file modification or patch installation. If installing via Preware you can tap "Show IPKG log" to see which packages/files are touched by outdated/unknown patching technologies. You can also check the webos-ausmt.log file in USB mode for this information.

Re-installation and Upgrades
There are various scenarios you may find yourself in where a patch may be installed or uninstalled. We will discuss what to do after each of these situations.

webOS Doctor
The webOS Doctor is a great way to ensure you are running completely stock Palm webOS files in the root filesystem. There are 3 situations you can be in with patches installed after WebOS Doctor.


 * If you used a doctor version that is a PRIOR webOS version than the one that was running when you installed the Patches, install "Emergency Patch Recovery" (EPR) to wipe the device of the patch package information. There are no supported downgrade automatic patch installations.


 * If you used a doctor version that is the SAME webOS version as the one that was used to install the Patches, simply install "Emergency Service Enabler" (ESE) to re-apply all of your installed patches.


 * If you used a doctor version that is a LATER webOS version than the one that was running when you installed the Patches, use Preware's Update All feature. Launch Preware, Update Feeds, tap Package updates and tap update all.

Partial/Full Erase
The situation may arise where you needed to do a partial or full erase without doctoring the device. If you perform a partial or full erase while patches are installed, this will only remove the package data that lists these patches as installed in Preware and webOS Quick Install. The patches will still be applied to Palm's WebOS files. There is not yet a supported method to recover the patch package data. For now it is recommended to clean up all the patches via one of the following methods. These methods are listed in order of robustness. The only -guaranteed- way to ensure stock Palm webOS files is by using the webOS doctor: Webos Doctor Versions


 * Install "Emergency Patch Recovery" (EPR)
 * webOS Repair Utility
 * webOS Doctor

AUPT patches are built with smart post-install scripts that are able to detect when a patch is already applied to the stock webOS files. If you remember all the patches you had installed before the partial/full erase you may simply re-install each Patch individually as usual (Preware or QI v3.01 or later)

Preware
In the past it was recommended and required to remove all patches prior to updating webOS Over The Air (OTA). The new AUPT-5 system strives to makes this unnecessary and allow you to leave patches installed and then update them all after an OTA update to a new version of webOS. Not all (e.g. muffle logging) patches are OTA-safe under the AUPT-4 system so it may still be recommended to do so in the meantime. After a webOS OTA update you may use Preware's Update All feature. After an OTA update perform the following steps:


 * Launch Preware
 * Tap application menu -> Update Feeds
 * Tap Package Updates
 * Tap Update All.

(SEE: Known Issues section for known roadbumps in Preware's Update All function with regards to patches)

WebOS Quick Install
WebOS Quick Install is fully compatible with webOS-Internals Auto-Update Patch Technology (AUPT). When you enter the Tweaks section, after a webOS update, WebOS Quick Install will detect the version change and will open an update helper.

For on-feed patches, the update helper will update out-of-date patches to the new version's equivalent (or a dummy package if an updated patch has not yet been released).

For .patch files installed with WebOS Quick Install, the update helper will uninstall them. It will also check to see if the patch can be successfully re-applied. If it can be re-applied, the patch will be reinstalled.

Submissions
Submit all patches to be included into the webos-patches feed found in Preware and webOS Quick Install to: http://patches.webos-internals.org/

aupt-1

 * First implementation

aupt-2

 * Attempt to re-order logic in prerm to check for OTA first before trying to -R the patch

aupt-3

 * Fixed order of OTA checking to avoid potential rare case of OTA containing changes that allow a patch to -R incorrectly
 * Fixed bug in aupt-2 so that patches actually get unapplied
 * Renamed backups file to file_list in patch control dir to avoid potential conflicts with Palm backup operations

aupt-5 (the basis of AUSMT)

 * Attempt to make all patches OTA safe and to support also patching of 3rd party applications
 * Also these scripts now supports themes, Theme Manager already utilizes these scripts to install themes
 * Has support for moving to aupt-6 at some point that uses different name for backup files
 * Added more check and made patching to abort in situations where end result can not be guaranteed such as if md5sum can not be retrieved for the file to be pathed
 * Binary patches are also now handled correctly and made sure that only original file can be binary patches
 * Disallowed replacing of files through additional files (can be configured to allow it if really needed)
 * Should support situations where OTA has removed/added files or even made the exact same change for the file than a patch

aupt-6 (never existed, will be added into AUSMT at some point)

 * Defaults to new backup file name (.webosinternals.orig. )
 * Updates old backup files if found, and wont install if older than aupt-5 patches installed

AUSMT Notes
- Install can (should :) only fail on following situation:

* Entered patch information is incorrect * One of the required binaries can not be found * Md5sum can not be find for the files to be patched * Generation of patch control data or backup files fails * Patch can not be fully applied and patch reversing test fails * File to be binary patched does not exist at all in the given path * File to be binary patched is not orginal state or already patched * Additional file already exists and is not the same file is not an   actual additional file (i.e. file is provided by system package)

- Un-install can (should :) only fail on following situation:

* Entered patch information is incorrect * One of the required binaries can not be found * Patch can not be unapplied cleanly and the files that fail are not updated by OTA (ok if patch is fully unapplied already) * Binary patch can not be restored and it is not updated by an OTA

- OTA / Update handling on patch installation (postinst)

* Check if file that has backup file is in original state, if it is then its most likely updated by ota so remove backup, so it gets re-created * Check if cryptofs files are being modified for the first time, if they are then update the file_control version info

- OTA / Update handling on removal of the patch (prerm)

* If md5sum cannot be fetched for a file that exists then its most likely removed by an OTA or is a file created by the patch so   make sure that file and backup remain removed after removal of    the patch (created_list) * Check if the files md5sum is the same as what the unmodified file should have, if yes then the file has been replaced by an OTA, so make sure that the file is as it is after removal of the patch and allow patching of that file to fail (restore_list) * Check if backup file has different md5sum now than when the patch was installed, if it has then its change is cause by OTA most likely so allow this restoring of this file to fail, also make sure that this file stays uneffected by the removal of the patch (restore_list) * Check if the file has been removed then it is most likely don by OTA so allow patching of that file to fail * If cryptofs file has been restored to original state then remove the version info of that file since its not needed anymore

Preware
There are some known bumps in Preware's update-all with regards to patches, but no major roadblocks. The known issues and workarounds for them are:


 * It will stop when trying to update a dependent package. The workaround here is to remove patches that depend on another patch or package that has an update. For instance the uscl memos patch depends on universal command line patch. The update all will fail when it gets to these patches, and you can workaround that by removing the uscl memos patch and then re-running update all.
 * When the "install" part of the remove/install update process for a patch fails, Preware's installed list doesn't refresh automatically so the failed patch still lists on the update screen as installed. You can workaround this by updating feeds or tapping "remove" on the left-over package in Preware.

Miscellaneous

 * There are rare circumstances where a collection of patches in the same category may have to be installed/removed in a certain order and may fail (safely) to install or remove in different orders.
 * aupt-2 has a bug in the removal logic that cause it to see all packages as updated and removes the package without actually unapplying the patch.

Troubleshooting
Patching is by nature a very ugly beast. There are bound to be unforeseen issues and difficult to debug situations. In the end you can always get back to a completely stock webOS by performing a full erase followed by a webOS doctor. Here we will list some known problems and workarounds.

Emergency
In the event that you find yourself in an unsupported situation with regards to patching or simply want to ensure a clean slate of stock Palm WebOS files without any patches, the following is the only guaranteed method:


 * Backup / take not of any homebrew packages installed as well as any App Catalog applications that are not backed up via your Palm Profile
 * Go into device info -> reset -> Partial Erase to erase all applications.
 * Perform webOS Doctor to ensure all Palm webOS files are stock.

You may also try the quick solution of installing one of the AUSMT recovery applications. Please note that this relies on information that patches saved/stored and is not a robust or guaranteed way to ensure patches are completely removed. It is very safe and works a vast majority of the time as intended, it simply is not guaranteed to clean up everything.