Last active
August 29, 2015 14:17
-
-
Save sigsergv/2825d3064ad5549d7265 to your computer and use it in GitHub Desktop.
dkms bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moduleconfig_update_obsoletes() | |
{ | |
# $@ = files to process | |
# do nothing if we have no obsoletes | |
[[ ${modules_conf_obsoletes[@]} ]] || return 0 | |
# generate sed args to remove obsolete modules | |
local mod_diff | |
for ((index=0; index < ${#dest_module_name[@]}; index++)); do | |
[[ ${modules_conf_obsoletes[$index]} ]] || continue | |
for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do | |
# for module.conf style syntax | |
sa_mc_o[${#sa_mc_o[@]}]="-e" | |
sa_mc_o[${#sa_mc_o[@]}]="s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) $obsolete_module$/\1 ${dest_module_name[$index]}/g" | |
# for /etc/sysconfig/kernel style syntax | |
sa_sck_o[${#sa_sck_o[@]}]="-e" | |
sa_sck_o[${#sa_sck_o[@]}]="s/\(INITRD_MODULES.*\)$obsolete_module\b\(.*\)/\1${dest_module_name[$index]}\2/" | |
done | |
done | |
# do all the changes at once, record the diffs for posterity | |
for file in "$@"; do | |
[[ $file && -w $file ]] || continue | |
_tmpf="$temp_dir_name/${file##*/}.new" | |
if [[ $file = /etc/sysconfig/kernel ]]; then | |
[ -z "${sa_sck_o[@]}" ] || sed "${sa_sck_o[@]}" "$file" > "$_tmpf" | |
else | |
[ -z "${sa_mc_o[@]}" ] || sed "${sa_mc_o[@]}" "$file" > "$_tmpf" | |
fi | |
if [ -f "$_tmpf" ] && ! mod_diff=$(diff -u "$_tmpf" "$file"); then | |
echo $"$file updated to replace obsoleted module references:" | |
echo "$mod_diff" | |
cp -fp "$_tmpf" "$file" | |
rm -f "$_tmpf" | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment