diff --git a/build/build.c b/build/build.c index bebec3e..c27a671 100644 --- a/build/build.c +++ b/build/build.c @@ -97,6 +97,12 @@ int doScript(Spec spec, int what, const char *name, StringBuf sb, int test) mTemplate = "%{?__spec_install_template}"; mPost = "%{?__spec_install_post}"; break; + case RPMBUILD_CHECK: + name = "%check"; + sb = spec->check; + mTemplate = "%{__spec_check_template}"; + mPost = "%{__spec_check_post}"; + break; case RPMBUILD_CLEAN: name = "%clean"; sb = spec->clean; @@ -321,6 +327,10 @@ int buildSpec(Spec spec, int what, int test) (rc = doScript(spec, RPMBUILD_INSTALL, NULL, NULL, test))) goto exit; + if ((what & RPMBUILD_CHECK) && + (rc = doScript(spec, RPMBUILD_CHECK, NULL, NULL, test))) + goto exit; + if ((what & RPMBUILD_PACKAGESOURCE) && (rc = processSourceFiles(spec))) goto exit; diff --git a/build/parseBuildInstallClean.c b/build/parseBuildInstallClean.c index b406ca6..927e8dd 100644 --- a/build/parseBuildInstallClean.c +++ b/build/parseBuildInstallClean.c @@ -22,6 +22,9 @@ int parseBuildInstallClean(Spec spec, rpmParseState parsePart) } else if (parsePart == PART_INSTALL) { sbp = &(spec->install); name = "%install"; + } else if (parsePart == PART_CHECK) { + sbp = &(spec->check); + name = "%check"; } else if (parsePart == PART_CLEAN) { sbp = &(spec->clean); name = "%clean"; @@ -36,7 +39,7 @@ int parseBuildInstallClean(Spec spec, rpmParseState parsePart) *sbp = newStringBuf(); - /* There are no options to %build, %install, or %clean */ + /* There are no options to %build, %install, %check, or %clean */ if ((rc = readLine(spec, STRIP_NOTHING)) == 1) return PART_NONE; if (rc) diff --git a/build/parseSpec.c b/build/parseSpec.c index e74f355..29aeea5 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -28,6 +28,7 @@ static struct PartRec { { PART_PREP, 0, "%prep"}, { PART_BUILD, 0, "%build"}, { PART_INSTALL, 0, "%install"}, + { PART_CHECK, 0, "%check"}, { PART_CLEAN, 0, "%clean"}, { PART_PREUN, 0, "%preun"}, { PART_POSTUN, 0, "%postun"}, @@ -710,6 +711,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU /*@switchbreak@*/ break; case PART_BUILD: case PART_INSTALL: + case PART_CHECK: case PART_CLEAN: rpmSetBuiltinMacroLookup(is_builtin_build_tag); rpmSetBuiltinMacroLookupFailedOK(1); diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 3da578a..721a73d 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -26,16 +26,17 @@ typedef enum rpmBuildFlags_e { RPMBUILD_PREP = (1 << 0), /*!< Execute %%prep. */ RPMBUILD_BUILD = (1 << 1), /*!< Execute %%build. */ RPMBUILD_INSTALL = (1 << 2), /*!< Execute %%install. */ - RPMBUILD_CLEAN = (1 << 3), /*!< Execute %%clean. */ - RPMBUILD_FILECHECK = (1 << 4), /*!< Check %%files manifest. */ - RPMBUILD_PACKAGESOURCE = (1 << 5), /*!< Create source package. */ - RPMBUILD_PACKAGEBINARY = (1 << 6), /*!< Create binary package(s). */ - RPMBUILD_RMSOURCE = (1 << 7), /*!< Remove source(s) and patch(s). */ - RPMBUILD_RMBUILD = (1 << 8), /*!< Remove build sub-tree. */ - RPMBUILD_STRINGBUF = (1 << 9), /*!< only for doScript() */ - RPMBUILD_RMSPEC = (1 << 10), /*!< Remove spec file. */ - RPMBUILD_PREPROCESS = (1 << 11), /*!< Preprocess spec file only. */ - RPMBUILD_MACROREQS = (1 << 12) /*!< Dump used macro names only. */ + RPMBUILD_CHECK = (1 << 3), /*!< Execute %%check. */ + RPMBUILD_CLEAN = (1 << 4), /*!< Execute %%clean. */ + RPMBUILD_FILECHECK = (1 << 5), /*!< Check %%files manifest. */ + RPMBUILD_PACKAGESOURCE = (1 << 6), /*!< Create source package. */ + RPMBUILD_PACKAGEBINARY = (1 << 7), /*!< Create binary package(s). */ + RPMBUILD_RMSOURCE = (1 << 8), /*!< Remove source(s) and patch(s). */ + RPMBUILD_RMBUILD = (1 << 9), /*!< Remove build sub-tree. */ + RPMBUILD_STRINGBUF = (1 << 10), /*!< only for doScript() */ + RPMBUILD_RMSPEC = (1 << 11), /*!< Remove spec file. */ + RPMBUILD_PREPROCESS = (1 << 12), /*!< Preprocess spec file only. */ + RPMBUILD_MACROREQS = (1 << 13) /*!< Dump used macro names only. */ } rpmBuildFlags; /*@=typeuse@*/ @@ -51,25 +52,26 @@ typedef enum rpmBuildFlags_e { * Spec file parser states. */ typedef enum rpmParseState_e { - PART_NONE = 0, /*!< */ - PART_PREAMBLE = 1, /*!< */ - PART_PREP = 2, /*!< */ - PART_BUILD = 3, /*!< */ - PART_INSTALL = 4, /*!< */ - PART_CLEAN = 5, /*!< */ - PART_FILES = 6, /*!< */ - PART_PRE = 7, /*!< */ - PART_POST = 8, /*!< */ - PART_PREUN = 9, /*!< */ - PART_POSTUN = 10, /*!< */ - PART_DESCRIPTION = 11, /*!< */ - PART_CHANGELOG = 12, /*!< */ - PART_TRIGGERIN = 13, /*!< */ - PART_TRIGGERUN = 14, /*!< */ - PART_VERIFYSCRIPT = 15, /*!< */ - PART_BUILDARCHITECTURES= 16,/*!< */ - PART_TRIGGERPOSTUN = 17, /*!< */ - PART_LAST = 18 /*!< */ + PART_NONE = 0, /*!< */ + PART_PREAMBLE = 1, /*!< */ + PART_PREP = 2, /*!< */ + PART_BUILD = 3, /*!< */ + PART_INSTALL = 4, /*!< */ + PART_CHECK = 5, /*!< */ + PART_CLEAN = 6, /*!< */ + PART_FILES = 7, /*!< */ + PART_PRE = 8, /*!< */ + PART_POST = 9, /*!< */ + PART_PREUN = 10, /*!< */ + PART_POSTUN = 11, /*!< */ + PART_DESCRIPTION = 12, /*!< */ + PART_CHANGELOG = 13, /*!< */ + PART_TRIGGERIN = 14, /*!< */ + PART_TRIGGERUN = 15, /*!< */ + PART_VERIFYSCRIPT = 16, /*!< */ + PART_BUILDARCHITECTURES= 17,/*!< */ + PART_TRIGGERPOSTUN = 18, /*!< */ + PART_LAST = 19 /*!< */ } rpmParseState; #define STRIP_NOTHING 0 @@ -212,7 +214,7 @@ void addChangelogEntry(Header h, time_t time, const char * name, int parseBuildInstallClean(Spec spec, rpmParseState parsePart) /*@globals rpmGlobalMacroContext, fileSystem @*/ - /*@modifies spec->build, spec->install, spec->clean, spec->macros, + /*@modifies spec->build, spec->install, spec->check, spec->clean, spec->macros, spec->fileStack, spec->readStack, spec->line, spec->lineNum, spec->nextline, spec->nextpeekc, spec->lbuf, spec->sl, rpmGlobalMacroContext, fileSystem @*/; diff --git a/build/rpmspec.h b/build/rpmspec.h index ce3c67a..9c361c1 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -139,6 +139,7 @@ struct SpecStruct { /*@only@*/ StringBuf prep; /*!< %prep scriptlet. */ /*@only@*/ StringBuf build; /*!< %build scriptlet. */ /*@only@*/ StringBuf install; /*!< %install scriptlet. */ +/*@only@*/ StringBuf check; /*!< %check scriptlet. */ /*@only@*/ StringBuf clean; /*!< %clean scriptlet. */ /*@owned@*/ struct PackageStruct * packages; /*!< Package list. */ diff --git a/build/spec.c b/build/spec.c index 0cae8f6..c4ebefd 100644 --- a/build/spec.c +++ b/build/spec.c @@ -453,6 +453,7 @@ Spec newSpec(void) spec->prep = NULL; spec->build = NULL; spec->install = NULL; + spec->check = NULL; spec->clean = NULL; spec->sources = NULL; @@ -498,6 +499,7 @@ Spec freeSpec(Spec spec) spec->prep = freeStringBuf(spec->prep); spec->build = freeStringBuf(spec->build); spec->install = freeStringBuf(spec->install); + spec->check = freeStringBuf(spec->check); spec->clean = freeStringBuf(spec->clean); spec->buildRootURL = _free(spec->buildRootURL); diff --git a/macros.in b/macros.in index 7d1f823..535d669 100644 --- a/macros.in +++ b/macros.in @@ -619,6 +619,8 @@ %__spec_build_custom_post %{nil} %__spec_install_custom_pre %{nil} %__spec_install_custom_post %{nil} +%__spec_check_custom_pre %{nil} +%__spec_check_custom_post %{nil} %__spec_autodep_custom_pre %{nil} %__spec_autodep_custom_post %{nil} %__spec_clean_custom_pre %{nil} @@ -692,6 +694,26 @@ #%{__spec_install_post}\ #%{nil} +%__spec_check_shell %{___build_shell} +%__spec_check_args %{___build_args} +%__spec_check_cmd %{___build_cmd} +%__spec_check_pre\ +%{___build_pre}\ +%{__spec_check_custom_pre}\ +%{nil} +%__spec_check_body %{___build_body} +%__spec_check_post\ +%{___build_post}\ +%{__spec_check_custom_post}\ +%{nil} +%__spec_check_template #!%{__spec_check_shell}\ +%{__spec_check_pre}\ +%{nil} + +#%{__spec_check_body}\ +#%{__spec_check_post}\ +#%{nil} + %__spec_autodep_shell %{___build_shell} %__spec_autodep_args %{___build_args} %__spec_autodep_cmd %{___build_cmd} diff --git a/rpmqv.c b/rpmqv.c index 6876f33..a7e9849 100755 --- a/rpmqv.c +++ b/rpmqv.c @@ -951,7 +951,8 @@ int main(int argc, const char ** argv) if (!poptPeekArg(optCon)) argerror(_("no packages files given for rebuild")); - ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL; + ba->buildAmount = + RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK; if (bigMode == MODE_REBUILD) { ba->buildAmount |= RPMBUILD_PACKAGEBINARY; if (rpmExpandNumeric ("%{?_rpmbuild_clean:%{_rpmbuild_clean}}%{?!_rpmbuild_clean:1}")) @@ -1007,7 +1008,7 @@ int main(int argc, const char ** argv) if (ba->shortCircuit) break; /*@fallthrough@*/ case 'i': - ba->buildAmount |= RPMBUILD_INSTALL; + ba->buildAmount |= RPMBUILD_INSTALL | RPMBUILD_CHECK; if (ba->shortCircuit) break; /*@fallthrough@*/ case 'c':