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
|
#! /bin/sh -e
# count-pkgs
#
# This shell script counts the packages in a Packages file, and also
# tells how many of these have been ramified (that is, how many of them
# include a Ramification field). In reality, all it does is to count
# Package and Ramification lines. If a package control included
# multiple Package or Ramification lines, the script wouldn't even
# notice.
#
# Usage:
#
# count-pkgs { Packages }
#
# If no Packages file is specified, the script looks for one
# named "Packages" in the current directory.
#
# THE RAMIFICATION CONTROL FIELD
#
# A standard Debian control header includes no ramification information.
# In debram development, however, a nonstandard "Ramification:" field is
# often added to each package control paragraph in the developer's local
# working copy of the Packages file. Usually the "Ramification:" line
# is added at the paragraph's head, above even the "Package:" line. For
# example,
#
# Ramification: 8214 DEBTAGS
# Package: debram
# Priority: extra
# Section: admin
# ...
#
# The ram title ("DEBTAGS" in the example) after the four-digit number
# is for the developer's convenience only and is entirely optional. It
# need not be correct. It need not be present at all. The helper
# scripts ignore it. Because the helper/new-debram-body script
# automatically corrects and adds titles as needed, normally the
# developer does not even bother to type them; he types only
#
# Ramification: 8214
#
# (and of course he uses some convenient editor macro like
# vim(1)'s ":imap <F1>" to enter the "Ramification: " part of the line,
# so in truth he does not manually type very much: only the four
# digits).
#
# Note that there is really no such thing as a "Ramification:" control
# field. It is a fiction, existing in the developer's local development
# directory only, as a convenience in development. No debram user ever
# sees the fictional "Ramification:" control field.
#
# BUGS
#
# A better, faster, more efficient, more robust script could surely be
# written, but there is no plan to write one, unless a development need
# thereto arose. This is after all only a development helper.
#
#
F0=Packages
if [[ $# > 0 ]]; then F=$1 ; else F=$F0 ; fi
echo -n "ramified pkgs: "
sed $F -ne '/^Ramification:/p' | wc -l
echo -n "total pkgs: "
sed $F -ne '/^Package:/p' | wc -l
|