Skip to content

Commit

Permalink
Use macros for constructin the %generate_buildrequires script
Browse files Browse the repository at this point in the history
  • Loading branch information
ffesti committed Apr 5, 2019
1 parent b36a7bc commit 30fed42
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion build/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ static rpmRC doBuildRequires(rpmSpec spec, int test) {
char * buildDir = rpmGenPath(spec->rootDir, "%{_builddir}", "");
char *scriptName = NULL;
char * buildCmd = NULL;
char * buildTemplate = NULL;
char * buildPost = NULL;

FD_t fd = NULL;
FILE * fp = NULL;
StringBuf sb_stdout = NULL;
Expand Down Expand Up @@ -230,11 +233,17 @@ static rpmRC doBuildRequires(rpmSpec spec, int test) {
goto exit;
}

buildTemplate = rpmExpand("%{__spec_buildrequires_template}", NULL);
buildPost = rpmExpand("%{__spec_buildrequires_post}", NULL);

(void) fputs(buildTemplate, fp);

fprintf(fp, "cd '%s'\n", buildDir);

if (spec->buildSubdir)
fprintf(fp, "cd '%s'\n", spec->buildSubdir);
fprintf(fp, "%s", getStringBuf(spec->buildrequires));
(void) fputs(buildPost, fp);
(void) fclose(fp);

if (test) {
Expand All @@ -243,7 +252,7 @@ static rpmRC doBuildRequires(rpmSpec spec, int test) {
}

/* execute script */
buildCmd = rpmExpand("/bin/sh", " ", scriptName, NULL);
buildCmd = rpmExpand("%{__spec_buildrequires_cmd}", " ", scriptName, NULL);
(void) poptParseArgvString(buildCmd, &argc, &argv);
rpmlog(RPMLOG_NOTICE, _("Executing(buildreqs): %s\n"), buildCmd);
if ((rc = rpmfcExec((ARGV_const_t)argv, NULL, &sb_stdout, 1, spec->buildSubdir)))
Expand Down Expand Up @@ -271,6 +280,8 @@ static rpmRC doBuildRequires(rpmSpec spec, int test) {
exit:
free(argv);
free(buildCmd);
free(buildTemplate);
free(buildPost);
free(output);
free(buildDir);
return rc;
Expand Down
15 changes: 15 additions & 0 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,21 @@ package or when debugging this package.\
#%{__spec_prep_post}\
#%{nil}

%__spec_buildrequires_shell %{___build_shell}
%__spec_buildrequires_args %{___build_args}
%__spec_buildrequires_cmd %{___build_cmd}
%__spec_buildrequires_pre %{___build_pre}
%__spec_buildrequires_body %{___build_body}
%__spec_buildrequires_post %{___build_post}
%__spec_buildrequires_template #!%{__spec_buildrequires_shell}\
%{__spec_buildrequires_pre}\
%{nil}

#%{__spec_buildrequires_body}\
#%{__spec_buildrequires_post}\
#%{nil}


%__spec_build_shell %{___build_shell}
%__spec_build_args %{___build_args}
%__spec_build_cmd %{___build_cmd}
Expand Down

0 comments on commit 30fed42

Please sign in to comment.