You are not logged in.
By popular demand https://bbs.archlinux.org/viewtopic.php?id=103494
for pkg in $(pacman -Quq); do
echo $(pacman -Q $pkg) $(sudo pacman -Sdp --print-format "=> %v" $pkg)
done
'-Qu' prints out-of-date packages
'-Sdp ... %v' skips dependency checks and prints the version number
[karol@black ~]$ ./new
intel-dri 7.5.1-2 => 7.8.2-1
kernel26 2.6.34.3-1 => 2.6.35.3-1
libdrm 2.4.19-1 => 2.4.21-2
libgl 7.5.1-2 => 7.8.2-1
xf86-input-evdev 2.2.5-1 => 2.4.0-2
xf86-input-keyboard 1.3.2-2 => 1.4.0-2
xf86-input-mouse 1.4.0-2 => 1.5.0-2
xf86-video-vesa 2.2.0-1 => 2.3.0-2
xorg-server 1.6.3.901-1 => 1.8.1.902-1
xorg-server-utils 7.4-7 => 7.5-6
It's just a three-liner so you can get all kinds of unwanted behavior. I have xf86-video-intel-legacy installed, but it's not in the repos anymore so 'pacman -Qu' won't show it.
Feel free to extend it.
Offline
I was getting this error on my IgnorePkgs
error: '$pkg': could not find or read package
so I added a quick and dodgy check on the exit status of -Sdp:
for pkg in $(pacman -Quq); do
if ver="$(sudo pacman -Sdp --print-format '=> %v' $pkg 2>/dev/null)" ; then
echo $(pacman -Q $pkg) $ver
fi
done
edit: fixed nested quotes...
Last edited by quigybo (2010-08-28 04:44:44)
Offline
I think a better way is to specify via '--config' a config file that has no ignored packages.
grep -v IgnorePkg /etc/pacman.conf > ~/no-ignore-pkgs-pacman.conf
Version 0.2
config="/home/karol/no-ignore-pkgs-pacman.conf"
main () {
for pkg in $(pacman -Quq); do
echo $(pacman -Q $pkg) "=>" $(sudo pacman -Sdp --config $config --print-format "%v" $pkg)
done | column -t;
}
main
Sample output:
intel-dri 7.5.1-2 => 7.8.2-1
kernel26 2.6.34.3-1 => 2.6.35.3-1
libdrm 2.4.19-1 => 2.4.21-2
libgl 7.5.1-2 => 7.8.2-1
086-input-evdev 2.2.5-1 => 2.4.0-2
086-input-keyboard 1.3.2-2 => 1.4.0-2
086-input-mouse 1.4.0-2 => 1.5.0-2
086-video-vesa 2.2.0-1 => 2.3.0-2
xorg-server 1.6.3.901-1 => 1.8.1.902-1
xorg-server-utils 7.4-7 => 7.5-6
Known issues:
None so far.
Features:
1. Buffered [1] and pretty-printed output.
[1] The output isn't written line-by-line but at once.
Offline
Err, shouldn't you include a:
pacman -Sy &> /dev/null
so you don't have to manually refresh the database to see new packages?
EDIT: Also, use full program paths.
/usr/bin/pacman -Sy &> /dev/null
for pkg in $(/usr/bin/pacman -Quq); do
echo $(/usr/bin/pacman -Q $pkg) $(/usr/bin/sudo /usr/bin/pacman -Sdp --print-format "=> %v" $pkg)
done
Last edited by cesura (2010-08-28 19:26:05)
Offline
Err, shouldn't you include a:
pacman -Sy &> /dev/null
so you don't have to manually refresh the database to see new packages?
Makes sense.
EDIT: Also, use full program paths.
I'll fix it in the next release - tomorrow ;P
BTW, is there a canonical way of naming functions? 'main' seemed better than 'foo'.
Offline
BTW, is there a canonical way of naming functions? 'main' seemed better than 'foo'.
I just name them for what they do. For example, if I have a function to parse an HTML file, then I would name it "parsehtml()". For the actual function that is run when your program is run, I like to stick to main.
Offline
Nuts to your for loops, do it in one command.
paste <(printf "%20s %15s =>\n" $(pacman -Qu)) <(pacman -Sdp --print-format "%v" $(pacman -Qqu))
Shameless plug for Xyne: powerpill does this by default. Took me a while to figure out why this thread existed.
Offline
Nuts to your for loops, do it in one command.
paste <(printf "%20s %15s =>\n" $(pacman -Qu)) <(pacman -Sdp --print-format "%v" $(pacman -Qqu))
That was my version 0.0 which I didn't post ;P
Shameless plug for Xyne: powerpill does this by default. Took me a while to figure out why this thread existed.
Oh yes, if somebody wants to do it like a pro, use
karol@black ~]$ bauerbill -Qu
core/kernel26 2.6.34.3-1 -> 2.6.35.3-1
extra/intel-dri 7.5.1-2 -> 7.8.2-1
extra/libdrm 2.4.19-1 -> 2.4.21-2
extra/libgl 7.5.1-2 -> 7.8.2-1
extra/xf86-input-evdev 2.2.5-1 -> 2.4.0-2
extra/xf86-input-keyboard 1.3.2-2 -> 1.4.0-2
extra/xf86-input-mouse 1.4.0-2 -> 1.5.0-2
extra/xf86-video-vesa 2.2.0-1 -> 2.3.0-2
extra/xorg-server 1.6.3.901-1 -> 1.8.1.902-1
extra/xorg-server-utils 7.4-7 -> 7.5-6
instead. :-) And with bauerbill you don't have to use another config file.
Offline
Oh yes, if somebody wants to do it like a pro, use
karol@black ~]$ bauerbill -Qu core/kernel26 2.6.34.3-1 -> 2.6.35.3-1 extra/intel-dri 7.5.1-2 -> 7.8.2-1 extra/libdrm 2.4.19-1 -> 2.4.21-2 extra/libgl 7.5.1-2 -> 7.8.2-1 extra/xf86-input-evdev 2.2.5-1 -> 2.4.0-2 extra/xf86-input-keyboard 1.3.2-2 -> 1.4.0-2 extra/xf86-input-mouse 1.4.0-2 -> 1.5.0-2 extra/xf86-video-vesa 2.2.0-1 -> 2.3.0-2 extra/xorg-server 1.6.3.901-1 -> 1.8.1.902-1 extra/xorg-server-utils 7.4-7 -> 7.5-6
instead. :-) And with bauerbill you don't have to use another config file.
Yes, but then you don't get the satisfaction of thinking "karol made this"!
Last edited by cesura (2010-08-28 21:34:59)
Offline
Don't forget pretty colored output:
echo "\e[1;33m" $(/usr/bin/pacman -Q $pkg) "\e[1;0m" $(/usr/bin/sudo /usr/bin/pacman -Sdp --print-format "\e[1;32m=>\e[0m %v" $pkg) "\e[0;0m"
Offline
Don't forget pretty colored output:
echo "\e[1;33m" $(/usr/bin/pacman -Q $pkg) "\e[1;0m" $(/usr/bin/sudo /usr/bin/pacman -Sdp --print-format "\e[1;32m=>\e[0m %v" $pkg) "\e[0;0m"
It just crashed all my terminals :-(
Aug 29 16:02:10 black kernel: urxvtd[2891]: segfault at 6d305b65 ip b73d53c4 sp bfa937a8 error 4 in libc-2.12.1. so[b73a8000+145000]
I think it should be 'echo -e' to interpret the escape sequences.
Last edited by karol (2010-08-29 20:33:27)
Offline
I won't use colors, because there's no need for them: the columns say it all.
I think paste + printf is a neat way, but 'column -t' is great for lazy people like me :-)
Version 0.3
config="/home/karol/no-ignore-pkgs-pacman.conf"
/usr/bin/sudo /usr/bin/pacman -Sy &> /dev/null
foo () {
for pkg in $(/usr/bin/pacman -Quq); do
echo $(/usr/bin/pacman -Q $pkg) "=>" $(/usr/bin/sudo /usr/bin/pacman -Sdp --config $config --print-format "%v" $pkg)
done | /usr/bin/column -t;
}
foo
Version 0.3-paste
config="/home/karol/no-ignore-pkgs-pacman.conf"
/usr/bin/sudo /usr/bin/pacman -Sy &> /dev/null
# printf: hard precision on package names, easy on version numbers
/usr/bin/paste -d " " <(/usr/bin/printf "%-20.20s %-12s => \n" $(/usr/bin/pacman -Qu)) <(/usr/bin/sudo /usr/bin/pacman -Sdp --config $config --print-format "%v" $(/usr/bin/pacman -Qqu))
Last edited by karol (2010-08-29 21:35:06)
Offline
itsbrad212 wrote:Don't forget pretty colored output:
echo "\e[1;33m" $(/usr/bin/pacman -Q $pkg) "\e[1;0m" $(/usr/bin/sudo /usr/bin/pacman -Sdp --print-format "\e[1;32m=>\e[0m %v" $pkg) "\e[0;0m"
It just crashed all my terminals :-(
Aug 29 16:02:10 black kernel: urxvtd[2891]: segfault at 6d305b65 ip b73d53c4 sp bfa937a8 error 4 in libc-2.12.1. so[b73a8000+145000]
I think it should be 'echo -e' to interpret the escape sequences.
You're right, it should be that. Interesting that it didn't crash for me, as I use urxvt as well.
Offline
Instead of defining a config, create it on the fly...
--config <(grep -v "^Ignore" /etc/pacman.conf)
This does, however, mean that you have to fork for each iteration of the loop. Perhaps use a cache file?
You also don't need sudo for -Sdp.
Offline
karol wrote:itsbrad212 wrote:Don't forget pretty colored output:
echo "\e[1;33m" $(/usr/bin/pacman -Q $pkg) "\e[1;0m" $(/usr/bin/sudo /usr/bin/pacman -Sdp --print-format "\e[1;32m=>\e[0m %v" $pkg) "\e[0;0m"
It just crashed all my terminals :-(
Aug 29 16:02:10 black kernel: urxvtd[2891]: segfault at 6d305b65 ip b73d53c4 sp bfa937a8 error 4 in libc-2.12.1. so[b73a8000+145000]
I think it should be 'echo -e' to interpret the escape sequences.
You're right, it should be that. Interesting that it didn't crash for me, as I use urxvt as well.
Well, honestly, I just wanted you to feel bad ;P It could have been completely unrelated as I can't reproduce it.
I've used your line twice and it printed all the escape codes and then all urxvt instances happily folded :-)
Offline
You also don't need sudo for -Sdp.
That means there will be another version. Back to reading 'man pacman' and friends.
Offline
Instead of defining a config, create it on the fly...
--config <(grep -v "^Ignore" /etc/pacman.conf)
This does, however, mean that you have to fork for each iteration of the loop. Perhaps use a cache file?
No need for a cache file if you use this with the paste method, it is only called once as there is no loop.
This along with the paste method is amazingly quicker than the for loop, tis definitely the winner imo.
I know it is personal preference, but I prefer something like this for printf and -d "" for paste:
"%-20.20s %12s => \n"
Last edited by quigybo (2010-08-30 12:07:19)
Offline
One thing I just realised about using -Qu to get the list of packages is that it will not show any new dependencies that the to-be-upgraded version of a package may have, so I propose using -Sup instead:
for pkg in $(/usr/bin/pacman -Sup --print-format "%n" | grep -v "Starting full system upgrade\|nothing to do"); do
/bin/echo $(/usr/bin/pacman -Q $pkg 2>/dev/null || /bin/echo $pkg new) "=>" $(/usr/bin/pacman -Sdp --print-format "%v" $pkg)
done | /usr/bin/column -t
Annoyingly pacman will still show "Starting full system upgrade" when using -u with -p (which you would think is mostly used for scripting). I wonder if it is worthy of a feature request on the bug tracker, as it is even the case when using --quiet? I'm happy to file it if people agree with me? edit: submitted here
I still think that the paste method is the way to go as it is quicker, however I couldn't see an easy/clean way to do it with the output of -Sup, as it can also contain new packages not yet in pacman's -Q database.
One side-effect of using -Sup instead is that it honours IgnorePkg properly, which is imo better than using a 'clean' config file. At least for me when I ignore a package I don't want to know or hear about it again. You can always include falconindy's --config <(grep ...) where appropriate if you feel otherwise.
Last edited by quigybo (2010-08-31 13:41:31)
Offline
$ pacman -Sup --print-format "%n"
:: Starting full system upgrade...
there is nothing to do
$ pacman -Qu
intel-dri 7.5.1-2
kernel26 2.6.34.3-1
libdrm 2.4.19-1
libgl 7.5.1-2
xf86-input-evdev 2.2.5-1
xf86-input-keyboard 1.3.2-2
xf86-input-mouse 1.4.0-2
xf86-video-vesa 2.2.0-1
xorg-server 1.6.3.901-1
xorg-server-utils 7.4-7
I have a bunch of IgnoredPkgs and -Qu sees them, -Sup does not.
Offline
I have a bunch of IgnoredPkgs and -Qu sees them, -Sup does not.
I actually prefer this behaviour, but as I mentioned you can easily add --config where needed if you feel otherwise. The main reason for using -Sup instead of -Qu is to show new (as yet uninstalled) dependencies that may arise when an installed package upgrades and its dependencies change.
Also, I submitted a feature request on pacman's -Supq behaviour here anyway, as it is relevant to another pacman script I have too.
Offline
karol wrote:I have a bunch of IgnoredPkgs and -Qu sees them, -Sup does not.
I actually prefer this behaviour, but as I mentioned you can easily add --config where needed if you feel otherwise. The main reason for using -Sup instead of -Qu is to show new (as yet uninstalled) dependencies that may arise when an installed package upgrades and its dependencies change.
Also, I submitted a feature request on pacman's -Supq behaviour here anyway, as it is relevant to another pacman script I have too.
Even -Sup won't show xf86-video-intel as a "new version" of my xf86-video-intel-legacy, neither will 'bauerbill -Qu'.
[karol@black ~]$ sudo pacman -Su
:: Starting full system upgrade...
warning: hdparm: local (9.29-1) is newer than core (9.28-1)
warning: lrzip: local (0.46-1) is newer than archlinuxfr (0.45-1)
warning: stfl: local (0.21-2) is newer than dragonlord (0.21-1)
:: Replace xf86-video-intel-legacy with archstuff/xf86-video-intel-newest? [Y/n] n
resolving dependencies...
looking for inter-conflicts...
:: xorg-server and xf86-video-intel-legacy are in conflict. Remove xf86-video-intel-legacy? [y/N] n
error: unresolvable package conflicts detected
error: failed to prepare transaction (conflicting dependencies)
:: xorg-server and xf86-video-intel-legacy are in conflict
I answered 'no' to both questions.
Can you post the output where you get new dependencies? How will you know what they are? Won't it look like:
intel-dri 7.5.1-2 => 7.8.2-1
jumanji-git 20100727-1 => 20100830-1
kernel26 2.6.34.3-1 => 2.6.35.4-1
libdrm 2.4.19-1 => 2.4.21-2
libgl 7.5.1-2 => 7.8.2-1
tcp_wrappers 7.6-11 => 7.6-12
udev 161-1 => 161-2
xf86-input-evdev 2.2.5-1 => 2.4.0-2
xf86-input-keyboard 1.3.2-2 => 1.4.0-2
xf86-input-mouse 1.4.0-2 => 1.5.0-2
=> 1.2.3.4
xf86-video-vesa 2.2.0-1 => 2.3.0-2
xorg-server 1.6.3.901-1 => 1.8.1.902-1
xorg-server-utils 7.4-7 => 7.5-6
Offline
Can you post the output where you get new dependencies? How will you know what they are?
Thats why I have "|| echo $pkg new" if you look closely. A little dodgy but oh well...
So as in your example it will look something like this:
xf86-input-mouse 1.4.0-2 => 1.5.0-2
newdependency new => 1.2.3.4
xf86-video-vesa 2.2.0-1 => 2.3.0-2
[karol@black ~]$ sudo pacman -Su :: Starting full system upgrade... warning: hdparm: local (9.29-1) is newer than core (9.28-1) warning: lrzip: local (0.46-1) is newer than archlinuxfr (0.45-1) warning: stfl: local (0.21-2) is newer than dragonlord (0.21-1) :: Replace xf86-video-intel-legacy with archstuff/xf86-video-intel-newest? [Y/n] n resolving dependencies... looking for inter-conflicts... :: xorg-server and xf86-video-intel-legacy are in conflict. Remove xf86-video-intel-legacy? [y/N] n error: unresolvable package conflicts detected error: failed to prepare transaction (conflicting dependencies) :: xorg-server and xf86-video-intel-legacy are in conflict
What happens with -Sup instead of just -Su? Sorry I don't have any replaces at the moment.
Offline
[karol@black code]$ pacman -Sup
:: Starting full system upgrade...
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/libdrm-2.4.21-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/libgl-7.8.2-1-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/intel-dri-7.8.2-1-i686.pkg.tar.xz
http://repo.archlinux.fr/i686/jumanji-git-20100830-1-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/core/os/i686/kernel26-2.6.35.4-1-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/core/os/i686/tcp_wrappers-7.6-12-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/core/os/i686/udev-161-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xf86-input-evdev-2.4.0-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xf86-input-keyboard-1.4.0-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xf86-input-mouse-1.5.0-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xf86-video-vesa-2.3.0-2-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xorg-server-utils-7.5-6-i686.pkg.tar.xz
http://darkstar.ist.utl.pt/archlinux/extra/os/i686/xorg-server-1.8.1.902-1-i686.pkg.tar.xz
Edit: Is there a way to show just the version numbers with 'pacman -Q' other than
pacman -Qu | cut -d " " -f 2
or some similar awking? '-Qp' means something entirely different than '-Sp'.
Last edited by karol (2010-08-31 15:02:26)
Offline
Strange that it doesn't list archstuff/xf86-video-intel-newest, maybe it has something to do with the fact that it is (I'm guessing) a local repo? I doubt it, but does -Sup --print-format "%n" make a difference?
Maybe -Sup doesn't list replaces properly, but it does list new dependencies when an installed package changes its dependency list, so at least it is a little step up from -Qu.
Offline
intel-legacy is not in the repos anymore (the package shows up in 'pacman -Qm') and when I upgrade I have to explicitly install xf86-video-intel, because pacman only warns me about conflicts.
[karol@black code]$ pacman -Sup --print-format "%n"
:: Starting full system upgrade...
libdrm
libgl
intel-dri
jumanji-git
kernel26
tcp_wrappers
udev
xf86-input-evdev
xf86-input-keyboard
xf86-input-mouse
xf86-video-vesa
xorg-server-utils
xorg-server
No Intel drivers here.
Last edited by karol (2010-08-31 16:00:06)
Offline