Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
emerge filter for -uDNvp world
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
ddc
Guru
Guru


Joined: 29 Aug 2006
Posts: 527

PostPosted: Wed Mar 12, 2008 4:35 pm    Post subject: emerge filter for -uDNvp world Reply with quote

hi,
i park it here, 'cause it has been developed to easy my gentoo administration life, in case it is a very easy piece of c, but it should be useful for you, too: so feel free to re use/improve/mv to dev/null it

Code:

/usr/bin/myemerge-update-power
if [ "$1" == "proof" ]
   then
       emerge -uDNvp world
   fi
if [ "$1" == "report" ]
   then
       emerge -uDNvp world | myemerge-filter 2>/dev/null
   fi

if [ "$1" == "fetch" ]
   then
       emerge -uDNfv world
   fi
if [ "*$1" == "*" ]   
   then
       emerge  -uDNv world
   fi





/usr/bin/myemerge-filter

Code:

myemerge-filter.c
#include <stdio.h>

char buffer[100], buffer_i;

char filter (char status, char ch)
     {
     if (status==0)
        {
   buffer_i=0;
   if (ch=='[')
      {
      status=1;
      }
        return status;
   }
     if (status==1)
        {
   if (ch==']')
      {
      status=2;
      }
        return status;
   }
     if (status==2)
        {
   if (ch==' ')
      {
      status=3;
      }
        return status;
   }
     if (status==3)
        {
   if (ch==' ')
      {
      status=4;
      }
        else
      {
      buffer[buffer_i++]=ch;
           }
        return status;
   }
     if (status==3)
        {
   status=0;
        return status;
   }
     return 0;   
     }

int  main ()
     {
     int  fr=!EOF;
     char status=0;
     char ch;
     do
           {
           fr=fgetc(stdin);
      if (fr!=EOF)
         {
         ch=(char)fr;
          status=filter(status, ch);
         if (status==4)
            {
       printf("%s\n",   buffer);
       }
         }
           }
     while ((fr!=EOF));
     return 1;
     }
Back to top
View user's profile Send private message
ddc
Guru
Guru


Joined: 29 Aug 2006
Posts: 527

PostPosted: Wed Mar 12, 2008 4:48 pm    Post subject: Reply with quote

it filters this

Quote:

[ebuild R ] dev-libs/DirectFB-0.9.25.1 USE="fbcon* gif jpeg mpeg png truetype v4l v4l2 zlib* -debug* (-fusion) (-mmx) -sdl (-sse) -sysfs" 2,016 kB
[ebuild FU ] dev-java/ibm-jdk-bin-1.4.2.10 [1.4.2.9] USE="X (-alsa*) -doc* -examples -javacomm (-nsplugin)" 65,221 kB
[ebuild U ] gnome-base/libgnomeprint-2.18.3 [2.18.0] USE="cups -debug -doc" 0 kB
[ebuild N ] x11-libs/gtkglarea-1.99.0 USE="-debug" 0 kB


to this

Quote:

dev-libs/DirectFB-0.9.25.1
dev-java/ibm-jdk-bin-1.4.2.10
gnome-base/libgnomeprint-2.18.3
x11-libs/gtkglarea-1.99.02.18.3
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10286
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Mar 12, 2008 5:05 pm    Post subject: Reply with quote

Code:
emerge -uDNvp world | awk -- '$1 ~ /\[ebuild/ { $0 = substr($0, 17); print $1 }'
If you learn AWK, sed, and, perhaps, depending on the time you have to invest, Perl, these little reformatting tasks become trivial. :wink:

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
ddc
Guru
Guru


Joined: 29 Aug 2006
Posts: 527

PostPosted: Tue Mar 18, 2008 9:58 pm    Post subject: Reply with quote

thank U for the suggestion: i confess i don't know awk and such things at all, I am a C/ppc-assembly guy at the moment, but I am realizing I'd better learn other languages and interpreter: 'cause they could simplify my administration life : P

the filter i did in C is based on finite state machine theory: it takes 5 minutes of my time to be implemented, unfortunately it need to be compiled, and it is not power, short, efficient,
and elegant as awk : P
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum