diff options
author | Callum Parsey | 2023-06-26 14:22:07 +0930 |
---|---|---|
committer | Callum Parsey | 2023-06-26 14:22:07 +0930 |
commit | f88d85097343a5c917236f20deb4e1e949a6fe6d (patch) | |
tree | 6eb59f2586a50a27631ee8cdd32a795b99f4d697 | |
parent | c1200a44e58f8e5df2ae1f0a39d5e0ecd6136bff (diff) | |
download | aur-f88d85097343a5c917236f20deb4e1e949a6fe6d.tar.gz |
Patch headers to support new install location
After CMake has finished installing the header files in the package
directory, a pass is run over all of them to replace all instances of
`# include <Quotient/` with `# include <QuotientE2EE/` to ensure that
the nested header includes work against the new install location. The
regular expression I used is sufficiently flexible to support a variety
of white-space scenarios and should be future-proofed for the inclusion
of new headers in the future.
-rw-r--r-- | PKGBUILD | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -53,4 +53,37 @@ build() { package() { DESTDIR="${pkgdir}" cmake --install build install -Dm644 "libQuotient-${pkgver}/README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md" + + # The header files expect to be installed in a system directory called + # `Quotient` as evidenced by their nested include statements. Since we + # install the headers to `/usr/include/QuotientE2EE` to prevent conflicts + # with software that use the official non-encryption package, we need to + # adjust the include statements in the headers to make sure that the right + # ones are used. We can't do this in the `prepare()` step because the build + # system stores the headers alongside the source code in a directory called + # `Quotient` and we therefore cannot change the include statements without + # also moving the entire source tree. So we have to let the library compile + # with unmodified headers, and then change them after CMake has installed + # them to the right place. + # + # Reference: + # - `s/<expression>/<replacement>/g` means to replace all instances of text + # which match the provided basic regular expression with the provided + # replacement text + # - The content of the expression between `\(` and `\)` represents a + # sub-expression. The `\1` in the replacement means to include the text + # which matched the first sub-expression verbatim. + # - `[[:blank:]]*` matches an arbitrary amount of white-space (space or + # horizontal tab characters) + # - Places where a forward slash needs to be part of the expression or + # replacement text are escaped with a backslash, i.e. `\/` + # - So the expression reads: match all instances of text which are of the + # form `# include <Quotient/`, with everything but the final forward + # slash contained in a sub-expression, and with an arbitrary amount of + # white-space allowed + # - And the replacement text will be whatever text matched the first + # sub-expression (i.e. `# include <Quotient` but with the right amount + # of white-space) followed by `E2EE/`. + find "${pkgdir}/usr/include/QuotientE2EE" -name '*.h' -exec sed -i \ + 's/\(#[[:blank:]]*include[[:blank:]]*<Quotient\)\//\1E2EE\//g' '{}' \; } |