Example #1
0
    def sanity_check_repo(self):
        """Sanity check our repo.

            - make sure we didn't compose a repo full of symlinks
            - sanity check our repodata
        """
        mash_path = os.path.join(self.path, self.id)
        self.log.info("Running sanity checks on %s" % mash_path)

        # sanity check our repodata
        arches = os.listdir(mash_path)
        for arch in arches:
            try:
                repodata = os.path.join(mash_path, arch, 'repodata')
                sanity_check_repodata(repodata)
            except Exception, e:
                self.log.error("Repodata sanity check failed!\n%s" % str(e))
                raise
Example #2
0
    def sanity_check_repo(self):
        """Sanity check our repo.

            - make sure we didn't compose a repo full of symlinks
            - sanity check our repodata
        """
        mash_path = os.path.join(self.path, self.id)
        self.log.info("Running sanity checks on %s" % mash_path)

        # sanity check our repodata
        arches = os.listdir(mash_path)
        for arch in arches:
            try:
                repodata = os.path.join(mash_path, arch, 'repodata')
                sanity_check_repodata(repodata)
            except Exception, e:
                self.log.error("Repodata sanity check failed!\n%s" % str(e))
                raise
Example #3
0
    def test_sanity_check_repodata(self):
        """
        Do an extremely basic check to make sure that the
        sanity_check_repodata code actually runs.  This is by no means
        a complete test for all possible forms of repodata corruption.
        """
        ## Initialize our temporary repo
        temprepo = tempfile.mkdtemp('bodhi')
        mkmetadatadir(temprepo)

        ## Verify sanity
        sanity_check_repodata(temprepo)

        ## Corrupt metadata
        os.system('echo 1 >> %s' % join(temprepo, 'repodata', 'repomd.xml'))

        # verify insanity
        try:
            sanity_check_repodata(temprepo)
            assert False, "Damaged repomd.xml not detected!"
        except yum.Errors.RepoMDError, e:
            assert e.value == "Damaged repomd.xml file"
Example #4
0
    def test_sanity_check_repodata(self):
        """
        Do an extremely basic check to make sure that the
        sanity_check_repodata code actually runs.  This is by no means
        a complete test for all possible forms of repodata corruption.
        """
        ## Initialize our temporary repo
        temprepo = tempfile.mkdtemp('bodhi')
        mkmetadatadir(temprepo)

        ## Verify sanity
        sanity_check_repodata(temprepo)

        ## Corrupt metadata
        os.system('echo 1 >> %s' % join(temprepo, 'repodata', 'repomd.xml'))

        # verify insanity
        try:
            sanity_check_repodata(temprepo)
            assert False, "Damaged repomd.xml not detected!"
        except yum.Errors.RepoMDError, e:
            assert e.value == "Damaged repomd.xml file"
Example #5
0
    def update_symlinks(self):
        """ Stage our updates repository.

        This entail doing various sanity checking, such as:
            - make sure each repo contains all supported arches
            - make sure we didn't compose a repo full of symlinks
            - sanity check our repodata

        If the above tests pass, then bodhi moves the repository to the
        mashed_stage_dir, and updates the live symlinks appropriately.
        """
        mashed_dir = config.get("mashed_dir")
        for repo, mashdir in self.mashed_repos.items():
            link = join(mashed_dir, repo)
            newrepo = join(mashdir, repo)
            arches = os.listdir(newrepo)

            log.debug("Running sanity checks on %s" % newrepo)

            # make sure the new repository has our arches
            for arch in config.get("arches").split():
                if "/" in arch:  # 'ppc/ppc64'
                    one, other = arch.split("/")
                    if one not in arches and other not in arches:
                        self.error_log("Cannot find arch %s OR %s in %s" % (one, other, newrepo))
                        raise MashTaskException
                    else:
                        if one in arches:
                            arch = one
                        else:
                            arch = other
                elif arch not in arches:
                    self.error_log("Cannot find arch %s in %s" % (arch, newrepo))
                    raise MashTaskException

                # sanity check our repodata
                try:
                    sanity_check_repodata(join(newrepo, arch, "repodata"))
                except Exception, e:
                    self.error_log("Repodata sanity check failed!\n%s" % str(e))
                    raise MashTaskException

            # make sure that mash didn't symlink our packages
            for pkg in os.listdir(join(newrepo, arches[0])):
                if pkg.endswith(".rpm"):
                    if islink(join(newrepo, arches[0], pkg)):
                        self.error_log("Mashed repository full of symlinks!")
                        raise MashTaskException
                    break

            # move the new repo to our mash stage
            stage_dir = config.get("mashed_stage_dir")
            if mashed_dir != stage_dir:
                log.debug("Moving %s => %s" % (mashdir, stage_dir))
                shutil.move(mashdir, stage_dir)
            else:
                log.debug("mashed_dir and mashed_stage_dir are the same.")

            # create a mashed_stage_dir/repo symlink so it goes live
            if islink(link):
                os.unlink(link)
            os.symlink(newrepo, link)
            log.debug("Created symlink: %s => %s" % (newrepo, link))
Example #6
0
    def update_symlinks(self):
        """ Stage our updates repository.

        This entail doing various sanity checking, such as:
            - make sure each repo contains all supported arches
            - make sure we didn't compose a repo full of symlinks
            - sanity check our repodata

        If the above tests pass, then bodhi moves the repository to the
        mashed_stage_dir, and updates the live symlinks appropriately.
        """
        mashed_dir = config.get('mashed_dir')
        for repo, mashdir in self.mashed_repos.items():
            link = join(mashed_dir, repo)
            newrepo = join(mashdir, repo)
            arches = os.listdir(newrepo)

            log.debug("Running sanity checks on %s" % newrepo)

            # make sure the new repository has our arches
            for arch in config.get('arches').split():
                if '/' in arch: # 'ppc/ppc64'
                    one, other = arch.split('/')
                    if one not in arches and other not in arches:
                        self.error_log("Cannot find arch %s OR %s in %s" % (one, other, newrepo))
                        raise MashTaskException
                    else:
                        if one in arches:
                            arch = one
                        else:
                            arch = other
                elif arch not in arches:
                    self.error_log("Cannot find arch %s in %s" % (arch, newrepo))
                    raise MashTaskException

                # sanity check our repodata 
                try:
                    sanity_check_repodata(join(newrepo, arch, 'repodata'))
                except Exception, e:
                    self.error_log("Repodata sanity check failed!\n%s" % str(e))
                    raise MashTaskException

            # make sure that mash didn't symlink our packages
            for pkg in os.listdir(join(newrepo, arches[0])):
                if pkg.endswith('.rpm'):
                    if islink(join(newrepo, arches[0], pkg)):
                        self.error_log("Mashed repository full of symlinks!")
                        raise MashTaskException
                    break

            # move the new repo to our mash stage
            stage_dir = config.get('mashed_stage_dir')
            if mashed_dir != mashed_dir:
                log.debug("Moving %s => %s" % (mashdir, stage_dir))
                shutil.move(mashdir, config.get('mashed_stage_dir'))
            else:
                log.debug("mashed_dir and mashed_stage_dir are the same.")

            # create a mashed_stage_dir/repo symlink so it goes live
            if islink(link):
                os.unlink(link)
            os.symlink(newrepo, link)
            log.debug("Created symlink: %s => %s" % (newrepo, link))