public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Script to rebuild existing installation
@ 2002-05-03 17:23 root
  2002-05-04 11:51 ` Markus Bertheau
  0 siblings, 1 reply; 2+ messages in thread
From: root @ 2002-05-03 17:23 UTC (permalink / raw
  To: gentoo-dev

Sean Kane asked a little while ago for a way to rebuild all packages without 
upgrading.

I saw someone post a script, but it was in base64 and I was on a cheap mail 
reader, so I couldn't see what it was.

I believe this one will do the trick. If anybody spots anything in it that is 
incorrect, please let me know. I'm still on the upward part of the learning 
curve regarding Portage.

#!/bin/bash

# The grep gets rid of the "[ Results for" and "[ Applications found" lines.
# The tr (which is 3 letters, an ESCAPE, "[", and "]" gets rid of stuff that
# will complicate life for awk later, and the sed cleans up the rest of the 
# garbage that the color stuff puts in.
# (If anyone can figure out how to turn the color stuff off, most of this 
# first section will be unecessary.)

emerge -s ".*" \
|grep -v "^\[" \
| tr ' ^[[]' '   ' \
| sed -e '
 s/0m//g
 s/32;01m//g
 s/01m//g
 s/^ $//
' > allapps

# If preferred, you can just pipe the output of the sed above into the awk.
# Don't forget to move or delete these comments if you do.

# The combination of the Field Separator being "\n" (return) and
# "" (aka '^$') means it will treat each "paragraph" of the output as one
# long line. Things like $1 and $3 below refer to _lines_, not words.
awk -F"\n" -v RS='' '

# Strip out all packages which are not installed.
$3 !~ /Not Installed/ {

# For the ones that are left, get the package name and version and
# write them out.
split($1,a," ");
pkg=a[2]; 
split($2,a," ");
ver=a[4];
print "=" pkg "-" ver}' < allapps > current

# Again, this can be turned into a pipe if you're allergic to files.
# I find having the "current" file, at least, fairly handy.
emerge --pretend $(cat current)




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-04 11:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-03 17:23 [gentoo-dev] Script to rebuild existing installation root
2002-05-04 11:51 ` Markus Bertheau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox