public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: root@clacour.com
To: gentoo-dev@gentoo.org
Subject: [gentoo-dev] Script to rebuild existing installation
Date: Fri, 3 May 2002 12:23:23 -0500	[thread overview]
Message-ID: <200205031223.23103.root@cornet> (raw)

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)




             reply	other threads:[~2002-05-04  0:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-03 17:23 root [this message]
2002-05-04 11:51 ` [gentoo-dev] Script to rebuild existing installation Markus Bertheau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200205031223.23103.root@cornet \
    --to=root@clacour.com \
    --cc=gentoo-dev@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox