Andrew D Kirch wrote:

> Here's the script that I used to generate this.
Just some bash hints. In a nutshell: please don't use ls in scripts.
> I have not manually 
> reviewed all of thousands of patches to determine the unique situation
> of each patch, however I would like a suggestion on how to demonstrate
> _real_ statistics short of auditing each and every patch in portage
> which I personally don't have time to do.
I think it's a great idea, and the other reply from robbat gives you a great
spec to start from in terms of classification.

> for I in `ls`; do
for f in *; do

Globs have a lot to recommend them: see http://wooledge.org:8000/glob
>     PATCH=`ls -R ${I} | grep patch | wc -l`
>     DIFF=`ls -R ${I} | grep diff | wc -l`
>     COUNT=$(( ${PATCH} + ${DIFF} ))
    while read -rd ''; do let count++
    done < <(find "$dir" \( -name '*.diff' -o -name '*.patch' \) -print0)

..in the general case, where you actually need a recursive descend. (We
don't here.)
>         if ! [ ${COUNT} == 0 ]
>         then
>                 echo $I $COUNT
>         fi
    ((count)) && { echo "$dir : $count" }

See http://bash-hackers.org/wiki/doku.php?id=syntax:words for an explanation
of why the quotes make a difference.

Putting it together you end up with this:

#!/bin/bash
# ./countPatchFiles > patchCount
# sed -nr '/^Category: (.*): (.*)/s//\1\2/p' patchCount |sort -n -k 2
PORTDIR=$(portageq envvar PORTDIR)
declare -i count tot=0 cTot
shopt -s nullglob
for d in "$PORTDIR"/*/; do
  c=${d#"$PORTDIR/"}; c=${c%/}
  [[ $c = *-* ]] || continue
  cTot=0
  echo "$c" >&2
  for p in "$d"*/; do
    files=("$p"files/*.patch "$p"files/*.diff)
    [EMAIL PROTECTED]
    ((count)) || continue
    p=${p#"$d"}; echo "$c/${p%/} : $count"
    ((tot+=count,cTot+=count))
  done
  echo "Category: $c : $cTot"
done
echo "Total: $tot"

-- HTH,
igli.
(The files are in that array, if their names should be needed.)



Reply via email to