[GTK] ensure the jhbuild used by webkit is as up-to-date as needed
authorkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 02:45:15 +0000 (02:45 +0000)
committerkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2012 02:45:15 +0000 (02:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76585

Reviewed by Martin Robinson.

This allows us to specify a minimum version of jhbuild required,
while also providing stability against changes done to the master
branch, by letting us choose what is the exact version that will
be used.

* gtk/run-with-jhbuild: refactored for more hackability and easier
reading
(jhbuild_installed): checks whether jhbuild is installed
(jhbuild_cloned): checks whether jhbuild has been cloned
(jhbuild_at_expected_revision): checks whether jhbuild is at the
expected revision
(update_jhbuild): brings jhbuild to the expected revision
(clone_jhbuild): clones jhbuild
(install_jhbuild): build and installs jhbuild
(update_webkitgtk_libs): runs update-webkitgtk-libs
(ensure_jhbuild): high-level logic to decide whether and which of
the steps above are executed

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105472 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/gtk/run-with-jhbuild

index eb64114..aae2b42 100644 (file)
@@ -1,3 +1,28 @@
+2012-01-19  Gustavo Noronha Silva  <gns@gnome.org>
+
+        [GTK] ensure the jhbuild used by webkit is as up-to-date as needed
+        https://bugs.webkit.org/show_bug.cgi?id=76585
+
+        Reviewed by Martin Robinson.
+
+        This allows us to specify a minimum version of jhbuild required,
+        while also providing stability against changes done to the master
+        branch, by letting us choose what is the exact version that will
+        be used.
+
+        * gtk/run-with-jhbuild: refactored for more hackability and easier
+        reading
+        (jhbuild_installed): checks whether jhbuild is installed
+        (jhbuild_cloned): checks whether jhbuild has been cloned
+        (jhbuild_at_expected_revision): checks whether jhbuild is at the
+        expected revision
+        (update_jhbuild): brings jhbuild to the expected revision
+        (clone_jhbuild): clones jhbuild
+        (install_jhbuild): build and installs jhbuild
+        (update_webkitgtk_libs): runs update-webkitgtk-libs
+        (ensure_jhbuild): high-level logic to decide whether and which of
+        the steps above are executed
+
 2012-01-19  Alexey Proskuryakov  <ap@apple.com>
 
         [WK2] DumpRenderTree converts "file:///" to a path differently
index 9dc6ffd..3ce48c5 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # Copyright (C) 2011 Igalia S.L.
+# Copyright (C) 2012 Gustavo Noronha Silva <gns@gnome.org>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -20,22 +21,59 @@ import os
 import subprocess
 import sys
 
-def install_and_run_jhbuild():
-    installation_prefix = os.path.abspath(common.top_level_path('WebKitBuild', 'Dependencies', 'Root'))
-    source_path = os.path.abspath(common.top_level_path('WebKitBuild', 'Dependencies', 'Source'))
-    jhbuild_source_path = os.path.join(source_path, 'jhbuild')
 
+jhbuild_revision = '1eedc423f75c605224b430579e4c303292199507'
+
+installation_prefix = os.path.abspath(common.top_level_path('WebKitBuild', 'Dependencies', 'Root'))
+source_path = os.path.abspath(common.top_level_path('WebKitBuild', 'Dependencies', 'Source'))
+jhbuild_source_path = os.path.join(source_path, 'jhbuild')
+jhbuild_path = common.top_level_path('WebKitBuild', 'Dependencies', 'Root', 'bin', 'jhbuild')
+
+
+def jhbuild_installed():
+    return os.path.exists(jhbuild_path)
+
+
+def jhbuild_cloned():
+    return os.path.exists(jhbuild_source_path)
+
+
+def jhbuild_at_expected_revision():
+    process = subprocess.Popen(['git', 'rev-list', 'HEAD^..'], cwd=jhbuild_source_path,
+                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    output, err = process.communicate()
+    if process.returncode != 0:
+        raise Exception('failed to find jhbuild revision: %s' % err)
+
+    return output.strip() == jhbuild_revision
+
+
+def update_jhbuild():
+    process = subprocess.Popen(['git', 'remote', 'update', 'origin'], cwd=source_path)
+    process.wait()
+    if process.returncode != 0:
+        raise Exception('jhbuild remote update origin failed with return code: %i' % process.returncode)
+
+    process = subprocess.Popen(['git', 'checkout', '%s' % jhbuild_revision],
+                               cwd=jhbuild_source_path)
+    process.wait()
+    if process.returncode != 0:
+        raise Exception('failed to checkout treeish %s: %i' % (jhbuild_revision, process.returncode))
+
+
+def clone_jhbuild():
     if not os.path.exists(source_path):
         os.makedirs(source_path)
     if not os.path.exists(installation_prefix):
         os.makedirs(installation_prefix)
 
-    if not os.path.exists(jhbuild_source_path):
-        process = subprocess.Popen(['git', 'clone', 'git://git.gnome.org/jhbuild'], cwd=source_path)
-        process.wait()
-        if process.returncode != 0:
-            raise Exception('jhbuild git clone failed with return code: %i' % process.returncode)
+    process = subprocess.Popen(['git', 'clone', 'git://git.gnome.org/jhbuild'], cwd=source_path)
+    process.wait()
+    if process.returncode != 0:
+        raise Exception('jhbuild git clone failed with return code: %i' % process.returncode)
+
 
+def install_jhbuild():
     # jhbuild is really unhappy about having MAKE defined to something like 'make -j4'
     # so we just undefine it here.
     env_without_make = dict(os.environ)
@@ -53,14 +91,28 @@ def install_and_run_jhbuild():
     if process.returncode != 0:
         raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
 
+
+def update_webkitgtk_libs():
     process = subprocess.Popen(common.top_level_path('Tools', 'Scripts', 'update-webkitgtk-libs'))
     process.wait()
     if process.returncode != 0:
         raise Exception('jhbuild configure failed with return code: %i' % process.returncode)
 
-jhbuild_path = common.top_level_path('WebKitBuild', 'Dependencies', 'Root', 'bin', 'jhbuild')
-if not os.path.exists(jhbuild_path):
-    install_and_run_jhbuild()
+
+def ensure_jhbuild():
+    if not jhbuild_cloned():
+        clone_jhbuild()
+        update_jhbuild()
+        install_jhbuild()
+        update_webkitgtk_libs()
+    elif not jhbuild_installed() \
+            or not jhbuild_at_expected_revision():
+        update_jhbuild()
+        install_jhbuild()
+
+
+ensure_jhbuild()
+
 
 process = subprocess.Popen([jhbuild_path, '--no-interact', '-f', common.top_level_path('Tools', 'gtk', 'jhbuildrc'), 'run'] + sys.argv[1:])
 process.wait()