diff --git a/SOURCES/weak-modules b/SOURCES/weak-modules index 65eea86..c4a6d55 100644 --- a/SOURCES/weak-modules +++ b/SOURCES/weak-modules @@ -286,6 +286,13 @@ module_weak_link() { module_krel="$(krel_of_module "$module")" subpath=$(echo $module | sed -nre "s:$BASEDIR(/usr)?/lib/modules/$module_krel/([^/]*)/(.*):\3:p") + if [[ -z $subpath ]]; then + # module is not in /lib/modules/$krel? + # It's possible for example for Oracle ACFS compatibility check + # Install it with its full path as a /lib/modules subpath + subpath="$module" + fi + echo "$BASEDIR/lib/modules/$krel/weak-updates/${subpath#/}" } @@ -387,9 +394,9 @@ remove_weak_link_quiet() { local krel="$2" local subpath="${link#*/lib/modules/$krel/weak-updates}" - doit rm -f $link + rm -f $link ( cd "$BASEDIR/lib/modules/$krel/weak-updates" && \ - doit rmdir --parents --ignore-fail-on-non-empty "$(dirname "${subpath#/}")" 2>/dev/null ) + rmdir --parents --ignore-fail-on-non-empty "$(dirname "${subpath#/}")" 2>/dev/null ) } #### Main logic @@ -421,6 +428,11 @@ update_modules_for_krel() { fi global_link_state_announce_changes $krel + + if [[ -n "$dry_run" ]]; then + pr_verbose "Dry run: restoring configuration" + global_link_state_restore $krel + fi } # update_modules: @@ -462,7 +474,11 @@ add_weak_links() { for module in "${modules[@]}"; do module_krel="$(krel_of_module $module)" - [[ "$module_krel" == "$krel" ]] && continue + case "$module" in + /lib/modules/$krel/*) + # Module already installed to the current kernel + continue ;; + esac if is_extra_exists $module $module_krel $krel; then pr_verbose "found $(module_short_name $module) for $krel while installing for $module_krel, update case?" @@ -478,8 +494,8 @@ add_weak_links() { weak_link="$(module_weak_link $module $krel)" - doit mkdir -p "$(dirname $weak_link)" - doit ln -sf $module $weak_link + mkdir -p "$(dirname $weak_link)" + ln -sf $module $weak_link done } @@ -499,8 +515,6 @@ remove_weak_links() { for module in "${modules[@]}"; do module_krel="$(krel_of_module $module)" - [[ "$module_krel" == "$krel" ]] && continue - weak_link="$(module_weak_link $module $krel)" target="$(readlink $weak_link)" @@ -642,13 +656,13 @@ global_link_state_restore() { pr_verbose "Falling back weak-modules state for kernel $krel" - ( cd "$weak_modules_dir" && doit rm -rf * ) + ( cd "$weak_modules_dir" 2>/dev/null && rm -rf * ) for link in "${!weak_modules_before[@]}"; do target=${weak_modules_before[$link]} - doit mkdir -p "$(dirname $link)" - doit ln -sf $target $link + mkdir -p "$(dirname $link)" + ln -sf $target $link done } @@ -767,6 +781,10 @@ while :; do ;; --dry-run) dry_run=1 + # --dry-run option is not pure dry run anymore, + # because of depmod used internally. + # For add/remove modules we have to add/remove the symlinks + # and just restore the original configuration afterwards. ;; --no-initramfs) no_initramfs=1 diff --git a/SPECS/kmod.spec b/SPECS/kmod.spec index d8069ad..0873c77 100644 --- a/SPECS/kmod.spec +++ b/SPECS/kmod.spec @@ -1,6 +1,6 @@ Name: kmod Version: 20 -Release: 15%{?dist}.2 +Release: 15%{?dist}.4 Summary: Linux kernel module management utilities Group: System Environment/Kernel @@ -130,6 +130,15 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf %{_libdir}/libkmod.so %changelog +* Fri Sep 15 2017 Yauheni Kaliuta - 20-15.el7_4.4 +- bump up version for internal reasons. + Related: rhbz#1489696. + +* Thu Sep 14 2017 Yauheni Kaliuta - 20-15.el7_4.3 +- weak-modules: implement dry run by symlink restoration. +- weak-modules: fix dry-run for non-lib-modules installation. + Resolves: rhbz#1489696. + * Thu Aug 17 2017 Yauheni Kaliuta - 20-15.el7_4.2 - libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS. - weak-modules: process only weak-updates related depmod output.