8.114. Libusb-1.0.28

8.114.1. Introduction to libusb

The libusb package contains a library used by some applications for USB device access.

Approximate build time: 0.1 SBU
Required disk space: 5.7 MB

8.114.2. Installation of libusb

Create the PKGBUILD for the libusb package with the following commands:

mkdir /sources/libusb
cd /sources/libusb
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="libusb"
pkgver="1.0.28"
pkgrel="1"
pkgdesc="Contains a library used by some applications for USB device access"
arch=('x86'
      'x86_64')
url="https://github.com/libusb"
license=('GPL3')
groups=('core')
depends=('glibc')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'gettext'
             'make'
             'sed'
             'texinfo')
optdepends=('doxygen')
source=('https://github.com//libusb/libusb/releases/download/v1.0.28/libusb-1.0.28.tar.bz2')
md5sums=('4022135a84975b292cf48381fbc8ffd8')

prepare()
  cd "${pkgname}-${pkgver}"
  # Prevent a warning when building documentation
  sed -i "s/^PROJECT_LOGO/#&/" doc/doxygen.cfg.in
{

build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr --disable-static
  # This package does not build correctly in parallel
  make -j1
}

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp libusb-1.0.28-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/libusb-1.0.28-1-$(uname -m).pkg.tar.xz

Update the local cache and install the libusb package:

pacman -Syu
pacman -S libusb --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/libusb
cp PKGBUILD /srv/pacman/source/LFS/libusb
cd /sources
rm -rf libusb

8.114.3. Configuring Libusb

To access raw USB devices (those not treated as a disk by the mass-storage driver), appropriate support must be available in the kernel. Check your kernel configuration:

Device Drivers --->
  [*] USB support --->                   [CONFIG_USB_SUPPORT]
    <*/M> Support for Host-side USB      [CONFIG_USB]
    (Select any USB hardware device drivers you may need on the same page)

8.114.4. Contents

Installed Library: libusb-1.0.so
Installed Directories: /usr/include/libusb-1.0 and /usr/share/doc/libusb-1.0.28

Short Descriptions

libusb-1.0

contains API functions used for accessing USB hardware.