wok-undigest diff linux/stuff/tools/copy_modules.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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/linux/stuff/tools/copy_modules.sh Fri Nov 15 16:49:43 2019 +0100 1.3 @@ -0,0 +1,122 @@ 1.4 +#!/bin/sh 1.5 +# copy_modules.sh: copy Linux Kernel modules for SliTaz GNU/Linux. 1.6 +# GNU General Public License. 1.7 +# 1.8 + 1.9 +kversion="$VERSION-slitaz" 1.10 +modroot="$install/lib/modules/$kversion/kernel" 1.11 +modlist="/tmp/modules.list.$$" 1.12 + 1.13 +# Redefine variables for the Linux 64 1.14 +if [ ${PACKAGE:0:7} == 'linux64' ]; then 1.15 + src="$WOK/linux64/source/tmp" 1.16 + install="$install/linux64" 1.17 + kversion="$VERSION-slitaz64" 1.18 +fi 1.19 + 1.20 + 1.21 +list_modules() { 1.22 + found="$(find $modroot/$1 -type f)" 1.23 + if [ -z "$found" ]; then 1.24 + echo -e "\n\nError: $1 does not exist.\n\n" >&2 1.25 + exit 1 1.26 + fi 1.27 + 1.28 + echo "Search modules for $1..." >&2 1.29 + for module in $(echo "$found" | sed "s|.*$kversion/||"); do 1.30 + grep $module: "$install/lib/modules/$kversion/modules.dep" 1.31 + done | sed 's|^kernel/||; s| kernel/| |g; s|:||' | \ 1.32 + awk '{ for (i = 1; i <= NF; i++) print $i; }' | \ 1.33 + sort -u | \ 1.34 + while read module; do 1.35 + if grep -qs ^$module$ "$modlist"; then 1.36 + echo " - $module" >&2 1.37 + continue 1.38 + else 1.39 + echo " + $module" >&2 1.40 + echo $module 1.41 + fi 1.42 + done 1.43 +} 1.44 + 1.45 + 1.46 +# 1.47 +# Main 1.48 +# 1.49 + 1.50 +# A. Build list of "restricted" modules: all these modules should be only in the "linux" package 1.51 + 1.52 +# A.1. Builtin modules 1.53 +awk '{sub(/^kernel\//, ""); print $1 ".xz"}' "$install/lib/modules/$kversion/modules.builtin" > "$modlist" 1.54 + 1.55 +# A.2. Using split.rules for the "linux" rules 1.56 +case $PACKAGE in 1.57 + linux|linux-libre|linux64) 1.58 + # make exception for the base "linux" package 1.59 + ;; 1.60 + *) 1.61 + while read rule_name rule_value; do 1.62 + [ "$rule_name" != 'linux' ] && continue 1.63 + list_modules $rule_value >> "$modlist" 2>/dev/null 1.64 + done < "$stuff/split.rules" 1.65 + ;; 1.66 +esac 1.67 + 1.68 +# A.3. Simulate deprecated (for receipts v2) variable $WANTED 1.69 +case $PACKAGE in 1.70 + linux-libre|linux64|linux) wanted='';; 1.71 + linux-libre-*) wanted='linux-libre';; 1.72 + linux64-*) wanted='linux64';; 1.73 + linux-*) wanted='linux';; 1.74 +esac 1.75 + 1.76 +# A.4. If package depends on other package - make these modules "restricted" (excluded) too 1.77 +if [ "$DEPENDS" != "$wanted" ]; then 1.78 + for i in $DEPENDS; do 1.79 + if [ "$i" != "$wanted" ]; then 1.80 + pkg_subname=${i#linux-libre-} 1.81 + pkg_subname=${pkg_subname#linux*-} 1.82 + 1.83 + while read rule_name rule_value; do 1.84 + [ "$pkg_subname" != "$rule_name" ] && continue 1.85 + list_modules $rule_value >> "$modlist" 2>/dev/null 1.86 + done < "$stuff/split.rules" 1.87 + fi 1.88 + done 1.89 +fi 1.90 + 1.91 + 1.92 +# B. Copy modules from the linux $install 1.93 + 1.94 +# B.1. Get the name of the rule 1.95 +# linux{,-libre,64}-subname -> subname 1.96 +case $PACKAGE in 1.97 + linux-libre|linux64|linux) pkg_subname="linux";; 1.98 + linux-libre-*) pkg_subname="${PACKAGE#linux-libre-}";; 1.99 + linux64-*) pkg_subname="${PACKAGE#linux64-}";; 1.100 + linux-*) pkg_subname="${PACKAGE#linux-}";; 1.101 +esac 1.102 + 1.103 +# B.2. Process rules, copy modules 1.104 +while read rule_name rule_value; do 1.105 + [ "$pkg_subname" != "$rule_name" ] && continue 1.106 + 1.107 + list_modules $rule_value | \ 1.108 + while read module; do 1.109 + dir=lib/modules/$kversion/kernel/$(dirname $module) 1.110 + mkdir -p $fs/$dir 1.111 + cp -a $modroot/$module $fs/$dir 1.112 + done 1.113 +done < "$stuff/split.rules" 1.114 + 1.115 +# B.3. Clean 1.116 +rm "$modlist" 1.117 + 1.118 + 1.119 +# C. Compare with the previous version: use the --diff (for example, `cook linux-acpi --diff`) 1.120 + 1.121 +if [ -n "$diff" ]; then 1.122 + lzcat /var/lib/tazpkg/files.list.lzma | grep ^$PACKAGE: | awk -F/ '{print $NF}' | sort > /tmp/old 1.123 + find $fs -type f | awk -F/ '{print $NF}' | sort > /tmp/new 1.124 + diff -d -U0 /tmp/old /tmp/new | sed '/^---/d; /^+++/d; /^@@/d; /\.ko\./!d' > $WOK/$PACKAGE/diff.diff 1.125 +fi