Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-01-21 13:32:25 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-01-21 13:32:25 (GMT)
commitbb597352b2241211a758f735820cb054b3695373 (patch)
tree9e85e766f5e6ce892f6e4c408a7a9b4fe283dfd0
parentd6738638c11365350cb7721763dcd470fbf8b7b6 (diff)
Add some initial dependency checking logic
-rw-r--r--dependency.py29
-rw-r--r--dependencychecker.py30
-rwxr-xr-xsugar-jhbuild16
-rw-r--r--updater.py13
4 files changed, 58 insertions, 30 deletions
diff --git a/dependency.py b/dependency.py
deleted file mode 100644
index 3fc7de5..0000000
--- a/dependency.py
+++ /dev/null
@@ -1,29 +0,0 @@
-import os
-
-class AbstractDependency:
- def __init__(self, name):
- self._name = name
-
- def get_name(self):
- return self._name
-
- def check(self):
- return False
-
-class LibDependency(AbstractDependency):
- def __init__(self, name, module):
- AbstractDependency.__init__(self, name)
- self._module = module
-
- def check(self):
- pid = os.fork()
- if not pid:
- os.execvp('pkg-config', [ 'pkg-config', '--exists', self._module ])
- return os.wait()[1] == 0
-
-def get_installed(dependencies):
- installed = []
- for dep in dependencies:
- if dep.check():
- installed.append(dep.get_name())
- return installed
diff --git a/dependencychecker.py b/dependencychecker.py
new file mode 100644
index 0000000..e892831
--- /dev/null
+++ b/dependencychecker.py
@@ -0,0 +1,30 @@
+import os
+import re
+
+def _check_module(self, module):
+ pid = os.fork()
+ if not pid:
+ os.execvp('pkg-config', [ 'pkg-config', '--exists', module ])
+ return os.wait()[1] == 0
+
+def _check_command_output(command, regexp):
+ f = os.popen(command)
+ output = f.read()
+ f.close()
+
+ return re.compile(regexp).search(output)
+
+class DependencyChecker:
+ def __init__(self):
+ self._missing = []
+
+ def check_python(self, version):
+ if not _check_command_output('python -V', version):
+ self._missing.append('python %s' % version)
+
+ def check_library(self, name):
+ if not _check_module(name):
+ self._missing.append(name)
+
+ def get_missing(self):
+ return self._missing
diff --git a/sugar-jhbuild b/sugar-jhbuild
index 828cff8..e9ded6a 100755
--- a/sugar-jhbuild
+++ b/sugar-jhbuild
@@ -8,11 +8,25 @@ sys.path.append(os.path.join(base_dir, 'build-scripts', 'jhbuild'))
import jhbuild.commands
-from config import Config
import bundlemodule
+from config import Config
+from updater import Updater
+from dependencychecker import DependencyChecker
+
+updater = Updater(base_dir)
+updater.update()
config = Config(base_dir)
+checker = DependencyChecker()
+checker.check_python('2.5')
+
+print 'Missing dependencies:'
+if len(checker.get_missing()) > 0:
+ for missing in checker.get_missing():
+ print missing
+ sys.exit(1)
+
args = []
command = 'build'
diff --git a/updater.py b/updater.py
new file mode 100644
index 0000000..a83073b
--- /dev/null
+++ b/updater.py
@@ -0,0 +1,13 @@
+import os
+
+class Updater(object):
+ def __init__(self, base_dir):
+ self._base_dir = base_dir
+
+ def update(self):
+ os.chdir(os.path.join(self._base_dir, 'build-scripts'))
+
+ cmd = ['svn', 'co', 'svn://svn.gnome.org/svn/jhbuild/trunk', 'jhbuild']
+ os.spawnvp(os.P_WAIT, 'svn', cmd)
+
+ os.chdir(self._base_dir)