1 |
Sean Kane asked a little while ago for a way to rebuild all packages without |
2 |
upgrading. |
3 |
|
4 |
I saw someone post a script, but it was in base64 and I was on a cheap mail |
5 |
reader, so I couldn't see what it was. |
6 |
|
7 |
I believe this one will do the trick. If anybody spots anything in it that is |
8 |
incorrect, please let me know. I'm still on the upward part of the learning |
9 |
curve regarding Portage. |
10 |
|
11 |
#!/bin/bash |
12 |
|
13 |
# The grep gets rid of the "[ Results for" and "[ Applications found" lines. |
14 |
# The tr (which is 3 letters, an ESCAPE, "[", and "]" gets rid of stuff that |
15 |
# will complicate life for awk later, and the sed cleans up the rest of the |
16 |
# garbage that the color stuff puts in. |
17 |
# (If anyone can figure out how to turn the color stuff off, most of this |
18 |
# first section will be unecessary.) |
19 |
|
20 |
emerge -s ".*" \ |
21 |
|grep -v "^\[" \ |
22 |
| tr ' ^[[]' ' ' \ |
23 |
| sed -e ' |
24 |
s/0m//g |
25 |
s/32;01m//g |
26 |
s/01m//g |
27 |
s/^ $// |
28 |
' > allapps |
29 |
|
30 |
# If preferred, you can just pipe the output of the sed above into the awk. |
31 |
# Don't forget to move or delete these comments if you do. |
32 |
|
33 |
# The combination of the Field Separator being "\n" (return) and |
34 |
# "" (aka '^$') means it will treat each "paragraph" of the output as one |
35 |
# long line. Things like $1 and $3 below refer to _lines_, not words. |
36 |
awk -F"\n" -v RS='' ' |
37 |
|
38 |
# Strip out all packages which are not installed. |
39 |
$3 !~ /Not Installed/ { |
40 |
|
41 |
# For the ones that are left, get the package name and version and |
42 |
# write them out. |
43 |
split($1,a," "); |
44 |
pkg=a[2]; |
45 |
split($2,a," "); |
46 |
ver=a[4]; |
47 |
print "=" pkg "-" ver}' < allapps > current |
48 |
|
49 |
# Again, this can be turned into a pipe if you're allergic to files. |
50 |
# I find having the "current" file, at least, fairly handy. |
51 |
emerge --pretend $(cat current) |