﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
308	update man hint with following code to rename symlinks to point to the new compressed filenames	gerard@…	markh@…	"From: blax <blax@specto.org>                                                    
To: gerard@linuxfromscratch.org                                                 
Subject: Man hint                                                               
Date: Tue, 12 Mar 2002 17:37:42 -0600                                           

Hello,                                                                          
                                                                                
To compress manpages that have symlinks to them I wrote the following           
perl script:                                                                    
                                                                                
<CODE>                                                                          
#!/usr/bin/perl -w                                                              
                                                                                
use strict;                                                                     
                                                                                
# Change $lfs_man_dir to your lfs_man_dir root                                  
my $lfs_man_dir = ""/home/lfs/build/usr/share/man"";                              
chdir(""$lfs_man_dir"") or die ""cannot chdir $lfs_man_dir: $!"";                   
                                                                                
for (my $i = 1; $i < 9; $i++) {                                                 
   opendir(M_DIR, ""man$i"") or die ""cannot opendir man$i: $!"";                   
   chdir(""man$i"");                                                              
                                                                                
   # change all symlinks to point to *.bz2                                      
   foreach (readdir M_DIR) {                                                    
       if (-l $_) {                                                             
           my $link = readlink($_) or die ""cannot readlink $_: $!"";             
           unlink($_) or die ""cannot unlink $_: $!"";                            
           symlink(""$link.bz2"", ""$_.bz2"")                                       
               or die ""cannot create symlink $link.bz2: $!"";                    
       }                                                                        
   }                                                                            
                                                                                
   # now compress all files                                                     
   opendir(M_DIR, ""."") or die ""cannot opendir man$i: $!"";                       
   foreach (readdir M_DIR) {                                                    
       next if -l $_ or /^\.(\.)?$/;                                            
       system(""bzip2 $_"");                                                      
   }                                                                            
   chdir("".."");                                                                 
   closedir(M_DIR);                                                             
}                                                                               
</CODE>                                                                         
                                                                                
It changes two things: the symlinks are renamed with a *.bz2 extension          
and now point to the file they were pointing to *.bz2.  Now the files           
they were pointing to can be compressed and the links point to the              
proper place.  The script doesn't handle hard links but the only man            
pages that have hard links to them are from the gzip package.  I removed        
all but gzip.1 and created symlinks to it manualy.                              
                                                                                
Cordialy,                                                                       
Jerry Bennett                                                                   
blax@specto.org"	defect	closed	normal		Book	CVS	normal	fixed		
