Adjust whitespace and tweak comments

Also drop the now-unused script.

The URL is restored because we have documentation there.

[skip changelog]

drop
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-08-07 21:40:14 +02:00
parent 9da9df8af2
commit 5c54ab3586
4 changed files with 16 additions and 44 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/package-notes-0.4.tar.gz
/redhat-package-notes

View File

@ -1,24 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: 0BSD
# Prints a quoted --package-metadata string suitable for being used from an RPM
# macro in a way that gets correctly propagated down to the linker.
cpe="$(cat /usr/lib/system-release-cpe)"
# We need to print the escapes as-is, so single quote echo, but also print the
# variables, so do it in multiple lines.
# The many quotes are necessary so that the compiler gets:
# -Xlinker "--package-metadata={\"type\":\"rpm\",\"name\":\"foo\",\"version\":\"bar\",\"architecture\":\"baz\",\"osCpe\":\"barbaz\"}"
# This way the inner quotes make it into the parsed string, and the outer quotes
# ensure the { } do not get expanded. -Xlinker instead of -Wl allows to use commas.
echo -n '-Xlinker \"--package-metadata={\\\"type\\\":\\\"rpm\\\",\\\"name\\\":\\\"'
echo -n "$1"
echo -n '\\\",\\\"version\\\":\\\"'
echo -n "$2"
echo -n '\\\",\\\"architecture\\\":\\\"'
echo -n "$3"
echo -n '\\\",\\\"osCpe\\\":\\\"'
echo -n "$cpe"
# Yes, the closing bracket needs to be escaped, otherwise it gets duplicated:
# "--package-metadata={\"type\":\"rpm\",\"name\":\"foo\",\"version\":\"bar\",\"architecture\":\"baz\",\"osCpe\":\"barbaz\"}"}
echo -n '\\\"\}\"'

View File

@ -4,14 +4,14 @@
# See https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects
# for details.
#
# To opt out of the use of this feature completely, include this in
# the spec file:
# To opt out of the use of this feature completely, include this in the spec
# file:
#
# %undefine _package_note_flags
#
# Which linker will be used? This should be either "bfd", "gold", or
# "mold". Unfortunately "lld" does not support the --package-metadata flag so
# the note insertion is disabled when using it.
# Which linker will be used? This should be either "bfd", "gold", or "mold".
# Unfortunately "lld" does not support the --package-metadata flag so the note
# insertion is disabled when using it.
#
# (The default linker for clang on armv7hl is lld.)
%_package_note_linker %["%_target_cpu" == "armv7hl" && "%{toolchain}" == "clang" ? "lld" : "bfd"]
@ -23,10 +23,7 @@
# Overall status: 1 if looks like we can insert the note, 0 otherwise
%_package_note_status %[0%{?_package_note_file:1} && 0%{?name:1} && "%_target_cpu" != "noarch" && "%_package_note_linker" != "lld" ? 1 : 0]
# The linker flags to be passed to the compiler to insert the notes section will be created by the spec file,
# to avoid issues with quoting and escaping across different build systems and shells.
%_package_note_flags %[%_package_note_status?"-specs=/usr/lib/rpm/redhat/redhat-package-notes":""]
# Passing linker flags inline via -Xlinker causes autotools failures, as libtool eats the escaped quotes
#%_package_note_json %(%{_rpmconfigdir}/generate-rpm-note.sh %name %version %_arch)
#%_package_note_flags %[%_package_note_status?"%_package_note_json":""]
# The linker flags to be passed to the compiler to insert the notes section will
# be created by the spec file, to avoid issues with quoting and escaping across
# different build systems and shells.
%_package_note_flags %[%_package_note_status ? "-specs=/usr/lib/rpm/redhat/redhat-package-notes" : ""]

View File

@ -3,10 +3,10 @@ Version: 0.5
Release: %autorelease
Summary: Generate LDFLAGS to insert .note.package section
License: 0BSD
URL: https://github.com/systemd/package-notes
Source0: redhat-package-notes.in
Source1: generate-rpm-note.sh
Source2: macros.package-notes-srpm
Source1: macros.package-notes-srpm
BuildArch: noarch
@ -25,23 +25,21 @@ Conflicts: mold < 1.3.0
%description srpm-macros
RPM macros to insert a section with an ELF note with a JSON payload that
describes the package the binary was built for via compiler spec file.
describes the package the binary was built for via a compiler spec file.
%prep
# nothing to do
%build
sed "s|@OSCPE@|$(cat /usr/lib/system-release-cpe)|" %{SOURCE0} > redhat-package-notes
sed "s|@OSCPE@|$(cat /usr/lib/system-release-cpe)|" %{SOURCE0} >redhat-package-notes
%install
install -Dt %{buildroot}%{_rpmconfigdir}/redhat/ redhat-package-notes
install -Dt %{buildroot}%{_rpmconfigdir}/ %{SOURCE1}
install -m0644 -Dt %{buildroot}%{_rpmmacrodir}/ %{SOURCE2}
install -m0644 -Dt %{buildroot}%{_rpmmacrodir}/ %{SOURCE1}
%files srpm-macros
%{_rpmconfigdir}/generate-rpm-note.sh
%{_rpmmacrodir}/macros.package-notes-srpm
%{_rpmconfigdir}/redhat/redhat-package-notes
%{_rpmmacrodir}/macros.package-notes-srpm
%changelog
%autochangelog