Skip to content

Commit

Permalink
Add parsed and expanded spec to src.rpm header (rpm-software-manageme…
Browse files Browse the repository at this point in the history
…nt#1241)

The trend of packaging is to hide more and more of what actually happens
behind helper macros and other dynamically generated constructs. While
this is mostly a good thing, it makes understanding and postmortem
analysis harder than it should be. Add the spec in its parsed and
expanded form into the src.rpm header to make the actual contents of the
build more trackable.

It can be argued this does not belong in the header and should be in
payload instead, my rationale for the placement is that this way the
payload remains effectively arch independent, whereas the header already
heavily reflects the particular environment where it was built.

Probably worth noting that %setup and %patch built-in macros are not
properly expanded in the stored spec, but that's a separate issue
related the special way %prep is processed.

Fixes: rpm-software-management#1241
  • Loading branch information
pmatilai committed May 3, 2022
1 parent fd3ef9b commit f77b805
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build/parseSpec.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ static void initSourceHeader(rpmSpec spec)
headerPutString(h, RPMTAG_PROVIDEVERSION, rpmdsEVR(p->ds));
}
}

/* Include spec in parsed and expanded form */
headerPutString(sourcePkg->header, RPMTAG_SPEC, getStringBuf(spec->parsed));
}

/* Add extra provides to package. */
Expand Down
1 change: 1 addition & 0 deletions include/rpm/rpmtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ typedef enum rpmTag_e {
RPMTAG_MODULARITYLABEL = 5096, /* s */
RPMTAG_PAYLOADDIGESTALT = 5097, /* s[] */
RPMTAG_ARCHSUFFIX = 5098, /* s extension */
RPMTAG_SPEC = 5099, /* s */

RPMTAG_FIRSTFREE_TAG /*!< internal */
} rpmTag;
Expand Down
1 change: 1 addition & 0 deletions tests/rpmgeneral.at
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ SOURCE
SOURCEPACKAGE
SOURCEPKGID
SOURCERPM
SPEC
SUGGESTFLAGS
SUGGESTNAME
SUGGESTNEVRS
Expand Down
2 changes: 2 additions & 0 deletions tests/rpmquery.at
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ runroot rpmspec -q --qf "[[%{*:tagnum}\n]]" --srpm /data/SPECS/mini.spec
1016
1021
1022
5099
],
[])

Expand All @@ -1005,6 +1006,7 @@ License
Group
Os
Arch
Spec
],
[])
AT_CLEANUP
46 changes: 46 additions & 0 deletions tests/rpmspec.at
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,49 @@ foo-bus = 1.0-1
],
[])
AT_CLEANUP

AT_SETUP([rpmbuild spec tag])
AT_KEYWORDS([build])
AT_CHECK([
runroot rpmspec -q --srpm --qf "%{spec}" /data/SPECS/foo.spec
],
[0],
[

Summary: foo
Name: foo
Version: 1.0
Release: 1
Source: hello-2.0.tar.gz
Patch1: hello-1.0-modernize.patch
Group: Testing
License: GPLv2+
BuildArch: noarch

%description
Simple rpm demonstration.

%package sub
Summary: foo
Requires: foo = 1.0-1

%description sub
foo

%package bus
Summary: foo
Requires: foo = 1.0-1

%description bus
foo

%files

%files sub

],
[])
AT_CLEANUP



0 comments on commit f77b805

Please sign in to comment.