]>
git.saurik.com Git - apple/xnu.git/blob - config/compress-man-pages.pl
2 # Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 # @APPLE_LICENSE_HEADER_START@
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
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.
21 # @APPLE_LICENSE_HEADER_END@
24 use File
::Basename
();
28 my $MyName = File
::Basename
::basename
($0);
36 return unless /\.[\dn][a-z]*$/;
40 return if -s _
< $MinSize;
41 my($dev, $ino) = stat(_
);
42 my $list = $inodes{$ino};
43 $list = $inodes{$ino} = [] unless defined($list);
49 die "Usage: $MyName [-d prefix] dir ...\n";
52 Getopt
::Std
::getopts
('d:');
53 usage
() unless scalar(@ARGV) > 0;
56 $dir = $opt_d . $dir if $opt_d ne '';
58 die "$dir: no such directory\n" unless -d _
;
67 my(@compress, @links);
68 for(values(%inodes)) {
69 push(@compress, $_->[0]);
70 push(@links, $_) if scalar(@$_) > 1;
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";;
80 foreach my $list (@links) {
81 my $main = shift(@$list);
83 printf "rm $_; ln $main.gz $_.gz\n";
84 unlink $_ or die "Can't unlink: $!\n";
86 link("$main.gz", "$_.gz") or die "Can't link: $!\n";;
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";