Poudriere : How to make custom patches for ports and apply those patches using poudriere ?

If someone could describe this a bit in detail, for the handbook or howto's/faqs, that would be nice ...
You must be in the correct directory ; must create & place patches in the correct directory ; use make correct step i.e. extract/patch/ etc ; use correct patch flags ; etc ...
 
I'm not entirely sure I understand your goal, but creating patches for a port is rather easy.

make extract
cd work/portname # typically
cp fileiwanttocreatepatchfor fileiwanttocreatepatchfor.orig
vim fileiwanttocreatepatchfor # change what I want
cd /usr/ports/category/portname
make makepatch

This will create a patch in the files dir (/usr/ports/category/portname/files). If you run poudriere it picks up patches automatically from there.
 
If you have patches for existing ports, submit them. Then we can all benefit from them.
 
The port /usr/ports/audio/soundtouch quarterly is broken.
I created 3 diff files and if you apply them on the port the port will compile fine.

Here are the 3 very short diff files:

1.distinfo_diff1
Code:
c3
< SIZE (soundtouch-soundtouch-762f56024b7ade81f6565903161dffec0ad4741e_GL0.tar.gz) = 523946
---
> SIZE (soundtouch-soundtouch-762f56024b7ade81f6565903161dffec0ad4741e_GL0.tar.gz) = 523846
To apply "patch distinfo distinfo_diff1"

2.distinfo_diff2
Code:
2c2
< SHA256 (soundtouch-soundtouch-762f56024b7ade81f6565903161dffec0ad4741e_GL0.tar.gz) = b2515ce4a1b8b69e401ca9d442d1913b23b7447157a76939b2f8791118941bd1
---
> SHA256 (soundtouch-soundtouch-762f56024b7ade81f6565903161dffec0ad4741e_GL0.tar.gz) = e4c54cb6088e1d483eeb16d1fd6fc2236d2c7cd86e7141411d150099fb8a1da6
To apply "patch distinfo distinfo_diff2"

3. Makefile_diff1:
Code:
cat Makefile_diff1
32a33,39
> post-extract:
>       mkdir  ${WRKSRC}
>       cd    "${WRKSRC}/.."
>       rmdir  ${WRKSRC}
>       echo $PWD
>       ln -s ./soundtouch-762f56024b7ade81f6565903161dffec0ad4741e-762f56024b7ade81f6565903161dffec0ad4741e ${WRKSRC}
>
To apply "patch Makefile Makefile_diff1"

This procedure works because distfile /Makefile is part of the ports-tree. For patching c-files i don't know.
 
If you put your local patches in <ports path>/category/package/files/ and configure /usr/local/etc/poudriere.conf as follows:
# Packages which should never be fetched. This is useful for ports that
# you have local patches for as otherwise the patches would be ignored if
# a remote package is used instead.
PACKAGE_FETCH_BLACKLIST="package1 package2 package3"

You'll have the packages built with your patches.

Note:If you built the packages before, delete the built .pkg files to force rebuild them.
rm /usr/local/poudriere/data/packages/<jail name>-<ports name>/All/package1.pkg
rm /usr/local/poudriere/data/packages/<jail name>-<ports name>/All/package2.pkg
rm /usr/local/poudriere/data/packages/<jail name>-<ports name>/All/package3.pkg
 
If you put your local patches in <ports path>/category/package/files/
I suggest making a new branch of the ports tree. And commit your changes to that new branch. Then you can update the ports tree using git pull and rebase your changes on top of it. If you just put your changes in the ports tree git(1) is going to complain when you try to update the ports tree.
 
Then you can update the ports tree using git pull and rebase your changes on top of it.
This is something I am not sure about. It is likely very basic but once I have created a mess in a repository because of such an action. Since that time I am scared when it is about rebase.

Do I have to checkout the "official branch" before git pull and the rebase of my changes?
Do I have to apply the rebase after each git pull?
 
According to Dan Langille's work here: FreeBSD custom port patches when using poudriere, I made the
local-patches directory under /usr/local/etc/poudriere.d/ where I put my patches.
In the hooks directory under /usr/local/etc/poudriere.d/ I have the script jail.sh to mount the patches directory into my poudriere jail.

In my srv-make.conf I have the following lines according to my patch for security/sshguard
Makefile:
.if ${.CURDIR:M*/security/sshguard}
EXTRA_PATCHES+= /local-patches/patch-src_parser_attack__scanner.l
.endif
 
This is something I am not sure about. It is likely very basic but once I have created a mess in a repository because of such an action. Since that time I am scared when it is about rebase.
IMHO, any "good" GIT workflow is built around rebasing. Merges tend to mess up the history and turn it into a big ball of yarn.

Do I have to checkout the "official branch" before git pull and the rebase of my changes?
Do I have to apply the rebase after each git pull?

You don't even have to use git pull at all. Assuming you're on your "local" branch which is branched off "main", the following is enough:
Bash:
git fetch origin main:main # fetch latest main from origin into our local main
git rebase main # rebase our current branch onto the latest main
 
According to Dan Langille's work here: FreeBSD custom port patches when using poudriere, I made the
local-patches directory under /usr/local/etc/poudriere.d/ where I put my patches.
In the hooks directory under /usr/local/etc/poudriere.d/ I have the script jail.sh to mount the patches directory into my poudriere jail.

In my srv-make.conf I have the following lines according to my patch for security/sshguard
Makefile:
.if ${.CURDIR:M*/security/sshguard}
EXTRA_PATCHES+= /local-patches/patch-src_parser_attack__scanner.l
.endif
I've tried EXTRA_PATCHES method but i have a lot of patches for a window manager and when i tried, it failed at patching, So, the method that i found works for me.
 
On the thread in general, it mixes two different things:
  1. Patching upstream source. There are a few ways to do it:
    • A patch in the PATCHDIR (defaults to files) of the port, named patch-<something>. You'll probably want to use this, the ports framework includes simple tools (make makepatch) to create and update these patches.
    • A patch virtually anywhere in the tree, referenced by EXTRA_PATCHES from the port's Makefile.
    • A patch fetched as an additional distfile, used with PATCH_SITES and PATCH_FILES.
  2. Patching the ports tree itself. And sure, this might include adding patch files to some files dirs. Well, there are many ways to do it, but I'd say your own local git branch is the easiest (and even independent from poudriere). Git is actually more a very elaborate patch management system than a classic source control or revision control system. A branch in git is just a name for a specific commit. And a commit is a patch applied on top of the "parent" commit. You certainly see the "Linux heritage" here, which was for a long time developed without any source control at all, just with patches mailed around (oh the horrors!) ... but with a powerful tool like git, it suddenly is a very nice way to work with source.
 
Back
Top