[SCM] debian-live/autotesting branch, master, updated. 7c25c59dad103a42f95d2fc6fb4cb4ce42fa3344

Brendan M. Sleight (none) bms at brum.
Tue May 18 21:56:45 UTC 2010


The following commit has been merged in the master branch:
commit 22d810c93e75e7db2487a088d472ab4e40332896
Author: Brendan M. Sleight <bms at brum.(none)>
Date:   Tue May 18 22:57:26 2010 +0100

    Adding autobuild script (python not sh for some reason)

diff --git a/examples/build-daily-bleeding-edge.py b/examples/build-daily-bleeding-edge.py
new file mode 100644
index 0000000..56bc283
--- /dev/null
+++ b/examples/build-daily-bleeding-edge.py
@@ -0,0 +1,237 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+
+# Depends: python, python-amara, wget, python-twitter, git-core, dpkg-dev, apache2-mpm-prefork
+# backports debhelper 
+
+# Build daily standard
+
+# 2 - build iso -> daily-standard + (tweet!)
+#   mkdir
+#   lh config -d sid --repositories live.debian.net --packages-lists standard
+#   lh build
+#   mv 
+# 3 - Download git and build and install
+# 4 - Build iso -> Bleeding edge  + (tweet!)
+# 5 - Test
+# 6 - Remove live-helper
+# 7 - install live-helper from live.debian.net 
+# 8 - ???
+# 9 - Profit
+
+# <dba> bmsleight: git clone git://live.debian.net/git/live-helper.git
+# cd live-helper
+# <dba> git checkout -b debian-next origin/debian-next
+
+
+from optparse import OptionParser
+import amara, datetime, os, shutil, subprocess, sys, tempfile, time, datetime, urllib, twitter, fcntl, glob
+
+class SingleInstance:
+    # Slimed down from excellent example given at:-
+    # http://stackoverflow.com/questions/380870/python-single-instance-of-program
+    def __init__(self):
+        self.lockfile = os.path.normpath(tempfile.gettempdir() + '/' + os.path.basename(__file__) + '.lock')
+        self.fp = open(self.lockfile, 'w')
+        try:
+            fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
+        except IOError:
+            log("Another copy of this script is already is already running, quitting.")
+            sys.exit(-1)
+
+def log(message):
+    """ Print [date] message """ 
+    now = datetime.datetime.now()
+    print "[" + str(now) + "] " + str(message) 
+    sys.stdout.flush()
+
+
+def parseTwitter(xml):
+    """ Get the xml file and load as a object using amara
+    returns amaraObject"""
+    twit = amara.parse(xml)
+    return twit.autotesting.twitter
+
+
+def wget(url, limit):
+    """ Use wget to download a file
+    return fileObject"""
+    # --limit-rate=4M
+    log("Downloading " + url)
+    tmpFile = tempfile.NamedTemporaryFile(prefix="autotesting_wget_")
+    L = ['wget', '-nv', str(url), '-O', tmpFile.name]
+    if limit == True:
+        L.append('--limit-rate=1.5M')
+    # Maybe do something with the retcode in the future.
+    retcode = subprocess.call(L)
+    return tmpFile
+
+def tiny_url(url):
+    apiurl = "http://tinyurl.com/api-create.php?url="
+    tinyurl = urllib.urlopen(apiurl + url).read()
+    return tinyurl
+
+def storeFile(tmpFile, copyLocation, symLocation):
+    if tmpFile:
+        shutil.copyfile(tmpFile, copyLocation)
+    try:
+        os.remove(symLocation)
+    except:
+        pass
+    os.symlink(copyLocation, symLocation)
+
+def mkdir(d):
+    try:
+        os.makedirs(d)
+    except:
+        pass
+
+def parseBuilds(xml):
+    builds = amara.parse(xml)
+    return builds.autotesting.builds
+
+def postTweet(twit, message, long_url=False):
+    if long_url:
+        tiny=tiny_url(long_url) 
+        tweet = message[:120] + "... " + str(tiny)
+    else:
+        tweet = message[:139]
+    try:
+        api = twitter.Api(username=str(twit.user), password=str(twit.passw) )
+        status = api.PostUpdate(tweet)
+        log("Tweet: " + tweet)
+    except:
+        log("Tweeting failed! " + tweet)
+
+
+def igore():
+    tweet =  "Autotesting of: " + str(test.description)[:90] + "... " + str(tiny)
+    api = twitter.Api(username=str(twit.user), password=str(twit.passw) )
+    status = api.PostUpdate(tweet)
+
+
+def log_process(c, cwd="/tmp/", storeLog=False, shell=False):
+    p = subprocess.Popen(c,
+                       stdin=subprocess.PIPE,
+                       stdout=subprocess.PIPE,
+                       stderr=subprocess.STDOUT,
+                       cwd=cwd)
+    (stdout, stderr) = p.communicate()
+    log(stdout)
+    if storeLog:
+        f = open(storeLog,"w")
+        f.write(stdout)
+        f.close()
+    return stdout
+
+def git_live_helper():
+    tempDir = tempfile.mkdtemp(prefix="autobuild_git_", suffix="_dir")
+    log("Building lh from git")
+    log_process(["git", "clone", "git://live.debian.net/git/live-helper.git"], tempDir)
+    log_process(["git", "checkout", "-b", "debian-next", "origin/debian-next"], tempDir + "/live-helper")
+    log_process(["dpkg-buildpackage", "-us", "-uc", "-rfakeroot"], tempDir + "/live-helper")    
+    debs = glob.glob(tempDir + "/*.deb")
+    for deb in debs:
+        log_process(["dpkg", "-i", deb], tempDir)
+    shutil.rmtree(tempDir)
+
+def remove_git_live():
+    #dpkg -r live-helper
+    log("Remove lh (git) and install lh from live.debian.net")
+    log_process(["dpkg", "-r", "live-helper"])
+    log_process(["apt-get", "update"])
+    log_process(["apt-get", "install", "live-helper"])
+
+
+def builds(buildsXML, moveDir, prefix, twit):
+    for d in buildsXML.distributions.distribution:
+        for p in buildsXML.package_lists.package_list:
+            build(d, p, moveDir, prefix, twit)
+
+def build(d, packageList, moveDir, prefix, twit):
+#   mkdir
+#   lh config -d sid --repositories live.debian.net --packages-lists standard
+#   lh build
+#   mv 
+    ISO_NAME = "binary-hybrid.iso"
+    tempDir = tempfile.mkdtemp(prefix="autobuild_iso_", suffix="_dir")
+    lh = ["lh", "config", "-d", str(d), 
+          "--repositories", "live.debian.net", "--packages-lists",
+          str(packageList)]
+    log_process(lh, tempDir, tempDir + "/config.log")
+    log_process(["lh", "build"], tempDir, tempDir + "/build.log")
+
+    today=str(datetime.date.today())
+    todayDir = moveDir + "/" + today + "/"
+    mkdir(todayDir)
+    currentDir = moveDir + "/current/"
+    mkdir(currentDir)
+    shortPrefix = prefix + str(d) + "-" + str(packageList) + "-"
+    todayPrefix = todayDir + shortPrefix
+    currentPrefix = currentDir + shortPrefix
+    
+    # Now this is ugly... why not /bin/sh instead of python ??
+    # Now that I've written it looks bad, real bad...
+    stores = ["build.log", "config.log", "binary-hybrid.iso", "binary.list", "binary.packages"]
+    for store in stores:
+        try:
+            storeFile(tempDir + "/" + store, todayPrefix + store, currentPrefix + store)
+        except:
+            log("Error copying " + store)
+    try:
+        log_process(["md5sum", shortPrefix + "binary-hybrid.iso" ], 
+                    todayDir, todayPrefix + "binary-hybrid.iso.md5sum" )
+        # Now this is ugly... why not /bin/sh instead of python ??
+        storeFile(False, todayPrefix + "binary-hybrid.iso.md5sum",
+                  currentPrefix + "binary-hybrid.iso.md5sum")
+    except:
+        log("Error making MD5SUM")
+
+    if twit:
+        long_url=str(twit.hosting.url) + "/" + today + "/"
+        message = "Autobuild Debian-Live, (" + prefix + ") " + str(d) + " " + str(packageList) + " "
+        postTweet(twit, message, long_url=long_url)
+    shutil.rmtree(tempDir)
+
+    # Remove old builds
+    keepDate = datetime.datetime.now() - datetime.timedelta(days=4)
+    log("Removing old Builds before " + keepDate.strftime("%A %B %d %I:%M:%S %p %Y"))
+    for f in os.listdir(moveDir):
+        fp = moveDir + f
+        if (time.mktime(keepDate.timetuple()) - os.path.getmtime(fp) ) > 0:
+            # Remove the old file
+            shutil.rmtree(fp)
+            log("Removing - " + fp)
+
+
+def main():
+    usage = "usage: %prog [options] \n       %prog --help for all options"
+    parser = OptionParser(usage, version="%prog ")
+    parser.add_option("-b", "--builds", dest="builds",
+                      help="complete the builds in the xml template")
+    parser.add_option("-l", "--limit", action="store_true", dest="limit",
+                      help="Limit download rates to 4M")
+    parser.add_option("-w", "--twitter", dest="twit",
+                      help="Tweet after each build is completed, accordig to the setting in xml template")
+    (options, args) = parser.parse_args() 
+    if not options.builds:
+        parser.error("Must pass a list of builds to complete.")
+    if options.twit:
+        twit = parseTwitter(options.twit)
+    else:
+        twit = False
+    
+    # Only one instance of ME should be running.
+    me = SingleInstance()
+    # Main loop
+    buildsXML = parseBuilds(options.builds)
+    wwwRoot = "/var/www/autobuild/debian-live/"
+    builds(buildsXML, wwwRoot, "live-snapshot-", twit)
+    git_live_helper()
+    builds(buildsXML, wwwRoot, "git-debian-next-", twit)
+    remove_git_live()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/examples/build.xml b/examples/build.xml
new file mode 100644
index 0000000..a33857a
--- /dev/null
+++ b/examples/build.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<autotesting>
+  <builds>
+    <distributions>
+      <distribution>sid</distribution>
+    </distributions>
+    <package_lists>
+      <package_list>standard</package_list>
+    </package_lists>
+  </builds>
+</autotesting>
diff --git a/examples/crontab b/examples/crontab
new file mode 100644
index 0000000..ed05f9d
--- /dev/null
+++ b/examples/crontab
@@ -0,0 +1 @@
+0  2   *   *   * /usr/bin/autotesting --test=/usr/share/autotesting/tests/full.xml --twitter=/home/autotesting/twitter.xml -l  >/var/log/autotesting/autotesting.log 2>&1
diff --git a/examples/rough-notes.txt b/examples/rough-notes.txt
new file mode 100644
index 0000000..fa93981
--- /dev/null
+++ b/examples/rough-notes.txt
@@ -0,0 +1,16 @@
+
+# Build daily standard
+# 1 - cron-apt
+# 2 - build iso -> daily-standard + (tweet!)
+# 3 - Download git and build and install
+# 4 - Build iso -> Bleeding edge  + (tweet!)
+# 5 - Test
+# 6 - Remove live-helper
+# 7 - install live-helper from live.debian.net 
+# 8 - ???
+# 9 - Profit
+
+# <dba> bmsleight: git clone git://live.debian.net/git/live-helper.git
+# <dba> git checkout -b debian-next origin/debian-next
+# <niktaris> dba, updated live-initramfs + live-sysvinit from live.debian.net. Do I need to add it in chroot/config/* someplace too ?
+# <dba> (or, if you have git >=1.7, you can also just do a 'git checkout debian-next' instead of the 'git checkout -b debian-next origin/debian-next')
diff --git a/tests-source/build-60alpha1-i386-iso-hybrid-xfce-daily.xml b/tests-source/build-60alpha1-i386-iso-hybrid-lxde-desktop-daily.xml
similarity index 80%
copy from tests-source/build-60alpha1-i386-iso-hybrid-xfce-daily.xml
copy to tests-source/build-60alpha1-i386-iso-hybrid-lxde-desktop-daily.xml
index 78d65c3..91a48ef 100644
--- a/tests-source/build-60alpha1-i386-iso-hybrid-xfce-daily.xml
+++ b/tests-source/build-60alpha1-i386-iso-hybrid-lxde-desktop-daily.xml
@@ -1,6 +1,7 @@
 <autotesting>
   <merge>
     <common>common-squeeze-build.xml</common>
+    <qemu>qemu.xml</qemu>
     <processors>
       <processor>processor-i386.xml</processor>
     </processors>
@@ -8,7 +9,7 @@
       <image>images-iso-hybrid.xml</image>
     </images>
     <packages>
-      <package>packages-xfce.xml</package>
+      <package>packages-lxde-desktop.xml</package>
     </packages>
     <frequency>frequency-daily.xml</frequency>
   </merge>
diff --git a/tests-source/parts/packages-xfce.xml b/tests-source/parts/packages-lxde-desktop.xml
similarity index 68%
copy from tests-source/parts/packages-xfce.xml
copy to tests-source/parts/packages-lxde-desktop.xml
index cbc6a20..5e189ca 100644
--- a/tests-source/parts/packages-xfce.xml
+++ b/tests-source/parts/packages-lxde-desktop.xml
@@ -1,7 +1,7 @@
 <autotesting>
   <common>
       <packages>
-        <package>xfce-desktop</package>
+        <package>lxde-desktop</package>
       </packages>
   </common>
 </autotesting>
diff --git a/tests-source/parts/qemu-powerpc.xml b/tests-source/parts/qemu-powerpc.xml
new file mode 100644
index 0000000..4b213df
--- /dev/null
+++ b/tests-source/parts/qemu-powerpc.xml
@@ -0,0 +1,10 @@
+<autotesting>
+  <common>
+    <qemu>
+      <xscreen>1024x768x16</xscreen>
+      <pause>10</pause>
+      <sendkeys>b,o,o,t,spc,c,d,r,o,m,shift-semicolon,kp_enter,kp_enter</sendkeys>
+      <time>900</time>
+    </qemu>
+  </common>
+</autotesting>
diff --git a/tests-source/parts/qemu.xml b/tests-source/parts/qemu.xml
new file mode 100644
index 0000000..9ca3c0d
--- /dev/null
+++ b/tests-source/parts/qemu.xml
@@ -0,0 +1,10 @@
+<autotesting>
+  <common>
+    <qemu>
+      <xscreen>1024x768x16</xscreen>
+      <pause>10</pause>
+      <sendkeys>kp_enter</sendkeys>
+      <time>900</time>
+    </qemu>
+  </common>
+</autotesting>
diff --git a/tests/autobuilds.xml b/tests/autobuilds.xml
new file mode 100644
index 0000000..9c58d85
--- /dev/null
+++ b/tests/autobuilds.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<autotesting>
+  <tests>
+    <test>
+      <download>
+        <url>http://autobuild.livecd.org/autobuild/debian-live/current/live-snapshot-sid-standard-binary-hybrid.iso</url>
+        <md5sum>http://autobuild.livecd.org/autobuild/debian-live/current/live-snapshot-sid-standard-binary-hybrid.iso.md5sum</md5sum>
+      </download>
+      <title>Debian Live Autobuild</title>
+      <description>Debian Live. Autobuild. Using lh snapshots at live.debian.net.[Sid Standard]</description>
+      <background>http://live.debian.net/image.png</background>
+      <frequency>daily</frequency>
+      <qemu>
+        <xscreen>1024x768x16</xscreen>
+        <binary>qemu-system-i386</binary>
+        <options>-cdrom</options>
+        <pause>10</pause>
+        <sendkeys>kp_enter</sendkeys>
+        <time>600</time>
+      </qemu>
+      <output>
+        <keep>4</keep>
+        <root>/var/www/autotesting/</root>
+        <video>autotesting.ogv</video>
+        <local>debian-live/autobuild/sid/standard/</local>
+        <screenshots>
+          <final>final-screenshot.png</final>
+          <montage>montage-of-video-frames.png</montage>
+        </screenshots>
+      </output>
+    </test>
+    <test>
+      <download>
+        <url>http://autobuild.livecd.org/autobuild/debian-live/current/git-debian-next-sid-standard-binary-hybrid.iso</url>
+        <md5sum>http://autobuild.livecd.org/autobuild/debian-live/current/git-debian-next-sid-standard-binary-hybrid.iso.md5sum</md5sum>
+      </download>
+      <title>Debian Live Autobbuild</title>
+      <description>Debian Live. Autobuild. Using lh from git debian-next branch [Sid Standard]</description>
+      <background>http://live.debian.net/image.png</background>
+      <frequency>daily</frequency>
+      <qemu>
+        <xscreen>1024x768x16</xscreen>
+        <binary>qemu-system-i386</binary>
+        <options>-cdrom</options>
+        <pause>10</pause>
+        <sendkeys>kp_enter</sendkeys>
+        <time>600</time>
+      </qemu>
+      <output>
+        <keep>4</keep>
+        <root>/var/www/autotesting/</root>
+        <video>autotesting.ogv</video>
+        <local>debian-live/autobuild/sid/standard/</local>
+        <screenshots>
+          <final>final-screenshot.png</final>
+          <montage>montage-of-video-frames.png</montage>
+        </screenshots>
+      </output>
+    </test>
+  </tests>
+</autotesting>

-- 
debian-live/autotesting



More information about the debian-live-changes mailing list