Hello,

During the process of learning how to manage packages in our beloved distro
- and even after knowing how to, but due to being in a hurry - I have my
"world" package set a bit cumbered with package names that would not need
to be there, as they are dependencies of other packages, as some libraries,
for instance.

So I thought on finding out which of those packages could be removed from
"world", and I have come up with the following script, which results in 3
files in the "/tmp" directory:

- world_remove_candidates
- world_remove_candidates_reasons
- world

- the first is a simple list of packages found in "world" that _probably_
could be removed from "world";
- the second includes which packages depends on each of the above mentioned
packages;
- the third, the cleaned up "world", without overwriting the original.

But, after backing up the original "world" file and replacing with the one
built by the script, things don't work as expected, as a lot of packages
were orphaned, by checking with "depclean".

Anyone could tell me what did I miss?

Here is the script:

#---------------------------------------------------------------------------
#! /bin/bash
cd /tmp
if [ -e world_remove_candidate ]
then
    rm -f world_remove_candidate
fi
if [ -e world_remove_candidate_reasons ]
then
    rm -f world_remove_candidate_reasons
fi
for i in `cat /var/lib/portage/world`
do
    A=`equery d $i`
    if [ "a$A" != "a" ]
    then
        echo $i >> world_remove_candidate
        echo "* * * * * * * * * * * * * "$i >>
world_remove_candidate_reasons
        for j in $A
        do
            echo $j >> world_remove_candidate_reasons
        done
    fi
done

cp -a /var/lib/portage/world .
for i in `cat world_remove_candidate`
do
    S=`echo $i | sed s+/+\\\\\\\\/+`  # this is to format the string
accorgingly to 'sed' (ugly, isn't it?)
    cat world | sed -e /"$S"/d > world.x
    rm -f world
    mv world.x world
done

# the following loop is for announcing it has finished.
A=20
while [ "$A" != "0" ]
do
    A=$(( $A - 1 ))
    sleep 1
    echo -n -e \\a
done

ls -halF world*
#---------------------------------------------------------------------------


Thanks!
Francisco

Reply via email to