File: count-release.sh

package info (click to toggle)
debian-faq 13.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,540 kB
  • sloc: makefile: 176; perl: 116; sh: 58
file content (91 lines) | stat: -rw-r--r-- 3,141 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# Script to extract the package count information for a given Release
#
# (c) 2007, 2013  Javier Fernández-Sanguino <jfs@debian.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# For more information please see
#  http://www.gnu.org/licenses/licenses.html#GPL


usage () {
	echo "$0 [mirror-directory] [architecture] [release]"
	echo "Prints the Debian package count for a given architecture in a given release."
	echo "Defaults to using the i386 architecture in the current published release."
	echo "The release is determined by processing the faqstatic.ent file"
}

if [ -n "$1" ] ; then
	mirror=$1
else
	mirror="/home/ftp/mirror/debian/"
fi
if [ -n "$2" ] ; then
	ARCH=$2 
else
	ARCH="i386"
fi
[ -n "$3" ] && RELEASE=$3 

if [ ! -e "$mirror" ] ; then 
	echo "ERROR: Cannot find the mirror directory $mirror. Aborting." >&2
	exit 1
fi

# Try to extract the release from the faqstatic.ent file
if [ -z "$RELEASE" ] && [ -r faqstatic.ent ] ; then
	RELEASE=`grep "entity releasename" faqstatic.ent  | sed -e 's/^.*"\(.*\)".*$/\1/'`
fi
if [ -z "$RELEASE" ] ; then
	RELEASE="jessie"
	echo "WARN: Cannot obtain the release information from 'faqstatic.ent', using $RELEASE instead." >&2
fi


mainP="$mirror/dists/$RELEASE/main/binary-$ARCH/Packages.gz"
contribP="$mirror/dists/$RELEASE/contrib/binary-$ARCH/Packages.gz"
nonfreeP="$mirror/dists/$RELEASE/non-free/binary-$ARCH/Packages.gz"

if [ -e "$mainP" ] ; then
	main=`gzip -d -c $mainP | grep-dctrl -s Package -F section -r ".*" - |wc -l`
else
	echo "ERROR: Cannot find the packages file to extract the information on main: '$mainP'" >&2
	main="UNKNOWN"
fi
if [ -e "$nonfreeP" ] ; then
	nonfree=`gzip -d -c $nonfreeP | grep-dctrl -s Package -F section -r "non-free/.*" - |wc -l`
else
	echo "ERROR: Cannot find the packages file to extract the information on non-free: '$nonfreeP'" >&2
	nonfree="UNKNOWN"
fi
if [ -e "$contribP" ] ; then
	contrib=`gzip -d -c $contribP | grep-dctrl -s Package -F section -r "contrib/.*" - |wc -l`
else
	echo "ERROR: Cannot find the packages file to extract the information on non-free: '$contribP'" >&2
	contrib="UNKNOWN"
fi
       
echo "Total package count for $RELEASE"
echo "Main packages:           $main"
echo "Non-free packages:       $nonfree"
echo "Contrib packages:        $contrib"
contribnonfree=$(($nonfree+$contrib))
total=$(($main+$contrib))
echo "Non-freee + Contrib:     $contribnonfree"
echo "Total packages:          $total"

exit 0