package/linux-pam: Remove unneeded flex dependency
### Check-list
- [x] I did not find the issue in the existing issues
- [x] I can reproduce the issue with unmodified Buildroot from [this
repository](https://gitlab.com/buildroot.org/buildroot), not from a
fork somewhere else
- [x] I can reproduce the issue on the latest commit of the branch I'm using:
- [x] master
- [ ] stable (i.e. 20NN.MM.x - please specify)
- [ ] LTS (i.e. 20NN.02.x - please specify)
- [x] I can reproduce the issue after running `make clean; make`
- [x] I attached the full build log file (e.g. `make 2>&1 |tee build.log`)
- [x] I attached a **minimal** defconfig file that can reproduce the
issue (`make BR2_DEFCONFIG=$(pwd)/issue_defconfig savedefconfig`)
- [ ] I also attached the configuration for kconfig-based packages that
are enabled (and necessary to reproduce the issue), most notably:
- [ ] busybox
- [ ] linux
- [ ] uclibc
- [ ] uboot
- [ ] …
What I did
- Buildroot commit sha1: 2024.08-814-gb98062f730
- Distribution of the build machine: Ubuntu 22.04.5 LTS (Jammy Jellyfish)
Use a very simple defconfig with linux-pam:
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
BR2_REPRODUCIBLE=y
BR2_PACKAGE_OPENSSL=y
BR2_PACKAGE_LINUX_PAM=y
BR2_PACKAGE_LINUX_PAM_LASTLOG=y
BR2_PACKAGE_LIBSELINUX=y
BR2_PACKAGE_AUDIT=y
What is expected
Build linux-pam with minimal dependencies.
What happens
flex is built and included in the target rootfs (libfl).
Extra information
linux-pam doesn't actually need to link with libfl from flex.
In the past libfl was needed because yywrap was used, but this changed in 1.2.0 in the following commit in december 2014:
https://github.com/linux-pam/linux-pam/commit/8da3f3c38e075498a24fb9db80ae9862bda7154d
I tested with the following patch, and it works properly and generates the exact same binaries without the target flex package:
diff --git a/package/linux-pam/Config.in b/package/linux-pam/Config.in
index 1aa9045333..6b08a9c4c2 100644
--- a/package/linux-pam/Config.in
+++ b/package/linux-pam/Config.in
@@ -5,7 +5,6 @@ config BR2_PACKAGE_LINUX_PAM
depends on !BR2_STATIC_LIBS
depends on BR2_USE_MMU # fork()
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C11/stdatomic.h
- select BR2_PACKAGE_FLEX
select BR2_PACKAGE_LIBXCRYPT if BR2_TOOLCHAIN_USES_GLIBC
help
A Security Framework that Provides Authentication for
diff --git a/package/linux-pam/linux-pam.mk b/package/linux-pam/linux-pam.mk
index 1433eb00b3..a5b8c9151f 100644
--- a/package/linux-pam/linux-pam.mk
+++ b/package/linux-pam/linux-pam.mk
@@ -16,7 +16,7 @@ LINUX_PAM_CONF_OPTS = \
--disable-regenerate-docu \
--enable-securedir=/lib/security \
--libdir=/lib
-LINUX_PAM_DEPENDENCIES = flex host-flex host-pkgconf \
+LINUX_PAM_DEPENDENCIES = host-flex host-pkgconf \
$(if $(BR2_PACKAGE_LIBXCRYPT),libxcrypt) \
$(TARGET_NLS_DEPENDENCIES)
LINUX_PAM_LICENSE = BSD-3-Clause