def git_archive(repo, spec, output_dir, treeish, prefix, comp_level,
                with_submodules):
    "Create a compressed orig tarball in output_dir using git_archive"
    comp_opts = ''
    if spec.orig_src['compression']:
        comp_opts = compressor_opts[spec.orig_src['compression']][0]

    output = os.path.join(output_dir, spec.orig_src['filename'])

    # Remove extra slashes from prefix, will be added by git_archive_x funcs
    prefix = prefix.strip('/')
    try:
        if repo.has_submodules(treeish) and with_submodules:
            repo.update_submodules()
            git_archive_submodules(repo, treeish, output, prefix,
                                   spec.orig_src['compression'],
                                   comp_level, comp_opts,
                                   spec.orig_src['archive_fmt'])

        else:
            git_archive_single(treeish, output, prefix,
                               spec.orig_src['compression'], comp_level,
                               comp_opts)
    except (GitRepositoryError, CommandExecFailed):
        gbp.log.err("Error generating submodules' archives")
        return False
    return True
Esempio n. 2
0
def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules):
    "create a compressed orig tarball in output_dir using git_archive"
    try:
        comp_opts = compressor_opts[comp_type][0]
    except KeyError:
        raise GbpError("Unsupported compression type '%s'" % comp_type)

    output = os.path.join(output_dir, du.orig_file(cp, comp_type))
    prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])

    try:
        if repo.has_submodules() and with_submodules:
            repo.update_submodules()
            git_archive_submodules(repo, treeish, output, prefix,
                                   comp_type, comp_level, comp_opts)

        else:
            git_archive_single(treeish, output, prefix,
                               comp_type, comp_level, comp_opts)
    except (GitRepositoryError, CommandExecFailed):
        gbp.log.err("Error generating submodules' archives")
        return False
    except OSError as err:
        gbp.log.err("Error creating %s: %s" % (output, err[0]))
        return False
    except GbpError:
        raise
    except Exception as e:
        gbp.log.err("Error creating %s: %s" % (output, e))
        return False
    return True
def git_archive(repo, spec, output_dir, treeish, prefix, comp_level,
                with_submodules):
    "Create a compressed orig tarball in output_dir using git_archive"
    comp_opts = ''
    if spec.orig_src['compression']:
        comp_opts = compressor_opts[spec.orig_src['compression']][0]

    output = os.path.join(output_dir, spec.orig_src['filename'])

    # Remove extra slashes from prefix, will be added by git_archive_x funcs
    prefix = prefix.strip('/')
    try:
        if repo.has_submodules(treeish) and with_submodules:
            repo.update_submodules()
            git_archive_submodules(repo, treeish, output, prefix,
                                   spec.orig_src['compression'], comp_level,
                                   comp_opts, spec.orig_src['archive_fmt'])

        else:
            git_archive_single(treeish, output, prefix,
                               spec.orig_src['compression'], comp_level,
                               comp_opts, spec.orig_src['archive_fmt'])
    except (GitRepositoryError, CommandExecFailed):
        gbp.log.err("Error generating submodules' archives")
        return False
    return True
Esempio n. 4
0
def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level,
                with_submodules):
    "create a compressed orig tarball in output_dir using git_archive"
    try:
        comp_opts = compressor_opts[comp_type][0]
    except KeyError:
        raise GbpError("Unsupported compression type '%s'" % comp_type)

    output = os.path.join(output_dir, du.orig_file(cp, comp_type))
    prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])

    try:
        if repo.has_submodules() and with_submodules:
            repo.update_submodules()
            git_archive_submodules(repo, treeish, output, prefix, comp_type,
                                   comp_level, comp_opts)

        else:
            git_archive_single(treeish, output, prefix, comp_type, comp_level,
                               comp_opts)
    except (GitRepositoryError, CommandExecFailed):
        gbp.log.err("Error generating submodules' archives")
        return False
    except OSError as err:
        gbp.log.err("Error creating %s: %s" % (output, err[0]))
        return False
    except GbpError:
        raise
    except Exception as e:
        gbp.log.err("Error creating %s: %s" % (output, e))
        return False
    return True
Esempio n. 5
0
def test_create_zip_archives():
    """Create an upstream zip archive"""
    git_archive_submodules(REPO, 'HEAD', 'with-submodules.zip', 'test', '', '',
                           '', 'zip')
    # Check that submodules were included
    contents = ls_zip('with-submodules.zip')
    ok_('test/test_submodule/testfile' in contents)

    git_archive_single('HEAD', 'without-submodules.zip', 'test', '', None, '',
                       'zip')
    contents = ls_zip('without-submodules.zip')
    ok_('test/test_submodule/testfile' not in contents)
def test_create_zip_archives():
    """Create an upstream zip archive"""
    git_archive_submodules(REPO, 'HEAD', 'with-submodules.zip', 'test',
                           '', '', '', 'zip')
    # Check that submodules were included
    contents = ls_zip('with-submodules.zip')
    ok_('test/test_submodule/testfile' in contents)

    git_archive_single('HEAD', 'without-submodules.zip', 'test',
                       '', '', '', 'zip')
    contents = ls_zip('without-submodules.zip')
    ok_('test/test_submodule/testfile' not in contents)