# poudriere - Where do patches go? Where is the crescent . . .



## byrnejb (May 3, 2020)

I need to add a patch to SAMBA410 so that it can provision an AD on a ZFS FS.  The patch is contained in a file in the /root directory.  Obviously I can move that anywhere.

I have installed `poudriere` and created the tool chain.  I have also successfully built the unmodified `samba410` port in the `poudiere` jail.  I understand that to modify a package's make file requires an entry in `/usr/local/etc/poudriere.d/make.conf`.  I understand that it has to have a conditional for the port.  The question is how to specify the file.

The Makefile for samba410 contains this:


```
EXTRA_PATCHES+=                 ${PATCHDIR}/0001-Zfs-provision-1.patch:-p1
EXTRA_PATCHES+=                 ${PATCHDIR}/0001-provision-use-ASCII-quotes.patch:-p1
```

I infer from other languages that I have used that `EXTRA_PATCHES` is a string variable and that `EXTRA_PATCHES+` appends to it.  I have no idea what the string `:-p1` means or does but I suspect that this is the source of the problem that I have.


```
cat poudr_12-1_samba.txt

net/samba410

cat /usr/local/etc/poudriere.d/make.conf
                   
if ${.CURDIR:M*/net/samba410}
#EXTRA_PATCHES+= ${PATCHDIR}/patch-bfs-provisioning:-p1
EXTRA_PATCHES+= /root/patch-bfs-provisioning:-p1
.endif
```


```
poudriere bulk -C -f /root/poudr_12-1_samba.txt -j freebsd_12-1x64 -p PORTS-12-1
[00:00:00] Creating the reference jail... done
[00:00:01] Mounting system devices for freebsd_12-1x64-PORTS-12-1
[00:00:01] Mounting ports/packages/distfiles
[00:00:01] Using packages from previously failed build: /usr/local/poudriere/data/packages/freebsd_12-1x64-PORTS-12-1/.building
[00:00:01] Mounting packages from: /usr/local/poudriere/data/packages/freebsd_12-1x64-PORTS-12-1
[00:00:01] Copying /var/db/ports from: /usr/local/etc/poudriere.d/freebsd_12-1x64-PORTS-12-1-options
[00:00:01] Appending to make.conf: /usr/local/etc/poudriere.d/make.conf
/etc/resolv.conf -> /usr/local/poudriere/data/.m/freebsd_12-1x64-PORTS-12-1/ref/etc/resolv.conf
[00:00:01] Starting jail freebsd_12-1x64-PORTS-12-1
make: "/etc/make.conf" line 11: Missing dependency operator
make: "/etc/make.conf" line 14: if-less endif
make: Fatal errors encountered -- cannot continuemake: Unknown modifier ':'
make: Unknown modifier ':'
make: Unknown modifier ':'
make: "/etc/make.conf" line 11: Missing dependency operator
make: "/etc/make.conf" line 14: if-less endif
make: Fatal errors encountered -- cannot continueeval: make:: not found
export: make:: bad variable name
[00:00:01] Logs: /usr/local/poudriere/data/logs/bulk/freebsd_12-1x64-PORTS-12-1/2020-05-03_17h47m21s
[00:00:01] WWW: https://vhost04.hamilton.harte-lyne.ca//build.html?mastername=freebsd_12-1x64-PORTS-12-1&build=2020-05-03_17h47m21s
[00:00:01] Loading MOVED for /usr/local/poudriere/data/.m/freebsd_12-1x64-PORTS-12-1/ref/usr/ports
make: "/etc/make.conf" line 11: Missing dependency operator
make: "/etc/make.conf" line 14: if-less endif
make: Fatal errors encountered -- cannot continue[00:00:02] Error: Error looking up pre-build ports vars
[00:00:02] Cleaning up
[00:00:02] Unmounting file systems
```

What am I doing wrong?


----------



## suntzu00 (May 3, 2020)

I think you're missing a . (dot) before the 'if' and the patch has to be available within the jail I think. the DISTFILE_CACHE is by default in /usr/ports/distfiles. add a folder in there, move the patch in the newly created folder and adjust the path in make.conf
`mkdir /usr/ports/distfiles/patches
cp {patches} /usr/ports/distfiles/patches`


```
.if ${.CURDIR:M*/net/samba410}
#EXTRA_PATCHES+= ${PATCHDIR}/patch-bfs-provisioning:-p1
EXTRA_PATCHES+= /distfiles/patches/patch-bfs-provisioning
.endif
```

see if it helps


----------



## byrnejb (May 4, 2020)

suntzu00 said:


> I think you're missing a . (dot) before the 'if' and the patch has to be available within the jail I think. t



Yes, adding in the missing dot permits the build to go forward.  I will see if the patch gets picked up (or actually works if it is) when I test the build.

I would like to know the significance of the trailing `:-p1` and what `${.CURDIR:M*` actually refers to.  Obviously this part means the path to the port but what does the `:M*` mean?


----------



## SirDice (May 4, 2020)

byrnejb said:


> Obviously this part means the path to the port but what does the  :M* mean?


*M*atch *, i.e. everything. But it's actually `${.CURDIR:M*/some/where}`. So this matches if */some/where matches, with * being the shell wildcard. In other words, if the path ends with /some/where.


----------



## byrnejb (May 4, 2020)

SirDice said:


> *M*atch *, i.e. everything. But it's actually `${.CURDIR:M*/some/where}`. So this matches if */some/where matches, with * being the shell wildcard. In other words, if the path ends with /some/where.



Thank you.  What is the significance of the trailing`:-p1` after the patch file name?


----------



## SirDice (May 4, 2020)

byrnejb said:


> What is the significance of the trailing `:-p1` after the patch file name?


I honestly don't know in this context. I know what `EXTRA_PATCHES` does: https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/slow-patch.html#slow-patch-extra


----------



## memreflect (May 4, 2020)

byrnejb said:


> Thank you.  What is the significance of the trailing`:-p1` after the patch file name?


It's used in the context of `patch -p1 <patchfile`, which strips 1 directory from the path before applying the patch.  See patch(1).


----------

