Ejemplo n.º 1
0
    def _load_recipes(self):
        self.recipes = {}
        recipes = defaultdict(dict)
        recipes_repos = self._config.get_recipes_repos()
        for reponame, (repodir, priority) in six.iteritems(recipes_repos):
            recipes[int(priority)].update(self._load_recipes_from_dir(repodir))
        # Add recipes by asceding pripority
        for key in sorted(recipes.keys()):
            self.recipes.update(recipes[key])

        # Check for updates in the recipe file to reset the status
        for recipe in self.recipes.values():
            if recipe.name not in self.status:
                continue
            st = self.status[recipe.name]
            # filepath attribute was added afterwards
            if not hasattr(st, 'filepath') or not getattr(st, 'filepath'):
                st.filepath = recipe.__file__
            if recipe.__file__ != st.filepath:
                self.reset_recipe_status(recipe.name)
            else:
                rmtime = os.path.getmtime(recipe.__file__)
                if rmtime > st.mtime:
                    # The mtime is different, check the file hash now
                    # Use getattr as file_hash we added later
                    saved_hash = getattr(st, 'file_hash', 0)
                    current_hash = shell.file_hash(st.filepath)
                    if saved_hash == current_hash:
                        # Update the status with the mtime
                        st.touch()
                    else:
                        self.reset_recipe_status(recipe.name)
Ejemplo n.º 2
0
    def _load_recipes(self):
        self.recipes = {}
        recipes = defaultdict(dict)
        recipes_repos = self._config.get_recipes_repos()
        for reponame, (repodir, priority) in recipes_repos.items():
            recipes[int(priority)].update(self._load_recipes_from_dir(repodir))
        # Add recipes by asceding pripority
        for key in sorted(recipes.keys()):
            self.recipes.update(recipes[key])

        # Check for updates in the recipe file to reset the status
        for recipe in list(self.recipes.values()):
            if recipe.name not in self.status:
                continue
            st = self.status[recipe.name]
            # filepath attribute was added afterwards
            if not hasattr(st, 'filepath') or not getattr(st, 'filepath'):
                st.filepath = recipe.__file__
            if recipe.__file__ != st.filepath:
                self.reset_recipe_status(recipe.name)
            else:
                rmtime = os.path.getmtime(recipe.__file__)
                if rmtime > st.mtime:
                    # The mtime is different, check the file hash now
                    # Use getattr as file_hash we added later
                    saved_hash = getattr(st, 'file_hash', 0)
                    current_hash = shell.file_hash(st.filepath)
                    if saved_hash == current_hash:
                        # Update the status with the mtime
                        st.touch()
                    else:
                        self.reset_recipe_status(recipe.name)
Ejemplo n.º 3
0
 def _recipe_status(self, recipe_name):
     recipe = self.get_recipe(recipe_name)
     if recipe_name not in self.status:
         filepath = None
         if hasattr(recipe, '__file__'):
             filepath = recipe.__file__
         self.status[recipe_name] = RecipeStatus(filepath, steps=[],
                 file_hash=shell.file_hash(filepath))
     return self.status[recipe_name]
Ejemplo n.º 4
0
 def _recipe_status(self, recipe_name):
     recipe = self.get_recipe(recipe_name)
     if recipe_name not in self.status:
         filepath = None
         if hasattr(recipe, '__file__'):
             filepath = recipe.__file__
         self.status[recipe_name] = RecipeStatus(
             filepath, steps=[], file_hash=shell.file_hash(filepath))
     return self.status[recipe_name]
Ejemplo n.º 5
0
    def _load_recipes(self):
        self.recipes = {}
        recipes = defaultdict(dict)
        recipes_repos = self._config.get_recipes_repos()
        for reponame, (repodir, priority) in recipes_repos.items():
            recipes[int(priority)].update(self._load_recipes_from_dir(repodir))
        # Add recipes by asceding pripority
        for key in sorted(recipes.keys()):
            self.recipes.update(recipes[key])

        # Check for updates in the recipe file to reset the status
        for recipe in list(self.recipes.values()):
            # Set the offline property, used by the recipe while performing the
            # fetch build step
            recipe.offline = self.offline
            if recipe.name not in self.status:
                continue
            st = self.status[recipe.name]
            # filepath attribute was added afterwards
            if not hasattr(st, 'filepath') or not getattr(st, 'filepath'):
                st.filepath = recipe.__file__
            # if filepath has changed, force using file_hash(), this will
            # allow safe relocation of the recipes.
            if recipe.__file__ != st.filepath:
                st.filepath = recipe.__file__
                st.mtime = 0
            # Need to check the version too, because the version can be
            # inherited from a different file, f.ex. recipes/custom.py
            if recipe.built_version() != st.built_version:
                self.reset_recipe_status(recipe.name)
            else:
                rmtime = os.path.getmtime(recipe.__file__)
                if rmtime > st.mtime:
                    # The mtime is different, check the file hash now
                    # Use getattr as file_hash we added later
                    saved_hash = getattr(st, 'file_hash', 0)
                    current_hash = shell.file_hash(st.filepath)
                    if saved_hash == current_hash:
                        # Update the status with the mtime
                        st.touch()
                    else:
                        self.reset_recipe_status(recipe.name)
Ejemplo n.º 6
0
    def _load_recipes(self):
        self.recipes = {}
        recipes = defaultdict(dict)
        recipes_repos = self._config.get_recipes_repos()
        for reponame, (repodir, priority) in recipes_repos.items():
            recipes[int(priority)].update(self._load_recipes_from_dir(repodir))
        # Add recipes by asceding pripority
        for key in sorted(recipes.keys()):
            self.recipes.update(recipes[key])

        # Check for updates in the recipe file to reset the status
        for recipe in list(self.recipes.values()):
            # Set the offline property, used by the recipe while performing the
            # fetch build step
            recipe.offline = self.offline
            if recipe.name not in self.status:
                continue
            st = self.status[recipe.name]
            # filepath attribute was added afterwards
            if not hasattr(st, 'filepath') or not getattr(st, 'filepath'):
                st.filepath = recipe.__file__
            if recipe.__file__ != st.filepath:
                self.reset_recipe_status(recipe.name)
            # Need to check the version too, because the version can be
            # inherited from a different file, f.ex. recipes/custom.py
            elif recipe.built_version() != st.built_version:
                self.reset_recipe_status(recipe.name)
            else:
                rmtime = os.path.getmtime(recipe.__file__)
                if rmtime > st.mtime:
                    # The mtime is different, check the file hash now
                    # Use getattr as file_hash we added later
                    saved_hash = getattr(st, 'file_hash', 0)
                    current_hash = shell.file_hash(st.filepath)
                    if saved_hash == current_hash:
                        # Update the status with the mtime
                        st.touch()
                    else:
                        self.reset_recipe_status(recipe.name)