Ejemplo n.º 1
0
    def run_package_command(self, package_hashes, wheel_dir='wheels'):
        logger.debug('Config')
        logger.debug(self.config)
        if not self.config['docker_container'].get('container_name', None):
            self.config['docker_container'][
                'container_name'] = 'invirtualenvapp/' + self.config['global'][
                    'name']
        self.config['docker_container']['files'].append(
            'deploy.conf /var/lib/invirtualenv/deploy.conf')
        for package, hash in package_hashes.items():
            source_filename = os.path.join(wheel_dir, package)
            dest_filename = '/var/lib/invirtualenv/wheels/{name}/{package}'.format(
                name=self.config['global']['name'], package=package)
            self.config['docker_container']['files'].append(source_filename +
                                                            ' ' +
                                                            dest_filename)

        self.write_command_scripts()

        logger.debug('Dockerfile')
        logger.debug(self.render_template_with_config())
        with open('Dockerfile', 'w') as dockerfile_handle:
            dockerfile_handle.write(self.render_template_with_config())
        container_tag = '{name}:{version}'.format(
            name=self.config['docker_container']['container_name'],
            version=self.config['global']['version'])
        command = [
            find_executable('docker'), 'build', '-t', container_tag, '.'
        ]
        logger.debug('Running command %r', ' '.join(command))
        subprocess.check_call(command)
        return container_tag
Ejemplo n.º 2
0
    def run_package_command(self, package_hashes, wheel_dir='wheels'):
        # Make sure the configuration is sane
        # self.config['rpm_package']['deps'].append('invirtualenv')
        self.config['rpm_package']['cwd'] = os.getcwd()
        description = self.config['global'].get('description', '').strip()
        if not description:
            self.config['global']['description'] = 'No description available'

        # Get the packaging script
        for script in ['rpm_scripts/post_install.py', 'rpm_scripts/pre_uninstall.py']:
            with open(os.path.basename(script), 'wb') as script_handle:
                script_handle.write(pkgutil.get_data('invirtualenv_plugins', script))

        logger.debug('Config')
        logger.debug(self.config)
        logger.debug('Spec')
        logger.debug(self.render_template_with_config())
        logger.debug('Deploy.conf')
        logger.debug(open('deploy.conf').read())
        with open('package.spec', 'w') as spec_handle:
            spec_handle.write(self.render_template_with_config())
        os.system('ls -lR')
        command = [find_executable('rpmbuild'), '-ba', 'package.spec']
        logger.debug('Running command %r', ' '.join(command))
        output = subprocess.check_output(command, env={'LANG': 'C'})
        output = output.decode(errors='ignore')
        packages = []
        for line in output.split('\n'):
            line = line.strip()
            if line.startswith('Wrote: '):
                packages.append(line.split()[-1])
        logger.debug('found packages %r', packages)
        if packages:
            return packages[-1]
Ejemplo n.º 3
0
    def run_package_command(self, package_hashes, wheel_dir='wheels'):
        logger.debug('Config')
        logger.debug(self.config)
        if not self.config['docker_container'].get('container_name', None):
            self.config['docker_container']['container_name'] = 'invirtualenvapp/' + self.config['global']['name']
        self.config['docker_container']['files'].append('deploy.conf /var/lib/invirtualenv/deploy.conf')
        for package, hash in package_hashes.items():
            source_filename = os.path.join(wheel_dir, package)
            dest_filename = '/var/lib/invirtualenv/wheels/{name}/{package}'.format(name=self.config['global']['name'], package=package)
            self.config['docker_container']['files'].append(source_filename + ' ' + dest_filename)

        self.write_command_scripts()

        logger.debug('Dockerfile')
        logger.debug(self.render_template_with_config())
        with open('Dockerfile', 'w') as dockerfile_handle:
            dockerfile_handle.write(self.render_template_with_config())
        container_tag = '{name}:{version}'.format(name=self.config['docker_container']['container_name'], version=self.config['global']['version'])
        command = [find_executable('docker'), 'build', '-t', container_tag, '.']
        logger.debug('Running command %r', ' '.join(command))
        subprocess.check_call(command)
        return container_tag
Ejemplo n.º 4
0
    def run_package_command(self, package_hashes, wheel_dir='wheels'):
        # Make sure the configuration is sane
        # self.config['rpm_package']['deps'].append('invirtualenv')
        self.config['rpm_package']['cwd'] = os.getcwd()
        description = self.config['global'].get('description', '').strip()
        if not description:
            self.config['global']['description'] = 'No description available'

        # Get the packaging script
        for script in [
                'rpm_scripts/post_install.py', 'rpm_scripts/pre_uninstall.py'
        ]:
            with open(os.path.basename(script), 'wb') as script_handle:
                script_handle.write(
                    pkgutil.get_data('invirtualenv_plugins', script))

        logger.debug('Config')
        logger.debug(self.config)
        logger.debug('Spec')
        logger.debug(self.render_template_with_config())
        logger.debug('Deploy.conf')
        logger.debug(open('deploy.conf').read())
        with open('package.spec', 'w') as spec_handle:
            spec_handle.write(self.render_template_with_config())
        os.system('ls -lR')
        command = [find_executable('rpmbuild'), '-ba', 'package.spec']
        logger.debug('Running command %r', ' '.join(command))
        output = subprocess.check_output(command)
        output = output.decode(errors='ignore')
        packages = []
        for line in output.split('\n'):
            line = line.strip()
            if line.startswith('Wrote: '):
                packages.append(line.split()[-1])
        logger.debug('found packages %r', packages)
        if packages:
            return packages[-1]
Ejemplo n.º 5
0
 def system_requirements_ok(self):
     if find_executable('docker'):
         return True
     logger.debug(
         'The docker command is not present, disabling the rpm plugin')
     return False
Ejemplo n.º 6
0
 def system_requirements_ok(self):
     if find_executable('rpmbuild'):
         return True
     logger.debug('The rpmbuild command is not present, disabling the rpm plugin')
     return False