Reworked devserver so that update images generated are cached in directories named after
the md5 hashes of the images used to generate the updates. Only the 12 most recent deltas
are preserved. All deltas generated (outside of the factory codepath) are modified.
The purpose of this is to speed up delta generation during automated tests, especially when
running autotest and/or ctest.
autoupdate.py has been refactored in a number of small ways.
All of the Generate methods now return the name of the update generated (or retrieved from
cache), instead of the update file being assumed to be static/update.gz.
Update files are now created directly in the cache directories instead of in the image
directory and then copied.
--clear_cache has been added to devserver.py to force clearing of all cached update values.
--use_cached no longer does anything, but has not yet been removed. It appears to be
intended to force the use of static/update.gz, but I can't find any cases where it's used.
TEST=The autoupdate unit test has been udpated and is passing.
./image_to_live.sh has been tested by hand with both full image and delta updates.
./ctest can run successfully.
BUG=chromium-os:8207 (early prep)
Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=710470d
Review URL: http://codereview.chromium.org/4906001
Change-Id: If2d358c7edab7840ffea479d5b31ef7b8ab81217
diff --git a/devserver.py b/devserver.py
index 8abdb8f..26c542f 100755
--- a/devserver.py
+++ b/devserver.py
@@ -13,6 +13,8 @@
import autoupdate
+CACHED_ENTRIES=12
+
# Sets up global to share between classes.
global updater
updater = None
@@ -113,6 +115,8 @@
help='serve archived builds only.')
parser.add_option('--board', dest='board',
help='When pre-generating update, board for latest image.')
+ parser.add_option('--clear_cache', action="store_true", default=False,
+ help='Clear out all cached udpates and exit')
parser.add_option('--client_prefix', dest='client_prefix',
help='Required prefix for client software version.',
default='MementoSoftwareUpdate')
@@ -131,8 +135,6 @@
parser.add_option('-t', action='store_true', dest='test_image')
parser.add_option('-u', '--urlbase', dest='urlbase',
help='base URL, other than devserver, for update images.')
- parser.add_option('--use_cached', action="store_true", default=False,
- help='Prefer cached image regardless of timestamps.')
parser.add_option('--validate_factory_config', action="store_true",
dest='validate_factory_config',
help='Validate factory config file, then exit.')
@@ -151,6 +153,22 @@
static_dir = os.path.realpath('%s/static' % devserver_dir)
os.system('mkdir -p %s' % static_dir)
+ cache_dir = os.path.join(static_dir, 'cache')
+ cherrypy.log('Using cache directory %s' % cache_dir, 'DEVSERVER')
+
+ if options.clear_cache:
+ # Clear the cache and exit
+ sys.exit(os.system('sudo rm -rf %s' % cache_dir))
+
+ if os.path.exists(cache_dir):
+ # Clear all but the last N cached updates
+ cmd = ('cd %s; ls -1tr | head --lines=-%d | xargs rm -rf' %
+ (cache_dir, CACHED_ENTRIES))
+ if os.system(cmd) != 0:
+ cherrypy.log('Failed to clean up old delta cache files with %s' % cmd,
+ 'DEVSERVER')
+ sys.exit(1)
+
cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER')
cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER')
@@ -163,7 +181,6 @@
factory_config_path=options.factory_config,
client_prefix=options.client_prefix,
forced_image=options.image,
- use_cached=options.use_cached,
port=options.port,
src_image=options.src_image,
vm=options.vm,