This is a helper script for extracting the used pkg-bindings calls from y2log file and building a markdown document with links to the source code at GitHub.
Last active
November 28, 2024 09:51
-
-
Save lslezak/4d59c037afdf7dec3031ee1cff90b3a4 to your computer and use it in GitHub Desktop.
Find used pkg-bindings calls in y2log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /bin/bash | |
| # A helper script hich extracts used pkg-bindings calls from y2log files and | |
| # build a markdown list with links to the GitHub sources. | |
| # Usage: | |
| # 1. Copy the y2log files (/var/log/YaST2/y2log*) from an installation | |
| # 2. Run this script in the pkg-bindings Git checkout | |
| # (https://github.com/yast/yast-pkg-bindings/), pass the path to y2log | |
| # files as arguments: | |
| # | |
| # ./pkg-calls.sh <y2log> ... | |
| # | |
| # You can use a shell glob: | |
| # | |
| # ./pkg-calls.sh y2log* | |
| # | |
| # grep the y2log files for the pkg-bindings calls, read the calls into an array, | |
| # use zgrep so it can read also the compressed files (y2log-*.gz) | |
| mapfile -t CALLS < <( zgrep "Pkg Builtin called" "$@" | sed -e "s/^.* Pkg Builtin called: //" | sort -u ) | |
| for C in "${CALLS[@]}"; do | |
| # use the first found occurence | |
| URL=$(grep -r -n "PkgFunctions::$C\\b" . | sed -e "s/\\.cc:\\([0-9]\\+\\):.*/.cc#L\\1/" -e "s@^./@https://github.com/yast/yast-pkg-bindings/blob/master/@" | head -n 1) | |
| echo "[$C]($URL)" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This call supports a lot of filtering options. Let's see which ones are actually used during the installation