[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fixing up /usr/doc



Joey Hess <joey@kitenet.net> said:

> find /usr/doc -type f |grep -v changelog |grep -v copyright \
> 	|grep -v 'README.[Dd]ebian' |less
> 
> Here are all the files in usr/doc that are not changelogs and copyrights. 
> 
> Or, you could adpot a different method of snooping around - look at dpkg -l
> and dpkg -s to find interesting packages. Then go to /usr/doc/<packagename>/.

along the same lines, here is a perl script i wrote a while back that
will show you all the new or modified README/CHANGES files.  perhaps
it will be useful in navigating the frothy seas of /usr/doc.

(this would be far simpler if the .changes file would make it into the
.deb file or the Packages file.)

john


#!/usr/bin/perl -w

######################################################################
#
# debchanges
# 30 dec 1998, john labovitz
#
# a little program to show any changes in README or CHANGES files.
# i find this especially useful for seeing what has actually changed
# after doing a debian update.
#
# there are no command-line options.  change the variables below if
# you need to.
#
# as distributed, debchanges will look for all directories under
# /usr/doc that have been modified in the last day, and display all
# README/CHANGES files that are in those directories.
#
# debchanges depends on a pager that will grok compressed files.
# `less' will do this, if you `eval $(lesspipe)' in your .bashrc (see
# less(1)).
#
######################################################################

#
# stuff we need (comes with stock perl)
#

use strict;
use File::Find;
use DirHandle;

#
# check for new files within this number of days from now
#

my $days = 1;

#
# the name of a pager program that will automatically handle
# uncompressing files (less(1) is a good one for this)
#

my $pager = "less";

#
# the directories to look in
#

my @dirs = qw(
    /usr/doc
);

#
# find all the files and make an alphabetically-sorted list
#

my @files = ();

find(\&wanted, @dirs);

@files = sort { lc($a) cmp lc($b) } @files;

#
# show them
#

system("$pager @files"); 

#
# the magic code that figures out whether a file should be shown
#

sub wanted {
    my $dir = $File::Find::name;

    #
    # first make sure we're looking at directories that have been
    # modified `recently'
    #

    return unless -d $dir && int(-M $dir) < $days;

    #
    # then look at each file in that directory
    #

    my $dh = new DirHandle $dir
	or do {
	    warn "can't open directory `$dir': $!\n";
	    return;
	};

    while (defined (my $file = $dh->read)) {
	#
	# we want to remember the file if it is (1) a file (not a
	# directory, device, etc.), (2) has the word `change' or
	# `readme' in its name, and (3) is either a text file or a
	# compressed file of a known type
	#

	push(@files, "$dir/$file")
	    if -f "$dir/$file" 
		and $file =~ /change|readme/i 
		and (-T "$dir/$file" || $file =~ /\.(gz|bz|Z)$/);
    }
}


Reply to: