changeset 35:4823f88ea3b6

add -0 option to pkg-files.
author Robert McIntyre <rlm@mit.edu>
date Sun, 10 Feb 2013 05:58:58 -0500
parents 6422228dfea7
children d66d34065dd9
files src/pkg-files.pl
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/src/pkg-files.pl	Sun Feb 10 05:52:35 2013 -0500
     1.2 +++ b/src/pkg-files.pl	Sun Feb 10 05:58:58 2013 -0500
     1.3 @@ -1,11 +1,23 @@
     1.4  #!/usr/bin/perl
     1.5  use File::stat;
     1.6  
     1.7 +$print0 = 0;
     1.8 +
     1.9  if ($ARGV[0] eq "--help"){
    1.10    print <<"HERE";
    1.11  
    1.12  pkg-examine -- print package contents.
    1.13  
    1.14 +usage:
    1.15 +    pkg-examine -0 <package>
    1.16 +
    1.17 +Prints the files which belong to the package user 
    1.18 +<package>.
    1.19 +
    1.20 +If the -0 option is given, prints all files belonging 
    1.21 +to <package> separated by null characters, as in the 
    1.22 +"-print0" option of find.
    1.23 +
    1.24  Written by Robert McIntyre. This software is free
    1.25  software and is released to the public domain.
    1.26    
    1.27 @@ -14,7 +26,17 @@
    1.28  }
    1.29  
    1.30  $" = " ";
    1.31 -$pkg_name = $ARGV[0];
    1.32 +
    1.33 +if ($ARGV[0] eq "-0"){
    1.34 +    $print0 = 1;
    1.35 +    $pkg_name = $ARGV[1];
    1.36 +}
    1.37 +else {
    1.38 +    $pkg_name = $ARGV[0];
    1.39 +}
    1.40 +
    1.41 +
    1.42 +
    1.43  
    1.44  `id -g $pkg_name 2>/dev/null`;
    1.45  if (($pkg_name eq "") || $?){
    1.46 @@ -22,7 +44,13 @@
    1.47      exit 0;
    1.48  }
    1.49  
    1.50 -@files = split(/\0/, `find /usr /opt /etc -group $pkg_name -print0`);
    1.51 +$file_str = `find /usr /opt /etc -group $pkg_name -print0`;
    1.52 +if ($print0){
    1.53 +    print $file_str;
    1.54 +    exit 0;
    1.55 +}
    1.56 +
    1.57 +@files = split(/\0/, $file_str);
    1.58  
    1.59  
    1.60  print "All files owned by this package:\n";