aboutsummaryrefslogtreecommitdiff
path: root/compute-unflattened-multiver-counts.sh
blob: 03b253a2240ee0a50bcc43b5ddbff3368814541f (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
#!/bin/sh

## SPDX-License-Identifier: CC0-1.0
##
## Copyright (C) 2025 Woj. Kosior <koszko@koszko.org>

set -e

TREE_SIZES_PATH="$1"

if [ "$2" = "--omit-packages-with-breaking-changes" ]; then
    BAD_ROW_REG=',1$'
else
    BAD_ROW_REG=',$' # never matched
fi

printf 'MULTIVER-COUNT,'
printf 'ALL-PACKAGES,IN-DEBIAN-PACKAGES,'
printf 'ALL-PACKAGES-NO-BC,IN-DEBIAN-PACKAGES-NO-BC\n'

./helper.sh --get-csv-columns "$TREE_SIZES_PATH" \
            IN-DEBIAN TREE-FLAT-MULTIVER BREAKING-CHANGES |
    grep -vE "$BAD_ROW_REG" | awk -F , '
        /^[0-9]/ {
            counts[$2]++;
            if ($1 > 0) {
                debian_counts[$2]++;
            }
        }
        END {
            for (key in counts) {
                printf "%d,%d,%d\n", key, counts[key], debian_counts[key];
            }
        }
    '