wok-undigest diff linux/stuff/devtools/check-split.sh @ rev 1257

recook binutils
author Hans-Günter Theisgen
date Sat Aug 13 10:55:58 2022 +0100 (2022-08-13)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linux/stuff/devtools/check-split.sh	Sat Aug 13 10:55:58 2022 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +#!/bin/sh
     1.5 +# check-split.sh: check split quality for the Linux modules
     1.6 +# Make the three-column Markdown-friendly table representing all the modules.
     1.7 +# Column #1: module path/name.ko.xz
     1.8 +# Column #2: package(s), which owns module
     1.9 +# Column $3: module description (if any)
    1.10 +
    1.11 +. /lib/libtaz.sh
    1.12 +WOK='/home/slitaz/wok'
    1.13 +tmp="$WOK/linux/tmp"; mkdir -p $tmp
    1.14 +out="$tmp/modules.split"
    1.15 +. $WOK/linux/receipt
    1.16 +
    1.17 +# List of all the modules
    1.18 +order="$WOK/linux/install/lib/modules/$VERSION-slitaz/modules.order"
    1.19 +maxlen=$(wc -L $order | cut -d' ' -f1)
    1.20 +maxlen1=$(( maxlen - 7 + 2 )) # leading "kernel/" will be removed (-7), "`...`" will be added (+2)
    1.21 +hline=$(printf "%${maxlen1}s" '' | tr -c '\n' '-')
    1.22 +
    1.23 +# First column: module name with local path
    1.24 +sort $order | awk -vhline=$hline '
    1.25 +BEGIN {
    1.26 +	printf("%-'$(( maxlen1 + 3))'s | \n", "Module path/name.ko.xz");
    1.27 +	printf("%s----|-\n", hline);
    1.28 +}
    1.29 +{
    1.30 +	sub("kernel/", "");
    1.31 +	gsub("/", "@");       # change "/" to "@" to easy use sed in the next step
    1.32 +	printf("%-'$maxlen1's | \n", "`" $0 "`");
    1.33 +}' > $out
    1.34 +
    1.35 +
    1.36 +# Second column: package name(s) for the module
    1.37 +for i in linux $SPLIT; do
    1.38 +	action "Processing $i..."
    1.39 +	while read f; do
    1.40 +		case $f in
    1.41 +			*.ko.xz)
    1.42 +				fshort=${f#*/kernel/}
    1.43 +				fshort=$(echo $fshort | sed 's|/|@|g')
    1.44 +				fshort=${fshort%.xz}
    1.45 +				sed -i "/$fshort/ s|$|$i |" $out
    1.46 +				;;
    1.47 +		esac
    1.48 +	done < "$WOK/$i/taz/$i-$VERSION/files.list"
    1.49 +	status
    1.50 +done
    1.51 +
    1.52 +
    1.53 +maxlen2=$(wc -L $out | cut -d' ' -f1)
    1.54 +hline=$(printf "%$(( maxlen2 - maxlen1 - 3 ))s" '' | tr -c '\n' '-')
    1.55 +mv $out $out.tmp
    1.56 +awk -vhline=$hline '{
    1.57 +	if (NR==1)
    1.58 +		printf("%-'$(( maxlen2 + 3 ))'s |\n", $0 "Package(s)");
    1.59 +	else if (NR==2)
    1.60 +		printf("%s-|\n", $0 hline);
    1.61 +	else
    1.62 +		printf("%-'$maxlen2's |\n", $0);
    1.63 +}' $out.tmp > $out
    1.64 +rm $out.tmp
    1.65 +
    1.66 +
    1.67 +tr '@' '/' < "$out" > "$out.tmp"; mv "$out.tmp" "$out"
    1.68 +sed -i 's|\.ko` |.ko.xz` |' "$out"
    1.69 +
    1.70 +
    1.71 +# Third column: descriptions
    1.72 +action "Getting descriptions..."
    1.73 +IFS=$'\n'
    1.74 +while read i; do
    1.75 +	echo -n "$i"
    1.76 +	module=${i%\`*}; module=${module#\`}
    1.77 +	if [ -f "$WOK/linux/install/lib/modules/$VERSION-slitaz/kernel/$module" ]; then
    1.78 +		info=$(modinfo -d $WOK/linux/install/lib/modules/$VERSION-slitaz/kernel/$module | tr '\n' ' ' | sed 's| $||')
    1.79 +		[ -n "$info" ] && info=" $info"
    1.80 +		echo "$info"
    1.81 +	else
    1.82 +		echo
    1.83 +	fi
    1.84 +done < "$out" > "$out.tmp"
    1.85 +unset IFS
    1.86 +
    1.87 +awk '{
    1.88 +	if (NR==1)
    1.89 +		printf("%s\n", $0 " Description");
    1.90 +	else if (NR==2)
    1.91 +		printf("%s\n", $0 "------------");
    1.92 +	else
    1.93 +		print;
    1.94 +}' "$out.tmp" > "$out"
    1.95 +rm "$out.tmp"
    1.96 +status
    1.97 +footer "File: $out"