diff options
author | Niels Thykier <niels@thykier.net> | 2020-06-28 17:12:16 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2020-07-05 11:24:29 +0000 |
commit | 49936d3e6823cb91628eb5217fe32df960d6322a (patch) | |
tree | e4c6f5d76ae7be3a4c1783690406936f017b880f /lib/Debian/Debhelper | |
parent | 43240d63a8907906523fd9df92acad26fac58917 (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')
-rw-r--r-- | lib/Debian/Debhelper/Dh_Buildsystems.pm | 28 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Dh_Lib.pm | 8 |
2 files changed, 26 insertions, 10 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; } diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm index 2787004b..2a06a8fa 100644 --- a/lib/Debian/Debhelper/Dh_Lib.pm +++ b/lib/Debian/Debhelper/Dh_Lib.pm @@ -2467,11 +2467,8 @@ sub setup_home_and_xdg_dirs { require Cwd; my $cwd = Cwd::getcwd(); my $home_dir = join('/', $cwd, generated_file('_source', 'home', 0)); - my $xdg_rundir = join('/', $cwd, generated_file('_source', 'xdg-runtime-dir', 0)); - my $creating_rundir = -d $xdg_rundir ? 0 : 1; my @paths = ( $home_dir, - $xdg_rundir, ); my @clear_env = qw( XDG_CACHE_HOME @@ -2479,16 +2476,13 @@ sub setup_home_and_xdg_dirs { XDG_CONFIG_HOME XDG_DATA_HOME XDG_DATA_DIRS + XDG_RUNTIME_DIR ); install_dir(@paths); - if ($creating_rundir) { - chmod(0700, $xdg_rundir) == 1 or warning("chmod(0700, \"$xdg_rundir\") failed: $! (ignoring)"); - } for my $envname (@clear_env) { delete($ENV{$envname}); } $ENV{'HOME'} = $home_dir; - $ENV{'XDG_RUNTIME_DIR'} = $xdg_rundir; return; } |