def pristine_tar_build_orig(repo, cp, output_dir, options): """ build orig using pristine-tar @return: True: orig tarball build, False: noop """ if options.pristine_tar: if not repo.has_branch(repo.pristine_tar_branch): gbp.log.warn('Pristine-tar branch "%s" not found' % repo.pristine_tar.branch) try: repo.pristine_tar.checkout(cp.name, cp.upstream_version, options.comp_type, output_dir) pristine_tree = repo.list_tree(repo.pristine_tar.branch, recurse=True) pristine_files = [ os.path.splitext(item[3])[0] for item in pristine_tree if item[3].endswith('.id') ] for component in du.orig_components(du.orig_file(cp, options.comp_type), pristine_files).iterkeys(): repo.pristine_tar.checkout(cp.name, cp.upstream_version, options.comp_type, output_dir, component) return True except CommandExecFailed: if options.pristine_tar_commit: gbp.log.debug("pristine-tar checkout failed, " "will commit tarball due to " "'--pristine-tar-commit'") else: raise return False
def extract_orig(orig_tarball, dest_dir): """extract orig tarball to export dir before exporting from git""" gbp.log.info("Extracting %s to '%s'" % (os.path.basename(orig_tarball), dest_dir)) move_old_export(dest_dir) upstream = UpstreamSource(orig_tarball) upstream.unpack(dest_dir) # Check if tarball extracts into a single folder or not: if upstream.unpacked != dest_dir: # If it extracts a single folder, move its contents to dest_dir: gbp.log.debug("Moving %s to %s" % (upstream.unpacked, dest_dir)) tmpdir = dest_dir + '.new' os.rename(upstream.unpacked, tmpdir) os.rmdir(dest_dir) os.rename(tmpdir, dest_dir) src_dir = os.path.dirname(orig_tarball) for component, filename in du.orig_components(orig_tarball, os.listdir(src_dir)).iteritems(): additional_component = UpstreamSource(filename) additional_component.unpack(dest_dir, strip_toplevel=False)