Exemple #1
0
 def test_translation_tempest_plugins(self):
     self.assertEqual(
         pymod2pkg.module2package('keystone-tempest-plugin', 'fedora'),
         'python-keystone-tests-tempest')
     self.assertEqual(
         pymod2pkg.module2package('zomg-tempest-plugin', 'fedora'),
         'python-zomg-tests-tempest')
Exemple #2
0
 def test_default_translation_rdo(self):
     self.assertEqual(pymod2pkg.module2package('oslo.db', 'fedora'),
                      'python-oslo-db')
     self.assertEqual(pymod2pkg.module2package('Babel', 'fedora'),
                      'python-babel')
     self.assertEqual(pymod2pkg.module2package('nova', 'fedora'),
                      'openstack-nova')
Exemple #3
0
 def test_default_translation_rdo(self):
     self.assertEqual(pymod2pkg.module2package('oslo.db', 'fedora'),
                      'python-oslo-db')
     self.assertEqual(pymod2pkg.module2package('Babel', 'fedora'),
                      'python-babel')
     self.assertEqual(pymod2pkg.module2package('nova', 'fedora'),
                      'openstack-nova')
Exemple #4
0
 def test_default_translation_py2py3_suse(self):
     self.assertEqual(
         pymod2pkg.module2package('oslo.db', 'suse', py_vers=['py2',
                                                              'py3']),
         ['python2-oslo.db', 'python3-oslo.db'])
     self.assertEqual(
         pymod2pkg.module2package('Babel', 'suse', py_vers=['py2', 'py3']),
         ['python2-Babel', 'python3-Babel'])
Exemple #5
0
 def test_translation_horizon_plugins(self):
     self.assertEqual(
         pymod2pkg.module2package('sahara-dashboard', 'fedora'),
         'openstack-sahara-ui')
     self.assertEqual(pymod2pkg.module2package('magnum-ui', 'fedora'),
                      'openstack-magnum-ui')
     self.assertEqual(pymod2pkg.module2package('zomg-dashboard', 'fedora'),
                      'openstack-zomg-ui')
Exemple #6
0
 def test_translation_horizon_plugins(self):
     self.assertEqual(pymod2pkg.module2package('sahara-dashboard',
                                               'fedora'),
                      'openstack-sahara-ui')
     self.assertEqual(pymod2pkg.module2package('magnum-ui', 'fedora'),
                      'openstack-magnum-ui')
     self.assertEqual(pymod2pkg.module2package('zomg-dashboard', 'fedora'),
                      'openstack-zomg-ui')
Exemple #7
0
 def test_translation_ubuntu(self):
     self.assertEqual(pymod2pkg.module2package('nova', 'ubuntu'),
                      'python-nova')
     self.assertEqual(
         pymod2pkg.module2package('python-cinderclient', 'ubuntu'),
         'python-cinderclient')
     self.assertEqual(
         pymod2pkg.module2package('python-neutronclient', 'ubuntu'),
         'python-neutronclient')
Exemple #8
0
 def test_translation_ubuntu(self):
     self.assertEqual(pymod2pkg.module2package('nova', 'ubuntu'),
                      'python-nova')
     self.assertEqual(pymod2pkg.module2package('python-cinderclient',
                                               'ubuntu'),
                      'python-cinderclient')
     self.assertEqual(pymod2pkg.module2package('python-neutronclient',
                                               'ubuntu'),
                      'python-neutronclient')
Exemple #9
0
 def test_translation_py2py3_ubuntu(self):
     self.assertEqual(
         pymod2pkg.module2package('nova', 'ubuntu', py_vers=['py2', 'py3']),
         ['python-nova', 'python3-nova'])
     self.assertEqual(
         pymod2pkg.module2package('python-cinderclient',
                                  'ubuntu',
                                  py_vers=['py2', 'py3']),
         ['python-cinderclient', 'python3-cinderclient'])
     self.assertEqual(
         pymod2pkg.module2package('python-neutronclient',
                                  'ubuntu',
                                  py_vers=['py2', 'py3']),
         ['python-neutronclient', 'python3-neutronclient'])
Exemple #10
0
    def preprocess(self, **kwargs):
        package_name = kwargs.get('package_name')
        commit_hash = kwargs.get('commit_hash')
        distgit_dir = self.distgit_dir(package_name)
        output_filename = "%s.spec" % module2package(package_name, 'fedora')
        source_dir = "%s/%s" % (self.config_options.datadir, package_name)
        preprocess = sh.renderspec.bake(_cwd=distgit_dir,
                                        _tty_out=False, _timeout=3600)
        preprocess('--spec-style', 'fedora', '--epoch',
                   '../../epoch/fedora.yaml', '--output', output_filename)
        # Replace %{version} with %{upstream_version} in spec
        # This is required by rpm-packaging specs
        for specf in os.listdir(distgit_dir):
            if specf.endswith(".spec"):
                filename = os.path.join(distgit_dir, specf)
                with open(filename, 'r+') as fp:
                    spec = fp.read()
                    spec = re.sub(r'-%{version}', '-%{upstream_version}', spec)
                    fp.seek(0)
                    fp.write(spec)

        for custom_preprocess in self.config_options.custom_preprocess:
            if custom_preprocess != '':
                run_external_preprocess(
                    cmdline=custom_preprocess,
                    pkgname=package_name,
                    distgit=distgit_dir,
                    source_dir=source_dir,
                    commit_hash=commit_hash)
Exemple #11
0
def reqquery(reqs, release, dist=None, module2pkg=True, verbose=False):
    info = rdoinfo.get_default_inforepo()
    distrepos = info.get_distrepos(release=release, dist=dist)
    r = []
    for rls, dist, repos in distrepos:
        packages = []
        for req in reqs:
            if module2pkg:
                pkg_name = pymod2pkg.module2package(req.name, dist)
            else:
                pkg_name = req.name
            vers = query.query_repos(repos, pkg_name, verbose=verbose)
            repo, nvr, v = None, None, None
            if vers:
                repo, nvr = vers[0]
                v = specfile.nvr2version(nvr)
            pkg = {
                'package': pkg_name,
                'version_required': req.vers or None,
                'version_available': v,
                'nvr_available': nvr,
                'repo_available': repo,
            }
            if module2pkg:
                pkg['module'] = req.name
            packages.append(pkg)
        vers = {
            'release': rls,
            'dist': dist,
            'packages': packages
        }
        r.append(vers)
    return r
Exemple #12
0
def get_builds_by_koji_tag(tag, mod_name, mod_version, provided_uc,
                           koji_profile, release, show_overridden_repos):
    """
    Find builds that provide the module.
    """
    try:
        builds = tag_builds[tag]
    except KeyError:
        builds = list_builds_from_tag(tag, koji_profile)
    pkg_name = pymod2pkg.module2package(mod_name, 'fedora')
    try:
        builds[pkg_name]
        provided_uc.append(UpperConstraint(mod_name, mod_version,
                                           pkg_name,
                                           builds[pkg_name]['version'],
                                           builds[pkg_name]['tag'],
                                           release,
                                           'N/A',
                                           show_overridden_repos))
    except KeyError:
        provided_uc.append(UpperConstraint(mod_name, mod_version,
                                           '',
                                           '',
                                           tag,
                                           release,
                                           'N/A',
                                           show_overridden_repos))
Exemple #13
0
def reqquery(reqs, release, dist=None, module2pkg=True, verbose=False):
    info = rdoinfo.get_default_inforepo()
    distrepos = info.get_distrepos(release=release, dist=dist)
    r = []
    for rls, dist, repos in distrepos:
        packages = []
        for req in reqs:
            if module2pkg:
                pkg_name = pymod2pkg.module2package(req.name, dist)
            else:
                pkg_name = req.name
            vers = query.query_repos(repos, pkg_name, verbose=verbose)
            repo, nvr, v = None, None, None
            if vers:
                repo, nvr = vers[0]
                v = specfile.nvr2version(nvr)
            pkg = {
                'package': pkg_name,
                'version_required': req.vers or None,
                'version_available': v,
                'nvr_available': nvr,
                'repo_available': repo,
            }
            if module2pkg:
                pkg['module'] = req.name
            packages.append(pkg)
        vers = {'release': rls, 'dist': dist, 'packages': packages}
        r.append(vers)
    return r
Exemple #14
0
    def preprocess(self, **kwargs):
        package_name = kwargs.get('package_name')
        commit_hash = kwargs.get('commit_hash')
        distgit_dir = self.distgit_dir(package_name)
        output_filename = "%s.spec" % module2package(package_name, 'fedora')
        source_dir = "%s/%s" % (self.config_options.datadir, package_name)
        preprocess = sh.renderspec.bake(_cwd=distgit_dir,
                                        _tty_out=False, _timeout=3600)
        preprocess('--spec-style', 'fedora', '--epoch',
                   '../../epoch/fedora.yaml', '--output', output_filename)
        # Replace %{version} with %{upstream_version} in spec
        # This is required by rpm-packaging specs
        for specf in os.listdir(distgit_dir):
            if specf.endswith(".spec"):
                filename = os.path.join(distgit_dir, specf)
                with open(filename, 'r+') as fp:
                    spec = fp.read()
                    spec = re.sub('-%{version}', '-%{upstream_version}', spec)
                    fp.seek(0)
                    fp.write(spec)

        for custom_preprocess in self.config_options.custom_preprocess:
            if custom_preprocess != '':
                run_external_preprocess(
                    cmdline=custom_preprocess,
                    pkgname=package_name,
                    distgit=distgit_dir,
                    source_dir=source_dir,
                    commit_hash=commit_hash)
Exemple #15
0
 def test_translation_py2py3_suse(self):
     self.assertEqual(
         pymod2pkg.module2package('nova',
                                  'suse',
                                  py_vers=['py', 'py2', 'py3']),
         ['openstack-nova', '', ''])
     self.assertEqual(
         pymod2pkg.module2package('aodhclient',
                                  'suse',
                                  py_vers=['py2', 'py3']),
         ['python2-aodhclient', 'python3-aodhclient'])
     self.assertEqual(
         pymod2pkg.module2package('gnocciclient',
                                  'suse',
                                  py_vers=['py2', 'py3']),
         ['python2-gnocciclient', 'python3-gnocciclient'])
     self.assertEqual(
         pymod2pkg.module2package('python-cinderclient',
                                  'suse',
                                  py_vers=['py2', 'py3']),
         ['python2-cinderclient', 'python3-cinderclient'])
     self.assertEqual(
         pymod2pkg.module2package('python-neutronclient',
                                  'suse',
                                  py_vers=['py2', 'py3']),
         ['python2-neutronclient', 'python3-neutronclient'])
     self.assertEqual(
         pymod2pkg.module2package('Tempest',
                                  'suse',
                                  py_vers=['py', 'py2', 'py3']),
         ['openstack-tempest', '', ''])
     self.assertEqual(
         pymod2pkg.module2package('devel', 'suse', py_vers=['py2', 'py3']),
         ['python-devel', 'python3-devel'])
Exemple #16
0
def pymodule2pkg(spectemplate):
    specname = os.path.splitext(spectemplate)[0]
    modulename = os.path.splitext(os.path.basename(specname))[0]
    pkgname = pymod2pkg.module2package(modulename,
                                       platform.linux_distribution()[0])
    if modulename == 'openstack-macros':
        pkgname = modulename

    return pkgname
Exemple #17
0
def pymodule2pkg(spectemplate):
    specname = os.path.splitext(spectemplate)[0]
    modulename = os.path.splitext(os.path.basename(specname))[0]
    pkgname = pymod2pkg.module2package(modulename,
                                       platform.linux_distribution()[0])
    if modulename == 'openstack-macros':
        pkgname = modulename

    return pkgname
Exemple #18
0
    def test_default_translation_py2py3_rdo(self):
        self.assertEqual(
            pymod2pkg.module2package('oslo.db',
                                     'fedora',
                                     py_vers=['py2', 'py3']),
            ['python-oslo-db', 'python3-oslo-db'])
        self.assertEqual(
            pymod2pkg.module2package('foobar',
                                     'fedora',
                                     py_vers=['py', 'py2', 'py3']),
            ['python-foobar', 'python-foobar', 'python3-foobar'])

        self.assertEqual(
            pymod2pkg.module2package('Babel', 'fedora', py_vers=['py2',
                                                                 'py3']),
            ['python-babel', 'python3-babel'])
        self.assertEqual(
            pymod2pkg.module2package('nova',
                                     'fedora',
                                     py_vers=['py', 'py2', 'py3']),
            ['openstack-nova', '', ''])
Exemple #19
0
def _pymod2pkg_translate(pkg_name, context, py_versions):
    """translate a given package name for a single or multiple py versions"""
    if py_versions and not isinstance(py_versions, (list, tuple)):
        py_versions = [py_versions]
    kwargs = {}
    if py_versions:
        kwargs['py_vers'] = list(
            set(py_versions) - set((context['skip_pyversion'], )))
    translations = pymod2pkg.module2package(pkg_name, context['spec_style'],
                                            **kwargs)
    # we want always return a list but module2package() might return a string
    if not isinstance(translations, (list, tuple)):
        translations = [translations]
    return translations
Exemple #20
0
 def test_translation_horizon_plugins(self):
     self.assertEqual(
         pymod2pkg.module2package('sahara-dashboard', 'fedora'),
         'openstack-sahara-ui')
     self.assertEqual(pymod2pkg.module2package('magnum-ui', 'fedora'),
                      'openstack-magnum-ui')
     self.assertEqual(pymod2pkg.module2package('zomg-dashboard', 'fedora'),
                      'openstack-zomg-ui')
     self.assertEqual(pymod2pkg.module2package('sahara-dashboard', 'suse'),
                      'openstack-horizon-plugin-sahara-ui')
     self.assertEqual(pymod2pkg.module2package('magnum-ui', 'suse'),
                      'openstack-horizon-plugin-magnum-ui')
     self.assertEqual(
         pymod2pkg.module2package('neutron-fwaas-dashboard', 'suse'),
         'openstack-horizon-plugin-neutron-fwaas-ui')
     self.assertEqual(
         pymod2pkg.module2package('horizon-plugin-neutron-fwaas-ui',
                                  'suse'),
         'python-horizon-plugin-neutron-fwaas-ui')
     self.assertEqual(pymod2pkg.module2package('zomg-dashboard', 'suse'),
                      'openstack-horizon-plugin-zomg-ui')
     self.assertEqual(pymod2pkg.module2package('XStatic-jquery-ui', 'suse'),
                      'python-XStatic-jquery-ui')
Exemple #21
0
 def preprocess(self, **kwargs):
     package_name = kwargs.get('package_name')
     distgit_dir = self.distgit_dir(package_name)
     output_filename = "%s.spec" % module2package(package_name, 'fedora')
     preprocess = sh.renderspec.bake(_cwd=distgit_dir,
                                     _tty_out=False, _timeout=3600)
     preprocess('--spec-style', 'fedora', '--epoch',
                '../../epoch/fedora.yaml', '--output', output_filename)
     # Replace %{version} with %{upstream_version} in spec
     # This is required by rpm-packaging specs
     for specf in os.listdir(distgit_dir):
         if specf.endswith(".spec"):
             filename = os.path.join(distgit_dir, specf)
             with open(filename, 'r+') as fp:
                 spec = fp.read()
                 spec = re.sub('-%{version}', '-%{upstream_version}', spec)
                 fp.seek(0)
                 fp.write(spec)
Exemple #22
0
 def test_translation_suse(self):
     self.assertEqual(pymod2pkg.module2package('nova', 'suse'),
                      'openstack-nova')
     self.assertEqual(pymod2pkg.module2package('aodhclient', 'suse'),
                      'python-aodhclient')
     self.assertEqual(pymod2pkg.module2package('gnocciclient', 'suse'),
                      'python-gnocciclient')
     self.assertEqual(
         pymod2pkg.module2package('python-cinderclient', 'suse'),
         'python-cinderclient')
     self.assertEqual(
         pymod2pkg.module2package('python-neutronclient', 'suse'),
         'python-neutronclient')
     self.assertEqual(pymod2pkg.module2package('Tempest', 'suse'),
                      'openstack-tempest')
     self.assertEqual(pymod2pkg.module2package('heat-agents', 'suse'),
                      'openstack-heat-agents')
def find_openbuildservice_pkg_version(published_xml, pkg_name):
    """find the version in the openbuildservice published xml for the given
    pkg name"""
    import pymod2pkg
    import xml.etree.ElementTree as ET

    if published_xml and os.path.exists(published_xml):
        with open(published_xml) as f:
            tree = ET.fromstring(f.read())

        distro_pkg_name = pymod2pkg.module2package(pkg_name, 'suse')
        for child in tree:
            if not child.attrib['name'].startswith('_') and \
               child.attrib['name'].endswith('.rpm') and not \
               child.attrib['name'].endswith('.src.rpm'):
                (name, ver, release, epoch, arch) = _rpm_split_filename(
                    child.attrib['name'])
                if name == distro_pkg_name:
                    return version.parse(ver)
    return version.parse('0')
def find_openbuildservice_pkg_version(published_xml, pkg_name):
    """find the version in the openbuildservice published xml for the given
    pkg name"""
    import pymod2pkg
    import xml.etree.ElementTree as ET

    if published_xml and os.path.exists(published_xml):
        with open(published_xml) as f:
            tree = ET.fromstring(f.read())

        distro_pkg_name = pymod2pkg.module2package(pkg_name, 'suse')
        for child in tree:
            if not child.attrib['name'].startswith('_') and \
               child.attrib['name'].endswith('.rpm') and not \
               child.attrib['name'].endswith('.src.rpm'):
                (name, ver, release, epoch,
                 arch) = _rpm_split_filename(child.attrib['name'])
                if name == distro_pkg_name:
                    return version.parse(ver)
    return version.parse('0')
Exemple #25
0
def get_packages_provided_by_repos(mod_name, mod_version, provided_uc,
                                   repo_url, repo, repos_dir, distro, release,
                                   show_overridden_repos):
    """
    Find packages that provide the module.
    For distro with releasever > 7, we take advantage of the Python
    dependency generator (e.g python3dist(foo)) which returns the package name.
    Else, we use pymod2pkg to get package names.
    After, the repoquery command execution, we append the global list with the
    result.
    """
    if int(distro[-1]) > 7:
        pkg_name = "python3dist({})".format(mod_name.lower())
    else:
        pkg_name = pymod2pkg.module2package(mod_name, 'fedora')
    download_repos_metadata(repo_url, repo, repos_dir, distro)
    latest_pkg = repoquery(provides=pkg_name, latest=True)
    all_repos_providing_pkg = get_all_repos_providing_pkg(pkg_name)
    try:
        pkg = latest_pkg.pop()
        all_repos_providing_pkg.remove(pkg.reponame)
        if len(all_repos_providing_pkg) > 0:
            overridden_repos = ' '.join(all_repos_providing_pkg)
        else:
            overridden_repos = 'None'
        provided_uc.append(UpperConstraint(mod_name, mod_version,
                                           pkg.name,
                                           pkg.version,
                                           pkg.reponame,
                                           release,
                                           overridden_repos,
                                           show_overridden_repos))
    except IndexError:
        provided_uc.append(UpperConstraint(mod_name, mod_version,
                                           '',
                                           '',
                                           '',
                                           release,
                                           '',
                                           show_overridden_repos))
Exemple #26
0
 def test_translation_suse(self):
     self.assertEqual(pymod2pkg.module2package('nova', 'suse'),
                      'openstack-nova')
     self.assertEqual(pymod2pkg.module2package('aodhclient',
                                               'suse'),
                      'python-aodhclient')
     self.assertEqual(pymod2pkg.module2package('gnocciclient',
                                               'suse'),
                      'python-gnocciclient')
     self.assertEqual(pymod2pkg.module2package('python-cinderclient',
                                               'suse'),
                      'python-cinderclient')
     self.assertEqual(pymod2pkg.module2package('python-neutronclient',
                                               'suse'),
                      'python-neutronclient')
     self.assertEqual(pymod2pkg.module2package('Tempest', 'suse'),
                      'openstack-tempest')
Exemple #27
0
def _context_py2pkg(context, pkg_name, pkg_version=None):
    """generate a distro specific package name with optional version tuple."""
    # package name handling
    name = pymod2pkg.module2package(pkg_name, context["spec_style"])

    # if no pkg_version is given, look in the requirements and set one
    if not pkg_version:
        if pkg_name in context["requirements"]:
            pkg_version = (">=", context["requirements"][pkg_name])

    # pkg_version is a tuple with comparator and number, i.e. "('>=', '1.2.3')"
    if pkg_version:
        # epoch handling
        if pkg_name in context["epochs"].keys():
            epoch = "%s:" % context["epochs"][pkg_name]
        else:
            epoch = ""
        v_comparator, v_number = pkg_version
        v_str = " %s %s%s" % (v_comparator, epoch, v_number)
    else:
        v_str = ""

    return "%s%s" % (name, v_str)
Exemple #28
0
def map_reqs2pkgs(reqs, dist):
    for r in reqs:
        r.name = pymod2pkg.module2package(r.name, dist)
    return reqs
Exemple #29
0
 def test_default_translation_suse(self):
     self.assertEqual(pymod2pkg.module2package('oslo.db', 'suse'),
                      'python-oslo.db')
     self.assertEqual(pymod2pkg.module2package('Babel', 'suse'),
                      'python-Babel')
Exemple #30
0
 def test_translation_suse(self):
     self.assertEqual(pymod2pkg.module2package('nova', 'suse'),
                      'openstack-nova')
     self.assertEqual(pymod2pkg.module2package('python-neutronclient',
                                               'suse'),
                      'python-neutronclient')
Exemple #31
0
def map_reqs2pkgs(reqs, dist):
    for r in reqs:
        r.name = pymod2pkg.module2package(r.name, dist)
    return reqs
Exemple #32
0
 def test_default_translation_suse(self):
     self.assertEqual(pymod2pkg.module2package('oslo.db', 'suse'),
                      'python-oslo.db')
     self.assertEqual(pymod2pkg.module2package('Babel', 'suse'),
                      'python-Babel')
Exemple #33
0
def _context_py2name(context, pkg_name):
    return pymod2pkg.module2package(pkg_name, context["spec_style"])