Parcourir la source

cleanup even more and be more flexible

Ralf S. Engelschall il y a 22 ans
Parent
commit
3ddd0a8821
2 fichiers modifiés avec 46 ajouts et 26 suppressions
  1. 44 24
      perl-openpkg/perl-openpkg.pl
  2. 2 2
      perl-openpkg/perl-openpkg.spec

+ 44 - 24
perl-openpkg/perl-openpkg.pl

@@ -49,7 +49,8 @@ my $CF = {
     perl_schema    => "vendor",
     perl_args      => [],
     perl_stdin     => "/dev/null",
-    rpm_files      => "-",
+    files_file     => "-",
+    files_unquoted => 0,
     prog_rpm       => '%path_prefix%/bin/rpm',
     prog_perl      => '%path_prefix%/bin/perl',
     mode_quiet     => 0,
@@ -133,7 +134,8 @@ my $result = GetOptions(
     's|schema=s'    => \$CF->{perl_schema},
     'A|args=s'      => \@{$CF->{perl_args}},
     'I|stdin=s'     => \$CF->{perl_stdin},
-    'F|files=s'     => \$CF->{rpm_files},
+    'F|files=s'     => \$CF->{files_file},
+    'U|unquoted'    => \$CF->{files_unquoted},
     'n|pkgname=s'   => \$CF->{pkg_name},
     'q|quiet'       => \$CF->{mode_quiet},
     'v|verbose'     => \$CF->{mode_verbose},
@@ -157,6 +159,7 @@ if ($CF->{run_help}) {
           " -A, --args <arguments>       Perl 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" .
           " -n, --pkgname <package-name> name of involved RPM package\n" .
           "\n" .
           " -q, --quiet                  operate in quiet   run-time mode\n" .
@@ -417,34 +420,44 @@ if (grep { $_ eq "fixate" } @steps_run) {
     &runcmd("find $libdir -type d -depth -print | (xargs rmdir >/dev/null 2>&1 || true)");
 
     #   determine RPM installation file list
-    my $files = '';
-    $files .= '"%not %dir '.$CF->{path_prefix}.'"'."\n";
-    $files .= '"%not %dir '.$CF->{path_prefix}.'/lib/perl"'."\n" if ($CF->{path_libdir} eq '');
-    $files .= '"%not %dir '.$CF->{path_libdir}.'"'."\n" if ($CF->{path_libdir} ne '');
-    $files .= '"%not %dir '.$pcfg->{installarchlib}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installarchlib}.'/auto'.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installprivlib}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installprivlib}.'/auto'.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{sitelib_stem}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installsitearch}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installsitearch}.'/auto'.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installsitelib}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installsitelib}.'/auto'.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{vendorlib_stem}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installvendorarch}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installvendorarch}.'/auto'.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installvendorlib}.'"'."\n";
-    $files .= '"%not %dir '.$pcfg->{installvendorlib}.'/auto'.'"'."\n";
-
+    my @files = ();
+    if ($CF->{path_libdir} ne '') {
+        push(@files, '%not %dir '.$CF->{path_libdir});
+    }
+    else {
+        push(@files, '%not %dir '.$CF->{path_prefix}.'/lib/perl');
+    }
+    push(@files, '%not %dir '.$pcfg->{installarchlib}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installarchlib});
+    push(@files, '%not %dir '.$pcfg->{installprivlib}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installprivlib});
+    push(@files, '%not %dir '.$pcfg->{sitelib_stem});
+    push(@files, '%not %dir '.$pcfg->{installsitearch}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installsitearch});
+    push(@files, '%not %dir '.$pcfg->{installsitelib}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installsitelib});
+    push(@files, '%not %dir '.$pcfg->{vendorlib_stem});
+    push(@files, '%not %dir '.$pcfg->{installvendorarch}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installvendorarch});
+    push(@files, '%not %dir '.$pcfg->{installvendorlib}.'/auto');
+    push(@files, '%not %dir '.$pcfg->{installvendorlib});
+
+    #   output RPM installation file list
     my $out;
-    if ($CF->{rpm_files} eq "-") {
+    if ($CF->{files_file} eq "-") {
         $out = new IO::Handle;
         $out->fdopen(fileno(STDOUT), "w");
     }
     else {
-        $out = new IO::File ">$CF->{rpm_files}";
+        $out = new IO::File ">$CF->{files_file}";
     }
-    print $out $files;
+    if ($CF->{files_unquoted}) {
+        print $out join("\n", @files) . "\n";
+    }
+    else {
+        print $out '"'. join('"'."\n".'"', @files).'"'."\n";
+    }
+    $out->close();
 }
 
 #   ==== STEP: 6. cleanup ====
@@ -487,6 +500,7 @@ B<perl-openpkg>
 [B<-A>|B<--args> I<arguments>]
 [B<-I>|B<--stdin> I<file-path>]
 [B<-F>|B<--files> I<file-path>]
+[B<-U>|B<--unquoted>]
 [B<-n>|B<--pkgname> I<name>]
 [B<-q>|B<--quiet>]
 [B<-v>|B<--verbose>]
@@ -583,6 +597,12 @@ Filesystem path to write the RPM C<%files> entries to describing the
 packaging list of all installed files. The default is "C<->" meaning
 that the list is written to F<stdout>.
 
+=item B<-U>, B<--unquoted>
+
+By default the RPM <%files> list is written with each path entry
+enclosed in quotation marks. For raw post-processing, this option allows
+the list to be written without enclosing quotation marks.
+
 =item B<-n>, B<--pkgname> I<name>
 
 Name of involved RPM package.

+ 2 - 2
perl-openpkg/perl-openpkg.spec

@@ -32,8 +32,8 @@ Packager:     The OpenPKG Project
 Distribution: OpenPKG [BASE]
 Group:        Language
 License:      PD
-Version:      20040126
-Release:      20040126
+Version:      20040127
+Release:      20040127
 
 #   list of sources
 Source0:      perl-openpkg.pl