This folder contains my patches for various pkgsrc packages. This README describes how to create and apply them. = Modifying a package = cd /usr/pkgsrc/path-to/package make fetch cd /usr/pkgsrc/distfiles tar xf archived-package.tgz cd extracted-package/ git init I like tracking my modifications with Git, if only temporarily. = Generating a patch = cd /path-to/extracted-package/ git diff ... | conv -i The resulting patch will be placed in ~/patches. = Applying a patch = Be sure to set the LOCALPATCHES variable in mk.conf: echo LOCALPATCHES = $HOME/patches >> /etc/mk.conf After that, local patches will be applied automatically, assuming they are formatted correctly and placed in the correct directory. = Undoing patches = In order to undo all patches, you need to extract the original files from the downloaded archive. cd /usr/pkgsrc/path-to/package w=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo) cd $(dirname $w) tar xf $w cd - find . -name '*.orig' | while read f; do f=${f%.orig} cp $w/${f#work/} $f done It is not reliable to restore the original files using the .orig files, as multiple patches may have been applied to the same file. = Rebuilding with new patch = First, you may want to undo the old patches as described above. make do-patch make do-build The first step will complain if patches have already been applied (and not undone), but your new patch should be applied regardless.