mkdeb without dkms add

Bug #238864 reported by Martin Pitt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DKMS
Fix Released
Undecided
Unassigned

Bug Description

It would be really nice if mkdeb, mkrpm, etc. would work without needing to "dkms add" the driver first. The latter needs special privileges to write into /usr/src, and also disrupts an already installed version of the driver to be packaged. For developing and packaging drivers it would generally be preferable to not deal with any system directory. Would it be possible to do "dkms mkdeb --sourcedir /path/to/source"?

Revision history for this message
Matt Domsch (matt-domsch) wrote :

This would take some work; additionally, it would only be useful for --source-only debs, because dkms looks in the /var/lib/dkms/<module>/<version>/<kernel> directory for the built modules to include.

You can avoid use of system directories by editing /etc/dkms_framework.conf to point at other locations for which you do have write permissions. I'd accept a patch to make it use an alternate configuration file.

Revision history for this message
Martin Pitt (pitti) wrote :

Hmm, taking a closer look at the manpage: "Note that these variables can also be manipulated on the command line with the undocumented --dkmstree, --sourcetree and --installtree options. Whoops, did I just document these?"

I think that provides pretty much what I need. :-)

So, with a series of two or three commands, the current version can achieve what I have in mind. Shall I leave this open and work on a more integrated solution to produce a .deb/.rpm from a source tree with just one command (no adding, etc.)? Or do you want to leave the design as it is?

Thanks! Martin

Revision history for this message
Mario Limonciello (superm1) wrote : RE: [Bug 238864] Re: mkdeb without dkms add

Matin,

I sent Matt some patches to make those clearer and also to add a new --dkmsframework option to include them in a framework for a particular package.

I'll let you know when he gets a chance to look them over/add them.

Mario Limonciello
Dell | Linux Engineering
<email address hidden>

-----Original Message-----
From: <email address hidden> on behalf of Martin Pitt
Sent: Wed 6/11/2008 4:56 AM
To: <email address hidden>
Subject: [Bug 238864] Re: mkdeb without dkms add

Hmm, taking a closer look at the manpage: "Note that these variables
can also be manipulated on the command line with the undocumented
--dkmstree, --sourcetree and --installtree options. Whoops, did I just
document these?"

I think that provides pretty much what I need. :-)

So, with a series of two or three commands, the current version can
achieve what I have in mind. Shall I leave this open and work on a more
integrated solution to produce a .deb/.rpm from a source tree with just
one command (no adding, etc.)? Or do you want to leave the design as it
is?

Thanks! Martin

--
mkdeb without dkms add
https://bugs.launchpad.net/bugs/238864
You received this bug notification because you are a member of The Dell
Team, which is subscribed to Dell Ubuntu Project.

Revision history for this message
Mario Limonciello (superm1) wrote :

Additionally, mkdeb needed improvements to allow this to all happen properly as not root if i remember correctly.

Mario Limonciello
Dell | Linux Engineering
<email address hidden>

-----Original Message-----
From: <email address hidden> on behalf of Martin Pitt
Sent: Wed 6/11/2008 4:56 AM
To: <email address hidden>
Subject: [Bug 238864] Re: mkdeb without dkms add

Hmm, taking a closer look at the manpage: "Note that these variables
can also be manipulated on the command line with the undocumented
--dkmstree, --sourcetree and --installtree options. Whoops, did I just
document these?"

I think that provides pretty much what I need. :-)

So, with a series of two or three commands, the current version can
achieve what I have in mind. Shall I leave this open and work on a more
integrated solution to produce a .deb/.rpm from a source tree with just
one command (no adding, etc.)? Or do you want to leave the design as it
is?

Thanks! Martin

--
mkdeb without dkms add
https://bugs.launchpad.net/bugs/238864
You received this bug notification because you are a member of The Dell
Team, which is subscribed to Dell Ubuntu Project.

Revision history for this message
Martin Pitt (pitti) wrote :

Mario Limonciello [2008-06-11 15:06 -0000]:
> Additionally, mkdeb needed improvements to allow this to all happen
> properly as not root if i remember correctly.

Not really. Of course you need to have fakeroot installed to build the
.deb, but that's not related to dkms. I have changed my make-dkms.sh
to set up two temporary dirs and use --sourcetree and --dkmstree,
which works wonderfully.

Thus from my side this issue is settled, and we can close this unless
you actually want to make it more slick upstream.

Thanks!

Revision history for this message
Matt Domsch (matt-domsch) wrote :

per martin, current code is good enough. :-)

Changed in dkms:
status: New → Fix Released
Changed in dell:
status: New → Fix Released
Revision history for this message
Robie Basak (racb) wrote :

Hi,

Could I ask that you please publish a suitable make-dkms.sh in /usr/share/doc/dkms/examples or even /usr/bin?

What I have is a dkms source tree (the contents of what goes in /usr/src/module-version) that contains a directory module-version-mkdeb. This for me is the canonical source; I'd like to put it in revision control and have a single command that builds me a deb.

I think that this is surely a pretty common case, so it would be nice to have a supplied command that does it all for me.

I can put something together and contribute it if you'd accept it - but could I please have your make-dkms.sh as a starting point?

Thanks!

Revision history for this message
Martin Pitt (pitti) wrote :

Robie,

sure, the script I used for the v4l-dvb backport is at http://people.ubuntu.com/~pitti/scripts/make-v4l-dkms.sh

However, this isn't very generic. For the casual KMP backport you just have one or two .ko's, and thus can easily write a dkms.conf by hand. However, because the v4l-dvb tree has over 200 kernel modules, and changes often, I found that impractical and instead wrote a shell script to generate it for me.

But if it helps you in any way, so much the better.

Revision history for this message
Robie Basak (racb) wrote : [PATCH] mkdeb without dkms add

Hi,

I've integrated support for mkdeb without dkms add into the dkms script
itself.

The mechanism is simple: -m and -v are required for most (all)
operations, and not supplying -m and -v didn't previously have any
meaning and was an error.

Now, if -m and -v are not supplied, then it is taken that you are in a
working copy of your DKMS source tree - for example if you manage this
using git or hg.

It is assumed that dkms.conf exists in the current directory and defines
the name and version of the module.

So now you can run, for example, "dkms mkdeb --source-only" from the
root of this working copy and you'll end up with a .deb in the parent
directory.

This should not break any existing functionality as the new mode of
operation only takes place if -m and -v aren't specified, which
previously was an error.

Robie.

Revision history for this message
Robie Basak (racb) wrote : [PATCH 1/2] make_debian: added missing popd for corresponding pushd

---
 dkms | 1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/dkms b/dkms
index 5d94435..ef4df63 100755
--- a/dkms
+++ b/dkms
@@ -3143,6 +3143,7 @@ function make_debian()
             invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_all.deb' '$deb_basedir'" "Moving built files to $deb_basedir"
             ;;
     esac
+ popd > /dev/null 2>&1

     #cleanup
     invoke_command "rm $temp_dir -fr" "Cleaning up temporary files"
--
1.5.6.3

Revision history for this message
Robie Basak (racb) wrote : [PATCH 2/2] make_debian: added temporary tree support
Download full text (3.3 KiB)

Previously, -m and -v were required in order to identify the module
being worked on.

Now, if neither -m nor -v are supplied, it is assumed that the current
directory is a working copy of a DKMS source tree. A temporary source
tree is created by taking a copy of the current directory, a temporary
DKMS tree is created, the source tree added, and a DKMS package
generated in the parent directory.

For example, from a working copy of a DKMS source tree:
    dkms mkdeb --source-only

Currently only the mkdeb and mkdsc commands are supported for use in
this fashion, but a framework exists to add support for other commands
in the future.
---
 dkms | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/dkms b/dkms
index ef4df63..17c9ef4 100755
--- a/dkms
+++ b/dkms
@@ -1966,6 +1966,46 @@ show_status ()
     fi
 }

+function create_temporary_trees ()
+{
+ if [ -n "$module" ] || [ -n "$module_version" ]; then
+ return
+ fi
+
+ [ -r dkms.conf ] || return
+
+ . dkms.conf
+ module="$PACKAGE_NAME"
+ module_version="$PACKAGE_VERSION"
+
+ source_tree=`mktemp -d`
+ dkms_tree=`mktemp -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"
+}
+
+function delete_temporary_trees ()
+{
+ $temporary_trees_del_command
+ if [ -n "$temporary_trees_del_command" ]; then
+ module=
+ module_version=
+ source_tree=
+ dkms_tree=
+ temporary_trees_del_command=
+ fi
+}
+
+function in_temporary_trees ()
+{
+ [ -n "$temporary_trees_del_command" ]
+ return $?
+}
+
 media_valid()
 {
     if [ "$media" == "floppy" ] ||
@@ -3001,6 +3041,9 @@ function make_debian()
 {
     create_type="$1"

+ create_temporary_trees
+ trap "delete_temporary_trees" EXIT HUP TERM
+
     make_common_test "mk${create_type}"

     debian_package=$(echo $module | sed s/_/-/)
@@ -3052,7 +3095,7 @@ function make_debian()
             echo $INSTALL_PACKAGES | sed 's/|/\ install\
 /g' > $TEMPFILE
             $ROOT "sh -c '/usr/sbin/synaptic --set-selections --non-interactive --hide-main-window < $TEMPFILE'"
- trap 'rm -f $TEMPFILE' EXIT HUP TERM
+ trap "rm -f $TEMPFILE; delete_temporary_trees" EXIT HUP TERM
         else
             $ROOT apt-get -y install $INSTALL_PACKAGES
         fi
@@ -3106,7 +3149,7 @@ function make_debian()

     #prepare build directory and copy template
     local temp_dir=`mktemp -d $tmp_location/dkms.XXXXXX`
- trap 'rm -rf $temp_dir' EXIT HUP TERM
+ 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
@@ -3145,8 +3188,14 @@ function make_debian()
     esac
     popd > /dev/null 2>&1

+ if in_temporary_trees; then
+ echo "Copying built files to "`pwd`"/.." >&2
+ cp "$dkms_tree/$module/$module_version/deb/"* ..
+ fi
+
     #c...

Read more...

Revision history for this message
Mario Limonciello (superm1) wrote :
Download full text (3.6 KiB)

Committed. Thanks

Robie Basak wrote:
> Previously, -m and -v were required in order to identify the module
> being worked on.
>
> Now, if neither -m nor -v are supplied, it is assumed that the current
> directory is a working copy of a DKMS source tree. A temporary source
> tree is created by taking a copy of the current directory, a temporary
> DKMS tree is created, the source tree added, and a DKMS package
> generated in the parent directory.
>
> For example, from a working copy of a DKMS source tree:
> dkms mkdeb --source-only
>
> Currently only the mkdeb and mkdsc commands are supported for use in
> this fashion, but a framework exists to add support for other commands
> in the future.
> ---
> dkms | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 51 insertions(+), 2 deletions(-)
>
> diff --git a/dkms b/dkms
> index ef4df63..17c9ef4 100755
> --- a/dkms
> +++ b/dkms
> @@ -1966,6 +1966,46 @@ show_status ()
> fi
> }
>
> +function create_temporary_trees ()
> +{
> + if [ -n "$module" ] || [ -n "$module_version" ]; then
> + return
> + fi
> +
> + [ -r dkms.conf ] || return
> +
> + . dkms.conf
> + module="$PACKAGE_NAME"
> + module_version="$PACKAGE_VERSION"
> +
> + source_tree=`mktemp -d`
> + dkms_tree=`mktemp -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"
> +}
> +
> +function delete_temporary_trees ()
> +{
> + $temporary_trees_del_command
> + if [ -n "$temporary_trees_del_command" ]; then
> + module=
> + module_version=
> + source_tree=
> + dkms_tree=
> + temporary_trees_del_command=
> + fi
> +}
> +
> +function in_temporary_trees ()
> +{
> + [ -n "$temporary_trees_del_command" ]
> + return $?
> +}
> +
> media_valid()
> {
> if [ "$media" == "floppy" ] ||
> @@ -3001,6 +3041,9 @@ function make_debian()
> {
> create_type="$1"
>
> + create_temporary_trees
> + trap "delete_temporary_trees" EXIT HUP TERM
> +
> make_common_test "mk${create_type}"
>
> debian_package=$(echo $module | sed s/_/-/)
> @@ -3052,7 +3095,7 @@ function make_debian()
> echo $INSTALL_PACKAGES | sed 's/|/\ install\
> /g' > $TEMPFILE
> $ROOT "sh -c '/usr/sbin/synaptic --set-selections
> --non-interactive --hide-main-window < $TEMPFILE'"
> - trap 'rm -f $TEMPFILE' EXIT HUP TERM
> + trap "rm -f $TEMPFILE; delete_temporary_trees" EXIT HUP
> TERM
> else
> $ROOT apt-get -y install $INSTALL_PACKAGES
> fi
> @@ -3106,7 +3149,7 @@ function make_debian()
>
> #prepare build directory and copy template
> local temp_dir=`mktemp -d $tmp_location/dkms.XXXXXX`
> - trap 'rm -rf $temp_dir' EXIT HUP TERM
> + 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...

Read more...

Revision history for this message
Mario Limonciello (superm1) wrote : Re: [PATCH 1/2] make_debian: added missing popd for corresponding pushd

Committed. Thanks

Robie Basak wrote:
> ---
> dkms | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/dkms b/dkms
> index 5d94435..ef4df63 100755
> --- a/dkms
> +++ b/dkms
> @@ -3143,6 +3143,7 @@ function make_debian()
> invoke_command "mv
> '$temp_dir/${debian_package}-dkms_${module_version}_all.deb'
> '$deb_basedir'" "Moving built files to $deb_basedir"
> ;;
> esac
> + popd > /dev/null 2>&1
>
> #cleanup
> invoke_command "rm $temp_dir -fr" "Cleaning up temporary files"
>

--
Mario Limonciello
*Dell | Linux Engineering*
<email address hidden>

Changed in somerville:
status: New → Fix Released
no longer affects: dell
Revision history for this message
Timothy R. Chavez (timrchavez) wrote :

The bug task for the somerville project has been removed by an automated script. This bug has been cloned on that project and is available here: https://bugs.launchpad.net/bugs/1305631

no longer affects: somerville
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.