Commit Graph

638 Commits

Author SHA1 Message Date
Arseny Maslennikov
76fa8b1172 Rename find-package to solve misconflict with rpm
It is not that easy to ship find-package as part of rpm-build.
We have to drop find-package from the filelist of rpm as well. For this
change to enter Sisyphus, both rpm-build and rpm have to be changed and
rebuilt in their own base build chroots.

If rpm-build is built to include find-package first, rpm is
uninstallable in the base chroot due to a misconflict, so it cannot be
rebuilt.
If rpm is built to exclude find-package first, it disappears from the
base chroot altogether, making rpm-build break, so no
package can be built as well.
2024-03-04 20:36:26 +03:00
Arseny Maslennikov
44ef3a03cd /usr/lib/rpm/find-package: re-import from rpm.git
In an environment created by `hsh --initroot-only`:
  $ for i in /usr/lib/rpm/*; do rpm -qf --qf='%{name}: '"$i"'\n' "$i"; done | grep '^rpm:'
  rpm: /usr/lib/rpm/0ldconfig.filetrigger
  rpm: /usr/lib/rpm/GROUPS
  rpm: /usr/lib/rpm/find-package
  rpm: /usr/lib/rpm/functions
  rpm: /usr/lib/rpm/macros.d
  rpm: /usr/lib/rpm/pdeath_execute
  rpm: /usr/lib/rpm/platform
  rpm: /usr/lib/rpm/posttrans-filetriggers
  rpm: /usr/lib/rpm/postupdate
  rpm: /usr/lib/rpm/rpmd
  rpm: /usr/lib/rpm/rpmdb_loadcvt
  rpm: /usr/lib/rpm/rpme
  rpm: /usr/lib/rpm/rpmi
  rpm: /usr/lib/rpm/rpmk
  rpm: /usr/lib/rpm/rpmpopt-4.13.0.1
  rpm: /usr/lib/rpm/rpmq
  rpm: /usr/lib/rpm/rpmu
  rpm: /usr/lib/rpm/rpmv

The `scripts/find-package` file is installed from the rpm project. We
replace our copy with that one, so the installed file does not change
but is installed as part of rpm-build.
2024-03-04 15:48:36 +03:00
Arseny Maslennikov
6bfa4a28aa /usr/lib/rpm/functions: split away to rpmb-functions
In an environment created by `hsh --initroot-only`:
  $ for i in /usr/lib/rpm/*; do rpm -qf --qf='%{name}: '"$i"'\n' "$i"; done | grep '^rpm:'
  rpm: /usr/lib/rpm/0ldconfig.filetrigger
  rpm: /usr/lib/rpm/GROUPS
  rpm: /usr/lib/rpm/find-package
  rpm: /usr/lib/rpm/functions
  rpm: /usr/lib/rpm/macros.d
  rpm: /usr/lib/rpm/pdeath_execute
  rpm: /usr/lib/rpm/platform
  rpm: /usr/lib/rpm/posttrans-filetriggers
  rpm: /usr/lib/rpm/postupdate
  rpm: /usr/lib/rpm/rpmd
  rpm: /usr/lib/rpm/rpmdb_loadcvt
  rpm: /usr/lib/rpm/rpme
  rpm: /usr/lib/rpm/rpmi
  rpm: /usr/lib/rpm/rpmk
  rpm: /usr/lib/rpm/rpmpopt-4.13.0.1
  rpm: /usr/lib/rpm/rpmq
  rpm: /usr/lib/rpm/rpmu
  rpm: /usr/lib/rpm/rpmv

The `scripts/functions` file is provided from the rpm project in real
installations. Let's ensure scripts in this package use the functions
file from this package.
2024-03-03 23:38:10 +03:00
Arseny Maslennikov
119d2f57f6 Introduce 044-verify-unit.brp
It is intended to check the sanity of systemd units installed in the
buildroot. As of today, it errors out on executable unit files and units
passing nobody as User=, Group= or in SupplementaryGroups=.
2024-01-11 17:00:00 +03:00
2b153b6f00 process-debuginfo: fixed re-compression of kernel modules
Linux kernel supports the direct loading of compressed modules
(via finit_module system call) since version 5.15. However
decompression options are less flexible (and are set at
the compile time). In particular kernel can read lzma archives
only with a dictionary size exactly 1 MiB, and crc32 checksum.

kmod started to make use of direct module loading since version
31. However kmod does not fall back to decompressing in the userspace
if the kernel compressed modules, which causes serious troubles
(boot failures, some devices not working, etc).

To avoid the problem teach process-debuginfo.in to re-compress
kernel modules correctly (crc32 checksum, 1 MiB dictionary)
so the kernel can load them directly.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fbf5892df21a8ccfcb2fda0fd65bc3169c89ed28
Reviewed-by: Vitaly Chikunov <vt@altlinux.org>
2024-01-11 17:00:00 +03:00
2230d27006 process-debuginfo: Do not strip&split debugging vmlinux binary
crash is unable to handle vmlinux split into vmlinux.debug because it
cannot find `.symtab`[1]. This is not expected to be fixed soon.

Really, there is not point to split it because both halves are in
the same -debuginfo package and this is only complicates things.

This also undoes approach taken in 894f4140c ("process-debuginfo: Add
.gnu_debuglink symlink for vmlinux").

Link: https://github.com/crash-utility/crash/issues/160
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2023-12-08 06:11:26 +03:00
894f4140ce process-debuginfo: Add .gnu_debuglink symlink for vmlinux
`eu-strip --strip-all` started to strip .symtab for un-def kernel
triggering different code path in crash(8) thus making it follow
value of `.gnu_debuglink` section and miss vmlinux.debug.

Also, this seems to be more portable overall - we can find vmlinux by
prepending `/usr/lib/debug` or by appending `.debug`.

With educated guess we assume eu-strip will put "BASENAME.debug" in
`.gnu_debuglink`.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2023-11-17 08:21:09 +03:00
Gleb Fotengauer-Malinovskiy
051d1fee67 scripts/provided_symbols: use elfutils' readelf instead of binutils' one
This script is designed to ignore lines that don't follow the expected
format, but it is widely known that the output format of readelf utility
from the binutils project can be quite unreliable.  The output format
may vary on certain architectures and ELFs created with certain build
tools may contain symbols with peculiar bits that affect the output.

Here is a couple of examples illustrating these issues:
* On PowerPC, ELF symbols frequently include the localentry bit.
  For instance:
$ readelf --wide --dyn-syms /lib64/libcrypto.so.1.1  | grep ASN1_VISIBLESTRING_new
   157: 00000000000938c0    60 FUNC    GLOBAL DEFAULT [<localentry>: 8]    11 ASN1_VISIBLESTRING_new@@OPENSSL_1_1_0
* On x86_64, a proprietary blob /usr/lib64/libjcPKCS11ds.so (distributed
  as an ELF) and on armh /usr/lib/libLLVM-16.so, contain symbols with
  OS-specific bits:
$ readelf --wide --dyn-syms /usr/lib64/libjcPKCS11ds.so | grep _ZNSt7collateIwE2idE
  2572: 00000000002df9c8     8 OBJECT  <OS specific>: 10 DEFAULT   26 _ZNSt7collateIwE2idE
$ readelf --wide --dyn-syms /usr/lib/libLLVM-16.so | grep _ZN4llvm13AllAnalysesOnINS_6ModuleEE6SetKeyE
 45060: 05af0478     8 OBJECT  <OS specific>: 10 DEFAULT   26 _ZN4llvm13AllAnalysesOnINS_6ModuleEE6SetKeyE@@LLVM_16

The issue related to PowerPC localentry bits was resolved in the commit
4f4a1d146 ("lib.prov, lib.req: enhance ProvidedSymbols") a long time
ago.  The issue related to OS-specific bits was discovered recently [1].

Instead of attempting to resolve the output issues of binutils' readelf
utility concerning OS-specific bits, it is more convenient to use
readelf from elfutils.  It has more reliable output (including the
handling of the cases described earlier) and is extensively utilized
within the project anyway.

[1] https://bugzilla.altlinux.org/46447

Reported-by: Konstantin A. Lepikhov <lakostis@altlinux.ru>
Reported-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Fixes: https://bugzilla.altlinux.org/46447
2023-06-08 05:00:00 +00:00
Arseny Maslennikov
95476ebe95 systemd-services.req.files: consider user units 2023-03-22 16:31:45 +03:00
Arseny Maslennikov
da32535a15 systemd-services.req.files: handle directories correctly 2023-03-22 15:24:26 +03:00
8b687ab59e systemd-services.req.in: fix autoreq for systemd units
Starting with systemd-239, Exec*= lines of unit files
are no longer required to reference absolute paths.
systemd-services.req, however, was expecting an absolute paths.

Given the new system-update-cleanup.service:
ExecStart=rm -fv /system-update
systemd-services.req used to find "/system-update" requirement:
systemd-services.req: /usr/src/tmp/systemd-buildroot/lib/systemd/system/system-update-cleanup.service: /system-update -> /system-update (raw, not installed)

This change updates systemd-services.req to the new systemd unit files
semantics, and also cleanups the code by removing redundant grep.
2023-01-25 19:50:49 +03:00
156cf74278 process-debuginfo: Keep .BTF section for kernel objects
`.BTF' section is needed to load kernel modules if
`CONFIG_DEBUG_INFO_BTF_MODULES' is enabled. This requirement is
introduced in Linux commit c446fdacb10d ("bpf: fix
register_btf_kfunc_id_set for !CONFIG_DEBUG_INFO_BTF").

`--keep-section=.BTF' is added also for vmlinux processing, because
commit seems to affect vmlinux (in case of `CONFIG_DEBUG_INFO_BTF').

Encountered error message:

  # modprobe nf_nat; dmesg | tail -1
  modprobe: ERROR: could not insert 'nf_nat': Unknown symbol in module, or unknown parameter (see dmesg)
  [16781.315808] missing module BTF, cannot register kfuncs

Reported-by: Andrew A. Vasilyev <andy@altlinux.org>
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
2022-06-24 00:36:36 +03:00
93297e9c33 s/egrep/grep -E/ 2022-04-26 08:00:00 +00:00
61e11d51a2 s/fgrep/grep -F/ 2022-04-26 08:00:00 +00:00
9db3eec288 lib.req: upgrade "library not found" warnings to errors
These "library not found" warnings are real packaging errors,
they also cause further ldd errors down the line.
2022-02-06 08:00:00 +00:00
Gleb Fotengauer-Malinovskiy
0240974c0a brp-sign-kmodules.in: add comment regarding this script's scope 2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
8e514bdbdd brp-sign-kmodules.in: sync xz compression flags with the Linux kernel 2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
f8431643d5 brp-sign-kmodules.in: add support for zstd-compressed modules
It means that we support all module compression methods supported by
the modern Linux kernel because the v5.15 version supports gzip-, xz-,
zstd-compressed and uncompressed modules.
2021-11-03 03:11:44 +03:00
Gleb Fotengauer-Malinovskiy
8e9f5a8100 brp-sign-kmodules.in: rewrite module (de)compression logic
This change makes easier to add support of zstd-compressed modules in
the next commit.
2021-11-03 03:11:44 +03:00
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