Gentoo Archives: gentoo-user

From: Greg Woodbury <redwolfe@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] A quick and easy set of eix extension scripts for you holiday present.
Date: Sat, 14 Dec 2013 23:13:52
Message-Id: 52ACE61D.10807@gmail.com
1 I have found some of the tools of portage a little opaque and confusing.
2 Once
3 I found eix, I put together a little set of shell scripts to make lists
4 of the
5 packages in portage.
6
7 The script 'makeeixall' goes through and does an eix update and then
8 generates
9 a set of lists of packages: all, installed, new (not installed) and updates.
10
11 The script 'eixall' and its aliases 'eixupdate' 'eixnew' and 'eixinst' grep
12 the associated lists and print matches to the standard out.
13
14 You will need to make the '/usr/local/tmp' directory or point EIXDIR to
15 some other location.
16 ------------------------------------------------------------------------------
17 #!/bin/bash
18
19 # script to create a database of packages for quick reference
20 # 27 June 2013 version to make system-wide db
21 # 05 Aug 2013 add "downgrades" to the eixupdate listing
22
23 EIXDIR="/usr/local/tmp"
24 EIXALL="$EIXDIR/eix-all.txt"
25 EIXINST="$EIXDIR/eix-installed.txt"
26 EIXUPD="$EIXDIR/eix-updates.txt"
27 EIXNEW="$EIXDIR/eix-new.txt"
28
29 # first: get rid of the old db
30 rm $EIXALL
31
32 # second: have EIX update its binary db
33 eix-update
34
35 # third: run through the categories and build the eix-all text file
36 echo -n "Prepping files: all..."
37 cd /usr/portage
38 cat profiles/categories | while read dname
39 do
40 eix --care -c -x -C $dname
41 done >>$EIXALL
42
43 # fourth: make some utility text databases
44 # the installed packages
45 echo -n "install..."
46 grep -F '[I]' $EIXALL >$EIXINST
47
48 # the upgradeable packages
49 # be careful to append the "downgrades"
50 echo -n "updates..."
51 grep -F '[U]' $EIXALL >$EIXUPD
52 grep -F '[D]' $EIXALL >>$EIXUPD
53 grep -F '[UD]' $EIXALL >>$EIXUPD
54
55 # these files are also "installed", append to inst file
56 cat $EIXUPD >>$EIXINST
57
58 # the "new" uninstalled packages
59 echo "not-installed (new)"
60 grep -F '[N]' $EIXALL >$EIXNEW
61
62 # fifth: make the text file readable by anyone
63 chmod 0444 /usr/local/tmp/eix*.txt
64
65 exit 0
66 -------------------------------------------------------------------------------
67
68
69 The script 'eixall' is for searching the outputs of 'makeeixall'
70
71
72 --------------------------------------------------------------------------------
73 #!/bin/bash
74
75 # script to search a database of packages for quick reference (see
76 makeeixall)
77 # 27 June 2013 version 1: to use system-wide db
78
79 EIXDIR="/usr/local/tmp"
80 EIXALL="$EIXDIR/eix-all.txt"
81 EIXINST="$EIXDIR/eix-installed.txt"
82 EIXUPD="$EIXDIR/eix-updates.txt"
83 EIXNEW="$EIXDIR/eix-new.txt"
84
85 # first: do we have an argument to search for?
86 if [ $# -eq 0 ]
87 then
88 echo "usage: $0 [<grep-options>] <pattern>"
89 exit 1
90 fi
91
92 # second: find out which database we want to search
93 EIXNAME=`basename $0`
94 case $EIXNAME in
95 eixall )
96 EIXDB=$EIXALL
97 ;;
98 eixinst )
99 EIXDB=$EIXINST
100 ;;
101 eixupdates )
102 EIXDB=$EIXUPD
103 ;;
104 eixnew )
105 EIXDB=$EIXNEW
106 ;;
107 * )
108 echo "usage: $0 [<grep-options>] <pattern>"
109 exit 1
110 ;;
111 esac
112
113 # third: is the database in existence and readable?
114 if [ ! -r "$EIXDB" ]
115 then #no - run makeixall to make dbs
116 sudo -E makeeixall
117 fi
118
119 # third: do the search
120 grep "$@" $EIXDB
121
122 exit $?
123 ------------------------------------------------------------------------------
124
125 Once eixall is in place, symlink the script to the aliases.
126
127
128 -----------------------------------------------------------------------------
129 cd /usr/local/bin
130 ln -s eixall eixnew
131 ln -s eixall eixinst
132 ln -s eixall eixupdate
133 ---------------------------------------------------------------------------
134
135
136 Typical usage would be:
137 1. emerge --sync
138 2. makeeixall
139 3. eixupdates . | less
140
141 and then do whatever to update your packages.
142
143
144 These scrips written by me are placed in the public domain, enjoy!
145
146 Gregory "Wolfe" Woodbury 14 Dec 2013
147 redwolfe@×××××.com

Replies

Subject Author
[gentoo-user] Re: A quick and easy set of eix extension scripts for you holiday present. James <wireless@×××××××××××.com>