Conversation
Escaping by backslash works only if file name contains wildcards, so replace single quote with [\']. Just ['] won't work, because it's converted into [] inside rpmbuild.
|
Hmm.. Odd. I test this on Fedora 36, rpm v4.17.1, and it seems to work fine on the main branch without this patch? The %files section contains: The package listing: |
|
@kpushkaryov Does this still fail for you? If it does, let me know. I'll try to do some additional testing specifically on CentOS 8 |
|
Can't reproduce the issue with fpm 1.15.0, rpmbuild 4.14.3 on AlmaLinux 8 (CentOS 8 is not supported anymore). Looks like it has been fixed by this commit to fpm which stopped escaping single quotes in paths without metacharacters. It's worth noting that rpmbuild's handling of escaping has changed substantially in the meantime. According to docs/manual/spec.md, now you shouldn't escape single quotes. The problem with the backslash on rpmbuild's side is explained in this comment. As of RPM 4.18.0 the changes haven't been released yet. |
This pull request fixes the cases when file names to be included in RPM package contain single quote but no spaces.
I'm using CentOS 8 with fpm 1.14.1, rpmbuild 4.14.3.
The case of mixed quotes and spaces has been fixed previously in #1774. Unfortunately, escaping by backslash works only if file name contains wildcards, so if I do:
fpm fails:
The
%filessection of the SPEC file is as follows:In the output of
strace -s 999 -f -vv fpm --verbose -s dir -t rpm -n example testthe following calls are of interest:So, the backslash is just passed as is to
lstat().Apparently,
rpmbuildchecks if the path contains wildcards and treats such paths specially. Other paths are interpreted literally and even backslashes have no effect. Thus, the single quote should be converted to[\']. The backslash is still needed, because otherwisepoptParseArgvString()called insiderpmbuildstrips the quote away.The problem wasn't triggered in #1774, because there the paths contained spaces, which are converted to "?" wildcards, thus enabling backslash escaping.
To verify my fix I've performed the following test:
There was no error and the package looks good:
Additionally, I noticed that fpm doesn't escape double quotes and fpm fails with paths containing them, so maybe this needs to be fixed too.