From 68b083eaa3f71c166adfece8e4f760e0cdf96185 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 7 Oct 2021 23:36:26 +0100 Subject: [PATCH] dkms: remove debian commands mkdeb mkdsc mkbmdeb Distributions know much better than us, what is the proper way to package a DKMS module. Remove in-tree, semi-constantly out-of-date code. Signed-off-by: Emil Velikov --- dkms | 204 +------------------------------------------ dkms.8 | 43 --------- dkms.bash-completion | 2 +- 3 files changed, 3 insertions(+), 246 deletions(-) diff --git a/dkms b/dkms index c66013e5..a51606ad 100644 --- a/dkms +++ b/dkms @@ -135,7 +135,7 @@ show_usage() { echo $"Usage: $0 [action] [options]" echo $" [action] = { add | remove | build | install | uninstall | match | autoinstall | mkdriverdisk |" - echo $" mktarball | ldtarball | mkrpm | mkkmp | mkdeb | mkdsc | mkbmdeb | status }" + echo $" mktarball | ldtarball | mkrpm | mkkmp | status }" echo $" [options] = [-m module] [-v module-version] [-k kernel-version] [-a arch]" echo $" [-d distro] [-c dkms.conf-location] [-q] [--force] [--force-version-override] [--all]" echo $" [--templatekernel=kernel] [--directive='cli-directive=cli-value']" @@ -2145,40 +2145,6 @@ show_status() fi } -create_temporary_trees() -{ - [[ $module || $module_version || ! -r dkms.conf ]] && return 0 - - . dkms.conf - module="$PACKAGE_NAME" - module_version="$PACKAGE_VERSION" - - source_tree=$(mktemp_or_die -d) - dkms_tree=$(mktemp_or_die -d) - - local source_tree_dir="$source_tree/$PACKAGE_NAME-$PACKAGE_VERSION" - mkdir -p "$source_tree_dir" - cp -a * "$source_tree_dir" # intentionally skip .git or .hg - add_module - temporary_trees_del_command="rm -rf $source_tree $dkms_tree" -} - -delete_temporary_trees() -{ - [[ $temporary_trees_del_command ]] || return 0 - $temporary_trees_del_command - module= - module_version= - source_tree= - dkms_tree= - temporary_trees_del_command= -} - -in_temporary_trees() -{ - [[ $temporary_trees_del_command ]] -} - media_valid() { local mrx='^(floppy|iso|tar)$' @@ -2918,163 +2884,6 @@ make_rpm() trap > /dev/null 2>&1 } -preproc_file() -{ - local date_str="$(date -R)" - echo "modifying $1..." - sed -e "s/DEBIAN_PACKAGE/$debian_package/g" \ - -e "s/DEBIAN_BUILD_ARCH/$debian_build_arch/g" \ - -e "s/KERNEL_VERSION/$kernelver/g" \ - -e "s/MODULE_NAME/$module/g" \ - -e "s/MODULE_VERSION/$module_version/g" \ - -e "s/DATE_STAMP/$date_str/" "$1" > "$1.dkms-pp" - mv "$1.dkms-pp" "$1" -} - -# Install a package on a debian system. -debian_install() -{ - local getroot tmpfile i - local -a packages=("$@") - for ((i=0; i < ${#packages[@]}; i++)); do - dpkg-query -s "${packages[$i]}"| egrep -q '^Status:.* installed$' || continue - unset package[$i] - done - # if they are already installed, we are OK. - [[ ${package[@]} ]] || return - if [[ $(id -u) != 0 ]]; then - # figure out how to get root - for getroot in su-to-root gksudo kdesu sudo; do - which $getroot >/dev/null 2>&1 || continue - case $getroot in - su-to-root) - getroot="$getroot -c" - ;; - gksudo) - [[ $DISPLAY ]] || continue - getroot="$getroot --description 'DKMS Debian package builder' " - ;; - kdesu) - [[ $DISPLAY ]] || continue - ;; - esac - break - done - fi - if [[ -x /usr/sbin/synaptic && $DISPLAY ]] && tmpfile=$(mktemp_or_die); then - # Pretty GUI install. - trap 'rm -f "$tmpfile"' EXIT - for ((i=0; i=${#packages[@]}; i++)); do - [[ ${packages[$i]} ]] && echo "install ${packages[$i]}" >>$tmpfile - done - $getroot "sh -c '/usr/sbin/synaptic --set-selections --non-interactive --hide-main-window < $tmpfile'" - else - $getroot apt-get -y install "${packages[@]}" - fi - if (( $? != 0)); then - die 4 $"Missing ${packages[@]} and unable to install. Please ask an admin to install for you." - fi -} - -make_debian() -{ - create_type="$1" - - create_temporary_trees - trap "delete_temporary_trees" EXIT HUP TERM - - make_common_test "mk${create_type}" - - debian_package=${module//_/-} - if [[ $source_only ]]; then - debian_build_arch='all' - else - debian_build_arch=$(dpkg-architecture -qDEB_BUILD_ARCH) - fi - - # Read the conf file - read_conf_or_die "$kernelver" "$arch" - debian_install fakeroot dpkg-dev debhelper - - # Skeleton to load templates from - local system_mk="$dkms_tree/$module/$module_version/source/$module-dkms-mk${create_type}" - local local_mk="/etc/dkms/template-dkms-mk${create_type}" - if [[ -e ${system_mk} ]]; then - echo $"Using ${system_mk}" - DEBDIR=${system_mk} - elif [[ -e ${local_mk} ]]; then - echo $"Using ${local_mk}" - DEBDIR=${local_mk} - else - die 5 $"Cannot find ${local_mk} which is needed by DKMS in order to use mk${create_type}." - fi - - # Prepare build directory and copy template - local temp_dir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) - trap "rm -rf $temp_dir; delete_temporary_trees" EXIT HUP TERM - local temp_dir_debian="$temp_dir/$debian_package-dkms-$module_version" - invoke_command "cp -ar '$DEBDIR/' '$temp_dir_debian'" "copying template" - pushd "$temp_dir_debian" > /dev/null 2>&1 - for file in debian/*; do - preproc_file "$file" - chmod 755 "$file" - done - popd > /dev/null 2>&1 - - # If using legacy mode, install common postinst - if ((legacy_postinst != 0)); then - invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '$temp_dir_debian'" "copying legacy postinstall template" - fi - - # Calculate destination directory - deb_basedir=$dkms_tree/$module/$module_version/${create_type} - mkdir -p ${deb_basedir} >/dev/null 2>&1 - - # Create deb - pushd "$temp_dir_debian" > /dev/null 2>&1 - case "$create_type" in - dsc) - invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '$temp_dir_debian/$module-$module_version'" "Copying source tree" - invoke_command "dpkg-buildpackage -S -us -uc 1>/dev/null" "Building source package" || \ - die 7 $"There was a problem creating your ${create_type}." - invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_source.changes' '$temp_dir/${debian_package}-dkms_${module_version}.dsc' '$temp_dir/${debian_package}-dkms_${module_version}.tar.gz' '$deb_basedir'" "Moving built files to $deb_basedir" - ;; - deb) - invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '$temp_dir_debian/$module-$module_version'" "Copying source tree" - invoke_command "dpkg-buildpackage -rfakeroot -d -b -us -uc 1>/dev/null" "Building binary package" || \ - die 7 $"There was a problem creating your ${create_type}." - invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_${debian_build_arch}.deb' '$deb_basedir'" "Moving built files to $deb_basedir" - ;; - bmdeb) - local archive_location="$dkms_tree/$module/$module_version/tarball/$module-$module_version.dkms.tar.gz" - # Force binaries_only - binaries_only="binaries-only" - invoke_command "make_tarball" "Gathering binaries" - if [[ -f $archive_location ]]; then - invoke_command "cp '$archive_location' '$temp_dir_debian'" "Copying DKMS tarball into DKMS tree" - else - die 12 $"Unable to find created tarball." - fi - export KVER="$kernelver" - export KARCH="$arch" - invoke_command "dpkg-buildpackage -rfakeroot -d -b -us -uc 1>/dev/null" "Building binary package" || \ - die 7 $"There was a problem creating your ${create_type}." - invoke_command "mv '$temp_dir/${debian_package}-modules-${kernelver}_${module_version}_${debian_build_arch}.deb' '$deb_basedir'" "Moving built files to $deb_basedir" - ;; - esac - popd > /dev/null 2>&1 - - if in_temporary_trees; then - echo "Copying built files to "`pwd`"/.." >&2 - cp "${deb_basedir}/"* .. - fi - - # Cleanup - invoke_command "rm $temp_dir -fr" "Cleaning up temporary files" - delete_temporary_trees || \ - die 7 $"There was a problem cleaning up temporary files." -} - make_common_test() { local create_type=$1 @@ -3585,7 +3394,7 @@ die_is_fatal="yes" no_depmod="" modprobe_on_install="" -action_re='^(remove|(auto|un)?install|match|mk(driverdisk|tarball|rpm|deb|bmdeb|dsc|kmp)|(un)?build|add|status|ldtarball)$' +action_re='^(remove|(auto|un)?install|match|mk(driverdisk|tarball|rpm|kmp)|(un)?build|add|status|ldtarball)$' # Parse command line arguments while (($# > 0)); do @@ -3815,15 +3624,6 @@ for action_to_run in $action; do mkrpm) make_rpm ;; - mkdeb) - make_debian "deb" - ;; - mkbmdeb) - make_debian "bmdeb" - ;; - mkdsc) - make_debian "dsc" - ;; mkkmp) have_one_kernel "mkkmp" && make_kmp ;; diff --git a/dkms.8 b/dkms.8 index 2282383f..caf1e944 100644 --- a/dkms.8 +++ b/dkms.8 @@ -274,44 +274,6 @@ load this tarball, build and install modules on the end user's system. If you d not want your RPM to contain any prebuilt binaries, be sure to specify .B \-\-source\-only in the mkrpm command. -.SY mkdeb -.OP module/module\-version -.OP -k kernel/arch -.YS -.IP "" 4 -This action allows you to create a debian binary package for a specified module / version. -It uses a template debian directory found in -.I /etc/dkms/template\-dkms\-mkdeb -as the basis for the package. Alternatively, if DKMS finds a file called -.I /usr/src/\-/\-dkms\-mkdeb -it will use that folder instead. In general, a DKMS tarball is placed inside the -contents of this package, and the package itself calls various DKMS commands to -load this tarball, build and install modules on the end user's system. -.SY mkbmdeb -.OP module/module\-version -.OP -k kernel/arch -.YS -.IP "" 4 -Creates a Debian binary package containing just the binary modules in the /lib/modules -installation path. This package does not depend on dkms and does not require a toolchain -to be installed on the target host. Useful if you want to have a package to install on -hosts identical to the build system without installing the full toolchain on them. -It uses a template debian directory found in -.I /etc/dkms/template\-dkms\-mkbmdeb -as the basis for the package. -.SY mkdsc -.OP module/module\-version -.OP -k kernel/arch -.YS -.IP "" 4 -This action allows you to create a debian source package for a specified module / version. -It will create a .tar.gz, and a .dsc. All options supported by -.B mkdeb -are supported by it. The main difference in it's usage is that it will look in -.I /etc/dkms/template\-dkms\-mkdsc -as the basis for the package. Alternatively, if DKMS finds a file called -.I /usr/src/\-/\-dkms\-mkdsc -it will use that folder instead. .SY mkkmp .OP module/module\-version .OP --spec specfile @@ -468,11 +430,6 @@ This option can be used in conjunction with or .B mkrpm or -.B mkdeb -in order to create a DKMS tarball which does not contain any prebuilt -kernel module binaries within it. This is helpful if you simply want -to easily tar up your source but don't want anything prebuilt within -it. Likewise, if you are using .B mkrpm but do not want the RPM you create to have any prebuilt modules within it, passing this option will keep its internal DKMS tarball from containing any diff --git a/dkms.bash-completion b/dkms.bash-completion index 4e2206f9..a734af56 100644 --- a/dkms.bash-completion +++ b/dkms.bash-completion @@ -30,7 +30,7 @@ _dkms() if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "add autoinstall remove build unbuild install uninstall \ - match mkdriverdisk mktarball ldtarball mkrpm mkdeb mkdsc mkkmp \ + match mkdriverdisk mktarball ldtarball mkrpm mkkmp \ status" -- $cur ) ) else