From 52efda141fcfc7c660dfbebb2a59542a7140a38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Tue, 1 Mar 2011 08:18:22 +0200 Subject: [PATCH 1/4] RSS: Just set the lastBuildDate, not channel pubDate. --- distrib/build_event.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/distrib/build_event.py b/distrib/build_event.py index 1c29edb766..c1717fb6fe 100644 --- a/distrib/build_event.py +++ b/distrib/build_event.py @@ -217,9 +217,8 @@ def update_feed(): print >> out, 'Automated binary builds of the Doomsday Engine.' print >> out, 'en-us' print >> out, 'skyjake@users.sourceforge.net (Jaakko Keränen)' - print >> out, '%s' % time.strftime(RFC_TIME, + print >> out, '%s' % time.strftime(RFC_TIME, time.gmtime(find_newest_build()['time'])) - print >> out, '%s' % time.strftime(RFC_TIME, time.gmtime()) print >> out, 'dengBot' print >> out, '720' # 12 hours From 29f8ef9c182e0fd31cf3ebdf0e4f1baa87aaa030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Tue, 1 Mar 2011 09:00:14 +0200 Subject: [PATCH 2/4] RSS: Fine-tuning. There were a couple of problems with the RSS feed. Most importantly, the build event timestamps were not properly determined. Also, now each item has a link to the index.html page of the build, meaning links such as http://code.iki.fi/builds/build59/ are valid. The build description was made a bit prettier. --- distrib/build_event.py | 73 +++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/distrib/build_event.py b/distrib/build_event.py index c1717fb6fe..5647a417f8 100644 --- a/distrib/build_event.py +++ b/distrib/build_event.py @@ -11,7 +11,7 @@ import time import glob -FILES_URI = "http://code.iki.fi/builds" +BUILD_URI = "http://code.iki.fi/builds" RFC_TIME = "%a, %d %b %Y %H:%M:%S +0000" @@ -50,13 +50,25 @@ def remote_copy(src, dst): os.system('scp %s %s' % (src, dst)) +def build_timestamp(tag): + path = os.path.join(EVENT_DIR, tag) + oldest = os.stat(path).st_ctime + + for fn in os.listdir(path): + t = os.stat(os.path.join(path, fn)) + if int(t.st_ctime) < oldest: + oldest = int(t.st_ctime) + + return oldest + + def find_newest_build(): newest = None for fn in os.listdir(EVENT_DIR): if fn[:5] != 'build': continue - s = os.stat(os.path.join(EVENT_DIR, fn)) - if newest is None or newest[0] < s.st_ctime: - newest = (s.st_ctime, fn) + bt = build_timestamp(fn) + if newest is None or newest[0] < bt: + newest = (bt, fn) if newest is None: return {'tag': None, 'time': time.time()} return {'tag': newest[1], 'time': newest[0]} @@ -66,14 +78,13 @@ def builds_by_time(): builds = [] for fn in os.listdir(EVENT_DIR): if fn[:5] == 'build': - s = os.stat(os.path.join(EVENT_DIR, fn)) - builds.append((int(s.st_ctime), fn)) + builds.append((build_timestamp(fn), fn)) builds.sort() builds.reverse() return builds -def encoded_build_description(name): +def html_build_description(name, encoded=True): buildDir = os.path.join(EVENT_DIR, name) msg = '' @@ -91,8 +102,16 @@ def encoded_build_description(name): else: s = '' msg += '

%i file%s available:

' else: @@ -102,9 +121,15 @@ def encoded_build_description(name): msg += '

Build Logs

' # Changes. @@ -112,7 +137,9 @@ def encoded_build_description(name): if os.path.exists(chgFn): msg += '

Revisions

' + file(chgFn, 'rt').read() - return '' + if encoded: return '' + + return msg def todays_build_tag(): @@ -202,6 +229,19 @@ def todays_platform_release(): git_checkout('master') +def write_index_html(tag): + f = file(os.path.join(EVENT_DIR, tag, 'index.html'), 'wt') + print >> f, "" + print >> f, "Build %s" % tag[5:] + print >> f, "" + print >> f, "

Build %s

" % tag[5:] + print >> f, "

The build event was started on %s.

" % (time.strftime(RFC_TIME, + time.gmtime(build_timestamp(tag)))) + print >> f, html_build_description(tag, False) + print >> f, "" + print >> f, "" + + def update_feed(): feedName = os.path.join(EVENT_DIR, "events.rss") print "Updating feed in %s..." % feedName @@ -213,7 +253,7 @@ def update_feed(): print >> out, 'Doomsday Engine Builds' print >> out, 'http://dengine.net/' - print >> out, '' + print >> out, '' % BUILD_URI print >> out, 'Automated binary builds of the Doomsday Engine.' print >> out, 'en-us' print >> out, 'skyjake@users.sourceforge.net (Jaakko Keränen)' @@ -225,11 +265,14 @@ def update_feed(): for timestamp, tag in builds_by_time(): print >> out, '' print >> out, 'Build %s' % tag[5:] + print >> out, '%s/%s/' % (BUILD_URI, tag) print >> out, 'skyjake@users.sourceforge.net (skyjake)' print >> out, '%s' % time.strftime(RFC_TIME, time.gmtime(timestamp)) - print >> out, '%s' % encoded_build_description(tag) + print >> out, '%s' % html_build_description(tag) print >> out, '%s' % tag print >> out, '' + + write_index_html(tag) # Close. print >> out, '' From a7fb69c9b6c2ff0b252de9676256b850b27567b8 Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 1 Mar 2011 20:09:41 +0200 Subject: [PATCH 3/4] Revised apt repository generation to accommodate multiple archs. --- distrib/build_event.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/distrib/build_event.py b/distrib/build_event.py index 5647a417f8..5dc76134a8 100644 --- a/distrib/build_event.py +++ b/distrib/build_event.py @@ -21,6 +21,7 @@ EVENT_DIR = sys.argv[2] #/Users/jaakko/Builds DISTRIB_DIR = sys.argv[3] #/Users/jaakko/Projects/deng +LOCAL_APT_DIR = '/home/jaakko/builds-apt' def git_checkout(ident): @@ -280,37 +281,16 @@ def update_feed(): def rebuild_apt_repository(): - aptDir = os.path.join(EVENT_DIR, 'apt') + aptDir = LOCAL_APT_DIR print 'Rebuilding the apt repository in %s...' % aptDir - # Empty the apt directory. - if os.path.exists(aptDir): - shutil.rmtree(aptDir, True) - os.mkdir(aptDir) - - # Copy the packages (preserving metadata). - binDir = os.path.join(aptDir, 'binary') - os.mkdir(binDir) - for timestamp, tag in builds_by_time(): - for debName in glob.glob(os.path.join(EVENT_DIR, tag, '*.deb')): - shutil.copy2(debName, os.path.join(binDir, os.path.basename(debName))) - - # Generate the apt package index. - distsDir = os.path.join(aptDir, 'dists/unstable/main/binary-i386') - os.makedirs(distsDir) - os.chdir(aptDir) - os.system("dpkg-scanpackages -a i386 binary /dev/null > %s" % os.path.join(distsDir, 'Packages')) - os.chdir(distsDir) - os.system("gzip -9 Packages") - - f = file('Release', 'wt') - print >> f, 'Archive: unstable' - print >> f, 'Component: main' - print >> f, 'Origin: skyjake@users.sourceforge.net' - print >> f, 'Label: Automated Doomsday Engine Builds' - print >> f, 'Architecture: i386' - f.close() - + os.system("apt-ftparchive generate ~/Dropbox/APT/ftparchive.conf") + os.system("apt-ftparchive -c ~/Dropbox/APT/ftparchive-release.conf release %s/dists/unstable > %s/dists/unstable/Release" % (LOCAL_APT_DIR, LOCAL_APT_DIR)) + os.chdir("%s/dists/unstable" % LOCAL_APT_DIR) + os.remove("Release.gpg") + os.system("gpg --output Release.gpg -ba Release") + os.system("~/Dropbox/Scripts/mirror-tree.py %s %s" % (LOCAL_APT_DIR, os.path.join(EVENT_DIR, 'apt'))) + if sys.argv[1] == 'create': create_build_event() From 1308ba5ccc4df40fec5c0124d859580e6b86c7c5 Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 1 Mar 2011 20:25:24 +0200 Subject: [PATCH 4/4] Moving deb packages to the apt repository. --- distrib/build_event.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/distrib/build_event.py b/distrib/build_event.py index 5dc76134a8..7e5c57a9b8 100644 --- a/distrib/build_event.py +++ b/distrib/build_event.py @@ -15,13 +15,16 @@ RFC_TIME = "%a, %d %b %Y %H:%M:%S +0000" -if len(sys.argv) != 4: - print 'The arguments must be: (command) (eventdir) (distribdir)' +if len(sys.argv) < 4: + print 'The arguments must be: (command) (eventdir) (distribdir) [localaptdir]' sys.exit(1) EVENT_DIR = sys.argv[2] #/Users/jaakko/Builds DISTRIB_DIR = sys.argv[3] #/Users/jaakko/Projects/deng -LOCAL_APT_DIR = '/home/jaakko/builds-apt' +if len(sys.argv) > 4: + APT_REPO_DIR = sys.argv[4] +else: + APT_REPO_DIR = '' def git_checkout(ident): @@ -220,6 +223,13 @@ def todays_platform_release(): # Copy any new files. remote_copy(os.path.join('releases', n), os.path.join(EVENT_DIR, todays_build_tag(), n)) + + if APT_REPO_DIR: + # Copy also to the appropriate apt directory. + arch = 'i386' + if '_amd64' in n: arch = 'amd64' + remote_copy(os.path.join('releases', n), + os.path.join(APT_REPO_DIR, 'dists/unstable/main/binary-%s' % arch, n)) # Also the build log. remote_copy('buildlog.txt', os.path.join(EVENT_DIR, todays_build_tag(), @@ -281,15 +291,15 @@ def update_feed(): def rebuild_apt_repository(): - aptDir = LOCAL_APT_DIR + aptDir = APT_REPO_DIR print 'Rebuilding the apt repository in %s...' % aptDir os.system("apt-ftparchive generate ~/Dropbox/APT/ftparchive.conf") - os.system("apt-ftparchive -c ~/Dropbox/APT/ftparchive-release.conf release %s/dists/unstable > %s/dists/unstable/Release" % (LOCAL_APT_DIR, LOCAL_APT_DIR)) - os.chdir("%s/dists/unstable" % LOCAL_APT_DIR) + os.system("apt-ftparchive -c ~/Dropbox/APT/ftparchive-release.conf release %s/dists/unstable > %s/dists/unstable/Release" % (aptDir, aptDir)) + os.chdir("%s/dists/unstable" % aptDir) os.remove("Release.gpg") os.system("gpg --output Release.gpg -ba Release") - os.system("~/Dropbox/Scripts/mirror-tree.py %s %s" % (LOCAL_APT_DIR, os.path.join(EVENT_DIR, 'apt'))) + os.system("~/Dropbox/Scripts/mirror-tree.py %s %s" % (aptDir, os.path.join(EVENT_DIR, 'apt'))) if sys.argv[1] == 'create':