diff --git a/build/Makefile.am b/build/Makefile.am index 8bc71817b..248d5e3ae 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -16,7 +16,7 @@ librpmbuild_la_SOURCES = \ build.c expression.c files.c misc.c pack.c \ parseSimpleScript.c parseChangelog.c parseDescription.c \ parseFiles.c parsePreamble.c parsePrep.c parseReqs.c parseScript.c \ - parseSpec.c reqprov.c rpmfc.c spec.c \ + parseSpec.c parseList.c reqprov.c rpmfc.c spec.c \ parsePolicies.c policies.c \ rpmbuild_internal.h rpmbuild_misc.h diff --git a/build/parseList.c b/build/parseList.c new file mode 100644 index 000000000..c382cbc6b --- /dev/null +++ b/build/parseList.c @@ -0,0 +1,32 @@ +/** \ingroup rpmbuild + * \file build/parseBuildInstallClean.c + * Parse %build/%install/%clean section from spec file. + */ +#include "system.h" + +#include +#include "build/rpmbuild_internal.h" +#include "debug.h" + + +int parseList(rpmSpec spec, const char *name, rpmTagVal tag) +{ + int res = PART_ERROR; + ARGV_t lst = NULL; + + /* There are no options to %patchlist and %sourcelist */ + if ((res = parseLines(spec, (STRIP_TRAILINGSPACE | STRIP_COMMENTS), + &lst, NULL)) == PART_ERROR) { + goto exit; + } + + for (ARGV_const_t l = lst; l && *l; l++) { + if (rstreq(*l, "")) + continue; + addSource(spec, 0, *l, tag); + } + +exit: + argvFree(lst); + return res; +} diff --git a/build/parseSpec.c b/build/parseSpec.c index 687c52214..dbd069230 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -74,6 +74,8 @@ static const struct PartRec { { PART_TRANSFILETRIGGERUN, LEN_AND_STR("%transfiletriggerun")}, { PART_TRANSFILETRIGGERPOSTUN, LEN_AND_STR("%transfiletriggerpostun")}, { PART_EMPTY, LEN_AND_STR("%end")}, + { PART_PATCHLIST, LEN_AND_STR("%patchlist")}, + { PART_SOURCELIST, LEN_AND_STR("%sourcelist")}, {0, 0, 0} }; @@ -891,6 +893,12 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags, parsePart = parsePreamble(spec, initialPackage); initialPackage = 0; break; + case PART_PATCHLIST: + parsePart = parseList(spec, "%patchlist", RPMTAG_PATCH); + break; + case PART_SOURCELIST: + parsePart = parseList(spec, "%sourcelist", RPMTAG_SOURCE); + break; case PART_PREP: parsePart = parsePrep(spec); break; diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h index 95deb3621..2d75876a9 100644 --- a/build/rpmbuild_internal.h +++ b/build/rpmbuild_internal.h @@ -187,7 +187,9 @@ typedef enum rpmParseState_e { PART_TRANSFILETRIGGERUN = 37+PART_BASE, /*!< */ PART_TRANSFILETRIGGERPOSTUN = 38+PART_BASE, /*!< */ PART_EMPTY = 39+PART_BASE, /*!< */ - PART_LAST = 40+PART_BASE /*!< */ + PART_PATCHLIST = 40+PART_BASE, /*!< */ + PART_SOURCELIST = 41+PART_BASE, /*!< */ + PART_LAST = 42+PART_BASE /*!< */ } rpmParseState; @@ -308,6 +310,9 @@ int parsePrep(rpmSpec spec); RPM_GNUC_INTERNAL int parseScript(rpmSpec spec, int parsePart); +RPM_GNUC_INTERNAL +int parseList(rpmSpec spec, const char *name, int stype); + /** \ingroup rpmbuild * Check for inappropriate characters. All alphanums are considered sane. * @param spec spec diff --git a/tests/Makefile.am b/tests/Makefile.am index ad9549a68..f4c73ecc5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,6 +40,7 @@ EXTRA_DIST += $(TESTSUITE_AT) ## testsuite data EXTRA_DIST += data/SPECS/attrtest.spec EXTRA_DIST += data/SPECS/hello.spec +EXTRA_DIST += data/SPECS/hello-auto.spec EXTRA_DIST += data/SPECS/hello-r2.spec EXTRA_DIST += data/SPECS/hello-script.spec EXTRA_DIST += data/SPECS/hello2.spec @@ -75,6 +76,7 @@ EXTRA_DIST += data/SPECS/test-subpackages-exclude.spec EXTRA_DIST += data/SPECS/test-subpackages-pathpostfixes.spec EXTRA_DIST += data/SPECS/vattrtest.spec EXTRA_DIST += data/SOURCES/hello-1.0-modernize.patch +EXTRA_DIST += data/SOURCES/hello-1.0-install.patch EXTRA_DIST += data/SOURCES/hello-1.0.tar.gz EXTRA_DIST += data/SOURCES/hello-2.0.tar.gz EXTRA_DIST += data/RPMS/foo-1.0-1.noarch.rpm diff --git a/tests/data/SOURCES/hello-1.0-install.patch b/tests/data/SOURCES/hello-1.0-install.patch new file mode 100644 index 000000000..7d9da10a0 --- /dev/null +++ b/tests/data/SOURCES/hello-1.0-install.patch @@ -0,0 +1,11 @@ +diff -up hello-1.0/Makefile.flags hello-1.0/Makefile +--- hello-1.0/Makefile.flags 2019-04-25 12:26:37.684540172 +0300 ++++ hello-1.0/Makefile 2019-04-25 12:27:22.438450581 +0300 +@@ -1,6 +1,7 @@ + all: hello + + install: ++ mkdir -p $(DESTDIR)/usr/local/bin/ + install -m 0755 hello $(DESTDIR)/usr/local/bin + + clean: diff --git a/tests/data/SPECS/hello-auto.spec b/tests/data/SPECS/hello-auto.spec new file mode 100644 index 000000000..ea0491b06 --- /dev/null +++ b/tests/data/SPECS/hello-auto.spec @@ -0,0 +1,30 @@ +Name: hello +Version: 1.0 +Release: 1 +Group: Testing +License: GPL +Summary: Simple rpm demonstration. + +%sourcelist +hello-1.0.tar.gz + +%patchlist +hello-1.0-modernize.patch +hello-1.0-install.patch + +%description +Simple rpm demonstration. + +%prep +%autosetup + +%build +%make_build CFLAGS="$RPM_OPT_FLAGS" + +%install +%make_install + +%files +%doc FAQ +/usr/local/bin/hello + diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at index 5379723f0..5dc667c3b 100644 --- a/tests/rpmbuild.at +++ b/tests/rpmbuild.at @@ -36,6 +36,20 @@ run rpmbuild \ [ignore]) AT_CLEANUP +AT_SETUP([rpmbuild -ba autosetup]) +AT_KEYWORDS([build]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-*.patch ${TOPDIR}/SOURCES +run rpmbuild \ + -ba "${abs_srcdir}"/data/SPECS/hello-auto.spec +], +[0], +[ignore], +[ignore]) +AT_CLEANUP # ------------------------------ # Check if rpmbuild --rebuild *.src.rpm works AT_SETUP([rpmbuild --rebuild])