Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcommands/check-system5
-rwxr-xr-xcommands/run2
-rw-r--r--devbot/build.py20
-rw-r--r--devbot/config.py11
-rw-r--r--devbot/state.py19
-rw-r--r--devbot/system.py21
-rw-r--r--devbot/utils.py18
7 files changed, 67 insertions, 29 deletions
diff --git a/commands/check-system b/commands/check-system
index 6d14978..2f501c0 100755
--- a/commands/check-system
+++ b/commands/check-system
@@ -18,6 +18,8 @@ parser.add_argument("--remove", action="store_true",
help="remove all the unnecessary packages")
parser.add_argument("--test", action="store_true",
help="don't add or remove packages, test only")
+parser.add_argument("--skip-if-unchanged", action="store_true",
+ help="skip if unchanged from the last check")
args = parser.parse_args()
def apply_ubuntu_tweaks():
@@ -38,4 +40,5 @@ interactive = "SUGAR_BUILDBOT" not in os.environ
system.check(update=args.update,
remove=args.remove,
test=args.test,
- interactive=interactive)
+ interactive=interactive,
+ skip_if_unchanged=args.skip_if_unchanged)
diff --git a/commands/run b/commands/run
index c71fe66..1f043d0 100755
--- a/commands/run
+++ b/commands/run
@@ -5,7 +5,7 @@ helpersdir=$commandsdir/helpers
rootdir=`dirname "$commandsdir"`
display=`$helpersdir/find-free-display`
-$commandsdir/check-system
+$commandsdir/check-system --skip-if-unchanged
if [ -f $rootdir/prefs ]; then
source $rootdir/prefs
diff --git a/devbot/build.py b/devbot/build.py
index 74ff7bf..6705274 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -10,16 +10,6 @@ from devbot import config
from devbot import environ
from devbot import state
-def get_module_commit_id(module):
- orig_cwd = os.getcwd()
- os.chdir(module.get_source_dir())
-
- commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"])
-
- os.chdir(orig_cwd)
-
- return commit_id.strip()
-
def unlink_libtool_files():
def func(arg, dirname, fnames):
for fname in fnmatch.filter(fnames, "*.la"):
@@ -90,13 +80,13 @@ def build_module(module):
print "Unknown build system"
sys.exit(1)
- state.add_built_module(module.name, get_module_commit_id(module))
+ state.touch_built_commit_id(module)
def clear_built_modules(modules, index):
if index < len(modules) - 1:
for module in modules[index + 1:]:
- if state.get_built_module(module.name) is not None:
- state.remove_built_module(module.name)
+ if state.get_built_commit_id(module) is not None:
+ state.remove_built_commit_id(module)
def rmtree(dir):
print "Deleting %s" % dir
@@ -113,8 +103,8 @@ def build():
try:
pull_source(module)
- old_commit_id = state.get_built_module(module.name)
- new_commit_id = get_module_commit_id(module)
+ old_commit_id = state.get_built_commit_id(module)
+ new_commit_id = module.get_commit_id()
if old_commit_id is None or old_commit_id != new_commit_id:
clear_built_modules(modules, i)
diff --git a/devbot/config.py b/devbot/config.py
index df037d6..123958a 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -3,6 +3,7 @@ import os
import tempfile
from devbot import distro
+from devbot import utils
config_dir = None
logs_dir = None
@@ -41,10 +42,20 @@ class Module:
def get_build_dir(self):
return os.path.join(get_build_dir(), self.name)
+ def get_commit_id(self):
+ return utils.get_commit_id(get_source_dir())
+
def _ensure_dir(dir):
if not os.path.exists(dir):
os.mkdir(dir)
+def get_commit_id():
+ commit_id = utils.get_commit_id(config_dir)
+ if commit_id is None:
+ commit_id = "snapshot"
+
+ return commit_id
+
def set_config_dir(dir):
global config_dir
config_dir = dir
diff --git a/devbot/state.py b/devbot/state.py
index bc17761..1eaf3ac 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -25,16 +25,23 @@ def _get_state():
def _state_changed():
json.dump(_state, open(_get_state_path(), "w+"))
-def add_built_module(name, commit_id):
- _get_state()["built_modules"][name] = commit_id
+def touch_built_commit_id(module):
+ _get_state()["built_modules"][module.name] = module.get_commit_id()
_state_changed()
-def remove_built_module(name):
- del _get_state()["built_modules"][name]
+def remove_built_commit_id(module):
+ del _get_state()["built_modules"][module.name]
_state_changed()
-def get_built_module(name):
- return _get_state()["built_modules"].get(name, None)
+def get_built_commit_id(module):
+ return _get_state()["built_modules"].get(module.name, None)
+
+def get_last_system_check():
+ return _get_state().get("last_system_check", None)
+
+def touch_last_system_check():
+ _get_state()["last_system_check"] = config.get_commit_id()
+ _state_changed()
def clean():
_state = None
diff --git a/devbot/system.py b/devbot/system.py
index 2a8d189..57e223c 100644
--- a/devbot/system.py
+++ b/devbot/system.py
@@ -6,8 +6,9 @@ import sys
from devbot import config
from devbot import distro
from devbot import command
+from devbot import state
+from devbot import utils
-devnull = open("/dev/null", "w")
xvfb_display = ":100"
libdirs = ["lib",
@@ -17,7 +18,7 @@ libdirs = ["lib",
def check_binary(check):
return subprocess.call(["which", check],
- stdout=devnull,
+ stdout=utils.devnull,
stderr=subprocess.STDOUT)
def check_pkgconfig(check):
@@ -25,7 +26,8 @@ def check_pkgconfig(check):
def check_python(check):
return subprocess.call(["python", "-c", check],
- stdout=devnull, stderr=subprocess.STDOUT) == 1
+ stdout=utils.devnull,
+ stderr=subprocess.STDOUT) == 1
def check_gtkmodule(check):
# Not sure we can do better than this, the gtkmodule stuff is private
@@ -109,7 +111,7 @@ def run_checks(package_manager, checks, packages):
def start_xvfb():
xvfb_proc = subprocess.Popen(args=["Xvfb", xvfb_display],
- stdout=devnull,
+ stdout=utils.devnull,
stderr=subprocess.STDOUT)
orig_display = os.environ.get("DISPLAY", None)
os.environ["DISPLAY"] = xvfb_display
@@ -163,7 +165,12 @@ def remove_packages(package_manager, packages):
if to_remove:
package_manager.remove_packages(to_remove)
-def check(remove=False, update=False, test=False, interactive=True):
+def check(remove=False, update=False, test=False, interactive=True,
+ skip_if_unchanged=False):
+ if skip_if_unchanged:
+ if config.get_commit_id() == state.get_last_system_check():
+ return
+
print "Checking the system"
package_manager = \
@@ -188,4 +195,6 @@ def check(remove=False, update=False, test=False, interactive=True):
package_manager.update()
if remove:
- remove_packages(package_manager, packages)
+ remove_packages(package_manager, packages)
+
+ state.touch_last_system_check()
diff --git a/devbot/utils.py b/devbot/utils.py
new file mode 100644
index 0000000..2864948
--- /dev/null
+++ b/devbot/utils.py
@@ -0,0 +1,18 @@
+import os
+import subprocess
+
+devnull = open("/dev/null", "w")
+
+def get_commit_id(dir):
+ orig_cwd = os.getcwd()
+ os.chdir(dir)
+
+ try:
+ commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"],
+ stderr=devnull).strip()
+ except subprocess.CalledProcessError:
+ commit_id = None
+
+ os.chdir(orig_cwd)
+
+ return commit_id