Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Picking package names from emerge output

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
tmo
n00b
n00b
Posts: 25
Joined: Mon Jun 16, 2003 10:57 pm
Location: Finland
Contact:
Contact tmo
Website

Picking package names from emerge output

  • Quote

Post by tmo » Sun Dec 18, 2005 12:48 pm

Tired of manually picking package names from emerge output?

emerge-cut-pkg:

Code: Select all

#!/bin/sh
sed -n 's/^[^]]*U \] \+\([^ ]*\).*/=\1/p'
Usage:

Code: Select all

# save list of packages to a tmp file because emerge is dog-slow
$ emerge -puD world | emerge-cut-pkg > /tmp/out

$ cat /tmp/out 
=sys-kernel/linux-headers-2.6.11-r3
=sys-libs/glibc-2.3.5-r3
=x11-libs/xtrans-1.0.0
=x11-libs/libICE-1.0.0
...

# emerge (pretend) only x11-libs/*
$ emerge -pvt `grep x11-libs /tmp/out`

These are the packages that I would merge, in reverse order:

Calculating dependencies ...done!
[ebuild     U ] x11-libs/libXevie-1.0.0 [0.99.3] 201 kB 
[ebuild     U ] x11-libs/libXinerama-1.0.0 [0.99.2] 196 kB 
[ebuild     U ] x11-libs/libXrandr-1.1.0.2 [1.1.0.1] 206 kB 
...
Edited the sed expression to include only updated packages
Last edited by tmo on Mon Dec 19, 2005 1:59 pm, edited 1 time in total.
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Mon Dec 19, 2005 9:12 am

Nice idea! I Wonder why I didn't come up with this myself. Maybe I'm still not lazy enough :D

One question, though: what's the purpose of \+ in the expression? Works without it, too.
I suppose it doesn't match a literal + and I couldn't find an explanation with a few searches
So please, educate me.
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Mon Dec 19, 2005 11:18 am

Silly me. It seems to work like I tought + would do alone (match one or more occurrences
of the previous block). I just don't understand why it has to be escaped. Back in the days,
at least Rute used to teach this the other way around.
Top
tmo
n00b
n00b
Posts: 25
Joined: Mon Jun 16, 2003 10:57 pm
Location: Finland
Contact:
Contact tmo
Website

  • Quote

Post by tmo » Mon Dec 19, 2005 12:22 pm

roseZ wrote:Silly me. It seems to work like I tought + would do alone (match one or more occurrences
of the previous block). I just don't understand why it has to be escaped. Back in the days,
at least Rute used to teach this the other way around.
Maybe sed got support for '+' later and without escaping it would have broken backward compatibility, I don't know really :)

I wonder why emerge doesn't have an option to output package names only...
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Mon Dec 19, 2005 9:26 pm

Ok, I did what I should have done right from the start. Read the man page of sed (and grep), that is :)

Apparently there are two kinds of regexps: basic and extended. Default for sed and grep is the former,
in which characters like ? + ( | { lose their special meaning unless preceded by a backslash.
I think I like the extended mode better, since it's more consistent. Excaping invokes literal meaning
instead of the opposite for all characters.

So we could shave a few characters off the script:

Code: Select all

#!/bin/sh
sed -nr 's/^[^]]*U \] +([^ ]*).*/=\1/p'
This will undoubtedly sacrifice some portability, although \+ is already a GNU extension ;)

About portage tools, they could definitely be polished, but the devs must have their hands full.
Top
slycordinator
Advocate
Advocate
User avatar
Posts: 3065
Joined: Sat Jan 31, 2004 9:51 pm
Location: Korea

  • Quote

Post by slycordinator » Fri Oct 13, 2006 1:10 am

I like this better:

Code: Select all

#!/bin/sh
sed -n 's/^[^]]*\] \+\([^ ]*\).*/=\1/p'
This gets all packages. I had edited the script before and couldn't figure out why it was missing every package that portage wanted to downgrade. Didn't take long to figure it out.
Top
Post Reply

6 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic