BB file to build USBIP tools, looking for feedback. Was: building the kernel's usbipd daemon

chuck kamas

I have successfully gotten yocto to build the USBIP-tools directory by adding a bb recipe for it, see below. However, I am sure that I have violated ever good and reasonable best practice! Therefore I am looking for feedback on how to improve the recipe before I attempt to submit it for inclusion in the database.

Feedback is welcome and desired! So please comment.

The issues I had to solve to get this recipe to work are:

1) the kernel source is removed from the tmp/work-shared/raspberrypi-cm3/kernel-source when the kernel is done building. I have not figured out how to keep this code populated so that this recipe can access it.  I have tried adding

DEPENDS = "virtual/kernel"

but this did not seem to keep the code around. Is there a best practice for this?

2) the code is in kernel-source/tools/usb/usbip, and is based on autotools. However, those autotools are hidden behind a few scrips: -> runs "autoreconf -i -f -v"

and -> removes all of the autogen code.

The issue I am having is that these shell scripts are currently modifying the work-shared/... copy and not a local copy. Should I be concerned? If so how to copy the code to a more reasonable place and then modify it? I saw something in the comments of the code that seams to do this....

3) is there a way to use (or should I) the autotools.bbclass? I have taken some code out of there to properly setup for the configure step. However, I feel that this is a dumb solution and I would rather reuse a class here. But, as far as I can tell the autotools needs to load the code from git and then configure it, but I only need the tools/usb/usbip directory of the kernel.

4) If I were to use the autotools class it is looking for .config files, but these are generated by the autoreconf program. How do I get the class to kick this off? do_configure_prepend ()??

I think that is enough questions for now.

Thank you all for your help!


-----------------code start-----------------------

SUMMARY = "USBip part of Linux kernel built in tools"
DESCRIPTION = " USB/IP protocol allows to pass USB device from server to \
client over the network. Server is a machine which provides (shares) a \
USB device. Client is a machine which uses USB device provided by server \
over the network. The USB device may be either physical device connected \
to a server or software entity created on a server using USB gadget subsystem."

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
DEPENDS = "virtual/kernel libtool udev"
PROVIDES = "virtual/usbip-tools"

inherit linux-kernel-base kernel-arch kernelsrc manpages

do_populate_lic[depends] += "virtual/kernel:do_patch"
do_configure[depends] += "virtual/kernel:do_shared_workdir"

    -C ${S}/tools/usb/usbip \
    O=${B} \
    CC="${CC}" \
    CCLD="${CC}" \
    LD="${LD}" \
    AR="${AR}" \
    ARCH="${ARCH}" \
    TMPDIR="${B}" \

    'DESTDIR=${D}' \

do_configure[depends] += "virtual/kernel:do_shared_workdir"

inherit autotools gettext

# stolen from autotools.bbclass

          --host=${HOST_SYS} \
          --target=${TARGET_SYS} \
          --prefix=${prefix} \
          --exec_prefix=${exec_prefix} \
          --bindir=${bindir} \
          --sbindir=${sbindir} \
          --libexecdir=${libexecdir} \
          --datadir=${datadir} \
          --sysconfdir=${sysconfdir} \
          --sharedstatedir=${sharedstatedir} \
          --localstatedir=${localstatedir} \
          --libdir=${libdir} \
          --includedir=${includedir} \
          --oldincludedir=${oldincludedir} \
          --infodir=${infodir} \
          --mandir=${mandir} \
          --disable-silent-rules \
          ${@append_libtool_sysroot(d)} \

do_configure_prepend () {
    cd ${S}/tools/usb/usbip
    ./configure ${CONFIGUREOPTS} ${EXTRA_OECONF}

do_compile() {

do_install() {
    oe_runmake DESTDIR=${D} install


python do_package_prepend() {
    d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0])

B = "${WORKDIR}/${BPN}-${PV}"