Bug#492898: /usr/lib/pbuilder/pdebuild-internal: The way $HOME issue was solved FTBFSes perl-5.10

Eric Pozharski whynot at pozharski.name
Tue Jul 29 14:53:22 UTC 2008


Package: pbuilder
Version: 0.181
Severity: normal
File: /usr/lib/pbuilder/pdebuild-internal
Tags: patch


Shortly what happened.  B<perl-5.10> builds successfully, that's the
testsuite what fails.  The troubles are with
F<lib/Module/Build/t/tilde.t>; two exempts of it in attempt to show
what's going on.

At line#39 of F<tilde.t>:

    my $home = $ENV{HOME} ? $ENV{HOME} : undef;
# Since I<$ENV{HOME}> is exported by F<pdebuild-internal> value of
# I<$home> becomes something like C</path/to/build/tree/..>
    skip "Needs case and syntax tweaks for VMS", 14 if $^O eq 'VMS';
    unless (defined $home) {
# Since I<$home> is B<defined> this block is ignored
      my @info = eval { getpwuid $> };
      skip "No home directory for tilde-expansion tests", 14 if $@;
      $home = $info[7];
    }

Now, how C<~> is expanded F<lib/Module/Build>Platform/Unix.pm> line#45

sub _detildefy {
  my ($self, $value) = @_;
  $value =~ s[^~(\w*)(?=/|$)]   # tilde with optional username
    [$1 ?
# No, I<$ENV{HOME}> is ignored
     ((getpwnam $1)[7] || "~$1") :
     (getpwuid $>)[7]
    ]ex;
  return $value;
# I<$value> is C</home/pbuser>
} 

As a result the only test that succeeds is the last one (it takes both
username and her/his home from B<getpwuid> (so from F<passwd>)).

I can't believe, that we can blame B<perl> or any other package for 
supposing that I<$ENV{HOME}> and 7th field of F<passwd> are equal.
Hence that's the problem with B<pbuilder>.

Two diffs are attached.  The F<naive.diff> one just fixes B<perl-5.10>
build.  (Since I use fixed version I can't be sure if only perl is
affected.)

Please excuse me a bit of speculation.  What if some package would
dislike relative path as I<$ENV{HOME}> value?  Than it would croak or
just FTBFS silently.  I think that F<advanced.diff> fixes that imagined
treat.  However I won't complain if the first would be choosen (possible
that's my ignorance makes me too suspective).

-- System Information:
Debian Release: 4.0
  APT prefers oldstable
  APT policy: (500, 'oldstable'), (500, 'testing'), (500, 'stable'), (110, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
-------------- next part --------------
--- pdebuild-internal.orig	2008-07-28 17:30:18.000000000 +0300
+++ pdebuild-internal	2008-07-28 17:39:31.000000000 +0300
@@ -83,7 +83,7 @@
 
 # create the user similar to that used outside
 groupadd -g "${BUILDRESULTGID}" -o pbgroup
-useradd -g pbgroup -u "${BUILDRESULTUID}" -o pbuser
+useradd -g pbgroup -u "${BUILDRESULTUID}" -d $(pwd)/../ -o pbuser
 
 # what about id -G output? if other groups than the designated is used, we're stuffed.
 export HOME=$(pwd)/../
-------------- next part --------------
--- pdebuild-internal.orig	2008-07-28 17:30:18.000000000 +0300
+++ pdebuild-internal	2008-07-28 18:09:23.000000000 +0300
@@ -82,11 +82,13 @@
 apt-get install -y --force-yes fakeroot
 
 # create the user similar to that used outside
+_HOME=$(pwd)
+_HOME=${_HOME%/*}
 groupadd -g "${BUILDRESULTGID}" -o pbgroup
-useradd -g pbgroup -u "${BUILDRESULTUID}" -o pbuser
+useradd -g pbgroup -u "${BUILDRESULTUID}" -d ${_HOME} -o pbuser
 
 # what about id -G output? if other groups than the designated is used, we're stuffed.
-export HOME=$(pwd)/../
+export HOME=${_HOME}
 
 executehooks "A"
 


More information about the Pbuilder-maint mailing list