update output directory to match snapshots.l.o organization

instead of putting pre-builts in their own directory, they will
now get placed with the hwpack like:

 http://snapshots.linaro.org/oneiric/lt-mx5-oneiric/20120321/1/images/<file>
diff --git a/build-images.py b/build-images.py
index 30dcfe3..1def1c0 100755
--- a/build-images.py
+++ b/build-images.py
@@ -30,6 +30,7 @@
 import datetime
 import os
 import re
+import urlparse
 
 # a mapping of hwpack name to l-m-c name
 HWPACKS = {
@@ -104,6 +105,21 @@
     bz2file = compress_image(imgfile)
     zsync_image(bz2file)
 
+def get_image_dir(outdir, url):
+    '''covert a url like:
+      http://snapshots.linaro.org/oneiric/lt-origen-oneiric/20120321/1/images/hwpack/hwpack_linaro-lt-origen_20120321-1_armel_supported.tar.gz
+    to:
+     oneiric/lt-origen-oneiric/20120321/1/images
+    '''
+    path = urlparse.urlparse(url).path
+    path = os.path.dirname(path)
+    path = os.path.split(path)[0]
+
+    path = '%s/%s' % (outdir, path)
+    if not os.path.exists(path):
+        os.makedirs(path)
+    return path
+
 def main():
     day = today()
     hwpacks = HWPACKS.keys()
@@ -140,15 +156,15 @@
         binaryf[binary] = url
 
     lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir
-    odir = '%s/%s' % (args.out_dir, args.date)
-    if not os.path.exists(odir):
-        os.mkdir(odir)
+    odir_root = '%s/pre-built' % args.out_dir
 
     for hwpack in hwpacks:
         hwpackname = "%s-%s" % (hwpack, args.platform)
         url = hwpack_available(args.date, hwpack, args.platform)
 
         if url is not None and url is not False:
+            odir = get_image_dir(odir_root, url)
+
             hwpf = dm.download(url, None)
             for binary in binaries:
                 imgfile = "%s/%s-%s_%s.img" %(odir,hwpack,args.platform,binary)