3 # Copyright 2011 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, version 3 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 if [ ! -e "/tmp/munin_portage/timestamp.chk" -o -n "`diff -N -q /tmp/munin_portage/timestamp.chk /usr/portage/metadata/timestamp.chk`" ]; then
20 mkdir -p /tmp/munin_portage/
22 if [ -e "/tmp/munin_portage/running.lock" ]; then
23 echo 'another instance is still running. rm "/tmp/munin_portage/running.lock"'>&2
26 echo "running since: `date`" > /tmp/munin_portage/running.lock
29 if [ -e "/tmp/munin_portage/ebuilds.txt" ]; then
30 mv /tmp/munin_portage/ebuilds.txt /var/lib/munin_portage_ebuilds.txt
32 if [ -e "/tmp/munin_portage/packages.txt" ]; then
33 mv /tmp/munin_portage/packages.txt /var/lib/munin_portage_packages.txt
36 find /usr/portage/ -mindepth 3 -maxdepth 3 -iname '*.ebuild' | grep -v "/usr/portage/distfiles" | grep -v "/usr/portage/metadata" | grep -v "/usr/portage/profiles" | sort > /tmp/munin_portage/ebuilds.txt
37 find /usr/portage/ -mindepth 2 -maxdepth 2 -type d | grep -v "/usr/portage/profiles/" | grep -v "/usr/portage/metadata/" | grep -v "/usr/portage/distfiles/" | grep -v "/usr/portage/eclass/" | sort > /tmp/munin_portage/packages.txt
39 if [ ! -e "/var/lib/munin_portage_ebuilds.txt" ]; then
40 cp /tmp/munin_portage/ebuilds.txt /var/lib/munin_portage_ebuilds.txt
42 if [ ! -e "/var/lib/munin_portage_packages.txt" ]; then
43 cp /tmp/munin_portage/packages.txt /var/lib/munin_portage_packages.txt
46 echo "packages.value `cat /tmp/munin_portage/packages.txt | wc -l`" > /tmp/munin_portage/packages.stat
47 echo "ebuilds.value `cat /tmp/munin_portage/ebuilds.txt | wc -l`" > /tmp/munin_portage/ebuilds.stat
48 echo "ebadded.value `diff -u0 /var/lib/munin_portage_ebuilds.txt /tmp/munin_portage/ebuilds.txt | grep -v @@ | grep '+/' | wc -l`" > /tmp/munin_portage/ebuilds_added.stat
49 echo "ebremoved.value `diff -u0 /var/lib/munin_portage_ebuilds.txt /tmp/munin_portage/ebuilds.txt | grep -v @@ | grep -e '-/' | wc -l`" > /tmp/munin_portage/ebuilds_removed.stat
50 echo "pkgadded.value `diff -u0 /var/lib/munin_portage_packages.txt /tmp/munin_portage/packages.txt | grep -v @@ | grep '+/' | wc -l`" > /tmp/munin_portage/packages_added.stat
51 echo "pkgremoved.value `diff -u0 /var/lib/munin_portage_packages.txt /tmp/munin_portage/packages.txt | grep -v @@ | grep -e '-/' | wc -l`" > /tmp/munin_portage/packages_removed.stat
53 emerge -qpuDN --package-moves=n --with-bdeps=y --color n @world | sed 's/^\[[^]]*\] //' > /tmp/munin_portage/updates.txt
54 echo "updates.extinfo `cat /tmp/munin_portage/updates.txt | awk '{ printf "%s ", $0 }'`" > /tmp/munin_portage/updates.list
55 echo "updates.value `cat /tmp/munin_portage/updates.txt | wc -l`" > /tmp/munin_portage/updates.stat
57 cp /usr/portage/metadata/timestamp.chk /tmp/munin_portage/timestamp.chk
58 rm /tmp/munin_portage/running.lock