wok-undigest view linux/stuff/devtools/check-split.sh @ rev 1217

copied linux receipt and stuff from wok-next
author Hans-G?nter Theisgen
date Fri Nov 15 16:49:43 2019 +0100 (2019-11-15)
parents
children
line source
1 #!/bin/sh
2 # check-split.sh: check split quality for the Linux modules
3 # Make the three-column Markdown-friendly table representing all the modules.
4 # Column #1: module path/name.ko.xz
5 # Column #2: package(s), which owns module
6 # Column $3: module description (if any)
8 . /lib/libtaz.sh
9 WOK='/home/slitaz/wok'
10 tmp="$WOK/linux/tmp"; mkdir -p $tmp
11 out="$tmp/modules.split"
12 . $WOK/linux/receipt
14 # List of all the modules
15 order="$WOK/linux/install/lib/modules/$VERSION-slitaz/modules.order"
16 maxlen=$(wc -L $order | cut -d' ' -f1)
17 maxlen1=$(( maxlen - 7 + 2 )) # leading "kernel/" will be removed (-7), "`...`" will be added (+2)
18 hline=$(printf "%${maxlen1}s" '' | tr -c '\n' '-')
20 # First column: module name with local path
21 sort $order | awk -vhline=$hline '
22 BEGIN {
23 printf("%-'$(( maxlen1 + 3))'s | \n", "Module path/name.ko.xz");
24 printf("%s----|-\n", hline);
25 }
26 {
27 sub("kernel/", "");
28 gsub("/", "@"); # change "/" to "@" to easy use sed in the next step
29 printf("%-'$maxlen1's | \n", "`" $0 "`");
30 }' > $out
33 # Second column: package name(s) for the module
34 for i in linux $SPLIT; do
35 action "Processing $i..."
36 while read f; do
37 case $f in
38 *.ko.xz)
39 fshort=${f#*/kernel/}
40 fshort=$(echo $fshort | sed 's|/|@|g')
41 fshort=${fshort%.xz}
42 sed -i "/$fshort/ s|$|$i |" $out
43 ;;
44 esac
45 done < "$WOK/$i/taz/$i-$VERSION/files.list"
46 status
47 done
50 maxlen2=$(wc -L $out | cut -d' ' -f1)
51 hline=$(printf "%$(( maxlen2 - maxlen1 - 3 ))s" '' | tr -c '\n' '-')
52 mv $out $out.tmp
53 awk -vhline=$hline '{
54 if (NR==1)
55 printf("%-'$(( maxlen2 + 3 ))'s |\n", $0 "Package(s)");
56 else if (NR==2)
57 printf("%s-|\n", $0 hline);
58 else
59 printf("%-'$maxlen2's |\n", $0);
60 }' $out.tmp > $out
61 rm $out.tmp
64 tr '@' '/' < "$out" > "$out.tmp"; mv "$out.tmp" "$out"
65 sed -i 's|\.ko` |.ko.xz` |' "$out"
68 # Third column: descriptions
69 action "Getting descriptions..."
70 IFS=$'\n'
71 while read i; do
72 echo -n "$i"
73 module=${i%\`*}; module=${module#\`}
74 if [ -f "$WOK/linux/install/lib/modules/$VERSION-slitaz/kernel/$module" ]; then
75 info=$(modinfo -d $WOK/linux/install/lib/modules/$VERSION-slitaz/kernel/$module | tr '\n' ' ' | sed 's| $||')
76 [ -n "$info" ] && info=" $info"
77 echo "$info"
78 else
79 echo
80 fi
81 done < "$out" > "$out.tmp"
82 unset IFS
84 awk '{
85 if (NR==1)
86 printf("%s\n", $0 " Description");
87 else if (NR==2)
88 printf("%s\n", $0 "------------");
89 else
90 print;
91 }' "$out.tmp" > "$out"
92 rm "$out.tmp"
93 status
94 footer "File: $out"