This has a very technical overview of the inner workings of ZooKeeper.  Feel free to skip it.  If you are a developer, feel free to suggest improvements or ask questions!

Update Methods

The Updates themselves are basically hand-crafted using highly compressed tar.xz files.  The tar files maintain all Unix/Linux permissions and other meta-data but you don't have to flash the entire disk image.  This also allows selective updating using intelligent scripts.  This is actually independant of the operation of ZooKeeper.

ZooKeeper first looks in the MIRROR site's ROM/.meta directory for WL-current-ROM.  This has the current release version and the system will instantly know if it's up to date.  In the future, I'll implement a WL-beta-ROM file as well that will allow for bumping up to beta-releases.  These files also let you safely upload files and make sure they are good before any downloading starts.  The contents of the file is a name.  If the name doesn't match, we have an update, and proceed to the next step.

ZooKeeper will now look in the same directory for a file that matches it's current release name.  For example, if you are on Badger, it looks for a file called Badger.  The contents will be the next ROM that needs to install.   If that doesn't match the current release from WL-current-ROM, then it chains to the next.  The content of every file fetched is the name of the next file to grab.   Following the chain builds a list of files to be downloaded, from ROM/download, in the form of Update-xxxx-to-yyyy.zip.  The chain method also means that if it's safe to skip an update (for example, Cuscus update will be easy to include in D's update), then we can easily unlink them from the chain so that fewer downloads are required if a user is a couple releases behind.

Every Update.zip also has a .zip.md5.   The md5 of the zip is computed and checked by ZooKeeper before it ever writes the name of the update to the OpenRecovery script.  You can turn on md5 checking in your recovery, but this will just slow things down since ZooKeeper has already checked it.  It will Notify you if the md5sums don't match (or it should - I haven't messed up a download yet).

 

Cron

Checking for updates at a certain time of day is done by just scheduling a cron job.   A heavily hacked crond start-up script is added to /etc/init.d with crontab files in /etc/crontabs.  A root user is faked and the root crontab in /etc/crontabs is actually a symbolic link.  The link is to the Cron directory in the /data/media/0/ filesystem, which is the actual place where data on your Internal Storage issystem/ kept.   This means it can see real Linux filesystem userids and permissions which cron wants in order to feel safe.  The /storage/sdcard/0 is a FUSE-based overlay that simulates a simpler filesystem, and the Cron directory their can be read and written to by your Android apps and editors.  Do NOT erase files!  Editors that write to a different file and then rename files will also fail because the permissions (set by a script that ZooKeeper runs) will not be preserved.

When the given time occurs, the crontab created by ZooKeeper uses busybox "run-parts" to execute all scripts in the given cron-directory, ex: /system/etc/cron.daily.  The system update that checks for ROMs is a separate entry in the crontab.   You can add your own scripts to the cron.daily, cron.hourly, and similar directories and they will be run at the given time.   If you want times other than what ZooKeeper provides, use the Advanced button to add your own crontab entries. 

If you screw up the cron files, erase all cron files from /system/etc and erase the /Cron directory and re-run ZooKeeper.  You'll have to reinstall any customizations, but erasing it all will cause ZooKeeper to install the default files with the correct permissions.   The text editor from FX File Manager is what I used to test, and it works flawlessly!