bash
apt-get update
apt-get install build-essential
apt-get install dpkg-dev
apt-get build-dep libvirt
apt-get source --compile libvirt
apt-get source --compile libvirt
默认构建的方式是从已安装的版本构建,但是有时候需要从 github 构建, 这个命令不可行, 但是往往使用的起点都是 apt 安装好,然后发现 bug,然后尝试修复,然后回合到社区。
可以考虑把自己修复的 patch 放入这些目录下,然后继续构建。
可以看到 Debian 把 libvirt 当作上游已经有很多自己的 patch:
- backport:有回合的代码
- 也有属于自己操作系统定制的代码
- 也有目前自己修改的代码

dpkg-source: info: extracting libvirt in libvirt-9.0.0
dpkg-source: info: unpacking libvirt_9.0.0.orig.tar.xz
dpkg-source: info: unpacking libvirt_9.0.0-4+deb12u2.debian.tar.xz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying backport/apparmor-Allow-umount-dev.patch
dpkg-source: info: applying backport/qemu_interface-Fix-managed-no-case-when-creating-an-ether.patch
bash
▶ head -n 50 /tmp/build.log
Reading package lists...
NOTICE: 'libvirt' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/libvirt-team/libvirt.git
Please use:
git clone https://salsa.debian.org/libvirt-team/libvirt.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 9,111 kB of source archives.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main libvirt 9.0.0-4+deb12u2 (dsc) [5,537 B]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main libvirt 9.0.0-4+deb12u2 (tar) [9,007 kB]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main libvirt 9.0.0-4+deb12u2 (asc) [833 B]
Get:4 http://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main libvirt 9.0.0-4+deb12u2 (diff) [98.0 kB]
dpkg-source: info: extracting libvirt in libvirt-9.0.0
dpkg-source: info: unpacking libvirt_9.0.0.orig.tar.xz
dpkg-source: info: unpacking libvirt_9.0.0-4+deb12u2.debian.tar.xz
dpkg-source: info: using patch list from debian/patches/series
dpkg-source: info: applying backport/apparmor-Allow-umount-dev.patch
dpkg-source: info: applying backport/qemu_interface-Fix-managed-no-case-when-creating-an-ether.patch
dpkg-source: info: applying backport/qemu_domain-Don-t-unref-NULL-hash-table-in-qemuDomainRefr.patch
dpkg-source: info: applying backport/qemu-Jump-to-cleanup-label-on-umount-failure.patch
dpkg-source: info: applying backport/qemu_namespace-Deal-with-nested-mounts-when-umount-ing-de.patch
dpkg-source: info: applying backport/qemuProcessRefreshDisks-Don-t-skip-filling-of-disk-inform.patch
dpkg-source: info: applying backport/qemu_extdevice-Do-cleanup-host-only-for-VIR_DOMAIN_TPM_TY.patch
dpkg-source: info: applying backport/qemu-blockjob-Handle-pending-blockjob-state-only-when-we-.patch
dpkg-source: info: applying backport/rpc-client-Don-t-check-return-value-of-virNetMessageNew.patch
dpkg-source: info: applying backport/rpc-Don-t-warn-about-max_client_requests-in-single-thread.patch
dpkg-source: info: applying backport/conf-Fix-migration-in-some-firmware-autoselection-scenari.patch
dpkg-source: info: applying backport/virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch
dpkg-source: info: applying backport/virsh-Make-domif-setlink-work-more-than-once.patch
dpkg-source: info: applying backport/storage-Fix-returning-of-locked-objects-from-virStoragePo.patch
dpkg-source: info: applying backport/Fix-off-by-one-error-in-udevListInterfacesByStatus.patch
dpkg-source: info: applying backport/remote-check-for-negative-array-lengths-before-allocation.patch
dpkg-source: info: applying backport/interface-fix-udev_device_get_sysattr_value-return-value-.patch
dpkg-source: info: applying backport/qemu-domain-Fix-logic-when-tainting-domain.patch
dpkg-source: info: applying backport/qemu_process-Skip-over-non-virtio-non-TAP-NIC-models-when.patch
dpkg-source: info: applying backport/apparmor-Allow-running-i686-VMs-on-Debian-12.patch
dpkg-source: info: applying forward/Skip-vircgrouptest.patch
dpkg-source: info: applying forward/Reduce-udevadm-settle-timeout-to-10-seconds.patch
dpkg-source: info: applying forward/Pass-GPG_TTY-env-var-to-the-ssh-binary.patch
dpkg-source: info: applying debian/Debianize-libvirt-guests.patch
dpkg-source: info: applying debian/Debianize-systemd-service-files.patch
dpkg-source: info: applying debian/apparmor_profiles_local_include.patch
dpkg-source: info: applying debian/Use-sensible-editor-by-default.patch
dpkg-source: info: applying debian/Disable-passt-support.patch
dpkg-buildpackage: info: source package libvirt
dpkg-buildpackage: info: source version 9.0.0-4+deb12u2
dpkg-buildpackage: info: source distribution bookworm
dpkg-buildpackage: info: source changed by Andrea Bolognani <[email protected]>
dpkg-buildpackage: info: host architecture amd64
dpkg-source: info: using options from libvirt-9.0.0/debian/source/options: --tar-ignore=debian/gbp.conf --tar-ignore=debian/salsa-ci.yml --tar-ignore=debian/scripts
dh clean --builddirectory=/root/gitee/libvirt-9.0.0/debian/build