package-notes/tests/simple-rpm/test.spec

51 lines
1.1 KiB
RPMSpec
Raw Normal View History

2022-02-22 23:51:08 +00:00
%bcond_with ld_lld
2022-08-29 13:20:25 +00:00
%bcond_with clang
2022-02-22 23:51:08 +00:00
%if %{with ld_lld}
%global extra_ldflags -fuse-ld=lld
%global _package_note_linker lld
%endif
2022-08-29 13:20:25 +00:00
%if %{with clang}
%global toolchain clang
%endif
2022-02-22 23:51:08 +00:00
Name: test
Version: 1
Release: 1
Summary: Test package for checking package notes
License: MIT
2022-08-29 13:20:25 +00:00
%if %{with clang}
BuildRequires: clang
%else
2022-02-22 23:51:08 +00:00
BuildRequires: gcc
2022-08-29 13:20:25 +00:00
%endif
2022-02-22 23:51:08 +00:00
# For %check
BuildRequires: binutils
BuildRequires: jq
%if %{with ld_lld}
BuildRequires: lld
%endif
%description
Test package for checking package notes
%build
echo 'int main(int argc, char **argv) { return 0; }' | %{build_cc} ${CFLAGS} -x c -c - -o main.o
2022-08-29 13:20:25 +00:00
%{build_cc} -Werror ${LDFLAGS} %{?extra_ldflags} main.o -o main
2022-02-22 23:51:08 +00:00
2022-08-29 13:20:25 +00:00
# Package notes not supported with clang, so the the build succeeding is enough.
%if %{without clang}
2022-02-22 23:51:08 +00:00
%check
# avoid any attempt to access the network by readelf
export DEBUGINFOD_URLS=
readelf --notes ./main | sed -r -n 's/.*Packaging Metadata: (.*)/\1/p' | tee package-note.text
test "`cat package-note.text | jq -r '[.type,.name,.version,.architecture]|join(" ")'`" == "rpm %{name} %{version}-%{release} %{_arch}"
%endif
%changelog
* Sat Aug 6 2022 Jane Doe <jane@example.org> - 1-1
- Dummy