| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. -e |
| 2 | |
| 3 | # count-pkgs |
| 4 | # |
| 5 | # This shell script counts the packages in a Packages file, and also |
| 6 | # tells how many of these have been ramified (that is, how many of them |
| 7 | # include a Ramification field). In reality, all it does is to count |
| 8 | # Package and Ramification lines. If a package control included |
| 9 | # multiple Package or Ramification lines, the script wouldn't even |
| 10 | # notice. |
| 11 | # |
| 12 | # Usage: |
| 13 | # |
| 14 | # count-pkgs { Packages } |
| 15 | # |
| 16 | # If no Packages file is specified, the script looks for one |
| 17 | # named "Packages" in the current directory. |
| 18 | # |
| 19 | # THE RAMIFICATION CONTROL FIELD |
| 20 | # |
| 21 | # A standard Debian control header includes no ramification information. |
| 22 | # In debram development, however, a nonstandard "Ramification:" field is |
| 23 | # often added to each package control paragraph in the developer's local |
| 24 | # working copy of the Packages file. Usually the "Ramification:" line |
| 25 | # is added at the paragraph's head, above even the "Package:" line. For |
| 26 | # example, |
| 27 | # |
| 28 | # Ramification: 8214 DEBTAGS |
| 29 | # Package: debram |
| 30 | # Priority: extra |
| 31 | # Section: admin |
| 32 | # ... |
| 33 | # |
| 34 | # The ram title ("DEBTAGS" in the example) after the four-digit number |
| 35 | # is for the developer's convenience only and is entirely optional. It |
| 36 | # need not be correct. It need not be present at all. The helper |
| 37 | # scripts ignore it. Because the helper/new-debram-body script |
| 38 | # automatically corrects and adds titles as needed, normally the |
| 39 | # developer does not even bother to type them; he types only |
| 40 | # |
| 41 | # Ramification: 8214 |
| 42 | # |
| 43 | # (and of course he uses some convenient editor macro like |
| 44 | # vim(1)'s ":imap <F1>" to enter the "Ramification: " part of the line, |
| 45 | # so in truth he does not manually type very much: only the four |
| 46 | # digits). |
| 47 | # |
| 48 | # Note that there is really no such thing as a "Ramification:" control |
| 49 | # field. It is a fiction, existing in the developer's local development |
| 50 | # directory only, as a convenience in development. No debram user ever |
| 51 | # sees the fictional "Ramification:" control field. |
| 52 | # |
| 53 | # BUGS |
| 54 | # |
| 55 | # A better, faster, more efficient, more robust script could surely be |
| 56 | # written, but there is no plan to write one, unless a development need |
| 57 | # thereto arose. This is after all only a development helper. |
| 58 | # |
| 59 | # |
| 60 | |
| 61 | F0=Packages |
| 62 | if [[ $# > 0 ]]; then F=$1 ; else F=$F0 ; fi |
| 63 | echoscip-shell system . . echo. -n "ramified pkgs: " |
| 64 | sedscip-shell system . . sed. $F -ne '/^Ramification:/pscip-shell filesystem . . `/^Ramification:/p`.' | wcscip-shell system . . wc. -l |
| 65 | echoscip-shell system . . echo. -n "total pkgs: " |
| 66 | sedscip-shell system . . sed. $F -ne '/^Package:/pscip-shell filesystem . . `/^Package:/p`.' | wcscip-shell system . . wc. -l |
| 67 |