Issue
I'm trying to build libc6 with a custom prefix by modifying the prefix=/usr
line in debian/rules
. However, this fails because the patch is applied multiple times. Curiously, patching another file does not result in the same error. I've distilled the failure down to this script:
#!/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
Here's the relevant output I'm seeing:
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
Commenting out the quilt import
and quilt push
commands for set-prefix.diff
results in success but of course the prefix isn't updated like I want. It seems like patches are getting applied multiple times which is fine for most files but not debian/rules
- maybe these patches are applied on a fresh source directory but the debian/
directory is left in tact?
What is the recommended way to build libc6 with a custom prefix without having dpkg-buildpackage
/dpkg-source
fail due to reapplying patches?
Solution
The debian/rules
directory is special [citation needed] and shouldn't be patched using the usual quilt
commands. You can modify them directly before building the package or use the patch
command (patch -p1
in this case).
Answered By - Marc Zych Answer Checked By - Willingham (WPSolving Volunteer)