def _build_rpm(channel, options):
    if has_changes() and channel != 'dev' and not options.force:
        print('The code was changed, aborting !')
        print('Use the dev channel if you change locally the code')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    cmd_options = {'dist': options.dist_dir}
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--dist-dir=%(dist)s --binary-only")

    # where's the spec file ?
    spec_file = get_spec_file()

    # if there's a spec file we use it
    if spec_file is not None:
        cmd_options['spec'] = spec_file
        cmd += ' --spec-file=%(spec)s'
    else:
        # if not we define a python-name for the rpm
        # grab the name and create a normalized one
        popen = subprocess.Popen('%s setup.py --name' % sys.executable,
                                 stdout=subprocess.PIPE,
                                 shell=True)
        name = [line for line in popen.stdout.read().split('\n') if line != '']
        name = name[-1].strip().lower()

        if not name.startswith('python'):
            name = '%s-%s' % (_PYTHON, name)
        elif name.startswith('python-'):
            name = '%s-%s' % (_PYTHON, name[len('python-'):])

        cmd_options['name'] = name
        cmd += ' --name=%(name)s'

    # now running the cmd
    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))
def _build_rpm(channel, options):
    if has_changes() and channel != 'dev':
        print('the code was changed, aborting!')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    # where's the spec file ?
    spec_file = get_spec_file()

    if spec_file is None:
        return

    cmd_options = {'spec': spec_file, 'dist': options.dist_dir}

    # now running the cmd
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--spec-file=%(spec)s --dist-dir=%(dist)s")

    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))
Exemple #3
0
def _build_rpm(channel, options):
    if has_changes() and channel != 'dev' and not options.force:
        print('The code was changed, aborting !')
        print('Use the dev channel if you change locally the code')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    cmd_options = {'dist': options.dist_dir}
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--dist-dir=%(dist)s --binary-only")

    # where's the spec file ?
    spec_file = get_spec_file()

    # if there's a spec file we use it
    if spec_file is not None:
        cmd_options['spec'] = spec_file
        cmd += ' --spec-file=%(spec)s'
    else:
        # if not we define a python-name for the rpm
        # grab the name and create a normalized one
        popen = subprocess.Popen('%s setup.py --name' % sys.executable,
                                 stdout=subprocess.PIPE, shell=True)
        name = [line for line in popen.stdout.read().split('\n') if line != '']
        name = name[-1].strip().lower()

        if not name.startswith('python'):
            name = '%s-%s' % (_PYTHON, name)
        elif name.startswith('python-'):
            name = '%s-%s' % (_PYTHON, name[len('python-'):])

        cmd_options['name'] = name
        cmd += ' --name=%(name)s'

    # now running the cmd
    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))