Solved help patching port locally / patch to musicpd fails to apply



Reaction score: 14
Messages: 43

I have written support for DoP (DirectStreamDigital over PCM) in mpd when using OSS as output. Its really hacky but works. Now I want to integrate this (locally) into the port for mpd.

- I have created a patch file which will be appended, its structure was modified to match another patch included with mpd
- The patch follows the naming scheme used by patches in the port system
- The patch does work when manually applied

When building, the patch however fails to apply. The mentioned rejects is created but empty.

===>  License GPLv2+ accepted by the user
===>   musicpd-0.22.8 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by musicpd-0.22.8 for building
===>  Extracting for musicpd-0.22.8 => SHA256 Checksum OK for mpd-0.22.8.tar.xz.
===>  Patching for musicpd-0.22.8
===>  Applying FreeBSD patches for musicpd-0.22.8 from /usr/ports/audio/musicpd/files Ignoring previously applied (or reversed) patch. 16 out of 16 hunks ignored--saving rejects to src/output/plugins/OssOutputPlugin.cxx.rej
===>  FAILED Applying FreeBSD patch-src_output_plugins_OssOutputPlugin.cxx
===> FAILED to apply cleanly FreeBSD patch(es)  patch-src_output_plugins_OssOutputPlugin.cxx *** Error code 1 Stop. make[1]: stopped in /usr/ports/audio/musicpd *** Error code 1 Stop. make: stopped in /usr/ports/audio/musicpd

This is the output of manually patching. I assume that the prompt for a filename is because xxx.orig is not created.

❯ patch -p1 < ../../files/patch-src_output_plugins_OssOutputPlugin.c
Hmm...  Looks like a unified diff to me.
The text leading up to this wa
|--- src/output/plugins/OssOutputPlugin.cxx.orig    2021-06-10 14:50:00 U
|+++ src/output/plugins/OssOutputPlugin.c
File to patch: src/output/plugins/OssOutputPlugin.c
Patching file src/output/plugins/OssOutputPlugin.cxx using Plan A.
Reversed (or previously applied) patch detected!  Assume -R? [y]
Hunk #1 succeeded at 1
Hunk #2 succeeded at 5
Hunk #3 succeeded at 7
Hunk #4 succeeded at 14
Hunk #5 succeeded at 20
Hunk #6 succeeded at 30
Hunk #7 succeeded at 33
Hunk #8 succeeded at 34
Hunk #9 succeeded at 37
Hunk #10 succeeded at 42
Hunk #11 succeeded at 47
Hunk #12 succeeded at 51
Hunk #13 succeeded at 55
Hunk #14 succeeded at 57
Hunk #15 succeeded at 58
Hunk #16 succeeded at 66
Can't backup src/output/plugins/OssOutputPlugin.cxx, output is in /tmp/patchobGEDN82Imn: Permission denied done

The patch used is attached.

Thank you for your time and help with this.


  • patch-src_output_plugins_OssOutputPlugin.cxx.txt
    26.3 KB · Views: 34


Son of Beastie

Reaction score: 1,704
Messages: 2,870

  • Extract the port and apply patches that are already present: make patch
  • Apply your patch to the work source with patch -b to make sure to also create *.orig files
  • Execute make makepatch from the root of the port