The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/config/compress-man-pages.pl

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 #!/usr/bin/perl
    2 # Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
    3 #
    4 # @APPLE_LICENSE_HEADER_START@
    5 # 
    6 # This file contains Original Code and/or Modifications of Original Code
    7 # as defined in and that are subject to the Apple Public Source License
    8 # Version 2.0 (the 'License'). You may not use this file except in
    9 # compliance with the License. Please obtain a copy of the License at
   10 # http://www.opensource.apple.com/apsl/ and read it before using this
   11 # file.
   12 # 
   13 # The Original Code and all software distributed under the License are
   14 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   15 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   16 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   17 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   18 # Please see the License for the specific language governing rights and
   19 # limitations under the License.
   20 # 
   21 # @APPLE_LICENSE_HEADER_END@
   22 
   23 use strict;
   24 use File::Basename ();
   25 use File::Find ();
   26 use Getopt::Std ();
   27 
   28 my $MyName = File::Basename::basename($0);
   29 my $N = 100;
   30 my $MinSize = 64;
   31 my %inodes;
   32 my @symlinks;
   33 our $opt_d = '';
   34 
   35 sub wanted {
   36     return unless /\.[\dn][a-z]*$/;
   37     if(-l $_) {
   38         push(@symlinks, $_);
   39     } elsif(-f _) {
   40         return if -s _ < $MinSize;
   41         my($dev, $ino) = stat(_);
   42         my $list = $inodes{$ino};
   43         $list = $inodes{$ino} = [] unless defined($list);
   44         push(@$list, $_);
   45     }
   46 }
   47 
   48 sub usage {
   49     die "Usage: $MyName [-d prefix] dir ...\n";
   50 }
   51 
   52 Getopt::Std::getopts('d:');
   53 usage() unless scalar(@ARGV) > 0;
   54 
   55 for my $dir (@ARGV) {
   56     $dir = $opt_d . $dir if $opt_d ne '';
   57     next unless -e $dir;
   58     die "$dir: no such directory\n" unless -d _;
   59 
   60     %inodes = ();
   61     @symlinks = ();
   62     File::Find::find({
   63         wanted => \&wanted,
   64         no_chdir => 1,
   65     }, $dir);
   66 
   67     my(@compress, @links);
   68     for(values(%inodes)) {
   69         push(@compress, $_->[0]);
   70         push(@links, $_) if scalar(@$_) > 1;
   71     }
   72 
   73     my $count;
   74     while(($count = scalar(@compress)) > 0) {
   75         $_ = $count > $N ? $N : $count;
   76         my @args = splice(@compress, 0, $_);
   77         print "gzip -f -n @args\n";
   78         system('gzip', '-f', '-n', @args) == 0 or die "gzip failed\n";;
   79     }
   80     foreach my $list (@links) {
   81         my $main = shift(@$list);
   82         for(@$list) {
   83             printf "rm $_; ln $main.gz $_.gz\n";
   84             unlink $_ or die "Can't unlink: $!\n";
   85             unlink "$_.gz";
   86             link("$main.gz", "$_.gz") or die "Can't link: $!\n";;
   87         }
   88     }
   89     for(@symlinks) {
   90         my $link = readlink($_);
   91         printf "rm $_; ln -s $link.gz $_.gz\n";
   92         unlink $_ or die "Can't unlink: $!\n";
   93         symlink("$link.gz", "$_.gz") or die "Can't symlink: $!\n";
   94     }
   95 }

Cache object: 435eaf0563b76c4b581c4760aa0d7d52


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.