Can I use rpm macros in a patch file?

Is it possible to use rpm macros in a patch like this?

--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -23,10 +23,10 @@ import (
 var testParentDir = ""
 
 // GocryptfsBinary is the assumed path to the gocryptfs build.
-const GocryptfsBinary = "../../gocryptfs"
+const GocryptfsBinary = "%{gobuilddir}/bin/gocryptfs"
 
 // UnmountScript is the fusermount/umount compatibility wrapper script
-const UnmountScript = "../../tests/fuse-unmount.bash"
+const UnmountScript = "%{gobuilddir}/src/%{goipath}/tests/fuse-unmount.bash"
 
 // X255 contains 255 uppercase "X". This can be used as a maximum-length filename.
 var X255 string
1 Like

Is there a corresponding environment variable I can use instead?

1 Like

No.

RPM macros are not evaluated in SOURCES or PATCHES.

The common way is to call sed in %prep or %build section of SPEC file.

2 Likes

Thank you :slightly_smiling_face:

1 Like