Closed Artoria2e5 closed 9 years ago
Btw as I always do, I think all RPM doc is trash.
Please go ahead and we will see with several packages.
They all have ambiguous file names, with [
and (
that can get in the way of scripting...
@MingcongBai Again you reminded me of those things! The rpm guys must have forgotten them again…
@Arthur2e5 That's pretty unfortunate, but! but! Keep in mind that writing a whole list of files included in a package is just unnecessary, but at the same time I am pretty much unsure with how to handle them.
Simply a /*
as in file list, then anything with special attributes and whatever goes behind that?
@MingcongBai that is acceptable, but maybe we have to do something with the attributes.
@Arthur2e5 What I am unsure as of now, is that with /*
, if the attribute of that wildcard will be passed onto any file after it.
Well, my dear readers, we posted something by mistake in #55.
It seems that RPM
%files
are shell globs with RPM%
macro expansion, which I should have mentioned quite a long time ago in.. maybe the QQ group.In the poorly-written doc, I got the following script to get a file list:
When we simplify it,
perl -pe 's/([?|*.\'"])/\\$1/g'
to the whole thing is actually the core of this escaping. So we gotBut this is sooooooo slow and introduces a perl dependency. BTW it's badly wrong since shells don't accept backslash-escapes in single quotes. The correct one is
perl -pe 's/([?|*.\'\''"])/\\$1/g'
.First we saw a Perl RE, with a
$1
which means the first matching group. We can rewrite it intosed -re "s/([?|*.\'"'"])/\\\1/g'
. Then we have a different test result, with perl\|
gets\\
and sed gets\\\|
. When I take a look into DebuggerEx with([?|*.\'"'"])
, it seems that perl did one more step of escape and changed\'
to'
. The sed one seems to be correct.Then we can eliminate the ERE dependency, by making it
sed -e "s/[?|*.\'"'"]/\\&/g'
. This is quite trivial.And then we can make it shell.