I have a file with DOS-style line endings in an *.orig.tar.xz source package that I need to patch before building a 3.0 (quilt) debian package. My patch currently has unix-style line endings.
We can inspect the files to see the patch has 29 unix-style line ending, and the source file has 5000 dos-style line endings.
$ dos2unix -i debian/patches/model_icd CONFIG/model_config_file.txt 0 29 0 no_bom text debian/patches/model_icd 5000 0 0 no_bom text CONFIG/model_config_file.txt Building results:
$ dpkg-buildpackage ... dpkg-source --before-build . dpkg-source: info: using patch list from debian/patches/series dpkg-source: info: applying model_icd patching file CONFIG/model_config_file.txt Hunk #1 FAILED at 1638 (different line endings). Hunk #2 FAILED at 4997 (different line endings). 2 out of 2 hunks FAILED dpkg-source: info: the patch has fuzz which is not allowed, or is malformed dpkg-source: info: if patch 'model_icd' is correctly applied by quilt, use 'quilt refresh' to update it dpkg-source: info: restoring quilt backup files for model_icd dpkg-source: error: LC_ALL=C patch -t -F 0 -N -p1 -u -V never -E -b -B .pc/model_icd/ --reject-file=- < debian/patches/model_icd subprocess returned exit status 1 dpkg-buildpackage: error: dpkg-source --before-build . subprocess returned exit status 2 Things I've tried:
First, I simply modified my patch to use dos-style line endings, but quilt strips that out and I get the same result
$ unix2dos debian/patches/model_icd $ dos2unix -i debian/patches/model_icd CONFIG/model_config_file.txt 29 0 0 no_bom text debian/patches/model_icd 5000 0 0 no_bom text CONFIG/model_config_file.txt $ dpkg-buildpackage ... dpkg-source: info: applying model_icd (Stripping trailing CRs from patch; use --binary to disable.) patching file CONFIG/model_config_file.txt Hunk #1 FAILED at 1638 (different line endings). Hunk #2 FAILED at 4997 (different line endings). 2 out of 2 hunks FAILED ... If I test with quilt directly, I can get it to work with the --binary option:
$ quilt push -a --binary Applying patch model_icd patching file CONFIG/model_config_file.txt Now at patch model_icd To get this to work more automatically, I've tried setting QUILT_PATCH_OPTS=:
$ QUILT_PATCH_OPTS="--binary" quilt push -a Applying patch model_icd patching file CONFIG/model_config_file.txt Now at patch model_icd So next, I tried setting this in debian/rules:
export QUILT_PATCH_OPTS="--binary" %: dh $@ But this doesn't get used by dpkg-source which uses patch directly, not quilt
Next, I tried to fool it by setting this flag in the patches/series file. dpkg-source(1) recommends against this, which suggests it could be possible.
# debian/patches/series model_icd --binary But that still doesn't work.
I've tried looking in source/options hoping for something, and I've been reading the maintainer's guide but I don't see this covered anywhere.
patchoptions inpatches/series, note that thedpkg-sourceman page doesn’t just recommend against it: “it does ignore those options and always expects patches that can be applied with the-p1option ofpatch.”