Files
nfpm/testdata/acceptance/rpm.scriptrequires.yaml
Laurent CoustetandLaurent Coustet edf3552720 feat(rpm): add script_requires to require script interpreters (#1151)
rpmbuild runs script.req on the executable files of a package, so a
package that ships a "#!/bin/bash" script requires /bin/bash without
any work from the packager. nfpm has no such generator, so the
interpreter of every script must be listed by hand, which is
error-prone.

Add the opt-in rpm.script_requires option. Like script.req with the
exeonly flag of script.attr, it reads the "#!" line of each executable
file and requires its interpreter, and the absolute program run by
env, flagged RPMSENSE_FIND_REQUIRES like the dependencies rpmbuild
generates. Documentation files, symlinks, directories and ghosts are
skipped. The mode checked is the one in the package, so file_info.mode
is honored and the option also works when building on Windows.

The generated spec sets AutoReqProv: no, so the requires are written
to it explicitly and rpmbuild --rebuild keeps them.

Add unit tests, a scriptrequires acceptance stage that reads the
requires back with rpm, and an executable script to the srpm rebuild
acceptance test.

Co-authored-by: Laurent Coustet <laurent.coustet@bluemind.net>
2026-10-28 16:45:58 +00:00

23 lines
536 B
YAML

name: "foo"
arch: "${BUILD_ARCH}"
platform: "linux"
version: "v1.2.3"
maintainer: "Foo Bar"
description: "Foo bar"
license: "MIT"
contents:
- src: ./testdata/acceptance/scripts/script_requires_bash.sh
dst: /usr/libexec/foo/bash-script
file_info:
mode: 0755
- src: ./testdata/acceptance/scripts/script_requires_env.sh
dst: /usr/libexec/foo/env-script
file_info:
mode: 0755
- src: ./testdata/acceptance/scripts/script_requires_perl.pl
dst: /usr/share/foo/data.pl
file_info:
mode: 0644
rpm:
script_requires: true