|
Lines 2-12
Link Here
|
| 2 |
|
2 |
|
| 3 |
############################################################################## |
3 |
############################################################################## |
| 4 |
# How it works: |
4 |
# How it works: |
| 5 |
# * Kernels install modules below /lib/modules/$krel/kernel/. |
5 |
# * Kernels install modules below /usr/lib/modules/$krel/kernel/. |
| 6 |
# * KMPs install modules below /lib/modules/$krel/updates/ or .../extra/. |
6 |
# * KMPs install modules below /usr/lib/modules/$krel/updates/ or .../extra/. |
| 7 |
# * Symbolic links to modules of compatible KMPs are created under |
7 |
# * Symbolic links to modules of compatible KMPs are created under |
| 8 |
# /lib/modules/$krel/weak-updates/{updates,extra}/... (the original path |
8 |
# /usr/lib/modules/$krel/weak-updates/{updates,extra}/... (the original path |
| 9 |
# below /lib/modules/$other_krel is used). |
9 |
# below /usr/lib/modules/$other_krel is used). |
| 10 |
# * Depmod searches the directories in this order: updates/, extra/, |
10 |
# * Depmod searches the directories in this order: updates/, extra/, |
| 11 |
# weak-updates/, kernel/ (see /etd/depmod.conf or |
11 |
# weak-updates/, kernel/ (see /etd/depmod.conf or |
| 12 |
# /etc/depmod.d/00-system.conf for details). |
12 |
# /etc/depmod.d/00-system.conf for details). |
|
Lines 45-51
Link Here
|
| 45 |
# $kmpshort: name of a kmp, e.g kqemu-kmp-default |
45 |
# $kmpshort: name of a kmp, e.g kqemu-kmp-default |
| 46 |
# $basename: portion of $kmp up to the "-kmp-" part, e.g kqemu |
46 |
# $basename: portion of $kmp up to the "-kmp-" part, e.g kqemu |
| 47 |
# $flavor: flavor of a kmp or kernel, e.g default |
47 |
# $flavor: flavor of a kmp or kernel, e.g default |
| 48 |
# $krel: kernel version, as in /lib/modules/$krel |
48 |
# $krel: kernel version, as in /usr/lib/modules/$krel |
| 49 |
# $module: full path to a module below updates/ |
49 |
# $module: full path to a module below updates/ |
| 50 |
# $symlink: full path to a module symlink below weak-updates/ |
50 |
# $symlink: full path to a module symlink below weak-updates/ |
| 51 |
# |
51 |
# |
|
Lines 139-145
strip_mod_extensions() {
Link Here
|
| 139 |
symlink_to_module() { |
139 |
symlink_to_module() { |
| 140 |
local module=$1 krel=$2 |
140 |
local module=$1 krel=$2 |
| 141 |
|
141 |
|
| 142 |
echo /lib/modules/$krel/weak-updates/${module#/lib/modules/*/} |
142 |
echo /usr/lib/modules/$krel/weak-updates/${module#/usr/lib/modules/*/} |
| 143 |
} |
143 |
} |
| 144 |
|
144 |
|
| 145 |
# Is a kmp already present in or linked to from this kernel? |
145 |
# Is a kmp already present in or linked to from this kernel? |
|
Lines 165-171
kmp_is_present() {
Link Here
|
| 165 |
return $res |
165 |
return $res |
| 166 |
} |
166 |
} |
| 167 |
|
167 |
|
| 168 |
# Add the modules of a kmp to /lib/modules/$krel |
168 |
# Add the modules of a kmp to /usr/lib/modules/$krel |
| 169 |
add_kmp_modules() { |
169 |
add_kmp_modules() { |
| 170 |
local kmp=$1 krel=$2 basedir=$3 |
170 |
local kmp=$1 krel=$2 basedir=$3 |
| 171 |
|
171 |
|
|
Lines 180-186
add_kmp_modules() {
Link Here
|
| 180 |
done < $tmpdir/modules-$kmp |
180 |
done < $tmpdir/modules-$kmp |
| 181 |
} |
181 |
} |
| 182 |
|
182 |
|
| 183 |
# Remove the modules of a kmp from /lib/modules/$krel |
183 |
# Remove the modules of a kmp from /usr/lib/modules/$krel |
| 184 |
remove_kmp_modules() { |
184 |
remove_kmp_modules() { |
| 185 |
local kmp=$1 krel=$2 basedir=$3 |
185 |
local kmp=$1 krel=$2 basedir=$3 |
| 186 |
|
186 |
|
|
Lines 194-202
remove_kmp_modules() {
Link Here
|
| 194 |
done < $tmpdir/modules-$kmp |
194 |
done < $tmpdir/modules-$kmp |
| 195 |
} |
195 |
} |
| 196 |
|
196 |
|
| 197 |
# Create a temporary working copy of /lib/modules/$1 |
197 |
# Create a temporary working copy of /usr/lib/modules/$1 |
| 198 |
create_temporary_modules_dir() { |
198 |
create_temporary_modules_dir() { |
| 199 |
local modules_dir=/lib/modules/$1 basedir=$2 |
199 |
local modules_dir=/usr/lib/modules/$1 basedir=$2 |
| 200 |
local opt_v=${opt_debug:+-v} |
200 |
local opt_v=${opt_debug:+-v} |
| 201 |
|
201 |
|
| 202 |
mkdir -p $opt_v $basedir$modules_dir/weak-updates |
202 |
mkdir -p $opt_v $basedir$modules_dir/weak-updates |
|
Lines 252-258
has_unresolved_symbols() {
Link Here
|
| 252 |
basenames_are_unique() { |
252 |
basenames_are_unique() { |
| 253 |
local kmp=$1 krel=$2 basedir=$3 dir |
253 |
local kmp=$1 krel=$2 basedir=$3 dir |
| 254 |
|
254 |
|
| 255 |
for dir in $basedir/lib/modules/$krel/{weak-updates,updates,extra}/; do |
255 |
for dir in $basedir/usr/lib/modules/$krel/{weak-updates,updates,extra}/; do |
| 256 |
if [ ! -d "$dir" ]; then |
256 |
if [ ! -d "$dir" ]; then |
| 257 |
continue |
257 |
continue |
| 258 |
fi |
258 |
fi |
|
Lines 273-279
__can_replace_kmp() {
Link Here
|
| 273 |
local old_kmp=$1 new_kmp=$2 krel=$3 |
273 |
local old_kmp=$1 new_kmp=$2 krel=$3 |
| 274 |
|
274 |
|
| 275 |
local basedir=$tmpdir/$krel |
275 |
local basedir=$tmpdir/$krel |
| 276 |
local weak_updates=/lib/modules/$krel/weak-updates/ |
276 |
local weak_updates=/usr/lib/modules/$krel/weak-updates/ |
| 277 |
|
277 |
|
| 278 |
[ -d "$basedir" ] || \ |
278 |
[ -d "$basedir" ] || \ |
| 279 |
create_temporary_modules_dir "$krel" "$basedir" |
279 |
create_temporary_modules_dir "$krel" "$basedir" |
|
Lines 305-311
check_kmp() {
Link Here
|
| 305 |
local kmp=$1 |
305 |
local kmp=$1 |
| 306 |
|
306 |
|
| 307 |
# Make sure all modules are for the same kernel |
307 |
# Make sure all modules are for the same kernel |
| 308 |
set -- $(sed -re 's:^/lib/modules/([^/]+)/.*:\1:' \ |
308 |
set -- $(sed -re 's:^/usr/lib/modules/([^/]+)/.*:\1:' \ |
| 309 |
$tmpdir/modules-$kmp \ |
309 |
$tmpdir/modules-$kmp \ |
| 310 |
| sort -u) |
310 |
| sort -u) |
| 311 |
if [ $# -ne 1 ]; then |
311 |
if [ $# -ne 1 ]; then |
|
Lines 317-323
check_kmp() {
Link Here
|
| 317 |
dlog "check_kmp: $kmp contains modules for $1" |
317 |
dlog "check_kmp: $kmp contains modules for $1" |
| 318 |
|
318 |
|
| 319 |
# Make sure none of the modules are in kernel/ or weak-updates/ |
319 |
# Make sure none of the modules are in kernel/ or weak-updates/ |
| 320 |
if grep -qE -e '^/lib/modules/[^/]+/(kernel|weak-updates)/' \ |
320 |
if grep -qE -e '^/usr/lib/modules/[^/]+/(kernel|weak-updates)/' \ |
| 321 |
$tmpdir/modules-$kmp; then |
321 |
$tmpdir/modules-$kmp; then |
| 322 |
echo "Error: package $kmp must not install modules into " \ |
322 |
echo "Error: package $kmp must not install modules into " \ |
| 323 |
"kernel/ or weak-updates/" >&2 |
323 |
"kernel/ or weak-updates/" >&2 |
|
Lines 342-348
find_kmps() {
Link Here
|
| 342 |
continue |
342 |
continue |
| 343 |
fi |
343 |
fi |
| 344 |
rpm -ql --nodigest --nosignature "$kmp" \ |
344 |
rpm -ql --nodigest --nosignature "$kmp" \ |
| 345 |
| sed -nr 's:^(/usr)?(/lib/modules/[^/]+/.+\.ko)(\.[gx]z|\.zst)?$:\2\3:p' \ |
345 |
| sed -nr 's:^(/usr/lib/modules/[^/]+/.+\.ko)(\.[gx]z|\.zst)?$:\1\2:p' \ |
| 346 |
> $tmpdir/modules-$kmp |
346 |
> $tmpdir/modules-$kmp |
| 347 |
if [ $? != 0 ]; then |
347 |
if [ $? != 0 ]; then |
| 348 |
echo "WARNING: $kmp does not contain any kernel modules" >&2 |
348 |
echo "WARNING: $kmp does not contain any kernel modules" >&2 |
|
Lines 455-461
run_depmod_build_initrd() {
Link Here
|
| 455 |
local status=0 |
455 |
local status=0 |
| 456 |
local system_map |
456 |
local system_map |
| 457 |
|
457 |
|
| 458 |
if [ -d /lib/modules/$krel ]; then |
458 |
if [ -d /usr/lib/modules/$kreli ]; then |
| 459 |
system_map=$(find_usrmerge_boot System.map "$krel") |
459 |
system_map=$(find_usrmerge_boot System.map "$krel") |
| 460 |
if [ -n "$system_map" ]; then |
460 |
if [ -n "$system_map" ]; then |
| 461 |
doit "$DEPMOD" -F "$system_map" -ae "$krel" || return 1 |
461 |
doit "$DEPMOD" -F "$system_map" -ae "$krel" || return 1 |
|
Lines 528-534
kernel_changed() {
Link Here
|
| 528 |
dlog "kernel_changed: kernel removed" |
528 |
dlog "kernel_changed: kernel removed" |
| 529 |
return 0 |
529 |
return 0 |
| 530 |
fi |
530 |
fi |
| 531 |
if [ ! -d /lib/modules/$krel ]; then |
531 |
if [ ! -d /usr/lib/modules/$krel ]; then |
| 532 |
# a kernel without modules - rebuild initrd nevertheless (to mount the |
532 |
# a kernel without modules - rebuild initrd nevertheless (to mount the |
| 533 |
# root fs, etc). |
533 |
# root fs, etc). |
| 534 |
dlog "kernel_changed: kernel without modules" |
534 |
dlog "kernel_changed: kernel without modules" |
|
Lines 548-554
add_kernel() {
Link Here
|
| 548 |
remove_kernel() { |
548 |
remove_kernel() { |
| 549 |
local krel=$1 |
549 |
local krel=$1 |
| 550 |
|
550 |
|
| 551 |
local dir=/lib/modules/$krel |
551 |
local dir=/usr/lib/modules/$krel |
| 552 |
if [ -d $dir/weak-updates ]; then |
552 |
if [ -d $dir/weak-updates ]; then |
| 553 |
rm -rf $dir/weak-updates |
553 |
rm -rf $dir/weak-updates |
| 554 |
fi |
554 |
fi |
|
Lines 580-587
add_kmp() {
Link Here
|
| 580 |
find_kmps "$basename" "$flavor" || return 1 |
580 |
find_kmps "$basename" "$flavor" || return 1 |
| 581 |
|
581 |
|
| 582 |
local dir krel status |
582 |
local dir krel status |
| 583 |
for dir in /lib/modules/*; do |
583 |
for dir in /usr/lib/modules/*; do |
| 584 |
krel=${dir#/lib/modules/} |
584 |
krel=${dir#/usr/lib/modules/} |
| 585 |
case "$krel" in |
585 |
case "$krel" in |
| 586 |
*-$flavor) |
586 |
*-$flavor) |
| 587 |
;; |
587 |
;; |
|
Lines 593-599
add_kmp() {
Link Here
|
| 593 |
system_map=$(find_usrmerge_boot System.map "$krel") |
593 |
system_map=$(find_usrmerge_boot System.map "$krel") |
| 594 |
[ -n "$system_map" ] || continue |
594 |
[ -n "$system_map" ] || continue |
| 595 |
if opt_debug=1 has_unresolved_symbols "$krel" "/"; then |
595 |
if opt_debug=1 has_unresolved_symbols "$krel" "/"; then |
| 596 |
echo "Warning: /lib/modules/$krel is inconsistent" >&2 |
596 |
echo "Warning: /usr/lib/modules/$krel is inconsistent" >&2 |
| 597 |
echo "Warning: weak-updates symlinks might not be created" >&2 |
597 |
echo "Warning: weak-updates symlinks might not be created" >&2 |
| 598 |
fi |
598 |
fi |
| 599 |
|
599 |
|
|
Lines 637-644
remove_kmp() {
Link Here
|
| 637 |
check_kmp "$kmp" || return 1 |
637 |
check_kmp "$kmp" || return 1 |
| 638 |
|
638 |
|
| 639 |
local dir krel status system_map |
639 |
local dir krel status system_map |
| 640 |
for dir in /lib/modules/*; do |
640 |
for dir in /usr/lib/modules/*; do |
| 641 |
krel=${dir#/lib/modules/} |
641 |
krel=${dir#/usr/lib/modules/} |
| 642 |
case "$krel" in |
642 |
case "$krel" in |
| 643 |
*-$flavor) |
643 |
*-$flavor) |
| 644 |
;; |
644 |
;; |
|
Lines 681-687
remove_kmp() {
Link Here
|
| 681 |
if [ $other_found -eq 1 ]; then |
681 |
if [ $other_found -eq 1 ]; then |
| 682 |
log "Weak-updates symlinks to no other $kmpshort package could be created" |
682 |
log "Weak-updates symlinks to no other $kmpshort package could be created" |
| 683 |
if [ $inconsistent -eq 1 ]; then |
683 |
if [ $inconsistent -eq 1 ]; then |
| 684 |
echo "Warning: /lib/modules/$krel was inconsistent before removal of $kmp" >&2 |
684 |
echo "Warning: /usr/lib/modules/$krel was inconsistent before removal of $kmp" >&2 |
| 685 |
[ -s $tmpdir/unresolved-"$krel" ] && \ |
685 |
[ -s $tmpdir/unresolved-"$krel" ] && \ |
| 686 |
cat $tmpdir/unresolved-"$krel" |
686 |
cat $tmpdir/unresolved-"$krel" |
| 687 |
fi |
687 |
fi |
| 688 |
- |
|
|