blob: 47938969bb28093ce7d4dc5e8999048b010277c2 [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001# Recipe for building userspace part of USB/IP
2#
3# Started with work from chuck kamas - 2021-11-05
4# https://lists.yoctoproject.org/g/yocto/topic/86249103?p=,,,20,0,0,0::recentpostdate/sticky,,,20,0,0,86249103
5# Though have rewritten all the logic to be much simpler
6#
7# SPDX-License-Identifier: MIT
8#
9# Author(s)
10# clst@ambu.com (Claus Stovgaard)
11#
12
13SUMMARY = "userspace usbip from Linux kernel tools"
14DESCRIPTION = " USB/IP protocol allows to pass USB device from server to \
15client over the network. Server is a machine which provides (shares) a \
16USB device. Client is a machine which uses USB device provided by server \
17over the network. The USB device may be either physical device connected \
18to a server or software entity created on a server using USB gadget subsystem."
19
Andrew Geissler9aee5002022-03-30 16:27:02 +000020LICENSE = "GPL-2.0-only"
Andrew Geissler595f6302022-01-24 19:11:47 +000021LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
22DEPENDS = "virtual/kernel udev"
23PROVIDES = "virtual/usbip-tools"
24
25inherit kernelsrc autotools-brokensep
26
27do_configure[depends] += "virtual/kernel:do_shared_workdir"
28
29# We need to set S, for not being set to STAGING_KERNEL_DIR, and by that
30# be wiped when we prune dest below. We just set it to usbip-tools-1.0
31S = "${WORKDIR}/${BP}"
32
33# Copy the source files from KERNEL/tools/usb/usbip to ${S}
34do_configure[prefuncs] += "copy_usbip_source_from_kernel"
35python copy_usbip_source_from_kernel() {
36 dir_in_kernel = "tools/usb/usbip"
37 src_dir = d.getVar("STAGING_KERNEL_DIR")
38 src = oe.path.join(src_dir, dir_in_kernel)
39 dest = d.getVar("S")
40 bb.utils.mkdirhier(dest)
41 bb.utils.prunedir(dest)
42 # copy src to dest folder
43 if not os.path.exists(src):
44 bb.fatal("Path does not exist: %s. Maybe dir_in_kernel does not match the kernel version." % src)
45 if os.path.isdir(src):
46 oe.path.copyhardlinktree(src, dest)
47 else:
48 src_path = os.path.dirname(src)
49 os.makedirs(os.path.join(dest,src_path),exist_ok=True)
50 bb.utils.copyfile(src, dest)
51}
52
53# Use local scripts before relying on inherited autotools
54do_configure () {
55 # We are in ${B} - equal to ${S}, so just run the scripts
56 ./cleanup.sh || bbnote "${PN} failed to cleanup.sh"
57 ./autogen.sh || bbnote "${PN} failed to autogen.sh"
58 oe_runconf
59}
60
61# As usbip integrate with the kernel module, we set this package to be build specific for
62# this machine, and not generally for the architecture
63PACKAGE_ARCH = "${MACHINE_ARCH}"
64
65# Even though the libusbip is set to version 0.0.1, set the package version to match kernel
66# e.g. usbip-tools-5.14.21-r0.qemux86_64.rpm for qemu package using kernel 5.14.21
67python do_package:prepend() {
68 d.setVar('PKGV', d.getVar("KERNEL_VERSION", True).split("-")[0])
69}