Search code examples
perlcpan

cpan2rpm cant stat /tmp folder


Im trying to build perl-Heap-Priority for RHEL6. Weired thing is when I run cpan2rpm Heap::Priority it shows following

...
Tarball extraction: [/root/rpm/SOURCES/Heap-Priority-0.01.tar.gz]
Can't stat /tmp/CldQkErG6r/18:51: No such file or directory
 at /usr/bin/cpan2rpm line 392
get_meta(): No such file or directory at /usr/bin/cpan2rpm line 396.
...

Practically this temporary folder is not created. Buy why? my tmp folder permission is 777

drwxrwxrwt.   3 root root  4096 May 29 16:35 tmp

Solution

  • Known problem, see https://rt.cpan.org/Ticket/Display.html?id=72421. The problem is the space in the user column of the output.

    $ tar -tzvf $HOME/rpmbuild/SOURCES/Heap-Priority-0.01.tar.gz |head -1
    drwxr-xr-x James Freeman/544 0 2002-05-07 14:51 Heap-Priority-0.01/
    

    Apply the following patch to fix the problem for this module. To get the name, instead of accessing the fifth column, we're accessing the last one. I do not know what else this patch might break, but it should be less wrong than the original code on average.

     diff --git a/cpan2rpm b/cpan2rpm
     index 28e8b01..6a36b68 100755
     --- a/cpan2rpm
     +++ b/cpan2rpm
     @@ -1259,7 +1259,7 @@ sub untar($) {
              ;
    
          chomp($_ = qx/$cmd/);
     -    $_ = (split)[5] unless $zip;
     +    $_ = (split)[-1] unless $zip;
          $dst .= "/$1" if m|^(\S+)/?|;
          $dst =~ s|/*$||;    # path shouldn't end in / or tardir gets wiped
          $dst =~ s|\./||;    # paths in tarballs shouldn't be relative
    

    You could have found out all of this by yourself by using the debugger. Learn to use this tool, it is invaluable.