diff options
-rw-r--r-- | debhelper.pod | 18 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Dh_Buildsystems.pm | 28 | ||||
-rw-r--r-- | lib/Debian/Debhelper/Dh_Lib.pm | 8 |
4 files changed, 41 insertions, 18 deletions
diff --git a/debhelper.pod b/debhelper.pod index c5fea580..1b7e2d3f 100644 --- a/debhelper.pod +++ b/debhelper.pod @@ -1143,9 +1143,10 @@ are identical). =item - The B<dh_auto_*> helpers now resets the environment variables B<HOME> -and common B<XDG_*> variable. B<HOME> and B<XDG_RUNTIME_DIR> are each -set to a distinct writable directory. The rest of the environment -variables are cleared. +and common B<XDG_*> variable. Please see description of the +environment variables in L</ENVIRONMENT> for how this handled. + +I<This feature changed between between debhelper 13 and debhelper 13.2.> =item - @@ -1482,12 +1483,13 @@ concrete variable directly. In compat 13 and later, these environment variables are reset before invoking the upstream build system via the B<dh_auto_*> helpers. The variables B<HOME> -and B<XDG_RUNTIME_DIR> will be set to a writable directory. The remaining -variables will be cleared. +(all B<dh_auto_*> helpers)and B<XDG_RUNTIME_DIR> (B<dh_auto_test> only) will +be set to a writable directory. All remaining variables and B<XDG_RUNTIME_DIR> +(except for during B<dh_auto_test>) will be cleared. -The directories will be created as empty directories but they will be reused -between calls to B<dh_auto_*>. Any content will persist until explicitly -deleted or B<dh_clean>. +The B<HOME> directory will be created as an empty directory but it will be +reused between calls to B<dh_auto_*>. Any content will persist until +explicitly deleted or B<dh_clean>. =item B<DEB_BUILD_OPTIONS> diff --git a/debian/changelog b/debian/changelog index 909b38f6..d803704a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,11 @@ debhelper (13.1.1) UNRELEASED; urgency=medium issues but may cause breakage if packages run binaries directly from the build directory. Thanks to Timo Röhling for the suggestion. (Closes: #962474) + * dh,dh_auto_*: Change the handling of XDG_RUNTIME_DIR in compat 13. + It is now only set to a writable directory for dh_auto_test but + set to a much shorter directory avoid issues with socket lengths. + In all other cases, the XDG_RUNTIME_DIR is now cleared. Thanks to + Simon McVittie for the report. (Closes: #961655) [ Anel Husakovic ] * debhelper.7: Fix typo/grammatical errors. 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; } |