diff -Nru testdrive-1.36/debian/changelog testdrive-1.37/debian/changelog --- testdrive-1.36/debian/changelog 2010-04-26 20:53:33.000000000 -0500 +++ testdrive-1.37/debian/changelog 2010-04-26 20:53:33.000000000 -0500 @@ -1,3 +1,15 @@ +testdrive (1.37-0ubuntu1) lucid; urgency=low + + [ Andres Rodriguez ] + * debian/control, testdrive, testdriverc: update the testdrive cache + at most once per week on launch, dynamically determine Ubuntu + development release and cache it, LP: #570485, #553616 + + [ Dustin Kirkland ] + * debian/control: recommend usb-creator for gtk or kde + + -- Dustin Kirkland Mon, 26 Apr 2010 20:27:54 -0500 + testdrive (1.36-0ubuntu1) lucid; urgency=low [ Vish ] diff -Nru testdrive-1.36/debian/control testdrive-1.37/debian/control --- testdrive-1.36/debian/control 2010-04-26 20:53:33.000000000 -0500 +++ testdrive-1.37/debian/control 2010-04-26 20:53:33.000000000 -0500 @@ -14,8 +14,9 @@ python, qemu-kvm | kvm ( >= 1:84+dfsg-0ubuntu12.4 ) | virtualbox-ose ( >= 3.0.8) | virtualbox-3.0 | virtualbox-3.1, rsync, - wget -Recommends: zsync, usb-creator-gtk, cpu-checker, kvm-pxe + wget, + python-launchpadlib +Recommends: zsync, usb-creator-gtk | usb-creator-kde, cpu-checker, kvm-pxe Description: run the daily Ubuntu ISO in a virtual machine Testdrive helps you download and run the daily Ubuntu development ISO in a virtual machine on your local hardware. diff -Nru testdrive-1.36/testdrive testdrive-1.37/testdrive --- testdrive-1.36/testdrive 2010-04-04 19:12:59.000000000 -0500 +++ testdrive-1.37/testdrive 2010-04-26 18:41:13.000000000 -0500 @@ -21,6 +21,7 @@ import commands, hashlib, os, string, sys, tempfile, time #import optparse from optparse import OptionParser +from launchpadlib.launchpad import Launchpad PKG = "testdrive" PKGRC = "%src" % PKG @@ -40,6 +41,8 @@ KVM_ARGS = os.getenv("KVM_ARGS", "") VBOX_NAME = os.getenv("VBOX_NAME", "") hasOptions = False +update_cache = None +codename = None def select_iso(): global ISO, CACHE_ISO @@ -146,6 +149,44 @@ kvm-ok\n\ sudo apt-get install virtualbox-ose") +def lp_obtain_release_codename(): + launchpad = Launchpad.login_anonymously('testdrive', 'production', CACHE) + return launchpad.distributions['ubuntu'].current_series.name + +def is_codename_cached(): + if not os.path.exists(CACHE): + os.makedirs(CACHE, 0700) + if not os.path.exists("%s/current" % CACHE): + return False + return True + +def is_cache_expired(): + cache_time = time.localtime(os.path.getmtime("%s/current" % CACHE)) + local_time = time.localtime() + time_difference = time.mktime(local_time) - time.mktime(cache_time) + # Check for new release at most once-per-week (60*60*24*7 = 604800) + if time_difference >= 604800: + return True + + return False + +def update_ubuntu_codename_cache(str): + try: + f = open("%s/current" % CACHE,'w') + f.write(str) + f.close + except IOError: + pass + +def get_ubuntu_codename(): + try: + f = open("%s/current" % CACHE,'r') + codename = f.read() + f.close + except IOError: + pass + return codename + ######## # Main # ######## @@ -187,6 +228,39 @@ get_virt() sys.exit(0) +if CACHE is None: + CACHE = "%s/.cache/%s" % (HOME, PKG) + +## Obtain Ubuntu Devel Release Codename ## +#Verify if the codename is cached, if not, set variable to update/create it +if is_codename_cached() is False: + update_cache = 1 +# If codename cached, verify if it is expired. If it is, set variable to update it. +elif is_cache_expired() is True: + update_cache = 1 + +# If variable set to update, obtain release from launchpad +if update_cache == 1: + info("Obtaining Ubuntu Development Release codename from Launchpad...") + try: + codename = lp_obtain_release_codename() + except: + print "ERROR: Could not obtain the Ubuntu Development Release codename from Launchpad...\n" + +# If release was obtained, update the cache file +if codename: + try: + update_ubuntu_codename_cache(codename) + except: + error("Unable to update Ubuntu Development Release codename cache.") + +# Try to retrieve Ubuntu Devel codename from cache +info("Retrieving Ubuntu Development Release codename from cache...") +try: + r = get_ubuntu_codename() +except: + error("Unable to retrieve Ubuntu Development Release codename from cache...") + # prime configuration with defaults config_files = ["/etc/%s" % PKGRC, "%s/.%s" % (HOME, PKGRC), "%s/.config/%s/%s" % (HOME, PKG, PKGRC) ] @@ -223,8 +297,8 @@ # Set defaults where undefined -if CACHE is None: - CACHE = "%s/.cache/%s" % (HOME, PKG) +#if CACHE is None: +# CACHE = "%s/.cache/%s" % (HOME, PKG) if CACHE_IMG is None: CACHE_IMG = '%s/img' % CACHE diff -Nru testdrive-1.36/testdriverc testdrive-1.37/testdriverc --- testdrive-1.36/testdriverc 2010-04-04 19:12:59.000000000 -0500 +++ testdrive-1.37/testdriverc 2010-04-26 18:34:32.000000000 -0500 @@ -57,7 +57,9 @@ # using rsync. # You can mangle or add to this list here (but you will get conffile conflicts on this # file at some point in the future upon upgrade. -r = "lucid" +# Uncomment the following line if you want to hardcode the Ubuntu release; otherwise, +# TestDrive will try to determine it dynamically. +#r = "lucid" m = ["i386"] u = "rsync://cdimage.ubuntu.com/cdimage" import platform