summaryrefslogtreecommitdiff
path: root/pcr/pactools/pt-pacman-info
blob: c2c82f2194de751253c25d00ebffaebbcfc1740f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
# pacman-info
# /usr/bin/pacman-info
# GPL v2
# neonskull [at] gmail.com

VERSION="0.1"
AUTHOR="Pável Varela Rodríguez [aka NeOnsKuLL]"

usage()
{
echo "pacman-info v$VERSION"
echo "usage: `basename $0` [OPTION]

OPTIONS:
  -cr|--configured-repos   List the names of configured repos in your
            pacman.conf

   -a|--all         Calculates the total number of available
            packages in your repos

  -br|--by-repo         Calculates the total number of available
            packages in each repo

   -i|--installed      Calculates the number of installed packages

   -f|--full         Generates a full Report

   -h|--help         Show this message

   -v|--version         Show version
"
}

[ "$#" -lt 1 ] && PARAM="-h";
[ "$#" -gt 1 ] && PARAM="*";
[ "$#" -eq 1 ] && PARAM="$1";

case $PARAM in
   "-a"|"--all")
      echo -e "Repositories information (total of packages in repos): `pacman -Sl|wc -l`"
   ;;
   "-cr"|"--configured-repos")
      echo "Repositories information (name of configured repos):"
      pacman -Sl|awk '{print $1}'|cut -d"/" -f 2|uniq -c|awk '{print "* " $2}'
   ;;
   "-br"|"--by-repo")
      echo "Repositories information (number of packages by repo):"
      pacman -Sl|awk '{print $1}'|cut -d"/" -f 2|uniq -c|awk '{print ":: "$2 "\t-> " $1 "\tpkgs"}'
   ;;
   "-i"|"--installed")
      echo -e "System information (total of installed packages): `pacman -Q|wc -l`"
   ;;
   "-f"|"--full")
      echo -e "Full Report about Repositories and Packages for Archlinux"
      echo -e "Node name: `uname -n`\n"
      $0 -cr
      echo
      $0 -a
      echo
      $0 -br
      echo
      $0 -i
      echo
      echo -e "Generated using `$0 -v` by $AUTHOR"
   ;;
   "-h"|"--help")
      usage
   ;;
   "-v"|"--version")
      echo "`basename $0` v$VERSION"
   ;;
   *)
      echo "Error! Unknown parameter."
      usage
   ;;
esac