Tim Mattson wrote:

Check in the "World" favorites file. It should be in /var/cache/db ...?


You can do a "locate world" and it'll give you a good indication of the file.



-----Original Message-----
From: Joshua Banks [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 7:24 AM
To: [EMAIL PROTECTED]
Subject: [gentoo-user] How to list all installed packages?



Whats the command to list all installed packages?


Thanks,
JBanks

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
[EMAIL PROTECTED] mailing list



--
[EMAIL PROTECTED] mailing list


This is not public yet but it's a script I've been working on for a few weeks.


save it to your HD, give it execute permissions and then type:
./tracker.sh -s -c
This will produce a CSV file in the same dir named tracker.output. Suck this into Excel and it will show you everything installed on your machine.


./tracker.sh -h will give you more info. If you are bored, read the code.

HTH,
=C=


-- * Cal Evans * http://www.eicc.com * We take care of your IT, * So you can take care of your business.
#!/bin/bash
#
# Name:
# tracker.sh
#
# Author:
# Cal Evans <[EMAIL PROTECTED]>
#
# Description :
# Client part of ebuild Tracker.
# Run it in a cron job every night or call it after every emerge. Either way it 
# gathers all the ebuilds installed on this machine and transmits them to the 
# server for processing.
#
# Copyright:
# (c) 2003 Cal Evans <[EMAIL PROTECTED]>
#
# License : 
# GPL 2.0
#
# Requirements :
# curl (net-ftp/curl)
# md5sum (sys-apps/textutils)
#
# Examples:
# ./tracker.sh -v -s
# Verbose Stand-alone mode
#
# ./tracker.sh -s -c
# Stand-alone mode, create the standard CSV  output file that can be imported 
# into a spreadsheet.
#
# ./tracker.sh -S billy.bobs.tracker.server.com 
# Gather the info and upload to billy.bobs.tracker.server.com 
#
# TODO:
# Need to pass in authentication information when updating the server.
# Capture machine profile
#
# NOTES:
#===============================================================================
# Version 1.0 : Thursday, July 24, 2003
# Initial Coding Began.
#
# Version 1.1 : Saturday, August 02, 2003
# Changed the way that ebuilds are gathered.
#
# Version 1.2 : Wednesday, September 03, 2003
# Copied the parser routine from masterTracker.sh.  It's much faster than the 
# original.
#
################################################################################
#
# DEFAULTS. If you don't want to pass information in on the command line then 
# set these to what you want them to be in the config file. DON'T CHANGE THESE!
#
DEFAULTTRACKERSERVER="192.168.0.122"
DEFAULTURL="/tracker.php"
DEFAULTPROTOCOL="http://";
DEFAULTOUTPUTFILE=./tracker.output
DEFAULTCONFIGFILE=/etc/ebuildTracker/ebuildTracker.conf
SOURCEDIR=/var/db/pkg/

#
# Init needed variables
#
TRACKERSERVER=""
URL=""
PROTOCOL=""
OUTPUTFILE=""
KERNEL=""
MACHINENAME=""
ACCOUNTID=""
MACHINEID=""
CHECKSUM=""
STANDALONEMODE=0
VERBOSEMODE=0
REGISTERMODE=0
CSVOUTPUTMODE=0

#
# If we have a config file, source it.
#
if [ -a $DEFAULTCONFIGFILE ]
then
        . $DEFAULTCONFIGFILE
fi

#
# Functions
#
print_usage() {
cat << EOT
tracker.sh - Client portion of the ebuildTracker system 
(c) 2003 Cal Evans ([EMAIL PROTECTED])
Released under GPL 2.0
(http://www.calevans.com/ebuildTracker)

./tracker.s [-h] [--help] 
            [-s] [--stand-alone]
            [-v] [--VERBOSEMODE]
            [[-S] [--server] SERVER]
            [[-c] [-csv-output] FILENAME]
            [[-r] [-register] ACCOUNTID]

EOT
}


print_help() {
        print_usage
cat <<EOT

  -h
  --help 
    This message
  -s
  --stand-alone
    Stand alone mode. Do not try to upload information to a server.
  -S
  --server SERVER IP or SERVER NAME
    If connecting to a tracker server you can specify the ip address or the name of 
the 
        server here. If not specified, it will connect to the default in the code.
  -v
  --VERBOSEMODE
    Display all the information gathered in a cryptic manner only discernable by 
    true geeks.   
  -c
  --csv-output FILENAME
    Write the information to a file name FILENAME in CSV format.

  -r
  --register ACCOUNTID
    Register server with a tracker server. This will collect some initial information 
        about the server and hand back a hash to identify the machine for future 
        connections. If available. The hash will be stored in 
        /etc/ebtracker/ebtracker.conf. You must supply an account id when you 
        register a server. 
  
Examples:

  ./tracker.sh -v -s
  VERBOSEMODE Stand-alone mode

  ./tracker.sh -s -c
  Stand-alone mode, create the standard CSV  output file

  ./tracker.sh -S billy.bobs.tracker.server.com 
  Upload the data to billy.bobs.tracker.server.com 
   
EOT
exit 0
}


verify_dep() {

        needed="curl mktemp cat rm awk ebuild md5sum hostname"
        for i in `echo $needed`
        do
                type $i > /dev/null 2>&1 /dev/null
                if [ $? -eq 1 ]
                then
                        echo "I am missing an important component : $i"
                        echo "Cannot continue, sorry, try to find the missing one..."
                        exit 3
                fi
        done
}


#
# Process Command line parameters
#
while test $# -gt 0
do
        
        case "$1" in
                -h|--help)
                                        print_help
                                        exit 0
                                        ;;
                -s|--stand-alone)
                                        STANDALONEMODE=1
                                        ;;
                -S|--server)
                                        if [ -n "$SERVER" ]
                                        then
                                                echo "Only one tracker server can be 
specified."
                                                echo ""
                                                print_help
                                                exit 3
                                        fi
                                        # Need some checking here to make sure this is 
not a parameter.
                                        shift
                                        TRACKERSERVER=$1
                                        ;;                
                                -v|--VERBOSEMODE)
                                        VERBOSEMODE=1
                                        ;;
                                -r|--register)
                                        if [ $STANDALONEMODE -eq 1 ]
                                        then
                                                Echo "Standalone mode ignored for 
registering."
                                                STANDALONEMODE=0;
                                        fi
                                        if [ $CSVOUTPUTMODE -eq 1 ]
                                        then
                                                Echo "CSV Output mode ignored for 
registering."
                                                CSVOUTPUTMODE=0;
                                        fi
                                        if [ -n "$ACCOUNTID" ]
                                        then
                                                echo "Only one account id can be 
specified."
                                                echo ""
                                                print_help
                                                exit 3
                                        fi
                                        REGISTERMODE=1
                                        # Need some checking here to make sure this is 
not a parameter.
                                        shift
                                        ACCOUNTID=$1
                                        ;;
                                -c|--csv-output)
                                        if [ -n "$OUTPUTFILE" ]
                                        then
                                                echo "Only one output file can be 
specified."
                                                echo ""
                                                print_help
                                                exit 3
                                        fi
                                        CSVOUTPUTMODE=1
                                        # Need some checking here to make sure this is 
not a parameter.
                                        shift
                                        OUTPUTFILE=$1
                                        ;;
        esac
        shift
done


#
# Set some defaults
#
if [ -z $TRACKERSERVER ] 
then 
        TRACKERSERVER=$DEFAULTTRACKERSERVER 
fi
if [ -z $URL ] 
then 
        URL=$DEFAULTURL 
fi
if [ -z $PROTOCOL ] 
then 
        PROTOCOL=$DEFAULTPROTOCOL 
fi
if [ $CSVOUTPUTMODE -eq 1 ] 
then 
        if [ -z $OUTPUTFILE ] 
        then
                OUTPUTFILE=$DEFAULTOUTPUTFILE
        fi
fi

#
# Check to make sure we have all of the necessary commands.
#
verify_dep


#
# We need a couple of temp files
#
TMPFILE=$(mktemp /tmp/tracker.XXXXXX)
OUTFILE=$(mktemp /tmp/tracker.XXXXXX)


#
# Make sure we cleanup any messes.
#
trap 'rm $TMPFILE $OUTFILE; exit' 0 1 2 3 15


#
# Gather Server wide info
#
KERNEL=$(uname -a | gawk '{print $3}')


#
# Register Mode Processing
#
if [ $REGISTERMODE -eq 1 ]
then
        MACHINENAME=$(hostname)
        if [ -a $DEFAULTCONFIGFILE ]
        then
                # I confess my ignorance. I do not know how to test for a file NOT 
                # existing.
                # I tried [ ! -a $DEFAULTCONFIGFILE ] and it did not work.
                # Help here would be appreciated.
                # This line exists because the else won't fire unless there is 
SOMETHING
                # between the then and the else. This is my version of a NOOP.
                echo > /dev/null
        else
                `mkdir -p $(dirname $DEFAULTCONFIGFILE)`
                `touch $DEFAULTCONFIGFILE`
        fi
        if [  $(grep MACHINENAME $DEFAULTCONFIGFILE|wc -l) -eq 0 ]
        then
                echo MACHINENAME=$MACHINENAME >> $DEFAULTCONFIGFILE
        fi
        if [  $(grep MACHINEID $DEFAULTCONFIGFILE|wc -l) -eq 1 ]
        then
                echo "This machine already has a machine id."
                exit 3
        fi
        MACHINEID=$(curl -s -F register=yes -F accountid=$ACCOUNTID -F 
machinename=$MACHINENAME $PROTOCOL$TRACKERSERVER$DEFAULTURL)
        if [ $? -gt 0 ]
        then
                echo "Curl reported an error connecting to the server."
                exit 3
        fi
        if [ $(echo $MACHINEID | grep ERROR | wc -l) -eq 1 ]
        then
                echo "ERROR MESSGE FROM $TRACKERSERVER"
                echo $MACHINEID
                exit 3
        fi

        if [ ${#MACHINEID} -lt 1 ]
        then
                echo "You did not receive a valid response from the tracker server. 
Please try again."
                exit 3
        else
                echo MACHINEID=$MACHINEID >> $DEFAULTCONFIGFILE
                echo ACCOUNTID=$ACCOUNTID >> $DEFAULTCONFIGFILE
        fi
        exit 0
fi


#
# Output the machine info.
#
echo "machine,$MACHINENAME,$KERNEL" >> $OUTFILE


#
# Gather all the packages in both SYSTEM and WORLD.  
# To the best of my knowledge this is a complete list of everything installed 
# on the system.
#
if [ $VERBOSEMODE -eq 1 ]
then
        echo "Gathering ebuilds."
fi
for item in $(find $SOURCEDIR -iname "*.ebuild"); do HOLDING=${item#$SOURCEDIR}&& echo 
${HOLDING%/*} >> $TMPFILE ;done 

# Now process the list.
if [ $VERBOSEMODE -eq 1 ]
then
        echo "Procesing the lists."
fi


#
# Currently ALL categories have a - in them and all other directories in 
# portage don't. This filters out skel, eclass, distfiles, etc.
#
for ITEM in $(find $SOURCEDIR -iname "*.ebuild" | grep '-')
do 
        ITEM=${ITEM#$SOURCEDIR}
        CATEGORY=${ITEM##/}
        CATEGORY=${CATEGORY%%/*}
        PACKAGE=${ITEM##*/}
        PACKAGE=${PACKAGE%.ebuild}
        PKGLENGTH=${#PACKAGE}
        VERSION=${PACKAGE##*-}
        REVISION=${VERSION##*-r}
        
        if [ ${REVISION:0:1} = 'r' ]
        then
                REVISION=${REVISION##*r}        
                PACKAGE=${PACKAGE%-$VERSION}    
                VERSION=${PACKAGE##*-}
        else
                REVISION=""     
        fi

        PACKAGE=${PACKAGE%-$VERSION}    

        if [ $VERBOSEMODE -eq 1 ]
        then
                echo "ORIGINAL = " $ITEM
                echo "CATEGORY = " $CATEGORY
                echo "PACKAGE  = " $PACKAGE
                echo "VERSION  = " $VERSION
                if [ -n $REVISION ]
                then
                        echo "REVISION = " $REVISION
                fi
                echo
        fi
        #
        # Final output
        #       
        echo "ebuild,$CATEGORY,$PACKAGE,$VERSION,$REVISION" >> $OUTFILE
done

#
# If a csv output has been requested then create it.
#
if [ $CSVOUTPUTMODE -eq 1 ]
then
        cp $OUTFILE $OUTPUTFILE 
fi


#
# If not in STANDALONEMODE mode, then post the entire thing with curl.
#
if [ $STANDALONEMODE -eq 0 ]
then
        if [ $VERBOSEMODE -eq 1 ]
        then
                echo "Contacting $TRACKERSERVER to upload results."
        fi
        CHECKSUM=$(md5sum < $OUTFILE)
        RESULTS=`$(curl -s -F [EMAIL PROTECTED] -F accountid=$ACCOUNTID -F 
machineid=$MACHINEID -F checksum="$CHECKSUM" $PROTOCOL$TRACKERSERVER$URL)`

        if [ $VERBOSEMODE -eq 1 ]
        then
                echo "Results:"
                echo $RESULTS
        fi
        if [ $? -gt 0 ]
        then
                echo "curl reported an error connecting to the server."
                exit 3
        fi
fi


#
# Final cleanup
#
exit 0

--
[EMAIL PROTECTED] mailing list

Reply via email to