View previous topic :: View next topic |
Author |
Message |
TrisMcC n00b
Joined: 23 Jun 2002 Posts: 8
|
Posted: Tue Jul 02, 2002 1:55 am Post subject: Helpful scriptlet that makes my life easier... |
|
|
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 |
|
|
fghellar Bodhisattva
Joined: 10 Apr 2002 Posts: 856 Location: Porto Alegre, BR
|
|
Back to top |
|
|
Dolio l33t
Joined: 17 Jun 2002 Posts: 650
|
Posted: Thu Jul 25, 2002 7:30 am Post subject: Hum dee dum |
|
|
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 |
|
|
Dolio l33t
Joined: 17 Jun 2002 Posts: 650
|
Posted: Thu Jul 25, 2002 7:40 am Post subject: Also |
|
|
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 |
|
|
|
|
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
|
|