Пример #1
0
    def setUp(self):
        from tribus.common.utils import get_path
        from tribus.common.iosync import makedirs, touch, ln, rmtree

        self.tmpdir = get_path(['/', 'tmp', 'test_io'])
        self.tmpdir_1 = get_path([self.tmpdir, '1'])
        self.tmpdir_2 = get_path([self.tmpdir, '2'])
        self.tmpfile_1 = get_path([self.tmpdir_1, '1.txt'])
        self.tmpfile_2 = get_path([self.tmpdir_2, '2.txt'])
        self.tmpfile_3 = get_path([self.tmpdir_2, '3.log'])
        self.tmpfile_4 = get_path([self.tmpdir_2, '4.txt'])
        self.tmpfile_5 = get_path([self.tmpdir, '5.log'])
        self.tmpfile_6 = get_path([self.tmpdir, '6.py'])

        if os.path.isdir(self.tmpdir):
            rmtree(self.tmpdir)

        makedirs(self.tmpdir_1)
        makedirs(self.tmpdir_2)
        touch(self.tmpfile_1)
        touch(self.tmpfile_2)
        touch(self.tmpfile_3)
        touch(self.tmpfile_5)
        touch(self.tmpfile_6)
        ln(self.tmpfile_3, self.tmpfile_4)
Пример #2
0
 def test_create_repository(self):
     from tribus.common.reprepro import create_repository
     test_repo = "/tmp/test_repo"
     test_dist = os.path.join(SAMPLESDIR, 'distributions')
     create_repository(test_repo, test_dist)
     self.assertTrue(os.path.isdir(test_repo))
     self.assertTrue(os.path.isdir(os.path.join(test_repo, 'db')))
     self.assertTrue(os.path.isdir(os.path.join(test_repo, 'dists')))
     self.assertTrue(
         os.path.isfile(os.path.join(test_repo, 'conf', 'distributions')))
     rmtree(test_repo)
Пример #3
0
 def tearDown(self):
     from tribus.common.iosync import rmtree
     if os.path.isdir(self.tmpdir):
         rmtree(self.tmpdir)
Пример #4
0
 def test_update_cache(self):
     import urllib
     from tribus.common.recorder import fill_db_from_cache, create_cache, update_cache
     from tribus.common.iosync import touch, rmtree
     env.samples_dir = SAMPLESDIR
     env.micro_repository_path = os.path.join('/', 'tmp', 'tmp_repo')
     env.micro_repository_conf = os.path.join('/', 'tmp', 'tmp_repo', 'conf')
     env.packages_dir = os.path.join(SAMPLESDIR, 'example_packages')
     env.pcache = os.path.join('/', 'tmp', 'pcache')
     env.distributions_path = os.path.join(env.micro_repository_path, 'distributions')
     
     source_seed_packages1 = 'http://paquetes.canaima.softwarelibre.gob.ve/pool'
     source_seed_packages2 = 'http://ftp.us.debian.org/debian/pool'
     
     list_seed_packages1 = [('main/c/cube2font', 'cube2font_1.2-2_i386.deb'),
                            ('main/c/cube2font', 'cube2font_1.2-2_amd64.deb'),
                            ('no-libres/c/cl-sql', 'cl-sql-oracle_6.2.0-1_all.deb'),
                            ('main/t/tacacs+', 'libtacacs+1_4.0.4.19-8_i386.deb'),
                            ('main/t/tacacs+', 'libtacacs+1_4.0.4.19-8_amd64.deb'),
                            ('aportes/a/acroread-debian-files', 'acroread-debian-files_9.5.8_i386.deb'),
                            ('aportes/a/acroread-debian-files', 'acroread-debian-files_9.5.8_amd64.deb')]
     
     list_seed_packages2 = [('main/c/cube2font', 'cube2font_1.3.1-2_i386.deb'),
                            ('main/c/cube2font', 'cube2font_1.3.1-2_amd64.deb'),
                            ('main/x/xine-lib', 'libxine1-plugins_1.1.19-2_all.deb'),
                            ('main/x/xine-lib', 'libxine1-plugins_1.1.21-1_all.deb')]
     
     for loc, name in list_seed_packages1:
         remote_path = os.path.join(source_seed_packages1, loc, name)
         local_path = os.path.join(env.packages_dir, name)
         try:
             urllib.urlretrieve(remote_path, local_path)
         except:
             print "No se pudo obtener una de las muestras, el test probablemente fallara"
     
     for loc, name in list_seed_packages2:
         remote_path = os.path.join(source_seed_packages2, loc, name)
         local_path = os.path.join(env.packages_dir, name)
         try:
             urllib.urlretrieve(remote_path, local_path)
         except:
             print "No se pudo obtener una de las muestras, el test probablemente fallara"
     
     with settings(command='mkdir -p %(micro_repository_conf)s' % env):
         local('%(command)s' % env, capture=False)
     
     with settings(command='cp %(samples_dir)s/distributions\
               %(micro_repository_conf)s' % env):
         local('%(command)s' % env, capture=False)
     
     with lcd('%(micro_repository_path)s' % env):
         touch(env.distributions_path)
         f = open(env.distributions_path, 'w')
         f.write('kukenan dists/kukenan/Release')
         f.close()
     
     with lcd('%(micro_repository_path)s' % env):
         with settings(command='reprepro -VVV export'):
             local('%(command)s' % env, capture=False)
     
     seed_packages = [('cube2font_1.2-2_i386.deb', 'main'), ('cube2font_1.2-2_amd64.deb', 'main'), 
                      ('cl-sql-oracle_6.2.0-1_all.deb', 'no-libres'), ('libxine1-plugins_1.1.19-2_all.deb', 'main'),
                      ('acroread-debian-files_9.5.8_i386.deb', 'aportes'), ('acroread-debian-files_9.5.8_amd64.deb', 'aportes')]
     
     with lcd('%(micro_repository_path)s' % env):
         for package, comp in seed_packages:
             with settings(command='reprepro -S %s includedeb %s %s/%s' %
                          (comp, test_dist, env.packages_dir, package)):
                 local('%(command)s' % env, capture=False)
     
     with lcd('%(micro_repository_path)s' % env):
         create_cache(env.micro_repository_path, env.pcache)
     
     with lcd('%(micro_repository_path)s' % env):
         fill_db_from_cache(env.pcache)
     
     add_list = [('libtacacs+1_4.0.4.19-8_amd64.deb', 'main'), ('libtacacs+1_4.0.4.19-8_i386.deb', 'main')]
     update_list = [('cube2font_1.3.1-2_i386.deb', 'main'), ('cube2font_1.3.1-2_amd64.deb', 'main'), 
                    ('libxine1-plugins_1.1.21-1_all.deb', 'main')]
     delete_list = [('cl-sql-oracle', 'no-libres'), ('acroread-debian-files', 'aportes'),
                    ('acroread-debian-files', 'aportes')]
     
     with lcd('%(micro_repository_path)s' % env):
         for package, comp in add_list:
             with settings(command='reprepro -S %s includedeb %s %s/%s' %
                          (comp, test_dist, env.packages_dir, package)):
                 local('%(command)s' % env, capture=False)
         
         for package, comp in update_list:
             with settings(command='reprepro -S %s includedeb %s %s/%s' %
                          (comp, test_dist, env.packages_dir, package)):
                 local('%(command)s' % env, capture=False)
         
         for package, comp in delete_list:
             with settings(command='reprepro remove %s %s' % 
                           (test_dist, package)):
                 local('%(command)s' % env, capture=False)
     
     update_cache(env.micro_repository_path, env.pcache)
     # FALTAN LOS ASSERT PARA VERIFICAR QUE LA ACTUALIZACION FUE CORRECTA
     rmtree(env.micro_repository_path)
     rmtree(env.pcache)
Пример #5
0
        for arch in archs:
            # if md5sum.get('name') == os.path.join(comp, 'binary-' + arch, 'Packages.gz'):

            remote_file_path = os.path.join(remote_branch_path, comp,
                                            'binary-' + arch)
            local_file_path = os.path.join(local_branch_path, comp,
                                           'binary-' + arch)

            #for md5sum in md5sums:
            #    if md5sum.get('name') == os.path.join(comp, 'binary-' + arch, 'Packages.gz'):
            #        print md5sum

            #if not os.path.isdir(local_file_path):
            #    os.makedirs(local_file_path)

rmtree(local)

# METODOS ALTERNATIVOS PARA REGISTRAR PAQUETES
# def setear_objeto(obj, section, fields):
#     """
#     Intento de abstraer la logica para crear y
#     actualizar objetos a partir de un archivo de control
#     y una lista de los campos considerados
#     """
#
#     for field in fields:
#         setattr(obj,
#                 field.replace("-", "") if "-" in field else field,
#                 section.get(field, None))
#     return obj