Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/common.py2
-rw-r--r--devbot/build.py3
-rw-r--r--devbot/clean.py2
-rw-r--r--devbot/git.py27
-rw-r--r--devbot/state.py54
5 files changed, 31 insertions, 57 deletions
diff --git a/commands/common.py b/commands/common.py
index 557c074..a7e16d1 100644
--- a/commands/common.py
+++ b/commands/common.py
@@ -10,8 +10,6 @@ from devbot import git
def setup(log_name=None):
- git.set_root_path(base_dir)
-
args = {"config_dir": os.path.join(base_dir, "config"),
"install_dir": os.path.join(base_dir, "install"),
"source_dir": os.path.join(base_dir, "source"),
diff --git a/devbot/build.py b/devbot/build.py
index 18f1c9a..c83c15a 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -59,6 +59,7 @@ def pull(lazy=False):
def build(full=False):
if full or state.full_build_is_required():
+ state.clean(build_only=True)
clean()
environ.setup()
@@ -102,8 +103,6 @@ def distribute():
def clean():
print "\n= Clean =\n"
- state.clean(build_only=True)
-
print "* Emptying install directory"
_empty_dir(config.install_dir)
diff --git a/devbot/clean.py b/devbot/clean.py
index 2ea935b..7601382 100644
--- a/devbot/clean.py
+++ b/devbot/clean.py
@@ -1,7 +1,9 @@
from devbot import build
from devbot import logs
+from devbot import state
def clean():
build.clean()
logs.clean()
+ state.clean()
diff --git a/devbot/git.py b/devbot/git.py
index 29365f7..cb361ef 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -2,11 +2,8 @@ import os
import subprocess
from devbot import command
-from devbot import utils
from devbot import config
-_root_path = None
-
def _chdir(func):
def wrapped(*args, **kwargs):
@@ -78,13 +75,6 @@ class Module:
return subprocess.check_output(["git", "describe"]).strip()
@_chdir
- def is_valid(self):
- result = subprocess.call(["git", "rev-parse", "HEAD"],
- stdout=utils.devnull,
- stderr=utils.devnull)
- return result == 0
-
- @_chdir
def get_commit_id(self):
return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
@@ -120,11 +110,6 @@ class Module:
return True
-def set_root_path(path):
- global _root_path
- _root_path = path
-
-
def get_module(module):
return Module(path=config.get_source_dir(),
name=module.name,
@@ -132,15 +117,3 @@ def get_module(module):
branch=module.branch,
tag=module.tag,
retry=10)
-
-
-def get_root_module():
- remote = "git://git.sugarlabs.org/sugar-build/sugar-build.git"
-
- module = Module(name=os.path.basename(_root_path),
- remote=remote,
- path=os.path.dirname(_root_path))
- if not module.is_valid():
- return None
-
- return module
diff --git a/devbot/state.py b/devbot/state.py
index 4e7e12a..1a6e5b0 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -3,7 +3,6 @@ import os
import json
from devbot import config
-from devbot import git
_BUILT_MODULES = "builtmodules"
_FULL_BUILD = "fullbuild"
@@ -12,7 +11,10 @@ _SYSTEM_CHECK = "syscheck"
def built_module_touch(module):
built_modules = _load_state(_BUILT_MODULES, {})
- built_modules[module.name] = {"source_hash": _compute_source_hash(module)}
+
+ source_hash = _compute_mtime_hash(module.get_source_dir())
+ built_modules[module.name] = {"source_hash": source_hash}
+
_save_state(_BUILT_MODULES, built_modules)
@@ -21,22 +23,32 @@ def built_module_is_unchanged(module):
if module.name not in built_modules:
return False
- source_hash = built_modules[module.name].get("source_hash", None)
+ built_module = built_modules[module.name]
+ if "source_hash" not in built_module:
+ return False
+
+ old_source_hash = built_module["source_hash"]
+ new_source_hash = _compute_mtime_hash(module.get_source_dir())
- return source_hash == _compute_source_hash(module)
+ return old_source_hash == new_source_hash
def system_check_is_unchanged():
system_check = _load_state(_SYSTEM_CHECK)
- if not system_check:
+ if not system_check or not "config_hash" in system_check:
return False
- return system_check["commit"] == _get_root_commit_id()
+ config_hash = _compute_mtime_hash(config.config_dir)
+
+ return system_check["config_hash"] == config_hash
def system_check_touch():
system_check = _load_state(_SYSTEM_CHECK, {})
- system_check["commit"] = _get_root_commit_id()
+
+ config_hash = _compute_mtime_hash(config.config_dir)
+ system_check["config_hash"] = config_hash
+
_save_state(_SYSTEM_CHECK, system_check)
@@ -61,11 +73,11 @@ def clean(build_only=False):
if not build_only:
names.append(_SYSTEM_CHECK)
- try:
- for name in names:
+ for name in names:
+ try:
os.unlink(_get_state_path(name))
- except OSError:
- pass
+ except OSError:
+ pass
def _get_state_path(name):
@@ -90,26 +102,16 @@ def _save_state(name, state):
f.write('\n')
-def _compute_source_hash(module):
- # For some reason if source_dir is unicode
- # we get a 10x slow down for some modules
- source_dir = str(module.get_source_dir())
+def _compute_mtime_hash(path):
+ # For some reason if path is unicode we
+ # get a 10x slow down for some directories
+ path = str(path)
data = ""
- for root, dirs, files in os.walk(source_dir):
+ for root, dirs, files in os.walk(path):
for name in files:
path = os.path.join(root, name)
mtime = os.lstat(path).st_mtime
data = "%s%s %s\n" % (data, mtime, path)
return hashlib.sha256(data).hexdigest()
-
-
-def _get_root_commit_id():
- git_module = git.get_root_module()
- if git_module:
- commit_id = git_module.get_commit_id()
- else:
- commit_id = "snapshot"
-
- return commit_id