Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

DESTDIR support #39

Closed
arekm opened this issue Jul 16, 2014 · 15 comments · Fixed by #65
Closed

DESTDIR support #39

arekm opened this issue Jul 16, 2014 · 15 comments · Fixed by #65

Comments

@arekm
Copy link

arekm commented Jul 16, 2014

DESTDIR is feature that allows to use "fake root" directory where everything gets installed
relative to this. DESTDIR is used by distributions for packaging software (using rpm, deb)

Regular Build.PL support destdir well. Unfortunately Alien/Base/ModuleBuild.pm doesn't support it.

[arekm@ixion-pld Alien-LibGumbo-0.02]$ perl Build.PL 'destdir=/home/users/arekm/test/libgumbo'
Archive::Extract will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm, line 16.
Checking prerequisites...
  requires:
    !  Path::Class is not installed

ERRORS/WARNINGS FOUND IN PREREQUISITES.  You may wish to install the versions
of the modules indicated above before proceeding with this installation

Run 'Build installdeps' to install missing prerequisites.

Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Alien-LibGumbo' version '0.02'
[arekm@ixion-pld Alien-LibGumbo-0.02]$ ./Build 
Archive::Extract will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm, line 16.
Building Alien-LibGumbo
Downloading File: libgumbo-0.2.tar.gz ... Done
Extracting Archive ... Done
[...]
  CXX      examples/positions_of_class.o
  CXXLD    positions_of_class
Done

built fine but now install part:

[arekm@ixion-pld Alien-LibGumbo-0.02]$ LC_ALL=C ./Build install
Archive::Extract will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm, line 16.
Building Alien-LibGumbo
Installing /home/users/arekm/test/libgumbo/usr/local/share/perl5/Alien/LibGumbo.pm
Installing /home/users/arekm/test/libgumbo/usr/local/share/perl5/Alien/LibGumbo/ConfigData.pm
Installing /home/users/arekm/test/libgumbo/usr/local/share/perl5/auto/share/dist/Alien-LibGumbo/README
Installing /home/users/arekm/test/libgumbo/usr/local/man/man3/Alien::LibGumbo::ConfigData.3pm
Failed to change directory to '/usr/local/share/perl5/auto/share/dist/Alien-LibGumbo': No such file or directory at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm line 312.
[arekm@ixion-pld Alien-LibGumbo-0.02]$

it did install few files correctly bug then failed :-/

Failed to change directory to '/usr/local/share/perl5/auto/share/dist/Alien-LibGumbo': No such file or directory at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm line 312.

   308    return if $self->config_data( 'install_type' ) eq 'system';
   309  
   310    {
   311      my $target = $self->alien_library_destination;
   312      local $CWD = $target;
   313  
   314      # The only form of introspection that exists is to see that the README file

So please implement destdir support in Alien Base.

One solution could be this patch:
http://git.pld-linux.org/gitweb.cgi?p=packages/perl-Alien-Base.git;a=blob_plain;f=perl-Alien-Base-DESTDIR.patch;hb=HEAD

@arekm
Copy link
Author

arekm commented Jul 16, 2014

sub alien_refresh_packlist also needs some support (one for $dir and one for ExtUtils::Installed)

@mohawk2
Copy link
Contributor

mohawk2 commented Jul 17, 2014

Given it's on github... fork, modify, add a test, then pull request?

@arekm
Copy link
Author

arekm commented Jul 17, 2014

If I have complete solution then I'll do that. In mean time I'll document here what the problems are.

New problem, destdir paths end up in ConfigData.pm (while they shouldn't):

                      'gumbo' => bless( {
                                          'package' => 'gumbo',
                                          'vars' => {
                                                      'includedir' => '${prefix}/include',
                                                      'pcfiledir' => '/home/users/arekm/rpm/BUILD/Alien-LibGumbo-0.02/_alien/libgumbo-0.2',
                                                      'exec_prefix' => '${prefix}',
                                                      'prefix' => '/usr/share/perl5/vendor_perl/auto/share/dist/Alien-LibGumbo',
                                                      'libdir' => '${exec_prefix}/lib'
                                                    },
                                          'keywords' => {
                                                          'Libs' => '-L${libdir} -lgumbo',
                                                          'Version' => '1.0',
                                                          'Description' => 'A fully-compliant HTML5 parser.',
                                                          'Libs.private' => '',
                                                          'Cflags' => '-I${includedir}',
                                                          'Name' => 'Gumbo'
                                                        }
                                        }, 'Alien::Base::PkgConfig' )
                    },
     'name' => 'libgumbo',
     'working_directory' => '/home/users/arekm/rpm/BUILD/Alien-LibGumbo-0.02/_alien/libgumbo-0.2',

@mohawk2
Copy link
Contributor

mohawk2 commented Aug 30, 2014

Please at least fork, make a test that reliably fails for this issue, then PR that.

@plicease
Copy link
Contributor

plicease commented Sep 8, 2014

Here is a concrete example:

https://build.opensuse.org/package/live_build_log/home:platypus:Alien-Base/perl-Acme-Alien-DontPanic/Fedora_20/x86_64

key part of the log is here:

[  154s] Installing /home/abuild/rpmbuild/BUILDROOT/perl-Acme-Alien-DontPanic-0.005-1.1.x86_64/usr/share/man/man3/Acme::Alien::DontPanic::ConfigData.3pm
[  154s] Installing /home/abuild/rpmbuild/BUILDROOT/perl-Acme-Alien-DontPanic-0.005-1.1.x86_64/usr/share/man/man3/Acme::Alien::DontPanic.3pm
[  154s] Failed to change directory to '/usr/share/perl5/vendor_perl/auto/share/dist/Acme-Alien-DontPanic': No such file or directory at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm line 328.
[  154s] error: Bad exit status from /var/tmp/rpm-tmp.SQ0gJe (%install)
[  154s] 
[  154s] 

It is important that we address this issue, because packaging systems like rpm and .dep rely on them for creating packages. That said, most Debian or RedHat maintainers are going to prefer to use the system libraries rather than install in install_type=share mode. A unit test would be useful, but we need to verify that we can create a .rpm package to make sure the usability for packagers.

@plicease
Copy link
Contributor

plicease commented Sep 8, 2014

This does some of what we want:

07e8ab7

but I get this weird MB error:

make[2]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/tmp/abtest2/home/ollisg/.perlbrew/libs/perl-5.18.2c34@dev/lib/perl5/auto/share/dist/Acme-Alien-DontPanic/lib/pkgconfig'
 /usr/bin/install -c -m 644 src/dontpanic.pc '/tmp/abtest2/home/ollisg/.perlbrew/libs/perl-5.18.2c34@dev/lib/perl5/auto/share/dist/Acme-Alien-DontPanic/lib/pkgconfig'
make[2]: Leaving directory `/home/ollisg/dev/Alien-Base-Extras/Acme-Alien-DontPanic/_alien/dontpanic-1.0'
make[1]: Leaving directory `/home/ollisg/dev/Alien-Base-Extras/Acme-Alien-DontPanic/_alien/dontpanic-1.0'
Done
Can't stat /home/ollisg/.perlbrew/libs/perl-5.18.2c34@test1/lib/perl5/auto/share/dist/Acme-Alien-DontPanic: No such file or directory
 at /home/ollisg/perl5/perlbrew/perls/perl-5.18.2c34/lib/5.18.2/Module/Build/Base.pm line 5279.
Installing /tmp/abtest2/home/ollisg/.perlbrew/libs/perl-5.18.2c34@test1/lib/perl5/Acme/Alien/DontPanic/ConfigData.pm
Acme::Alien::DontPanic is not installed at /home/ollisg/.perlbrew/libs/perl-5.18.2c34@test1/lib/perl5/Alien/Base/ModuleBuild.pm line 766.

after an otherwise correct install

@plicease
Copy link
Contributor

plicease commented Sep 8, 2014

@arekm I am not seeing the destdir paths in the ConfigData.pm file. This is what I get:

         'working_directory' => '/home/ollisg/dev/Alien-Base-Extras/Acme-Alien-DontPanic/_alien/dontpanic-1.0',
         'name' => 'dontpanic',
         'pkgconfig' => {
                          '_manual' => bless( {
                                                'vars' => {
                                                            'pcfiledir' => '/home/ollisg/.perlbrew/libs/perl-5.18.2c34@test1/lib/perl5/auto/share/dist/Acme-Alien-DontPanic'
                                                          },
                                                'keywords' => {
                                                                'Version' => '',
                                                                'Libs' => '',
                                                                'Cflags' => ''
                                                              },
                                                'package' => 'dontpanic'
                                              }, 'Alien::Base::PkgConfig' ),
                          'dontpanic' => bless( {
                                                  'package' => 'dontpanic',
                                                  'keywords' => {
                                                                  'Description' => 'An example library',
                                                                  'Libs.private' => '',
                                                                  'Cflags' => '-I${includedir}',
                                                                  'Name' => 'dontpanic',
                                                                  'Version' => '1.0',
                                                                  'Libs' => '-L${libdir} -ldontpanic'
                                                                },
                                                  'vars' => {
                                                              'libdir' => '${exec_prefix}/lib',
                                                              'exec_prefix' => '${prefix}',
                                                              'prefix' => '/home/ollisg/.perlbrew/libs/perl-5.18.2c34@dev/lib/perl5/auto/share/dist/Acme-Alien-DontPanic',
                                                              'pcfiledir' => '/home/ollisg/dev/Alien-Base-Extras/Acme-Alien-DontPanic/_alien/dontpanic-1.0/src',
                                                              'includedir' => '${prefix}/include'
                                                            }
                                                }, 'Alien::Base::PkgConfig' )
                        },

destdir was set to /tmp/abtest2, which does not appear in the file. Am I missing it, or can you clarify?

@arekm
Copy link
Author

arekm commented Sep 8, 2014

Tested on 0.004_02 and DESTDR patch 07e8ab7 - seems to be working, no DESTDIR in ConfigData.pm.

Unfortunately the same problem as 2 comments ago:
make[1]: Leaving directory '/home/users/arekm/rpm/BUILD/Alien-LibGumbo-0.02/_alien/libgumbo-0.2'
Done
Installing /home/users/arekm/tmp/perl-Alien-LibGumbo-0.02-root-arekm/usr/share/perl5/vendor_perl/Alien/LibGumbo/ConfigData.pm
Alien::LibGumbo is not installed at /usr/share/perl5/vendor_perl/Alien/Base/ModuleBuild.pm line 766.

@mohawk2
Copy link
Contributor

mohawk2 commented Sep 8, 2014

We should probably add tests for DESTDIR support in AB. cf the tests for DESTDIR support in https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/blob/master/t/basic.t

@plicease
Copy link
Contributor

plicease commented Sep 8, 2014

@arekm I think I am close to a solution for the second error
@mohawk2 I will include a unit test with my PR when I am done.

@plicease plicease mentioned this issue Sep 9, 2014
@plicease
Copy link
Contributor

plicease commented Sep 9, 2014

@arekm if you want to try my destdir branch I think I've resolved all the DESTDIR issues.

@plicease plicease mentioned this issue Sep 9, 2014
@arekm
Copy link
Author

arekm commented Sep 9, 2014

Could you try building Alien-LibGumbo with it? http://search.cpan.org/dist/Alien-LibGumbo/ Builds fine now (no more " is not installed" problem) but generated Alien/LibGumbo/ConfigData.pm contains DESTDIR in paths.

There is also

# perl
use Alien::LibGumbo;
Failed to find share dir for dist 'Alien-LibGumbo' at /usr/share/perl5/vendor_perl/Alien/Base.pm line 70.
BEGIN failed--compilation aborted at - line 1.

but didn't verify (yet) if it is DESTDIR related issue.

@plicease
Copy link
Contributor

plicease commented Sep 9, 2014

@arekm I am not seeing any DESTDIR inside ConfigData.pm, here is the sequence of commands that I used:

   116  3:53    wget http://search.cpan.org/CPAN/authors/id/R/RU/RUZ/Alien-LibGumbo-0.02.tar.gz
   117  3:53    tar xf Alien-LibGumbo-0.02.tar.gz
   118  3:53    cd Alien-LibGumbo-0.02
   119  3:54    ls
   120  3:54    perl Build.PL
   121  3:54    cpanm Path::Class
   122  3:54    perl Build.PL
   123  3:54    ./Build
   124  3:54    ./Build test
   125  3:54    ./Build install destdir=/tmp/testlibgumbo
         'working_directory' => '/home/ollisg/test/Alien-LibGumbo-0.02/_alien/libgumbo-0.2',
         'name' => 'libgumbo',
         'install_type' => 'share',
         'alien_version' => '0.2',
         'finished_installing' => 1,
         'msys' => 0,
         'pkgconfig' => {
                          '_manual' => bless( {
                                                'keywords' => {
                                                                'Version' => '',
                                                                'Libs' => '-L${pcfiledir}/lib -lgumbo',
                                                                'Cflags' => '-I${pcfiledir}/include'
                                                              },
                                                'vars' => {
                                                            'pcfiledir' => '/home/ollisg/.perlbrew/libs/perl-5.20.0@test1/lib/perl5/auto/share/dist/Alien-LibGumbo'
                                                          },
                                                'package' => 'libgumbo'
                                              }, 'Alien::Base::PkgConfig' ),
                          'gumbo' => bless( {
                                              'vars' => {
                                                          'includedir' => '${prefix}/include',
                                                          'prefix' => '/home/ollisg/.perlbrew/libs/perl-5.20.0@test1/lib/perl5/auto/share/dist/Alien-LibGumbo',
                                                          'exec_prefix' => '${prefix}',
                                                          'pcfiledir' => '/home/ollisg/test/Alien-LibGumbo-0.02/_alien/libgumbo-0.2',
                                                          'libdir' => '${exec_prefix}/lib'
                                                        },
                                              'package' => 'gumbo',
                                              'keywords' => {
                                                              'Name' => 'Gumbo',
                                                              'Libs.private' => '',
                                                              'Libs' => '-L${libdir} -lgumbo',
                                                              'Cflags' => '-I${includedir}',
                                                              'Version' => '1.0',
                                                              'Description' => 'A fully-compliant HTML5 parser.'
                                                            }
                                            }, 'Alien::Base::PkgConfig' )
                        },
         'version' => '0.2'

@plicease
Copy link
Contributor

plicease commented Sep 9, 2014

Also created an rpm for Alien::LibGumbo (using DESTDIR of course) and was able to use it after installing it:

bash-4.2# perl
use Alien::LibGumbo;
bash-4.2# 

@arekm
Copy link
Author

arekm commented Sep 9, 2014

Was doing:

$ perl Build.PL destdir=$RPM_BUILD_ROOT
$ DESTDIR=$RPM_BUILD_ROOT ./Build install

but using your way works. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants