summaryrefslogtreecommitdiff
path: root/lib/Debian/Debhelper/Dh_Buildsystems.pm
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2020-06-28 17:12:16 +0000
committerNiels Thykier <niels@thykier.net>2020-07-05 11:24:29 +0000
commit49936d3e6823cb91628eb5217fe32df960d6322a (patch)
treee4c6f5d76ae7be3a4c1783690406936f017b880f /lib/Debian/Debhelper/Dh_Buildsystems.pm
parent43240d63a8907906523fd9df92acad26fac58917 (diff)
Rewrite how XDG_RUNTIME_DIR is handled in compat 13
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'lib/Debian/Debhelper/Dh_Buildsystems.pm')
-rw-r--r--lib/Debian/Debhelper/Dh_Buildsystems.pm28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/Debian/Debhelper/Dh_Buildsystems.pm b/lib/Debian/Debhelper/Dh_Buildsystems.pm
index 43017ea5..1c4730bf 100644
--- a/lib/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/lib/Debian/Debhelper/Dh_Buildsystems.pm
@@ -281,9 +281,31 @@ sub buildsystems_do {
my $buildsystem = load_buildsystem($opt_buildsys, $step);
if (defined $buildsystem) {
- $buildsystem->pre_building_step($step);
- $buildsystem->$step(@_, @{$dh{U_PARAMS}});
- $buildsystem->post_building_step($step);
+ my ($xdg_runtime_dir, $err, $ref);
+ local $SIG{'INT'} = sub { $ref = 'INT'; die(\$ref); };
+ local $SIG{'TERM'} = sub { $ref = 'TERM'; die(\$ref); };
+ if ($step eq 'test' and not compat(12)) {
+ require File::Temp;
+ $xdg_runtime_dir = File::Temp->newdir('dh-xdg-rundir-XXXXXXXX',
+ TMPDIR => 1,
+ CLEANUP => 1,
+ );
+ $ENV{'XDG_RUNTIME_DIR'} = $xdg_runtime_dir->dirname;
+ }
+ eval {
+ $buildsystem->pre_building_step($step);
+ $buildsystem->$step(@_, @{$dh{U_PARAMS}});
+ $buildsystem->post_building_step($step);
+ };
+ $err = $@;
+ doit('rm', '-fr', '--', $xdg_runtime_dir) if $xdg_runtime_dir;
+ if ($err) {
+ my $sig;
+ die($err) if $err ne \$ref;
+ $sig = $ref;
+ delete($SIG{$sig});
+ kill($sig => $$);
+ }
}
return 0;
}