dpkg-buildpackage 将补丁重新应用到 debian/rules

dpkg-buildpackage reapplies patches to debian/rules

我正在尝试通过修改 debian/rules 中的 prefix=/usr 行来构建带有自定义前缀的 libc6。但是,这失败了,因为多次应用了补丁。奇怪的是,修补 另一个 文件不会导致相同的错误。我已经将失败归结为这个脚本:

#!/bin/bash

set -exuo pipefail

work_dir=$(mktemp -d)
cd "$work_dir"

apt-get source libc6
cd eglibc-2.19

cat <<'PATCH' > ../set-prefix.diff
Index: eglibc-2.19/debian/rules
===================================================================
--- eglibc-2.19.orig/debian/rules>2022-03-01 17:27:53.068299816 -0800
+++ eglibc-2.19/debian/rules>-2022-03-01 17:27:53.068299816 -0800
@@ -85,7 +85,7 @@
 # Default setup
 EGLIBC_PASSES ?= libc

-prefix=/usr
+prefix=/new/prefix
 bindir=$(prefix)/bin
 datadir=$(prefix)/share
 localedir=$(prefix)/lib/locale
PATCH

cat <<'PATCH' > ../change-readme.diff
Index: eglibc-2.19/README
===================================================================
--- eglibc-2.19.orig/README     2013-10-18 14:33:25.000000000 -0700
+++ eglibc-2.19/README  2022-03-02 17:00:49.954759733 -0800
@@ -1,5 +1,7 @@
 This directory contains the Embedded GNU C Library (EGLIBC).

+Add a line.
+
 EGLIBC is a variant of the GNU C Library (GLIBC) that is designed to
 work well on embedded systems. EGLIBC strives to be source and binary
 compatible with GLIBC. EGLIBC's goals include reduced footprint,
PATCH

quilt import ../change-readme.diff -P any/change-readme.diff
quilt push

quilt import ../set-prefix.diff -P any/set-prefix.diff
quilt push

dpkg-buildpackage -us -uc -S -ai386

这是我看到的相关输出:

 dpkg-source -b eglibc-2.19
dpkg-source: info: using options from eglibc-2.19/debian/source/options: --compression=xz
dpkg-source: info: using source format `3.0 (quilt)'
dpkg-source: info: building eglibc using existing ./eglibc_2.19.orig.tar.xz
patching file debian/rules
Reversed (or previously applied) patch detected!  Skipping patch.
1 out of 1 hunk ignored
dpkg-source: info: fuzz is not allowed when applying patches
dpkg-source: info: if patch 'any/set-prefix.diff' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-source: error: LC_ALL=C patch -t -F 0 -N -p1 -u -V never -g0 -E -b -B .pc/any/set-prefix.diff/ --reject-file=- < eglibc-2.19.orig.yzNU0V/debian/patches/any/set-prefix.diff gave error exit status 1
dpkg-buildpackage: error: dpkg-source -b eglibc-2.19 gave error exit status 2

注释掉 set-prefix.diffquilt importquilt push 命令会成功,但当然前缀不会像我想要的那样更新。似乎补丁被应用了多次,这对大多数文件来说都很好,但 debian/rules - 也许这些补丁被应用在一个新的源目录上,但 debian/ 目录保持完好?

使用自定义前缀构建 libc6 而不会因重新应用补丁而导致 dpkg-buildpackage/dpkg-source 失败的推荐方法是什么?

debian/rules 目录是特殊的 [需要引用],不应使用通常的 quilt 命令进行修补。您可以在构建包之前直接修改它们或使用 patch 命令(在本例中为 patch -p1)。