I have found some of the tools of portage a little opaque and confusing.
 Once
I found eix, I put together a little set of shell scripts to make lists
of the
packages in portage.

The script 'makeeixall' goes through and does an eix update and then
generates
a set of lists of packages: all, installed, new (not installed) and updates.

The script 'eixall' and its aliases 'eixupdate' 'eixnew' and 'eixinst' grep
the associated lists and print matches to the standard out.

You will need to make the '/usr/local/tmp' directory or point EIXDIR to
some other location.
------------------------------------------------------------------------------
#!/bin/bash

# script to create a database of packages for quick reference
# 27 June 2013  version to make system-wide db
# 05  Aug 2013  add "downgrades" to the eixupdate listing

EIXDIR="/usr/local/tmp"
EIXALL="$EIXDIR/eix-all.txt"
EIXINST="$EIXDIR/eix-installed.txt"
EIXUPD="$EIXDIR/eix-updates.txt"
EIXNEW="$EIXDIR/eix-new.txt"

# first: get rid of the old db
rm $EIXALL

# second: have EIX update its binary db
eix-update

# third: run through the categories and build the eix-all text file
echo -n "Prepping files: all..."
cd /usr/portage
cat profiles/categories | while read dname
do
        eix --care -c -x -C $dname
done >>$EIXALL

# fourth: make some utility text databases
#         the installed packages
echo -n "install..."
grep -F '[I]' $EIXALL >$EIXINST

#         the upgradeable packages
#               be careful to append the "downgrades"
echo -n "updates..."
grep -F '[U]' $EIXALL >$EIXUPD
grep -F '[D]' $EIXALL >>$EIXUPD
grep -F '[UD]' $EIXALL >>$EIXUPD

#       these files are also "installed", append to inst file
cat $EIXUPD >>$EIXINST

#         the "new" uninstalled packages
echo "not-installed (new)"
grep -F '[N]' $EIXALL >$EIXNEW

# fifth: make the text file readable by anyone
chmod 0444 /usr/local/tmp/eix*.txt

exit 0
-------------------------------------------------------------------------------


The script 'eixall' is for searching the outputs of 'makeeixall'


--------------------------------------------------------------------------------
#!/bin/bash

# script to search a database of packages for quick reference (see
makeeixall)
# 27 June 2013  version 1: to use system-wide db

EIXDIR="/usr/local/tmp"
EIXALL="$EIXDIR/eix-all.txt"
EIXINST="$EIXDIR/eix-installed.txt"
EIXUPD="$EIXDIR/eix-updates.txt"
EIXNEW="$EIXDIR/eix-new.txt"

# first: do we have an argument to search for?
if [ $# -eq 0 ]
then
        echo "usage: $0 [<grep-options>] <pattern>"
        exit 1
fi

# second: find out which database we want to search
EIXNAME=`basename $0`
case $EIXNAME in
eixall )
        EIXDB=$EIXALL
        ;;
eixinst )
        EIXDB=$EIXINST
        ;;
eixupdates )
        EIXDB=$EIXUPD
        ;;
eixnew )
        EIXDB=$EIXNEW
        ;;
* )
        echo "usage: $0 [<grep-options>] <pattern>"
        exit 1
        ;;
esac

# third: is the database in existence and readable?
if [ ! -r "$EIXDB" ]
then                    #no - run makeixall to make dbs
        sudo -E makeeixall
fi

# third: do the search
grep "$@" $EIXDB

exit $?
------------------------------------------------------------------------------

Once eixall is in place, symlink the script to the aliases.


-----------------------------------------------------------------------------
cd /usr/local/bin
ln -s eixall eixnew
ln -s eixall eixinst
ln -s eixall eixupdate
---------------------------------------------------------------------------


Typical usage would be:
  1.    emerge --sync
  2.    makeeixall
  3.    eixupdates . | less

and then do whatever to update your packages.


These scrips written by me are placed in the public domain, enjoy!

Gregory "Wolfe" Woodbury    14 Dec 2013
[email protected]

Reply via email to