Example #1
0
 def _update_locked_repo(self):
     # Internal call that assumes the flock is already held
     # If the createrepo command crashes for some reason it may leave behind
     # its work directories. createrepo refuses to run if .olddata exists,
     # createrepo_c refuses to run if .repodata exists.
     workdirs = [
         os.path.join(self.rpmspath, dirname)
         for dirname in ['.repodata', '.olddata']
     ]
     for workdir in workdirs:
         if os.path.exists(workdir):
             log.warn('Removing stale createrepo directory %s', workdir)
             shutil.rmtree(workdir, ignore_errors=True)
     # Removed --baseurl, if upgrading you will need to manually
     # delete repodata directory before this will work correctly.
     command, returncode, out, err = run_createrepo(cwd=self.rpmspath,
                                                    update=True)
     if out:
         log.debug("stdout from %s: %s", command, out)
     if err:
         log.warn("stderr from %s: %s", command, err)
     if returncode != 0:
         if returncode < 0:
             msg = '%s killed with signal %s' % (command, -returncode)
         else:
             msg = '%s failed with exit status %s' % (command, returncode)
         if err:
             msg = '%s\n%s' % (msg, err)
         raise RuntimeError(msg)
Example #2
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath,osmajor)
        if os.path.islink(dest):
            continue # skip symlinks
        syncer = RepoSyncer(urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            syncer.sync()
        except KeyboardInterrupt:
            raise
        except HarnessRepoNotFoundError:
            log.warning('Harness packages not found for OS major %s, ignoring', osmajor)
            continue
        flag_path = os.path.join(dest, '.new_files')
        if os.path.exists(flag_path):
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError('Createrepo failed.\nreturncode:%s cmd:%s err:%s'
                        % (returncode, command, err))
            os.unlink(flag_path)
Example #3
0
 def _update_locked_repo(self):
     # Internal call that assumes the flock is already held
     # If the createrepo command crashes for some reason it may leave behind 
     # its work directories. createrepo refuses to run if .olddata exists, 
     # createrepo_c refuses to run if .repodata exists.
     workdirs = [os.path.join(self.rpmspath, dirname) for dirname in
             ['.repodata', '.olddata']]
     for workdir in workdirs:
         if os.path.exists(workdir):
             log.warn('Removing stale createrepo directory %s', workdir)
             shutil.rmtree(workdir, ignore_errors=True)
     # Removed --baseurl, if upgrading you will need to manually
     # delete repodata directory before this will work correctly.
     command, returncode, out, err = run_createrepo(
             cwd=self.rpmspath, update=True)
     if out:
         log.debug("stdout from %s: %s", command, out)
     if err:
         log.warn("stderr from %s: %s", command, err)
     if returncode != 0:
         if returncode < 0:
             msg = '%s killed with signal %s' % (command, -returncode)
         else:
             msg = '%s failed with exit status %s' % (command, returncode)
         if err:
             msg = '%s\n%s' % (msg, err)
         raise RuntimeError(msg)
Example #4
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath, osmajor)
        if os.path.islink(dest):
            continue  # skip symlinks
        syncer = RepoSyncer(
            urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            has_new_packages = syncer.sync()
        except KeyboardInterrupt:
            raise
        except Exception, e:
            log.warning('%s', e)
            continue
        if has_new_packages:
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError(
                    'Createrepo failed.\nreturncode:%s cmd:%s err:%s' %
                    (returncode, command, err))
Example #5
0
 def _create_remote_harness(self, base_path, name):
     tmp_dir = os.path.join(base_path, name)
     os.mkdir(tmp_dir)
     rpm_file = pkg_resources.resource_filename('bkr.server.tests', \
         'tmp-distribution-beaker-task_test-2.0-5.noarch.rpm')
     shutil.copy(rpm_file, tmp_dir)
     result = run_createrepo(cwd=tmp_dir)
     self.assertEqual(result.returncode, 0, result.err)
Example #6
0
 def _update_locked_repo(self):
     # Internal call that assumes the flock is already held
     # Removed --baseurl, if upgrading you will need to manually
     # delete repodata directory before this will work correctly.
     command, returncode, out, err = run_createrepo(cwd=self.rpmspath, update=True)
     if out:
         log.debug("stdout from %s: %s", command, out)
     if err:
         log.warn("stderr from %s: %s", command, err)
     if returncode != 0:
         raise RuntimeError("Createrepo failed.\nreturncode:%s cmd:%s err:%s" % (returncode, command, err))
Example #7
0
def update_repos(baseurl, basepath):
    for osmajor in OSMajor.query:
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath,osmajor)
        syncer = RepoSyncer(urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            has_new_packages = syncer.sync()
        except KeyboardInterrupt:
            raise
        except Exception, e:
            log.warning('%s', e)
            continue
        if has_new_packages:
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError('Createrepo failed.\nreturncode:%s cmd:%s err:%s'
                     % (returncode, command, err))
Example #8
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath,osmajor)
        if os.path.islink(dest):
            continue # skip symlinks
        syncer = RepoSyncer(urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            has_new_packages = syncer.sync()
        except KeyboardInterrupt:
            raise
        except Exception, e:
            log.warning('%s', e)
            continue
        if has_new_packages:
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError('Createrepo failed.\nreturncode:%s cmd:%s err:%s'
                     % (returncode, command, err))