Skip to content

Commit

Permalink
Introduce 'dkms unbuild' command
Browse files Browse the repository at this point in the history
Add an action "unbuild" to align with the existing "build" one.

This provides for a complete symmetry - add/remove, build/unbuild and
install/uninstall.

Apart from the seeming cosmetic affect, this function is required when
the binary kernel module(s) produced with "dkms build" must be pruned.

Without this command that is not possible since using:
 - "dkms uninstall" will remove the symlinks/copies produced with
"dkms install", while
 - "dkms remove" will erase all references of the dkms module. Hence
"dkms status" will have no references about the module.

This allows for a proper fix for #20
while avoiding regressions like #77

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
  • Loading branch information
evelikov-work authored and superm1 committed Feb 19, 2020
1 parent 69859ff commit c4f3db2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
27 changes: 26 additions & 1 deletion dkms
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,28 @@ do_unbuild()
[[ $(find $dkms_tree/$module/$module_version/$1/* -maxdepth 0 -type d 2>/dev/null) ]] || \
rm -rf "$dkms_tree/$module/$module_version/$1"
}

# Remove the build module, w/o removing/unregistering it.
# This uninstalls any installed modules along the way
unbuild_module()
{
# Check that the right arguments were passed
check_module_args unbuild

# Check that $module is in the dkms tree
module_is_added_or_die

local i
for ((i=0; i < ${#kernelver[@]}; i++)); do
# Only do stuff if module/module version is currently built
module_is_built_or_die "${kernelver[$i]}" "${arch[$i]}"

do_uninstall "${kernelver[$i]}" "${arch[$i]}"

do_unbuild "${kernelver[$i]}" "${arch[$i]}"
done
}

# Unregister a DKMS module. This uninstalls any installed modules along the way.
remove_module()
{
Expand Down Expand Up @@ -3650,7 +3672,7 @@ die_is_fatal="yes"
[ -x /usr/lib/module-init-tools/weak-modules ] && weak_modules='/usr/lib/module-init-tools/weak-modules'
no_depmod=""

action_re='^(remove|(auto|un)?install|match|mk(driverdisk|tarball|rpm|deb|bmdeb|dsc|kmp)|build|add|status|ldtarball)$'
action_re='^(remove|(auto|un)?install|match|mk(driverdisk|tarball|rpm|deb|bmdeb|dsc|kmp)|(un)?build|add|status|ldtarball)$'

# Parse command line arguments
while (($# > 0)); do
Expand Down Expand Up @@ -3846,6 +3868,9 @@ for action_to_run in $action; do
remove)
check_root && remove_module
;;
unbuild)
check_root && unbuild_module
;;
install)
check_root && check_all_is_banned "install" && install_modules
;;
Expand Down
12 changes: 12 additions & 0 deletions dkms.8
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ case
can take the same arguments that
.B add
can.
.SY unbuild
.OP module/module\-version
.OP -k kernel/arch
.OP \-\-all
.YS
.IP "" 4
Undoes the build for a module/version or module/version/kernel/arch combination from the
tree. If the module is currently installed, it first uninstalls it
and if applicable, will replace it with its original_module. Finally all binary
kernel modules are removed. Use the
.B \-\-all
option in order to remove all instances for every kernel at once.
.SY install
.OP module/module\-version
.OP -k kernel/arch
Expand Down
2 changes: 1 addition & 1 deletion dkms.bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _dkms()
cur=${COMP_WORDS[COMP_CWORD]}

if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $( compgen -W "add autoinstall remove build install uninstall \
COMPREPLY=( $( compgen -W "add autoinstall remove build unbuild install uninstall \
match mkdriverdisk mktarball ldtarball mkrpm mkdeb mkdsc mkkmp \
status" -- $cur ) )
else
Expand Down

0 comments on commit c4f3db2

Please sign in to comment.