Created
August 16, 2010 13:31
-
-
Save hron84/526940 to your computer and use it in GitHub Desktop.
Mass unmask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my( $pack ) = "" ; | |
$pack .= " $_" for ( @ARGV ) ; | |
my( $b ) = 1; | |
while( $b ) | |
{ | |
$b = '' ; | |
@out = `emerge -pv$pack` ; | |
$portage = '/etc/portage/package' ; | |
$umfile = "$portage.unmask"; | |
$kwfile = "$portage.keywords"; | |
if( -d $kwfile ) { | |
$kwfile = "$kwfile/mass"; | |
} | |
if( -d $umfile ) { | |
$umfile = "$umfile/mass"; | |
} | |
for ( @out ) | |
{ | |
if ( /^-\s+(.+?\/.+?)\-\d+\..*?\(masked by: (.+?(\,\s+.+?)*)\)/i ) | |
{ | |
my( $package , $masked ) = ( $1 , $2 ) ; | |
foreach $a ( split( /\,\s+/, $masked ) ) | |
{ | |
if ( $a eq "package.mask" ) | |
{ | |
$b .= "echo $package >> $umfile\n" ; | |
} | |
elsif ( $a =~ /(\W.+?)\s+keyword/i ) | |
{ | |
$b .= "echo $package $1 >> $kwfile\n" ; | |
} | |
elsif ( $a =~ /(missing)\s+keyword/i ) | |
{ | |
$b .= "echo \"$package ~*\" >> $kwfile\n" ; | |
$b .= "echo $package >> $umfile\n" ; | |
} | |
} | |
last ; | |
} | |
} | |
print $b ; | |
print `$b` ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment