[Bug 308] New: update man hint with following code to rename symlinks to point to the new compressed filenames

bugzilla at linuxfromscratch.org bugzilla at linuxfromscratch.org
Tue Mar 12 15:55:11 PST 2002


http://bugs.linuxfromscratch.org/show_bug.cgi?id=308

           Summary: update man hint with following code to rename symlinks
                    to point to the new compressed filenames
           Product: Linux From Scratch
           Version: CVS
          Platform: PC
               URL:
        OS/Version: Other
            Status: NEW
 Status Whiteboard:
          Keywords:
        Resolution:
          Severity: normal
          Priority: P3
         Component: Book
        AssignedTo: lfs-book at linuxfromscratch.org
        ReportedBy: gerard at linuxfromscratch.org


From: blax <blax at specto.org>                                                    
To: gerard at 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 at specto.org
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-book' in the subject header of the message



More information about the lfs-book mailing list