Merge ~lool/git-build-recipe:fallback-on-pristine-tar-checkout-failures into git-build-recipe:master

Proposed by Loïc Minier
Status: Needs review
Proposed branch: ~lool/git-build-recipe:fallback-on-pristine-tar-checkout-failures
Merge into: git-build-recipe:master
Diff against target: 46 lines (+16/-6)
1 file modified
gitbuildrecipe/deb_util.py (+16/-6)
Reviewer Review Type Date Requested Status
Hector CAO (community) Needs Information
Launchpad code reviewers Pending
Review via email: mp+443943@code.launchpad.net

Commit message

Trying to build https://code.launchpad.net/~lool/+recipe/linux-nvidia-tegra-sidecar-daily I first run into issues with missing refs for pristine-tar to work, but fixing these (https://code.launchpad.net/~lool/git-build-recipe/+git/git-build-recipe/+merge/443942) I run into a pristine-tar issue:
tar: /tmp/pristine-tar.CAMo9gloTn/recreatetarball: Wrote only 8192 of 10240 bytes
tar: Error is not recoverable: exiting now
pristine-tar: command failed: tar cf /tmp/pristine-tar.CAMo9gloTn/recreatetarball --owner 0 --group 0 --numeric-owner -C /tmp/pristine-tar.CAMo9gloTn/workdir --no-recursion --mode 0644 --verbatim-files-from --files-from /tmp/pristine-tar.CAMo9gloTn/manifest
pristine-tar: failed to generate tarball

The code doesn't fallback to generating an archive from git tags or from the source package if pristine-tar checkout fails, this is my somewhat clumsy attempt at doing this

To post a comment you must log in.
Revision history for this message
Hector CAO (hectorcao) wrote :

great work, some questions

review: Needs Information

Unmerged commits

264015b... by Loïc Minier

Fallback if pristine-tar checkout fails

Fallback to generating a tarball from tags, or from source package,
if pristine-tar checkout fails. Ideally, pristine-tar wouldn't fail
and if it does, we'd triage between the kind of issues it has.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitbuildrecipe/deb_util.py b/gitbuildrecipe/deb_util.py
2index d0a6666..4724de6 100644
3--- a/gitbuildrecipe/deb_util.py
4+++ b/gitbuildrecipe/deb_util.py
5@@ -48,13 +48,14 @@ def debian_source_package_name(control_path):
6 return control["Source"]
7
8
9-def extract_upstream_tarball(path, package, version, dest_dir):
10+def extract_upstream_tarball(path, package, version, dest_dir, fallback=True):
11 """Extract the upstream tarball from a Git repository.
12
13 :param path: Path to the Git repository
14 :param package: Package name
15 :param version: Package version
16 :param dest_dir: Destination directory
17+ :param fallback: Extract from tag if pristine-tar fails
18 """
19 prefix = "%s_%s.orig.tar." % (package, version)
20 dest_filename = None
21@@ -68,11 +69,20 @@ def extract_upstream_tarball(path, package, version, dest_dir):
22 finally:
23 pristine_tar_list.wait()
24 if dest_filename is not None:
25- subprocess.check_call(
26- ["pristine-tar", "checkout",
27- os.path.abspath(os.path.join(dest_dir, dest_filename))],
28- cwd=path)
29- else:
30+ try:
31+ subprocess.check_call(
32+ ["pristine-tar", "checkout",
33+ os.path.abspath(os.path.join(dest_dir, dest_filename))],
34+ cwd=path)
35+ # ideally we'd triage between pristine-tar issues
36+ except subprocess.CalledProcessError as e:
37+ print("pristine-tar exception")
38+ if not fallback:
39+ raise e
40+ if os.path.exists(dest_filename):
41+ os.remove(dest_filename)
42+ # no pristine-tar data or pristine-tar failed
43+ if not os.path.exists(dest_filename):
44 tag_names = ["upstream/%s" % version, "upstream-%s" % version]
45 git_tag_list = subprocess.Popen(
46 ["git", "tag"], stdout=subprocess.PIPE, cwd=path)

Subscribers

People subscribed via source and target branches