diff --git a/pym/bob/scm/imp.py b/pym/bob/scm/imp.py index 076171f6..43b4a917 100644 --- a/pym/bob/scm/imp.py +++ b/pym/bob/scm/imp.py @@ -116,6 +116,7 @@ class ImportScm(Scm): DEFAULTS = { schema.Optional('dir') : str, schema.Optional('prune') : bool, + schema.Optional('recipeRelative') : bool, } __SCHEMA = { @@ -134,6 +135,11 @@ def __init__(self, spec, overrides=[], pruneDefault=None, fixDigestBug=False, pr self.__data = spec.get("__data") self.__projectRoot = spec.get("__projectRoot", projectRoot) self.__fixDigestBug = fixDigestBug + self.__recipeRelative = spec.get("recipeRelative", False) + + def _getSrcDir(self): + rootDir = os.path.dirname(self._getRecipe()) if self.__recipeRelative else self.__projectRoot + return os.path.join(rootDir, self.__url) def getProperties(self, isJenkins, pretty=False): ret = super().getProperties(isJenkins) @@ -142,9 +148,10 @@ def getProperties(self, isJenkins, pretty=False): 'url' : self.__url, 'dir' : self.__dir, 'prune' : self.__prune, + 'recipeRelative' : self.__recipeRelative, }) if isJenkins: - ret['__data'] = packTree(self.__url) + ret['__data'] = packTree(self._getSrcDir()) else: ret['__projectRoot'] = self.__projectRoot return ret @@ -154,7 +161,7 @@ async def invoke(self, invoker): os.makedirs(dest, exist_ok=True) if self.__prune: emptyDirectory(dest) if self.__data is None: - src = os.path.join(self.__projectRoot, self.__url) + src = self._getSrcDir() if not os.path.isdir(src): invoker.fail("Cannot import '{}': not a directory!".format(src)) copyTree(src, dest, invoker) diff --git a/pym/bob/scm/scm.py b/pym/bob/scm/scm.py index abbd2eb0..bef6adbd 100644 --- a/pym/bob/scm/scm.py +++ b/pym/bob/scm/scm.py @@ -231,6 +231,9 @@ def _diffSpec(self, oldScm): ret -= {"if"} return ret + def _getRecipe(self): + return self.__recipe + def getSource(self): return self.__source