Gentoo Archives: gentoo-user

From: Francisco Ares <frares@×××××.com>
To: gentoo-user <gentoo-user@l.g.o>
Subject: [gentoo-user] cleaning /var/lib/portage/world
Date: Wed, 16 Aug 2017 11:33:17
Message-Id: CAHH9eM5QRHeQhV3GDikpMFRCgVBEN8AjgL4TpV7v9wTxQOjnBw@mail.gmail.com
1 Hello,
2
3 During the process of learning how to manage packages in our beloved distro
4 - and even after knowing how to, but due to being in a hurry - I have my
5 "world" package set a bit cumbered with package names that would not need
6 to be there, as they are dependencies of other packages, as some libraries,
7 for instance.
8
9 So I thought on finding out which of those packages could be removed from
10 "world", and I have come up with the following script, which results in 3
11 files in the "/tmp" directory:
12
13 - world_remove_candidates
14 - world_remove_candidates_reasons
15 - world
16
17 - the first is a simple list of packages found in "world" that _probably_
18 could be removed from "world";
19 - the second includes which packages depends on each of the above mentioned
20 packages;
21 - the third, the cleaned up "world", without overwriting the original.
22
23 But, after backing up the original "world" file and replacing with the one
24 built by the script, things don't work as expected, as a lot of packages
25 were orphaned, by checking with "depclean".
26
27 Anyone could tell me what did I miss?
28
29 Here is the script:
30
31 #---------------------------------------------------------------------------
32 #! /bin/bash
33 cd /tmp
34 if [ -e world_remove_candidate ]
35 then
36 rm -f world_remove_candidate
37 fi
38 if [ -e world_remove_candidate_reasons ]
39 then
40 rm -f world_remove_candidate_reasons
41 fi
42 for i in `cat /var/lib/portage/world`
43 do
44 A=`equery d $i`
45 if [ "a$A" != "a" ]
46 then
47 echo $i >> world_remove_candidate
48 echo "* * * * * * * * * * * * * "$i >>
49 world_remove_candidate_reasons
50 for j in $A
51 do
52 echo $j >> world_remove_candidate_reasons
53 done
54 fi
55 done
56
57 cp -a /var/lib/portage/world .
58 for i in `cat world_remove_candidate`
59 do
60 S=`echo $i | sed s+/+\\\\\\\\/+` # this is to format the string
61 accorgingly to 'sed' (ugly, isn't it?)
62 cat world | sed -e /"$S"/d > world.x
63 rm -f world
64 mv world.x world
65 done
66
67 # the following loop is for announcing it has finished.
68 A=20
69 while [ "$A" != "0" ]
70 do
71 A=$(( $A - 1 ))
72 sleep 1
73 echo -n -e \\a
74 done
75
76 ls -halF world*
77 #---------------------------------------------------------------------------
78
79
80 Thanks!
81 Francisco

Replies

Subject Author
Re: [gentoo-user] cleaning /var/lib/portage/world Arve Barsnes <arve.barsnes@×××××.com>