Commit Graph

602 Commits

Author SHA1 Message Date
a2e3f87824 Add a wrapper for install in %install section to skip strip
`strip' is called by `install -s` that could occur in unpatched
Makefiles, breaking debuginfo generation.

Try to catch `install` invocations via:

- %__install macro used in `make INSTALL=`.
- Prefix PATH with `/usr/libexec/rpm-build` with install and strip
  wrappers.

Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
2020-12-15 04:05:15 +03:00
623707e728 debuginfo: Fix 'warning: File listed twice' for debug sources
debugedit sometimes output top level directory, since we do not filter
regular files in process-debuginfo since 309af2d59 ("debuginfo: Create
empty src/debug directories for paths with `..'") we need to filter
them out before passing into %files for debuginfo package.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: 309af2d59 ("debuginfo: Create empty src/debug directories for paths with `..'")
2020-11-15 17:54:34 +03:00
309af2d59e debuginfo: Create empty src/debug directories for paths with `..'
Create empty directories under `/usr/src/debug` tree for source paths
containing `..` (for example `../../src` in elfutils). This should fix
debuginfo sources for autotools builds in subdir.

Fixes: https://bugzilla.altlinux.org/39175
2020-11-12 22:08:42 +03:00
8b68c147ee brp-sign-kmodules: Sign kernel modules after kernel build
Try to work similar to `CONFIG_MODULE_SIG_ALL=y'.
2020-11-06 15:16:45 +03:00
4738619b15 debuginfo: Allow kbuilds with the output directory
Consider another directory level when searching for vmlinux, for kernel
builds in sub-directory using `make O=output_dir'. Also, improve warning
message making it more understandable.
2020-11-06 15:16:45 +03:00
4f5394b5a1 scripts/brp-compress.in: extend the range of autocompressed file types
Autocompress "[^:]*ASCII.* text.*" file types in addition to
"[^:]*troff or preprocessor input text.*".
2020-09-11 08:00:00 +00:00
1357563e49 scripts/brp-compress.in: use sed -rn 2020-09-11 08:00:00 +00:00
453b0907f5 debuginfo: Do not try to use eu-elfcompress if it does not exist
Reason: ae1ecef8 ("process-debuginfo: Do not call eu-elfcompress if it doesn't exist")
Fixes: 8682814b ("debuginfo: Try to uncompress if debugedit failed to extract sources list")
2020-08-28 03:09:00 +03:00
b9ea232966 debuginfo: Fix adding non-existent files into debuginfo package
Do not add (uncompressed) module (or vmlinux) into debuginfo package if
it does not actually exists.

Due to other bugs there could be compressed kernel module, (which
implies adding uncompressed module into debuginfo), but, uncompressed
version (which brp-debuginfo should create) does not exist, making
build errors such as:

  error: No such file or directory: /usr/src/tmp/kernel-image-std-def-buildroot/usr/lib/debug/lib/modules/5.8.0-std-def-alt1/kernel/fs/nfs/flexfilelayout/nfs_layout_flexfiles.ko

Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
Fixes: 7aa048df ("Generate debuginfo for kernel packages")
2020-08-28 03:09:00 +03:00
f946b5c3b5 find-debuginfo-files: Fix processing of root directory
`%dir /' would cause errors (ALT#38842):

  error: No such file or directory: /usr/src/tmp/broken-debug-buildroot/usr/lib/debug/lib/modules
  error: No such file or directory: /usr/src/tmp/broken-debug-buildroot/usr/lib/debug/lib/modules/vmlinux

Reported-by: Vitaly Lipatov <lav@altlinux.org>
BZ: https://bugzilla.altlinux.org/show_bug.cgi?id=38842
2020-08-24 22:11:27 +03:00
8682814b04 debuginfo: Try to uncompress if debugedit failed to extract sources list
If debugedit failed to extract sources list, uncompress and try again.
Then compress back.

ps. Interesting relevant reading:
  https://blogs.oracle.com/solaris/elf_section_compression-v2

Spelling suggestions by Dmitry V. Levin <ldv@altlinux.org>.
2020-08-23 17:02:20 +03:00
aba565d889 debuginfo: Implement %_stripped_files_terminate_build
Terminate build if stripped ELF files are found. Usage:

  %define _stripped_files_terminate_build 1

Formatting suggestions by Dmitry V. Levin <ldv@altlinux.org>.
2020-08-23 17:01:20 +03:00
1f5bc5f866 debuginfo: Warn if stripped ELFs are found 2020-08-23 17:00:58 +03:00
a64fcaf7a3 process-debuginfo: Change 'echo Warning' to 'Warning' call
Use dedicated `Warning' function instead of `echo'.

Suggested-by: Dmitry V. Levin <ldv@altlinux.org>
2020-08-21 23:38:49 +03:00
deaca8d8e3 debuginfo: Show warnings if .debug sections are absent
Actually, `.debug_line` section is checked (implicitly by debugedit)
which should go together with all `.debug_*` sections. This
simplification will make check faster.

Note: Only non-stripped binaries are checked.

Spelling fixes, usage of `Warning' function, and redirect to stderr is
suggested by Dmitry V. Levin <ldv@altlinux.org>.
2020-08-21 23:37:05 +03:00
ae1ecef8bd process-debuginfo: Do not call eu-elfcompress if it doesn't exist
E2K arch have old elfutils-0.159 which doesn't have eu-elfcompress.
Error:

  /usr/lib/rpm/process-debuginfo: line 68: eu-elfcompress: command not found

Reported-by: Andrey Savchenko <bircoph@altlinux.org>
2020-07-09 19:23:18 +03:00
30d528d7bc debuginfo.req: Fix 'vmlinux' processing error on ppc64le
`vmlinux' on ppc appears to have `Dynamic Section', this triggers its
processing with `/usr/lib/rpm/ldd' which returns error:

  ldd: ERROR: /usr/src/tmp/kernel-image-std-test-buildroot/usr/lib/debug/lib/modules/5.4.49-std-test-alt4/vmlinux: failed to find the program interpreter
  find-requires: ERROR: /usr/lib/rpm/debuginfo.req failed
  error: /bin/sh failed
  error: Failed to find Requires

Reported-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
2020-07-09 19:23:18 +03:00
ce2db3795b brp-debuginfo: fix thinko in the previous fix
Re-enable processing of ELF relocatable objects that *are* kernel modules.

Reported-by: Vitaly Chikunov <vt@altlinux.org>
Fixes: d71728c2c8 ("brp-debuginfo: fix handling of packages containing
ELF relocatable objects")
2020-07-09 08:00:00 +00:00
d71728c2c8 brp-debuginfo: fix handling of packages containing ELF relocatable objects
Do not try to process ELF relocatable objects that are not kernel
modules, this fixes the following regression:

/usr/lib/rpm/debugedit: ./usr/lib64/gcc/x86_64-alt-linux/9/crtfastmath.o: DWARF version 0 unhandled
objdump: ./usr/lib64/gcc/x86_64-alt-linux/9/crtfastmath.o: bad value
verify-elf: ERROR: ./usr/lib64/gcc/x86_64-alt-linux/9/crtfastmath.o: objdump failed

Fixes: 7aa048df38 ("Generate debuginfo for kernel packages")
2020-07-08 08:00:00 +00:00
50705f69b7 debuginfo: Fix processing of hard-linked binaries
while-end output into the pipe forgets all set inside variables.

Error message:

  ln: .debuginfo/src/: hard link not allowed for directory
2020-07-07 13:44:03 +03:00
ea366ac608 process-debuginfo: Better search for vmlinux
Find first file, in any dir name, three levels max from $RPM_BUILD_DIR.

Fix incompatibility found by building ovz kernel.
2020-07-07 02:09:44 +03:00
f73a3de55c process-debuginfo: Do not eu-elfcompress vmlinux.debug
Allow `crash` (gdb-7.6 based) to work out of the box.

Otherwise it will fail with the error:

  Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4)

Alas, it will not be able to load debuginfo for the ko modules, but, advanced
user can `eu-elfcompress -t none` them manually.

We can't keep modules uncompressed due to `cpio archive too big - 4136M'
RPM build error.
2020-07-06 08:48:55 +03:00
1f2ad272a1 debugedit: Add -n to avoid recomputing of build-id
Avoid `DWARF version 0 unhandled' for compressed ELFs in
find-debuginfo-files.

Based on 6e9fd97f6 ("debugedit: Add -n, --no-recompute-build-id.")
by Mark Wielaard <mark@klomp.org>.
2020-07-05 01:06:16 +03:00
5cc014bed6 Process debuginfo in parallel
- Split processing of single binary into separate script.
- Call it from xargs -P.
2020-07-05 01:06:16 +03:00
7aa048df38 Generate debuginfo for kernel packages
- Support uncompressed (std-def) and compressed (un-def) modules. Also,
  support xz(1) compression if we'd switch to it.
- If module is uncompressed it stays in the kernel-image rpm, if it's
  compressed then uncompressed module goes into /usr/lib/debug tree and
  will be in debuginfo rpm. Compressed modules will be re-compressed after
  stripping.
- vmlinuz binary triggers extraction of vmlinux from the kernel-source
  tree, and it's then placed into /usr/lib/debug tree, then processed and
  stripped as usual.
- Logic of processing of vmlinux binary for domU packages is not changed.
  Some flavours do not even pack it. Thus, do not remove your
  `%brp_strip_none'.
- Output of file(1) for vmlinuz is only parsed for filename, because, on
  different architectures it detects completely different things.
- Debug files are compressed with `eu-elfcompress'.
- You still need to enable `CONFIG_DEBUG_INFO=y' in for `.config'.
  No other changes to spec should be needed.

Thanks to Nikita Ermakov for starting this work.
2020-07-05 01:06:16 +03:00
56058a3e7d ldd.in: make preloading of PIE objects work again
glibc starting with commit glibc-2.30~85
(elf: Refuse to dlopen PIE objects [BZ #24323])
no longer supports preloading of PIE objects.

Workaround this by swapping the target object and the preloading
PIE object when possible.

Reported-by: ALT beekeeper
Reported-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
2020-04-21 17:37:55 +00:00
Alexey Tourbin
75b044f2cb find-package, shebang.req: introduced RPM_FINDPACKAGE_MANDATORY=1 2020-04-07 11:05:34 +03:00
Anton V. Boyarshinov
54a2ca259c Auto-requies on binaries used in systemd .service files added 2019-12-26 14:09:03 +00:00
Ivan Zakharyaschev
48bd55e50d shell.req: correctly detect #!/bin/env bash (ALT#35376)
The patterns used were OK for the output of "file -NF$'\t'": it would
put a space after the separator (the default separator being ":").
But not for the output of "file -b": we need to pad the result with a
space to use the same patterns.

Putting a space at the beggining is convenient, because it allows to
match independently for "* sh" or "* bash", otherwise "*sh" would
consume "bash", too.

Other uses of "file -b" in scripts/ don't suffer from this problem.
2019-01-31 21:58:32 +03:00
0ea2deffe3 suggest_bpp: fix harmless off-by-one error in bpp estimation
Give detailed explanation of the formulae which makes the mistake obvious.

Also rewrite suggest_bpp from perl to C.
2019-01-20 23:40:39 +00:00
132ca8f9e1 lib.req: update the list of standard libraries with guaranteed versioning
Add more libraries from glibc:
libresolv, libmvec, librt, libutil, and libanl.
2019-01-14 20:56:55 +00:00
92f91356e0 lib.prov: print the number of provided symbols and the bpp value for each library 2019-01-14 20:56:55 +00:00
2107482334 scripts: move ProvidedSymbols() and SuggestBPP() to separate files
ProvidedSymbols() used to be defined both in lib.prov.in and lib.req.in,
fix this code duplication by moving ProvidedSymbols() to separate
provided_symbols executable script.

Likewise, SuggestBPP() used to be defined both in lib.prov.in and
lib.req.in, fix this code duplication by moving SuggestBPP() to separate
suggest_bpp executable script.
2019-01-14 20:56:55 +00:00
Konstantin A. Lepikhov
d093bb9f0d cpp.req: skip cpp checks for llvm
Skip any cpp checks for llvm packages, anyway we don't know how to deal
with them.

Signed-off-by: Konstantin A. Lepikhov <lakostis@altlinux.ru>
2019-01-13 22:39:58 +00:00
Konstantin A. Lepikhov
169f3ece9a verify-elf: bypass lint checks by request
lld linked binaries differ by structure from GNU ld, so eu-lint will
always complaint about.  Allow to skip those checks by passing
%set_verify_elf_method lint=(skip|no)

Signed-off-by: Konstantin A. Lepikhov <lakostis@altlinux.ru>
2019-01-13 22:39:58 +00:00
Nikita Ermakov (0x90)
835d775268 Disable stack verification and elflint on RISC-V 2018-12-20 11:46:01 +00:00
Gleb Fotengauer-Malinovskiy
4f4a1d1465 lib.prov, lib.req: enhance ProvidedSymbols
This enhances ProvidedSymbols() in two ways:
* fixes st_shndx check for the case when it is not $7 in
"readelf --wide --dyn-syms" output as it happens on some architectures
like ppc64le;
* filters out special symbols (__bss_start, _edata, _end, _fini, _init)
after stripping of versioning.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-12-16 23:09:47 +00:00
6feb190125 0common-files.req.list: remove /etc/syslog.d
Since /etc/syslog.d has been moved from syslog-common to filesystem,
there is no need to keep /etc/syslog.d in the list.
2018-08-28 18:05:40 +00:00
Ivan A. Melnikov
c038a07d61 Disable stack verification and elflint on mips*
Most of the binaries on mipsel do not contain the stack section,
so this check is not relevant for that architecture. Morover,
it fails, since it can't find the stack section, which is
(rightfully) not present.

eu-elflint does not understand mipsel binaries currently,
so here we disable that check, too.
2018-07-26 17:44:30 +03:00
Ivan Zakharyaschev
ea7ca90347 verify-elf(get_verify_policy): fix whitespace 2018-05-23 17:02:10 +03:00
Ivan Zakharyaschev
c8d9060245 shell.req.files: include #!/usr/bin/env sh 2018-05-23 17:00:54 +03:00
Ivan Zakharyaschev
67ec541700 verify_rpath(): distinguish grep's failure and a normal valid case
Previously (according to the exit statuses):

0. if something strange was found in $rpath, an error was reported;
1. if nothing strange was found, no error was reported;
2. if grep failed, it looked like the previous case and no error was
reported (as if $rpath was valid).

Now, the pipe (and the whole script) would abort on grep's failure.
2018-05-23 17:00:54 +03:00
Ivan Zakharyaschev
b491c783f6 verify_stack(): distinguish failures and a normal status of grep
Now, if something fails, the pipe (and the function, and the whole
script) will fail.

If the exit codes are normal, they are handled according to our logic.

Previously, a failure (which is an exceptional rare case) would lead to:

1. skipping the further exe_stack check and error_strict STACK "$f" 'STACK entry not found'
2. silently skipping the exe_stack check (which was impossible anyway because of the failure)
2018-05-23 17:00:54 +03:00
Ivan Zakharyaschev
cdefa4ab34 verify-elf(verify_unresolved): correctly treat grep's status, allow standalone use
The pipe (and the function, and the whole script) would fail when the
resulting constructed rpath was empty. But usually at least
$RPM_VERIFY_ELF_LDD_RPATH is not empty, so the bad behavior has not
been observed.

However, when verify-elf is used standalone, $RPM_VERIFY_ELF_LDD_RPATH
is empty indeed, and this improvement becomes important.

Before this improvement:

$ RPM_BUILD_ROOT=/home /usr/lib/rpm/verify-elf /bin/pwd; echo $?
1

After this improvement:

$ VERIFY_ELF_UNRESOLVED=strict RPM_BUILD_ROOT=/home /usr/lib/rpm/verify-elf /bin/pwd; echo $?
0
$ VERIFY_ELF_UNRESOLVED=strict RPM_BUILD_ROOT=/home /usr/lib/rpm/verify-elf /usr/lib64/python3/site-packages/_cffi_backend.cpython-35m.so; echo $?
verify-elf: ERROR: /usr/lib64/python3/site-packages/_cffi_backend.cpython-35m.so: undefined symbol: PyExc_SystemError
....
1
2018-05-23 17:00:54 +03:00
30d9979184 ldd.in: try interpreters listed in /usr/bin/ldd
When the given ELF file doesn't specify PT_INTERP, e.g. if it's a shared
library, we have to guess it.  We used to try the program interpreter
of dump_ld_config, but it doesn't work well enough in multilib
environments, so extend the guess by trying interpreters listed
in RTLDLIST from /usr/bin/ldd script.
2018-05-15 17:26:10 +00:00
Ivan Zakharyaschev
e8c7bc4453 find-package.in: group the pruned packages nicer in the list 2018-05-15 17:26:10 +00:00
2c2a5545e5 brp-check_contents: do not suppress normal grep output
The concerns of grep output were baseless, let grep print lines
matching the pattern.
2017-10-26 14:23:23 +00:00
232c7538e1 brp-check_contents: enable strict error checking
As the test rebuild of all packages in Sisyphus repository has shown
no false positives, it's safe to enable strict error checking.
2017-10-26 14:19:58 +00:00
7a81369647 Introduce brp-check_contents
Add a brp interface for checking contents of files in buildroot.
The initial revision of brp-check_contents scripts checks
for suspicious path names like /var/lib/run, complementing
the change introduced in sisyphus_check-0.8.43-alt1.
2017-10-25 03:16:59 +00:00
696f192aea scripts: ignore ELF shared objects with "no" machine type
When scanning files for deps, debuginfo, fixup, and verify_elf,
ignore files with type that matches "ELF * shared object, no machine, *"
pattern.

These are ELF files generated by GNU Guile, ignore them for now.
2017-04-18 16:42:41 +00:00