Commits

catseye  committed 0590b83

Implement require_executables hint.

  • Participants
  • Parent commits 6bdbeb2

Comments (0)

Files changed (3)

File README.markdown

 
 The names of hints are as follows.
 
-*   `requires_executables`
+*   `require_executables`
     
-    Example: `requires_executables perl`
+    Example: `require_executables perl`
     
     A space-separated list of executables required to dock and run the source.
     When this is given, `toolshelf` first checks if you have the named

File cookies.catalog

 gh:catseye/VICE
   only_paths src
   build_command autogen.sh && ./configure --enable-gnomeui && make
+
+bb:catseye/yucca
+  require_executables python

File toolshelf.py

     'exclude_paths',
     'only_paths',
     #'prerequisites',
-    #'requires_executables',
+    'require_executables',
 )
 
 CWD = os.getcwd()
     pass
 
 
+class DependencyError(ValueError):
+    pass
+
+
 ### Helper Functions
 
 def is_executable(filename):
 
         chdir(self.dir)
         build_command = self.hints.get('build_command', None)
-        if build_command is not None:
+        if build_command:
             run(build_command, shell=True)
         elif os.path.isfile('build.sh'):
             run('./build.sh')
 
     def may_use_path(self, dirname):
         only_paths = self.hints.get('only_paths', None)
-        if only_paths is not None:
+        if only_paths:
             only_paths = only_paths.split(' ')
             for path in only_paths:
                 if dirname == os.path.join(self.dir, path):
                     return True
             return False
         exclude_paths = self.hints.get('exclude_paths', None)
-        if exclude_paths is not None:
+        if exclude_paths:
             exclude_paths = exclude_paths.split(' ')
             for path in exclude_paths:
                 verboten = os.path.join(self.dir, path)
     if problems:
         raise SourceSpecError(repr(problems))
     for source in sources:
-        # XXX for now, skip if already docked
-        if not source.docked:
+        if source.docked:
+            print "%s already docked." % source.name
+        else:
+            require_executables = source.hints.get(
+                'require_executables', None
+            )
+            if require_executables:
+                p = Path()
+                for executable in require_executables.split(' '):
+                    if not p.which(executable):
+                        raise DependencyError(
+                            '%s requires `%s` not found on search path' %
+                            (source.name, executable)
+                        )
             source.checkout()
             source.build()
     path_cmd(result, ['rebuild'] + [s.name for s in sources])