| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. -u |
| 2 | |
| 3 | # Copyright (c) 2020 Yubico AB. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style |
| 5 | # license that can be found in the LICENSE file. |
| 6 | # SPDX-License-Identifier: BSD-2-Clause |
| 7 | |
| 8 | sort_by_idscip-shell shell shell-project 0.0.0 sort_by_id().() { |
| 9 | awkscip-shell system . . awk. '{ printf "%d\n", $3 }' | sortscip-shell system . . sort. -Cnu |
| 10 | } |
| 11 | |
| 12 | if ! grepscip-shell system . . grep. '^vendor' "$1" | sort_by_idscip-shell shell shell-project 0.0.0 sort_by_id().; then |
| 13 | echoscip-shell system . . echo. unsorted vendor section 1>&2 |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | VENDORS=$(grepscip-shell system . . grep. '^vendor' "$1" | awkscip-shell system . . awk. '{ print $2 }') |
| 18 | PRODUCTS=$(grepscip-shell system . . grep. '^product' "$1" | awkscip-shell system . . awk. '{ print $2 }' | uniqscip-shell system . . uniq.) |
| 19 | |
| 20 | if [scip-shell system . . `[`. "${VENDORS}" != "${PRODUCTS}" ]; then |
| 21 | echoscip-shell system . . echo. vendors: "$(echoscip-shell system . . echo. "${VENDORS}" | trscip-shell system . . tr. '\n' ',')" 1>&2 |
| 22 | echoscip-shell system . . echo. products: "$(echoscip-shell system . . echo. "${PRODUCTS}" | trscip-shell system . . tr. '\n' ',')" 1>&2 |
| 23 | echoscip-shell system . . echo. vendors and products in different order 1>&2 |
| 24 | exit 2 |
| 25 | fi |
| 26 | |
| 27 | for v in ${VENDORS}; do |
| 28 | if ! grepscip-shell system . . grep. "^product ${v}" "$1" | sort_by_idscip-shell shell shell-project 0.0.0 sort_by_id().; then |
| 29 | echoscip-shell system . . echo. "${v}": unsorted product section 1>&2 |
| 30 | exit 3 |
| 31 | fi |
| 32 | done |