diff mbox series

[1/2] which: update 2.21 -> 2.23, build with meson

Message ID 20250922113920.2693840-1-alex.kanavin@gmail.com
State New
Headers show
Series [1/2] which: update 2.21 -> 2.23, build with meson | expand

Commit Message

Alexander Kanavin Sept. 22, 2025, 11:39 a.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

This (and 2.22) is a first release in many years. Rather than try
to use upstream's absurdly overblown, incompatible build system
(see below), I added a small-ish meson file. This means:

- drop tweaks and dependency on cwautomacros as that is no longer used

- drop patch as configure.ac has been rewritten, and the recipe is using meson anyway

- drop --disable-iberty for the same reason

In this realease, cwautomacros has been replaced by an equally custom, weird set
of macros, written by 'which' maintainer: https://github.com/CarloWood/cwm4

- one effect of that is that autoreconf isn't happy with which's configure.ac and won't run;
one is supposed to use a custom script instead: https://github.com/CarloWood/cwm4/blob/master/scripts/bootstrap.sh

- alas, that script is not shipped in tarballs; the maintainer wants
everyone to trust their 200k configure script (hello xz backdoor)

- building from git (where the script exists) is not impossible,
but that has no version tags

All this 'special handling' for what, exactly? Five .c files to produce one
single-function executable, and one manpage. Wich should all be in coreutils
to begin with. GNU's attachment to autotools defies reason.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 .../which/which-2.21/automake.patch           | 19 ----
 ...opt-Fix-signature-of-getenv-function.patch | 29 ++++---
 .../which/which-2.23/meson.build              | 87 +++++++++++++++++++
 .../which/{which_2.21.bb => which_2.23.bb}    | 11 +--
 4 files changed, 108 insertions(+), 38 deletions(-)
 delete mode 100644 meta/recipes-extended/which/which-2.21/automake.patch
 rename meta/recipes-extended/which/{which-2.21 => which-2.23}/0001-getopt-Fix-signature-of-getenv-function.patch (51%)
 create mode 100644 meta/recipes-extended/which/which-2.23/meson.build
 rename meta/recipes-extended/which/{which_2.21.bb => which_2.23.bb} (71%)
diff mbox series

Patch

diff --git a/meta/recipes-extended/which/which-2.21/automake.patch b/meta/recipes-extended/which/which-2.21/automake.patch
deleted file mode 100644
index 4d0f2e4d7be..00000000000
--- a/meta/recipes-extended/which/which-2.21/automake.patch
+++ /dev/null
@@ -1,19 +0,0 @@ 
-Update autoconf prologue to use "foreign" strictness.
-
-Upstream-Status: Pending
-Signed-off-by: Ross Burton <ross.burton@intel.com>
-
-diff --git a/configure.ac b/configure.ac
-index d974461..a20dfa8 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1,7 +1,7 @@
- dnl Process this file with autoconf to produce a configure script.
- AC_INIT([which], [2.21])
- AC_CONFIG_SRCDIR(which.c)
--AM_INIT_AUTOMAKE
-+AM_INIT_AUTOMAKE([foreign])
- AM_CONFIG_HEADER(config.h)
- AM_MAINTAINER_MODE
- 
-
diff --git a/meta/recipes-extended/which/which-2.21/0001-getopt-Fix-signature-of-getenv-function.patch b/meta/recipes-extended/which/which-2.23/0001-getopt-Fix-signature-of-getenv-function.patch
similarity index 51%
rename from meta/recipes-extended/which/which-2.21/0001-getopt-Fix-signature-of-getenv-function.patch
rename to meta/recipes-extended/which/which-2.23/0001-getopt-Fix-signature-of-getenv-function.patch
index e006d797d3c..c54368a0840 100644
--- a/meta/recipes-extended/which/which-2.21/0001-getopt-Fix-signature-of-getenv-function.patch
+++ b/meta/recipes-extended/which/which-2.23/0001-getopt-Fix-signature-of-getenv-function.patch
@@ -1,4 +1,4 @@ 
-From 16a1647fc26953fab659de5f55d4c0defdfb894f Mon Sep 17 00:00:00 2001
+From 83d2ed3fd203868a8f287d2ebedc7c304c74fbb4 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Sat, 22 Mar 2025 17:56:19 -0700
 Subject: [PATCH] getopt: Fix signature of getenv function
@@ -13,27 +13,32 @@  Upstream-Status: Submitted [https://lists.gnu.org/archive/html/which-bugs/2025-0
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
  getopt.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ getopt.h | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
 
+diff --git a/getopt.c b/getopt.c
+index 9ac2ed6..b1aa322 100644
 --- a/getopt.c
 +++ b/getopt.c
-@@ -209,7 +209,7 @@ static char *posixly_correct;
+@@ -205,7 +205,7 @@ static char *posixly_correct;
  /* Avoid depending on library functions or files
     whose names are inconsistent.  */
  
--char *getenv ();
+-char *getenv();
 +char *getenv (const char*);
  
- static char *
- my_index (str, chr)
+ static char *my_index(str, chr) const char *str;
+ int chr;
+diff --git a/getopt.h b/getopt.h
+index f080053..e04e3ca 100644
 --- a/getopt.h
 +++ b/getopt.h
-@@ -103,7 +103,7 @@ struct option
+@@ -102,7 +102,7 @@ struct option {
     errors, only prototype getopt for the GNU C library.  */
- extern int getopt (int argc, char *const *argv, const char *shortopts);
- #else /* not __GNU_LIBRARY__ */
--extern int getopt ();
+ extern int getopt(int argc, char *const *argv, const char *shortopts);
+ #else  /* not __GNU_LIBRARY__ */
+-extern int getopt();
 +extern int getopt (int, char * const [], const char *);
  #endif /* __GNU_LIBRARY__ */
- extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- 		        const struct option *longopts, int *longind);
+ extern int getopt_long(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind);
+ extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts,
diff --git a/meta/recipes-extended/which/which-2.23/meson.build b/meta/recipes-extended/which/which-2.23/meson.build
new file mode 100644
index 00000000000..97b3d23d5ae
--- /dev/null
+++ b/meta/recipes-extended/which/which-2.23/meson.build
@@ -0,0 +1,87 @@ 
+project('which', 'c', version: '2.23')
+
+add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
+
+src = ['bash.c','getopt1.c','getopt.c','tilde.c','which.c']
+
+executable('which', src, install: true)
+install_man('which.1')
+
+conf_data = configuration_data()
+
+conf_data.set('GETGROUPS_T', 'gid_t')
+
+compiler = meson.get_compiler('c')
+if compiler.has_function('strchr')
+    conf_data.set('HAVE_STRCHR', 1)
+endif
+if compiler.has_function('memcpy')
+    conf_data.set('HAVE_MEMCPY', 1)
+endif
+if compiler.has_function('getopt_long')
+    conf_data.set('HAVE_GETOPT_LONG', 1)
+endif
+if compiler.has_function('getcwd')
+    conf_data.set('HAVE_GETCWD', 1)
+endif
+if compiler.has_function('getwd')
+    conf_data.set('HAVE_GETWD', 1)
+endif
+if compiler.has_function('sysconf')
+    conf_data.set('HAVE_SYSCONF', 1)
+endif
+if compiler.has_function('getgroups')
+    conf_data.set('HAVE_GETGROUPS', 1)
+endif
+if compiler.has_function('eaccess')
+    conf_data.set('HAVE_EACCESS', 1)
+endif
+if compiler.has_function('getpwent')
+    conf_data.set('HAVE_GETPWENT', 1)
+endif
+if compiler.has_function('getpwnam')
+    conf_data.set('HAVE_GETPWNAM', 1)
+endif
+if compiler.has_function('getpwuid')
+    conf_data.set('HAVE_GETPWUID', 1)
+    conf_data.set('HAVE_GETPW_DECLS', 1)
+endif
+
+if compiler.has_header('unistd.h')
+    conf_data.set('HAVE_UNISTD_H', 1)
+endif
+if compiler.has_header('string.h')
+    conf_data.set('HAVE_STRING_H', 1)
+endif
+if compiler.has_header('stdlib.h')
+    conf_data.set('HAVE_STDLIB_H', 1)
+endif
+if compiler.has_header('memory.h')
+    conf_data.set('HAVE_MEMORY_H', 1)
+endif
+if compiler.has_header('pwd.h')
+    conf_data.set('HAVE_PWD_H', 1)
+endif
+if compiler.has_header('strings.h')
+    conf_data.set('HAVE_STRINGS_H', 1)
+endif
+if compiler.has_header('inttypes.h')
+    conf_data.set('HAVE_INTTYPES_H', 1)
+endif
+if compiler.has_header('stdio.h')
+    conf_data.set('HAVE_STDIO_H', 1)
+endif
+if compiler.has_header('stdint.h')
+    conf_data.set('HAVE_STDINT_H', 1)
+endif
+if compiler.has_header('sys/stat.h')
+    conf_data.set('HAVE_SYS_STAT_H', 1)
+endif
+if compiler.has_header('sys/types.h')
+    conf_data.set('HAVE_SYS_TYPES_H', 1)
+endif
+conf_data.set('NEED_XMALLOC', 1)
+conf_data.set('STDC_HEADERS', 1)
+conf_data.set('VERSION', '"' + meson.project_version() + '"')
+
+configure_file(output: 'config.h', configuration: conf_data)
diff --git a/meta/recipes-extended/which/which_2.21.bb b/meta/recipes-extended/which/which_2.23.bb
similarity index 71%
rename from meta/recipes-extended/which/which_2.21.bb
rename to meta/recipes-extended/which/which_2.23.bb
index 7279a047373..0bbc3510d87 100644
--- a/meta/recipes-extended/which/which_2.21.bb
+++ b/meta/recipes-extended/which/which_2.23.bb
@@ -9,21 +9,18 @@  HOMEPAGE = "https://carlowood.github.io/which/"
 LICENSE = "GPL-3.0-or-later"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504\
                     file://which.c;beginline=1;endline=17;md5=a9963693af2272e7a8df6f231164e7a2"
-DEPENDS     = "cwautomacros-native"
 
-inherit autotools texinfo update-alternatives
-
-EXTRA_OECONF = "--disable-iberty"
+inherit meson update-alternatives
 
 SRC_URI = "${GNU_MIRROR}/which/which-${PV}.tar.gz \
-           file://automake.patch \
+           file://meson.build \
            file://0001-getopt-Fix-signature-of-getenv-function.patch \
            "
 
-SRC_URI[sha256sum] = "f4a245b94124b377d8b49646bf421f9155d36aa7614b6ebf83705d3ffc76eaad"
+SRC_URI[sha256sum] = "a2c558226fc4d9e4ce331bd2fd3c3f17f955115d2c00e447618a4ef9978a2a73"
 
 do_configure:prepend() {
-	sed -i -e 's%@ACLOCAL_CWFLAGS@%-I ${STAGING_DIR_NATIVE}/usr/share/cwautomacros/m4%g' ${S}/Makefile.am ${S}/tilde/Makefile.am
+       cp ${UNPACKDIR}/meson.build ${S}
 }
 
 ALTERNATIVE:${PN} = "which"