Package: git-buildpackage
Version: 0.9.43
Severity: important
Tags: patch

Since 0.9.36 (c9cc8df4, "buildpackage: remove export_dir if build
fails"), gbp buildpackage also purges the export dir after errors. The
current check only looks at whether --git-export-dir is set, not
whether this run created the directory. This causes two problems:

1. If gbp fails after the export dir name is known but before the
export, an existing <export-dir>/<package>-<version> is deleted. A
successful run would have moved it to <dir>.obsolete.<time> instead.
This happens e.g. with a failing preexport hook or a missing upstream
tarball. For example, for a package foo with upstream version 1.0:

  $ mkdir -p ../ba/foo-1.0
  $ echo data > ../ba/foo-1.0/important.txt
  $ gbp buildpackage --git-export-dir=../ba --git-preexport=false
  gbp:info: Running Preexport hook
  gbp:error: Preexport-hook 'false' failed: it exited with 1

Afterwards ../ba/foo-1.0/important.txt is gone.

2. If gbp stops before the export dir name is known, for example
because of uncommitted changes or the wrong branch, RemoveTree(None)
raises a TypeError and a traceback follows the error message. This is
#1091554 again: 68768a2d went back to the old check to fix #1111340.

This merge request purges only when this run has created the export
tree, with tests for both cases, for #1111340 and for purging after a
failed build:
https://salsa.debian.org/agx/git-buildpackage/-/merge_requests/112

I set the severity to important because of the data loss in case 1,
like #1111340.

Viorel

Reply via email to