diff options
Diffstat (limited to 'helper.sh')
-rwxr-xr-x | helper.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/helper.sh b/helper.sh new file mode 100755 index 0000000..6d0f12e --- /dev/null +++ b/helper.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +## SPDX-License-Identifier: CC0-1.0 +## +## Copyright (C) 2025 Woj. Kosior <koszko@koszko.org> + +set -e + +DESCRIPTION_SED_SCRIPT=' +s/TREE$/Vanilla dependency tree/; +s/TREE-MIN/Unnecessary direct dependencies removed/; +s/TREE-DUMMY/Unnecessary dependencies dummified/; +s/TREE-FLAT/Conflicts removed where possible/; +' + +if [ "$1" = "--get-measure-types" ]; then + printf %s "VERS DEPS MULTIVER" +elif [ "$1" = "--get-tree-kinds" ]; then + printf %s "$DESCRIPTION_SED_SCRIPT" | awk -F '[/$]' '{print $2}' +elif [ "$1" = "--make-tree-kind-description" ]; then + sed "$DESCRIPTION_SED_SCRIPT" +elif [ "$1" = "--get-csv-columns" ]; then + shift + + RESULTS_PATH="$1" + + shift + + COL_REFS="" + + SEP="" + + while [ -n "$1" ]; do + HEAD_PART="$(head -1 "$RESULTS_PATH" | grep -Eo "^(.+,)?$1(,|\$)")" + + COL_NUM=$(($(printf %s "$HEAD_PART" | grep -oE ',.' | wc -l) + 1)) + + COL_REFS="$COL_REFS$SEP \$$COL_NUM" + + shift + + SEP=' ","' + done + + awk -F , "{print$COL_REFS;}" < "$RESULTS_PATH" +else + exit 1 +fi |