Esempio n. 1
0
    def backup(self, basedir, include=[], exclude=[]):
        '''backup apt configuration and repositories'''
        # backup the apt config in /etc/apt
        repos = []
        for apt_conf in FileManager.get_all_files(include=['/etc/apt']):
            SFile(apt_conf).copy_to(basedir)
            repos.append(Repo()) # FIXME parse repo info

        # write record file to basedir
        record = ReposRecordFile(basedir + "/repos.xml")
        record.write(repos)
Esempio n. 2
0
    def testWriteReposRecordFile(self):
        file_path = os.path.join(os.path.dirname(__file__), "data/repos-out.xml")
        repos  = [Repo(name='yum.morsi.org', url='http://yum.morsi.org'),
                  Repo(name='apt.morsi.org', url='http://apt.morsi.org')]

        repo_record_file = ReposRecordFile(file_path)
        repo_record_file.write(repos)
        contents = FileManager.read_file(file_path)

        self.assertEqual("<repos><repo>http://yum.morsi.org</repo><repo>http://apt.morsi.org</repo></repos>", contents)
        os.remove(file_path)
Esempio n. 3
0
    def backup(self, basedir, include=[], exclude=[]):
        '''backup yum configuration and repositories'''
        # first backup the yum config
        SFile("/etc/yum.conf").copy_to(basedir)

        # then backup the individual repo files
        repos = []
        for yum_repo in FileManager.get_all_files(include=['/etc/yum.repos.d']):
            SFile(yum_repo).copy_to(basedir)

            # parse/extract repo info
            baseurl = re.compile('baseurl=(.*)\n')
            mirrorlist = re.compile('mirrorlist=(.*)\n')
            contents = FileManager.read_file(yum_repo)
            for match in baseurl.findall(contents):
                repos.append(Repo(url=match))
            for match in mirrorlist.findall(contents):
                repos.append(Repo(url=match))

        # write record file to basedir
        record = ReposRecordFile(basedir + "/repos.xml")
        record.write(repos)