Пример #1
0
    def build(self, src_name, src_dir, env=None):
        # copy files into shared volume
        shared_dir = os.path.join(self.settings['build-dir'], src_name)
        host.execute('mkdir -p %s' % shared_dir)
        src_dir = os.path.abspath(src_dir)
        parent_dir, src = os.path.dirname(src_dir), os.path.basename(src_dir)
        args = [
            "rsync --delete-excluded --recursive",
            "--include='%s'" % src,
            "--include='%s/*'" % src,
            "--include='%s/**/*'" % src,
            "--include='%s_*.orig.*'" % src_name,
            "--include='%s.orig.*'" % src_name,
            "--exclude='*'",
            "%s/" % parent_dir,
            "%s/" % shared_dir,
        ]
        host.execute(' '.join(args))

        # build packages

        client = connect()

        work_dir = os.path.join('/meuh/build', src_name, src)
        env = ctx.inline(env or {})

        for cmd in self.settings['publish-commands']:
            formatted = ['/bin/sh', '-c', '%s' % cmd]
            logger.info('execute %s', cmd)
            for res in client.execute(self.container_id,
                                      cmd=formatted,
                                      stream=True):
                print(res, end='')

        for cmd in self.settings['build-commands']:
            formatted = ['/bin/sh',
                         '-c',
                         'cd %s && %s %s' % (work_dir, env, cmd)]
            logger.info('execute %s', 'cd %s && %s %s' % (work_dir, env, cmd))
            for res in client.execute(self.container_id,
                                      cmd=formatted,
                                      stream=True):
                print(res, end='')

        # publish results
        args = [
            "rsync --recursive",
            "--include='*.deb'",
            "--include='*.udeb'",
            "--include='*.dsc'",
            "--include='*.changes'",
            "--exclude='*'",
            "%s/" % os.path.join('/meuh/build', src_name),
            '/meuh/publish'
        ]
        self.execute(' '.join(args))
        logger.info('artifacts are published into /meuh/publish')
Пример #2
0
    def fetch_src(self, pkg, parent_dir):
        """Fetch sources of package"""

        work_dir = '/tmp/meuh/%s' % pkg
        self.execute('mkdir -p %s' % work_dir)
        self.execute('rm -rf %s/*' % work_dir)
        self.execute('cd %s && apt-get update && apt-get source %s' % (work_dir, pkg))  # noqa

        tmp_dir = host.execute('mktemp -d /tmp/meuh-src.XXXX').stdout.strip()
        self.download(work_dir, tmp_dir, extract_here=True)
        host.execute('mkdir -p %s' % parent_dir)
        host.execute('rsync --delete-after --recursive %s/* %s/' % (tmp_dir, parent_dir))  # noqa
        host.execute('rm -rf %s' % tmp_dir)
        self.execute('rm -rf %s/*' % work_dir)
Пример #3
0
def is_running(name):
    from meuh import host
    resp = host.execute("ps aux | grep '\--comment boot2docker-vm'").returncode
    return resp == 0