Skip to content

Instantly share code, notes, and snippets.

@hron84
Created August 16, 2010 13:31
Show Gist options
  • Save hron84/526940 to your computer and use it in GitHub Desktop.
Save hron84/526940 to your computer and use it in GitHub Desktop.
Mass unmask
#!/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