Commit Graph

619 Commits

Author SHA1 Message Date
Gleb Fotengauer-Malinovskiy
b80ad41451 brp-sign-kmodules.in: call nproc(1) utility once 2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
d60876ea4f brp-sign-kmodules.in: fix couple of shellcheck warnings
SC2162 ("read without -r will mangle backslashes") and SC2086: ("Double
quote to prevent globbing and word splitting").  These actually seem to
be harmless in our case.
2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
7a87954821 process-debuginfo.in: sync xz compression flags with the Linux kernel 2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
b996912c5d brp-debuginfo.in, process-debuginfo.in: add support for zstd-compressed modules 2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
b07d68eab5 process-debuginfo.in: rewrite module (de)compression logic
This change makes easier to add support of zstd-compressed modules in
the next commit.
2021-11-03 02:33:13 +03:00
fcc291f3a6 process-lto: enhance __gnu_lto_slim diagnostics
Turn __gnu_lto_slim diagnostics into a concise phrase printed for each
faulty archive file followed by a single lengthy multi-line descriptive
text.

Suggested-by: Vitaly Chikunov <vt@altlinux.org>
Link: https://lore.altlinux.org/devel/20210827221847.arp4wv7ngnkdliwm@altlinux.org/T/#u
2021-09-08 08:00:00 +00:00
457de4ae02 process-lto: add explicit diagnostics about failed strip
While strip is verbose when it fails to process files,
it's not quite obvious that it exits with a non-zero status,
hence an explicit diagnostics message might be useful.
2021-09-08 08:00:00 +00:00
6903fbf1b7 process-lto: Fix suggestion text
Using `%define` produces error messages like this:

  [i586] error: Recursion depth(25) greater than max(24)
  [i586]  23<                                               (empty)
  [i586]  22<                                             (empty)
  [i586]  21<                                           (empty)
  [i586]  20<                                         (empty)
  [i586]  19<                                       (empty)
  [i586]  18<                                     (empty)
  [i586]  17<                                   (empty)
  [i586]  16<                                 (empty)
  [i586]  15<                               (empty)
  [i586]  14<                             (empty)
  [i586]  13<                           (empty)
  [i586]  12<                         (empty)
  [i586]  11<                       (empty)
  [i586]  10<                     (empty)
  [i586]   9<                   (empty)
  [i586]   8<                 (empty)
  [i586]   7<               (empty)
  [i586]   6<             (empty)
  [i586]   5<           (empty)
  [i586]   4<         (empty)
  [i586]   3<       (empty)
  [i586]   2<     (empty)
  [i586]   1<   -pipe -frecord-gcc-switches -Wall -g -O2
  [i586]   0< CFLAGS="-pipe -frecord-gcc-switches -Wall -g -O2
  [i586] error: line 90: CFLAGS="-pipe -frecord-gcc-switches -Wall -g -O2
  [i586] hsh-rebuild: pkg.tar: failed to fetch build dependencies.
2021-08-24 22:34:59 +03:00
715065e999 brp: Add brp-strip-lto script
Strip LTO sections and symbols from objects and archives (static
libraries). %brp_strip_none macro is respected.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
2021-08-24 00:52:22 +03:00
b893f89a7f Fix regression introduced by forgotten file usage
There was two forgotten file instances. Fix error such as:

  /root/tmp/rpm-tmp.80ZNEF: line 1: /usr/sbin/post_service: No such file or directory
  error: %post(traefik-2.4.14-alt1.x86_64) scriptlet failed, exit status 127
  error: traefik-2.4.14-alt1.x86_64: install failed

Fixes: 5ef5c8ff4 ("Use file4 instead of file")
2021-08-18 01:20:36 +03:00
5ef5c8ff4a Use file4 instead of file
This will allow upgrading system file to v5, leaving rpmbuild using
stable file v4.
2021-08-12 13:23:31 +03:00
89e3f8b764 Use system provided debugedit
Debugedit is split into a separate package, use it.

References:
  https://sourceware.org/bugzilla/show_bug.cgi?id=27351
  http://lists.rpm.org/pipermail/rpm-ecosystem/2021-February/000734.html
  https://sourceware.org/debugedit/
2021-04-29 22:39:21 +03:00
bb6b349cb4 Move brp-bytecompile_python and brp-hardlink_pyo_pyc to rpm-build-python
If there are .py files to bytecompile, then rpm-build-python has to be
installed, so move these scripts to rpm-build-python where they belong.
2021-04-29 12:00:00 +00:00
ca8e8131b4 ldd.in: fix trace_elf error diagnostics 2021-01-11 08:00:00 +00:00
5e710ba046 Add fixup method: gnuconfig
Replaces all config.guess and config.sub files outside gnu-config
to symlinks leading to /usr/share/gnu-config/{config.guess,config.sub}.
2020-12-21 08:00:00 +00:00
cd0eca00e9 brp-debuginfo: Add debug sources check
Warn if debuginfo is present, but debug sources aren't.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
2020-12-18 03:45:22 +03:00
457fef1d64 debuginfo: strip --reloc-debug-sections for kernel modules
`--reloc-debug-sections` resolves trivial relocs between debug
sections and designed for use on kernel modules debug (.ko.debug)
reducing their sizes.
2020-12-18 03:45:22 +03:00
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