Exemplo n.º 1
0
    def do_pkg_rpm(self, destdir=None, targz_fp=None):
        if not targz_fp:
            targz_fp = self.pkg_tarball(destdir=destdir)

        # untar tarball
        with archive.tarfile(targz_fp, 'r:gz') as tar:
            tar.extractall(destdir)

        # create skeleton for rpmbuild
        rpmbuild_dir = join(destdir, 'rpmbuild')
        for d in ['RPMS', 'SOURCES', 'SPECS', 'SRPMS', 'BUILD']:
            d = join(rpmbuild_dir, d)
            os.makedirs(d)

        # copy tarball to the right place
        shutil.copyfile(targz_fp,
                        join(rpmbuild_dir, 'SOURCES', self.targz_name))

        # clone spec file
        specfile = '{0}.spec'.format(self.name)
        specfile_fp = join(destdir, specfile)
        shutil.copyfile(join(self.repo_basedir, 'etc', 'packaging', 'skel.spec'),
                        specfile_fp)

        # extract list of installed files from makefile
        makefile_fp = join(destdir, self.pkgname, 'Makefile')
        content = open(makefile_fp, 'rt').read()
        content = text.safefind('(?s)install:\s*.*', content)

        files = []
        lines = content.split('\n')
        for line in lines:
            if '${DESTDIR}' in line:
                parts = re.split('[ ]', line)
                path = parts[-1]
                path = re.sub('^' + re.escape('${DESTDIR}'), '', path)
                files.append(path)
        files.sort()

        # patch spec file
        context = {
            '(?m)^(Summary:\s*).*': '\g<1> {0}'.format(self.rpmmeta_summary),
            '(?m)^(Name:\s*).*': '\g<1> {0}'.format(self.name),
            '(?m)^(Version:\s*).*': '\g<1> {0}'.format(self.versiontag),
            '(?m)^(Release:\s*).*': '\g<1> {0}'.format(self.buildnum),
            '(?m)^(License:\s*).*': '\g<1> {0}'.format(self.license),
            '(?m)^(Group:\s*).*': '\g<1> {0}'.format(self.rpmmeta_group),
            '(?m)^(BuildArch:\s*).*': '\g<1> {0}'.format(self.rpmmeta_arch),
            '(?m)^(Source:\s*).*': '\g<1> {0}'.format(self.targz_name),
            '(?m)^(BuildRoot:\s*).*': '\g<1> {0}/%{{name}}-buildroot'.format(d),
            '(?m)^(Requires:\s*).*': '\g<1> {0}'.format(', '.join(self.rpmmeta_requires)),
            '(?m)^.*[<]desc[>].*': self.rpmmeta_desc,
            '(?m)^.*[<]files[>].*': '\n'.join(files),
        }
        text.patch_file(context, specfile_fp, dest=specfile_fp, literal=False)

        with warn_only():
            run_cmd('rpmbuild -ba {0} --define "_topdir {1}"'.format(
                specfile_fp, rpmbuild_dir))
Exemplo n.º 2
0
def start():
    ldap_env = LdapEnv.get()

    if ldap_env.is_tmp_daemon:
        args = ldap_env.slapd_args
        args = ' '.join(args)
        with warn_only():
            proc.run_cmd(args, sudo=True)
    else:
        env.sudo('service slapd start')
Exemplo n.º 3
0
    def include_deps_post_hook(self, destdir, venv):
        # Collect static files
        py = join(venv.location, 'bin', 'python')
        manage_py = join(destdir, 'webservice', 'manage.py')

        with proc.setenv('PYTHONPATH', destdir):
            output = run_cmd('{0} {1} collectstatic --noinput'.format(
                py, manage_py))
            output = run_cmd('{0} {1} compile_pygments_css'.format(
                py, manage_py))
            stdio.write(output)
Exemplo n.º 4
0
def get_commit_id():
    '''Find the commit id of the checked out repo we are in.'''

    id = ''

    if fs.sh_which('svn'):
        with quiet():
            content = run_cmd('svn info')
            if content:
                detected = text.safefind('(?m)^Revision: ([0-9]+)', content)
                if detected:
                    id = detected

    if not id:
        if fs.sh_which('git'):
            with quiet():
                content = run_cmd('git svn info')
                if content:
                    detected = text.safefind('(?m)^Revision: ([0-9]+)', content)
                    if detected:
                        id = detected

    return id
Exemplo n.º 5
0
def sh_mkenv(cwd, name, **kwargs):
    with lcd(cwd):
        with quiet():
            return run_cmd('virtualenv {0}'.format(name),
                           capture=True,
                           **kwargs)
Exemplo n.º 6
0
    def do_pkg_deb(self, destdir=None, targz_fp=None):
        if not targz_fp:
            targz_fp = self.pkg_tarball(destdir=destdir)

        # untar tarball
        with archive.tarfile(targz_fp, 'r:gz') as tar:
            tar.extractall(destdir)

        # clone dh_make
        dh_make_src = fs.sh_which('dh_make')
        dh_make = join(destdir, 'dh_make')
        shutil.copy2(dh_make_src, dh_make)

        # get rid of dh_make interactive prompt
        context = {
            '(?m)^.*my [$]dummy = <STDIN>.*$': '',
        }
        text.patch_file(context, dh_make, dest=dh_make, literal=False)

        pkgloc = join(destdir, self.pkgname)
        with lcd(pkgloc):
            # debianize
            os.environ['DEBFULLNAME'] = self.maintainer_fullname
            os.environ['DEBEMAIL'] = self.maintainer_email
            run_cmd('{0} -i -c {1} -e {2} -f {3}'.format(
                dh_make, self.license, self.maintainer_email,
                '../{0}'.format(self.targz_name)))

            # patch control file
            control_fp = join(pkgloc, 'debian', 'control')
            context = {
                '(?m)^(Section:).*$': '\g<1> {0}'.format(self.debmeta_section),
                '(?m)^(Homepage:).*$': '\g<1> {0}'.format(self.debmeta_homepage),
                '(?m)^(Depends:.*)$': '\g<1>, {0}'.format(', '.join(self.debmeta_depends)),
                '(?m)^(Description:).*$': '\g<1> {0}'.format(self.debmeta_desc),
                '(?m)^ [<]insert long description.*$': ' {0}'.format(self.debmeta_longdesc),
            }
            text.patch_file(context, control_fp, dest=control_fp, literal=False)

            # patch changelog file
            changelog_fp = join(pkgloc, 'debian', 'changelog')
            context = {
                '(?m)^.*[*] Initial release.*$': '  * {0}'.format(self.debmeta_changelog_msg),
                '(?m)^.*({0} )[(]([0-9._-]+)[)](.*)$'.format(self.name): '\g<1>({0}-{1})\g<3>'.format(self.release, self.buildnum),
            }
            text.patch_file(context, changelog_fp, dest=changelog_fp, literal=False)

            # replace copyright file
            copyright_fp = join(pkgloc, 'debian', 'copyright')
            shutil.copyfile(
                join(self.repo_basedir, 'etc', 'packaging',
                     '{0}.license'.format(self.name)),
                copyright_fp,
            )

            debian_dir = join(pkgloc, 'debian')
            fs.rm(debian_dir, 'README.Debian')
            fs.rm(debian_dir, '*.ex')
            fs.rm(debian_dir, '*.EX')

            # build the package
            with warn_only():
                run_cmd('dpkg-buildpackage -rfakeroot -uc -us')  # omit pgp signing
Exemplo n.º 7
0
def sh_mkenv(cwd, name, **kwargs):
    with lcd(cwd):
        with quiet():
            return run_cmd('virtualenv {0}'.format(name), capture=True, **kwargs)