Browse Source

add initial support for Module::Build based Build.PL scripts

Ralf S. Engelschall 20 years ago
parent
commit
9a441b4fbd
2 changed files with 74 additions and 39 deletions
  1. 73 38
      perl-openpkg/perl-openpkg.pl
  2. 1 1
      perl-openpkg/perl-openpkg.spec

+ 73 - 38
perl-openpkg/perl-openpkg.pl

@@ -155,7 +155,7 @@ if ($CF->{run_help}) {
           " -P, --perl <file-path>       filesystem path to Perl program\n" .
           "\n" .
           " -s, --schema <schema>        Perl INSTALLDIRS schema\n" .
-          " -A, --args <arguments>       Perl Makefile.PL passed through arguments\n" .
+          " -A, --args <arguments>       Perl Build.PL/Makefile.PL passed through arguments\n" .
           " -I, --stdin <file-path>      filesystem path to connect to stdin\n" .
           " -F, --files <file-path>      filesystem path to write RPM \%files list to\n" .
           " -U, --unquoted               output RPM \%files list in unquoted format\n" .
@@ -328,19 +328,37 @@ if (grep { $_ eq "prepare" } @steps_run) {
 if (grep { $_ eq "configure" } @steps_run) {
     &verbose("step 2: configure");
 
-    #   sanity check
-    if (not -f "Makefile.PL") {
-        die "file \"Makefile.PL\" not found in working directory";
-    }
-
     #   determine Makefile.PL arguments
-    my $perl_args = " PERL=$perlwrap FULLPERL=$perlwrap";
-    $perl_args .= " INSTALLDIRS=$CF->{perl_schema}";
-    $perl_args .= " INSTALLMAN3DIR=none INSTALLSITEMAN3DIR=none INSTALLVENDORMAN3DIR=none";
-    $perl_args .= " DESTDIR=$CF->{path_buildroot} PREFIX=$CF->{path_prefix}";
-    if ($CF->{path_libdir} ne '') {
-        $perl_args .= " LIB=$CF->{path_libdir}";
+    my $perl_args = '';
+    if (-f "Build.PL") {
+        #   new-style Module::Build "Build.PL"
+        $perl_args .= " installdirs=$CF->{perl_schema}";
+        $perl_args .= " --install_path libdoc=remove-me-later";
+        $perl_args .= " destdir=$CF->{path_buildroot}";
+        if ($CF->{path_prefix} ne '' and $CF->{path_prefix} ne '@l_prefix@') {
+            $perl_args .= " install_base=$CF->{path_prefix}";
+        }
+        if ($CF->{path_libdir} ne '') {
+            $perl_args .= " --install_path lib=$CF->{path_libdir}";
+        }
     }
+    elsif (-f "Makefile.PL") {
+        #   old-style ExtUtils::MakeMaker "Makefile.PL"
+        $perl_args .= " PERL=$perlwrap FULLPERL=$perlwrap";
+        $perl_args .= " INSTALLDIRS=$CF->{perl_schema}";
+        $perl_args .= " INSTALLMAN3DIR=none INSTALLSITEMAN3DIR=none INSTALLVENDORMAN3DIR=none";
+        $perl_args .= " DESTDIR=$CF->{path_buildroot}";
+        if ($CF->{path_prefix} ne '') {
+            $perl_args .= " PREFIX=$CF->{path_prefix}";
+        }
+        if ($CF->{path_libdir} ne '') {
+            $perl_args .= " LIB=$CF->{path_libdir}";
+        }
+    }
+    else {
+        die "neither Module::Build \"Build.PL\" nor ExtUtils::MakeMaker \"Makefile.PL\" file found";
+    }
+
     if ($#{@{$CF->{perl_args}}} >= 0) {
         my $user_args = join(" ", @{$CF->{perl_args}});
         if ($user_args =~ m|#|) {
@@ -353,9 +371,16 @@ if (grep { $_ eq "configure" } @steps_run) {
     }
 
     #   fixate Makefile.PL
-    &runcmd("chmod u+rw Makefile.PL");
-    &runcmd("cp Makefile.PL Makefile.PL.orig");
-    &runcmd("sed -e \"s:\\\$^X:'$perlwrap':g\" <Makefile.PL.orig >Makefile.PL");
+    if (-f "Build.PL") {
+        &runcmd("chmod u+rw Build.PL");
+        &runcmd("cp Build.PL Build.PL.orig");
+        &runcmd("sed -e \"s:\\\$^X:'$perlwrap':g\" <Build.PL.orig >Build.PL");
+    }
+    elsif (-f "Makefile.PL") {
+        &runcmd("chmod u+rw Makefile.PL");
+        &runcmd("cp Makefile.PL Makefile.PL.orig");
+        &runcmd("sed -e \"s:\\\$^X:'$perlwrap':g\" <Makefile.PL.orig >Makefile.PL");
+    }
 
     #   determine stdin
     if ($CF->{perl_stdin} ne "-") {
@@ -363,43 +388,53 @@ if (grep { $_ eq "configure" } @steps_run) {
     }
 
     #   execute Makefile.PL
-    &runcmd("$perlwrap Makefile.PL $perl_args");
+    if (-f "Build.PL") {
+        &runcmd("$perlwrap ./Build.PL $perl_args");
+    }
+    elsif (-f "Makefile.PL") {
+        &runcmd("$perlwrap ./Makefile.PL $perl_args");
+    }
 }
 
 #   ==== STEP: 3. build ====
 if (grep { $_ eq "build" } @steps_run) {
     &verbose("step 3: build");
 
-    #   sanity check
-    if (not -f "Makefile") {
-        die "file \"Makefile\" not found in working directory";
+    if (-f "Build.PL" and -f "Build") {
+        #   execute Build script
+        &runcmd("$perlwrap Build build");
+    }
+    elsif (-f "Makefile.PL" and -f "Makefile") {
+        #   execute Makefile procedure
+        my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
+        $make =~ s|\n+$||s;
+        my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
+        &runcmd("$make $make_args pure_all");
+    }
+    else {
+        die "neither \"Build\" nor \"Makefile\" found in working directory";
     }
-
-    #   determine make(1) command and flags
-    my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
-    $make =~ s|\n+$||s;
-    my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
-
-    #   execute make(1)
-    &runcmd("$make $make_args pure_all");
 }
 
 #   ==== STEP: 4. install ====
 if (grep { $_ eq "install" } @steps_run) {
     &verbose("step 4: install");
 
-    #   sanity check
-    if (not -f "Makefile") {
-        die "file \"Makefile\" not found in working directory";
+    if (-f "Build.PL") {
+        #   execute Build script
+        &runcmd("$perlwrap Build install");
+        &runcmd("rm -rf $CF->{path_buildroot}$CF->{path_prefix}/remove-me-later");
+    }
+    elsif (-f "Makefile.PL") {
+        #   execute Makefile procedure
+        my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
+        $make =~ s|\n+$||s;
+        my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
+        &runcmd("$make $make_args pure_install");
+    }
+    else {
+        die "neither \"Build\" nor \"Makefile\" found in working directory";
     }
-
-    #   determine make(1) command and flags
-    my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
-    $make =~ s|\n+$||s;
-    my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
-
-    #   execute make(1)
-    &runcmd("$make $make_args pure_install");
 }
 
 #   ==== STEP: 5. fixate ====

+ 1 - 1
perl-openpkg/perl-openpkg.spec

@@ -36,7 +36,7 @@ Class:        BASE
 Group:        Language
 License:      PD
 Version:      %{V_perl}
-Release:      20050603
+Release:      20051031
 
 #   list of sources
 Source0:      perl-openpkg.pl