Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Helpful scriptlet that makes my life easier...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
TrisMcC
n00b
n00b


Joined: 23 Jun 2002
Posts: 8

PostPosted: Tue Jul 02, 2002 1:55 am    Post subject: Helpful scriptlet that makes my life easier... Reply with quote

I wrote a shell script that has proven to be very helpful in maintaining my installed package list and keeping myself bleeding edge with portage.

first, portage has to be recent - I am using 2.0.8.

All the ^[ are escape sequences (CTRL-V + ESC) due to the fact that emerge outputs in color.

What this script does it parse the output of 'emerge -pe world' file to make it look identical to the output of qpkg (from the gentoolkit package) and sorts the two files, and outputs the difference of the files. This is helpful in that it tells you exactly what files were updated from the rsync server.

This assumes that your /var/cache/edb/world file is good. A really good thing about this also, is if you want to completely remove a file and its dependencies from your computer without removing a file that another program depends on, you can remove it from your world file and it will tell you which files you need to remove. Therefore, it is helpful if you only have programs in your world file, and not stuff like libraries and such.

Before running this script, you should do an emerge rsync to make sure your portage tree is up to date.

I usually run this script, and it tells me what has been updated, so I do an

Code:

emerge --oneshot <package>


So that the programs aren't added to my world file (unless needed).

Code:

#!/bin/sh

/usr/bin/emerge -pe world > /tmp/output
/bin/sed -e s/"\[ebuild  ^[\[32;01mN^[\[0m   \] "//g -e s/" to \/"//g -e \
1,4d -e '$d' /tmp/output | sort > /tmp/emerge

/usr/bin/qpkg -I -nc -v | sort > /tmp/qpkg

/usr/bin/diff /tmp/qpkg /tmp/emerge



Hope this may help someone...

-Tristan
Back to top
View user's profile Send private message
fghellar
Bodhisattva
Bodhisattva


Joined: 10 Apr 2002
Posts: 856
Location: Porto Alegre, BR

PostPosted: Tue Jul 02, 2002 3:42 am    Post subject: Reply with quote

--> Tips & Tricks
_________________
| www.gentoo.org | www.tldp.org | www.google.com |
Back to top
View user's profile Send private message
Dolio
l33t
l33t


Joined: 17 Jun 2002
Posts: 650

PostPosted: Thu Jul 25, 2002 7:30 am    Post subject: Hum dee dum Reply with quote

Unfortunately, I couldn't get your original script to work. However, I fiddled around with it and got something like it working, but didn't like the diff output (guess I'm too much of a noob), so I modified it some more, and got it to print out just the packages spit out by qpkg that aren't in emerge -pe world

Code:

#!/bin/bash
emerge -pe world | grep 'ebuild' | sed 's/\[[^]]\+\] //g' | sed 's/ to \///g' | sort > /tmp/output

qpkg -I -nc -v | sort > /tmp/qpkg

sed 's/\//\\\//g' /tmp/output > /tmp/emerge

for package in `cat /tmp/emerge`
do
        sed "s/$package\$//g" /tmp/qpkg > /tmp/qpk
        mv -f /tmp/qpk /tmp/qpkg
done

egrep '^.+$' /tmp/qpkg


This runs slower than the diff did, but I find it easier to read the output (you could also grep the output if you're trying to figure out if you need a certain package).

Don't just go around killing packages this spits out, though. It tells me that I don't need some stuff that has things depending on it in qpkg -u (apparently xscreensaver has a lot of gnome dependencies on my system. I'm going to have to look into that, I guess).

Edit: Not sure how this script looks on your browser, but I should note that everything between the shebang and the first qpkg should be on one line, just in case it wraps.
_________________
They don't have a good bathroom to do coke in.


Last edited by Dolio on Thu Jul 25, 2002 7:42 am; edited 2 times in total
Back to top
View user's profile Send private message
Dolio
l33t
l33t


Joined: 17 Jun 2002
Posts: 650

PostPosted: Thu Jul 25, 2002 7:40 am    Post subject: Also Reply with quote

Additionally, while we're on helpful scriptlets,

If you want the above to work, you should only have the programs you want to use in your world file, and not any of their dependencies. However, if you do this, there's no way to know when their dependencies get updated, unless they get updated. For example, when I do

emerge -pu world

I get binutils (because I installed a newer version. Go figure), and baselayout (same reason). However, qt 3.0.5 is out, and I have qt 3.0.4.20020606-r1, which is obviously older. So, I made this scriptlet to check for dependency updates.

Code:

#!/bin/bash

list=""

for package in `qpkg -I -nc`
do
        list="$list $package"
done

emerge -p $list | egrep 'U \[[^m]+m \]'


Which will print the appropriate packages. Now that I think of it, though, emerging these by hand will add them to the world file, gradually killing any usefulness of the first script, so I guess this scriptlet is of dubious usefulness. At the very least, I suppose if you want everything installed in your world file (and as I recall, there's a script for that somewhere on this board), this can help you catch stragglers.

Cheers.

Edit: Silly me. I should have read the documentation. emerge --oneshot will update the package without adding it to the world file. This scriptlet is semi-useful after all. :)
_________________
They don't have a good bathroom to do coke in.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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