Skip to content

Added build-deb.sh to create debian package for QUD kernel driver#31

Open
shasaror wants to merge 4 commits intomainfrom
QUD-1829-kernel-debian-support
Open

Added build-deb.sh to create debian package for QUD kernel driver#31
shasaror wants to merge 4 commits intomainfrom
QUD-1829-kernel-debian-support

Conversation

@shasaror
Copy link
Copy Markdown
Contributor

@shasaror shasaror commented Apr 30, 2026

Overview

This change introduces a Debian-package (.deb) build and install flow for the Qualcomm USB kernel driver (qud). The packager produces build/qud_<version>_all.deb, whose maintainer scripts handle dependency removal, kernel-header provisioning, and module build/load through the existing qcom_drivers.sh. The package is mutually exclusive with qualcomm-userspace-driver and lets dpkg perform an atomic swap between the two drivers.

Features

1. Resolves the dpkg lock-frontend conflict during userspace-driver removal

Earlier attempts had postinst call dpkg -r/--purge (or apt remove/purge) on qualcomm-userspace-driver from inside its own install script. This always failed with dpkg: error: dpkg frontend lock was locked by another process, because dpkg holds an exclusive lock on /var/lib/dpkg/lock-frontend for the full duration of any maintainer script — Debian Policy explicitly forbids a package from manipulating other packages during its own install. The 2nd commit is to delegate the removal to dpkg itself via Conflicts: qualcomm-userspace-driver / Replaces: qualcomm-userspace-driver / Breaks: qualcomm-userspace-driver in DEBIAN/control (with the symmetric declarations added to the userspace packager so both directions work). dpkg now removes the conflicting package automatically before our postinst runs, in the same transaction, with no nested package-manager calls.

2. Comprehensive install logging — /opt/qcom/QUD/qcom_kernel_install.log

Every step of the install flow - from script-permission setup to the final qcom_drivers.sh output — is captured in /opt/qcom/QUD/qcom_kernel_install.log. The log is reset by preinst on each install, and stages are framed by clearly-titled === banner blocks so a non-developer can read it top-to-bottom and tell exactly what happened, in what order, with what result. Uninstall events are written to a parallel file /opt/qcom/QUD/qcom_kernel_uninstall.log.

3. Handles cleanup of prior QUD installations and services

postinst runs a structured cleanup sequence before installing the new driver:

  • qpm-cli QUD removal - silently uninstalls any prior qud.internal, qud, or qud.slt packages that were installed via qpm-cli.
  • Legacy QUD driver cleanup - runs the bundled legacy/installer/QcDevDriver.sh uninstall if present, removing artifacts from older QUD layouts.
  • Service cleanup - stops, disables, and removes both the legacy QUDService.service and the current qcom-qud.service systemd units if present.

4. Ensures kernel headers for the running kernel

postinst checks for /lib/modules/$(uname -r)/build; if missing, it auto-installs linux-headers-$(uname -r) via apt-get install -y so the modules can be built against the running kernel. This currently lives in the postinst because it is Debian-specific. Future work will move this responsibility into qcom_drivers.sh itself so it is shared across all platforms (rpm-based, source-tarball installs, etc.).

5. Installs the latest QUD driver via qcom_drivers.sh

The unchanged, canonical install pipeline is reused: postinst's final step is (cd /opt/qcom/QUD/build && ./qcom_drivers.sh install). This builds the kernel modules with the headers from step 4, signs them when MOK keys are available, copies them under /lib/modules/$(uname -r)/, lays down udev rules, refreshes blacklists, and loads qtiDevInf, qcom_usb, and qcom_usbnet. prerm mirrors this with qcom_drivers.sh uninstall. Keeping the build/load logic in one shell script means the Debian flow stays a thin wrapper rather than a parallel implementation.

6. Picks the package version from version.h

build-deb.sh parses DRIVER_VERSION out of qcom-usb-kernel-drivers/src/linux/version.h at build time and stamps it into both the .deb filename (qud_<version>_all.deb) and the Version: field of DEBIAN/control. There are no hardcoded version strings in the packager - bumping version.h is the single source of truth, and dpkg -s qud | grep ^Version will always report the same value.

7. Packages only the essential payload

build-deb.sh packs the qcom-usb-kernel-drivers/src/linux/ tree (kernel sources, Makefile, qcom_drivers.sh, signing helpers, version.h, RELEASES.md, README.md, plus the bundled legacy installer) into the .deb, while explicitly excluding the build/ output directory and the packager script itself. Local kernel build artifacts (*.o, *.ko, *.mod*, *.cmd, Module.symvers, modules.order, .tmp_versions) are stripped from the payload, so a developer-machine make doesn't pollute releases. The full payload is unpacked under /opt/qcom/QUD/build/ on the target.

Signed-off-by: shasaror <shasaror@qti.qualcomm.com>
@shasaror shasaror requested review from 5656hcx and rohimish-qc April 30, 2026 20:15
@shasaror shasaror self-assigned this Apr 30, 2026
@shasaror shasaror added the enhancement New feature or request label Apr 30, 2026
shasaror added 3 commits May 6, 2026 10:57
Previously, our QUD Debian kernel installer attempted to remove
the qualcomm-userspace-driver package using dpkg purge as part
of its installation flow.
However, this approach led to failures and installer hangs.

When the QUD kernel installer is executed,dpkg already holds
an exclusive frontend lock on: /var/lib/dpkg/lock-frontend

As a result, any nested attempt within the same installer script to
invoke package management commands—such as:

dpkg -r / dpkg --purge
apt remove / apt purge

will fail and may cause the installer process to hang with the following error:
"dpkg: error: dpkg frontend lock was locked by another process"

This behavior is by design according to Debian policy: A package must not
attempt to manipulate other packages during its own installation lifecycle.

Solution:
Now, 'qualcomm-userspace-driver' is removed by dpkg itself before postinst runs,
via the Conflicts/Replaces/Breaks fields declared in DEBIAN/control.

Signed-off-by: shasaror <shasaror@qti.qualcomm.com>
Signed-off-by: shasaror <shasaror@qti.qualcomm.com>
Signed-off-by: shasaror <shasaror@qti.qualcomm.com>
@shasaror
Copy link
Copy Markdown
Contributor Author

shasaror commented May 6, 2026

changes looks good. I have tested throughly mutiple times along with userspace debian installer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant