Skip to content

Commit

Permalink
Add "local_generator"
Browse files Browse the repository at this point in the history
This generator can be used by .spec file, which ships their own
generators:

~~~
Source1: generator.req
%global __local_generator_requires bash %{SOURCE1}
%global __local_generator_path .*
~~~

Resolves #782
  • Loading branch information
voxik committed Oct 25, 2023
1 parent c284d09 commit 8a532b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build/rpmfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,13 +1184,15 @@ static int initAttrs(rpmfc fc)

/* Discover known attributes from pathnames + initialize them */
if (rpmGlob(attrPath, NULL, &files) == 0) {
nattrs = argvCount(files);
int nfiles = argvCount(files);
nattrs = nfiles + 1;
fc->atypes = xcalloc(nattrs + 1, sizeof(*fc->atypes));
for (int i = 0; i < nattrs; i++) {
for (int i = 0; i < nfiles; i++) {
char *bn = basename(files[i]);
bn[strlen(bn)-strlen(".attr")] = '\0';
fc->atypes[i] = rpmfcAttrNew(bn);
}
fc->atypes[nattrs - 1] = rpmfcAttrNew("local_generator");
fc->atypes[nattrs] = NULL;
argvFree(files);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/rpmbuild.at
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,23 @@ runroot rpm -qp --requires /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^
[])
RPMTEST_CLEANUP

AT_SETUP([Local dependency generator])
AT_KEYWORDS([build])
RPMTEST_CHECK([
RPMDB_INIT

runroot rpmbuild -bb --quiet \
--define '__local_generator_provides() foo(%{basename:%{1}})' \
--define '__local_generator_path .*' \
/data/SPECS/shebang.spec
runroot rpm -qp --provides /build/RPMS/noarch/shebang-0.1-1.noarch.rpm|grep -v ^rpmlib
],
[0],
[foo(shebang)
],
[])
RPMTEST_CLEANUP

AT_SETUP([elf dependencies])
AT_KEYWORDS([build])
RPMDB_INIT
Expand Down

0 comments on commit 8a532b2

Please sign in to comment.