Use basename (3) for the %basename macro

This commit is contained in:
Florian Festi 2024-03-05 13:47:02 +01:00
parent 9571e3d9a2
commit 3ad98187cc
2 changed files with 11 additions and 4 deletions

View File

@ -1301,10 +1301,7 @@ static void doFoo(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed)
if (rstreq("basename", me->name)) { if (rstreq("basename", me->name)) {
buf = xstrdup(argv[1]); buf = xstrdup(argv[1]);
if ((b = strrchr(buf, '/')) == NULL) b = basename(buf);
b = buf;
else
b++;
} else if (rstreq("dirname", me->name)) { } else if (rstreq("dirname", me->name)) {
buf = xstrdup(argv[1]); buf = xstrdup(argv[1]);
b = dirname(buf); b = dirname(buf);

View File

@ -373,6 +373,11 @@ runroot rpm --eval "%dirname /foo"
runroot rpm --eval "%dirname /foo/" runroot rpm --eval "%dirname /foo/"
runroot rpm --eval "%dirname /foo/foobar" runroot rpm --eval "%dirname /foo/foobar"
runroot rpm --eval "%dirname /foo/foobar/" runroot rpm --eval "%dirname /foo/foobar/"
runroot rpm --eval "%basename /foo/foobar"
runroot rpm --eval "%basename /foo/foobar/"
runroot rpm --eval "%basename /"
runroot rpm --eval "%basename foobar/"
runroot rpm --eval "%basename foobar"
runroot rpm --define '%xxx /hello/%%%%/world' --eval '%{dirname:%xxx}' runroot rpm --define '%xxx /hello/%%%%/world' --eval '%{dirname:%xxx}'
runroot rpm --eval "%{uncompress}" runroot rpm --eval "%{uncompress}"
runroot rpm --eval "%{uncompress:}" runroot rpm --eval "%{uncompress:}"
@ -403,6 +408,11 @@ runroot rpm --eval "%verbose foo"
/ /
/foo /foo
/foo /foo
foobar
foobar
/
foobar
foobar
/hello/%% /hello/%%
bar bar