wok-next view linux/stuff/tools/copy_modules.sh @ rev 19777

Update aufs to latest; linux: package 'linux' went without modules.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jun 16 13:35:47 2017 +0300 (2017-06-16)
parents 960a052d15d3
children
line source
1 #!/bin/sh
2 # copy_modules.sh: copy Linux Kernel modules for SliTaz GNU/Linux.
3 # GNU General Public License.
4 #
6 kversion="$VERSION-slitaz"
7 modroot="$install/lib/modules/$kversion/kernel"
8 modlist="/tmp/modules.list.$$"
10 # Redefine variables for the Linux 64
11 if [ ${PACKAGE:0:7} == 'linux64' ]; then
12 src="$WOK/linux64/source/tmp"
13 install="$install/linux64"
14 kversion="$VERSION-slitaz64"
15 fi
18 list_modules() {
19 found="$(find $modroot/$1 -type f)"
20 if [ -z "$found" ]; then
21 echo -e "\n\nError: $1 does not exist.\n\n" >&2
22 exit 1
23 fi
25 echo "Search modules for $1..." >&2
26 for module in $(echo "$found" | sed "s|.*$kversion/||"); do
27 grep $module: "$install/lib/modules/$kversion/modules.dep"
28 done | sed 's|^kernel/||; s| kernel/| |g; s|:||' | \
29 awk '{ for (i = 1; i <= NF; i++) print $i; }' | \
30 sort -u | \
31 while read module; do
32 if grep -qs ^$module$ "$modlist"; then
33 echo " - $module" >&2
34 continue
35 else
36 echo " + $module" >&2
37 echo $module
38 fi
39 done
40 }
43 #
44 # Main
45 #
47 # A. Build list of "restricted" modules: all these modules should be only in the "linux" package
49 # A.1. Builtin modules
50 awk '{sub(/^kernel\//, ""); print $1 ".xz"}' "$install/lib/modules/$kversion/modules.builtin" > "$modlist"
52 # A.2. Using split.rules for the "linux" rules
53 case $PACKAGE in
54 linux|linux-libre|linux64)
55 # make exception for the base "linux" package
56 ;;
57 *)
58 while read rule_name rule_value; do
59 [ "$rule_name" != 'linux' ] && continue
60 list_modules $rule_value >> "$modlist" 2>/dev/null
61 done < "$stuff/split.rules"
62 ;;
63 esac
65 # A.3. Simulate deprecated (for receipts v2) variable $WANTED
66 case $PACKAGE in
67 linux-libre|linux64|linux) wanted='';;
68 linux-libre-*) wanted='linux-libre';;
69 linux64-*) wanted='linux64';;
70 linux-*) wanted='linux';;
71 esac
73 # A.4. If package depends on other package - make these modules "restricted" (excluded) too
74 if [ "$DEPENDS" != "$wanted" ]; then
75 for i in $DEPENDS; do
76 if [ "$i" != "$wanted" ]; then
77 pkg_subname=${i#linux-libre-}
78 pkg_subname=${pkg_subname#linux*-}
80 while read rule_name rule_value; do
81 [ "$pkg_subname" != "$rule_name" ] && continue
82 list_modules $rule_value >> "$modlist" 2>/dev/null
83 done < "$stuff/split.rules"
84 fi
85 done
86 fi
89 # B. Copy modules from the linux $install
91 # B.1. Get the name of the rule
92 # linux{,-libre,64}-subname -> subname
93 case $PACKAGE in
94 linux-libre|linux64|linux) pkg_subname="linux";;
95 linux-libre-*) pkg_subname="${PACKAGE#linux-libre-}";;
96 linux64-*) pkg_subname="${PACKAGE#linux64-}";;
97 linux-*) pkg_subname="${PACKAGE#linux-}";;
98 esac
100 # B.2. Process rules, copy modules
101 while read rule_name rule_value; do
102 [ "$pkg_subname" != "$rule_name" ] && continue
104 list_modules $rule_value | \
105 while read module; do
106 dir=lib/modules/$kversion/kernel/$(dirname $module)
107 mkdir -p $fs/$dir
108 cp -a $modroot/$module $fs/$dir
109 done
110 done < "$stuff/split.rules"
112 # B.3. Clean
113 rm "$modlist"
116 # C. Compare with the previous version: use the --diff (for example, `cook linux-acpi --diff`)
118 if [ -n "$diff" ]; then
119 lzcat /var/lib/tazpkg/files.list.lzma | grep ^$PACKAGE: | awk -F/ '{print $NF}' | sort > /tmp/old
120 find $fs -type f | awk -F/ '{print $NF}' | sort > /tmp/new
121 diff -d -U0 /tmp/old /tmp/new | sed '/^---/d; /^+++/d; /^@@/d; /\.ko\./!d' > $WOK/$PACKAGE/diff.diff
122 fi