summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorIsmael Luceno2019-08-01 18:51:22 +0200
committerIsmael Luceno2019-08-01 18:51:22 +0200
commitaff1c77e38ffb2496e34ecf45948830b57e04219 (patch)
tree902e9c1a1dc4de5fb9f95b06a6e6d87a6612f499 /utils
parent8f0c51e0d5747c36fddb7f2784bd92d218ecf656 (diff)
lshw: Fix build against musl libc
- Import patches from void-linux - Add a proper fix for _SC_LONG_BIT
Diffstat (limited to 'utils')
-rw-r--r--utils/lshw/HISTORY6
-rwxr-xr-xutils/lshw/PRE_BUILD3
-rw-r--r--utils/lshw/patches/fix-array-bounds.patch15
-rw-r--r--utils/lshw/patches/musl-basename.patch30
-rw-r--r--utils/lshw/patches/musl-long_bit.patch15
-rw-r--r--utils/lshw/patches/musl-path_max.patch14
6 files changed, 83 insertions, 0 deletions
diff --git a/utils/lshw/HISTORY b/utils/lshw/HISTORY
index 39ef48f2af..908af7280c 100644
--- a/utils/lshw/HISTORY
+++ b/utils/lshw/HISTORY
@@ -1,3 +1,9 @@
+2019-08-01 Ismael Luceno <ismael@sourcemage.org>
+ * PRE_BUILD, patches/fix-array-bounds.patch,
+ patches/musl-basename.patch, patches/musl-path_max.patch:
+ Imported musl patches from void-linux
+ * patches/musl-long_bit.patch: Replaced the non-standard _SC_LONG_BIT
+
2017-01-20 Treeve Jelbert <treeve@sourcemage.org>
* DETAILS: version B.02.18
diff --git a/utils/lshw/PRE_BUILD b/utils/lshw/PRE_BUILD
new file mode 100755
index 0000000000..c230ad14bf
--- /dev/null
+++ b/utils/lshw/PRE_BUILD
@@ -0,0 +1,3 @@
+default_pre_build &&
+cd "$SOURCE_DIRECTORY" &&
+apply_patch_dir patches
diff --git a/utils/lshw/patches/fix-array-bounds.patch b/utils/lshw/patches/fix-array-bounds.patch
new file mode 100644
index 0000000000..5592e8e76d
--- /dev/null
+++ b/utils/lshw/patches/fix-array-bounds.patch
@@ -0,0 +1,15 @@
+From: https://github.com/void-linux/void-packages/tree/7bfdb7ab051fbb43309c764ed4613d39ee590679/srcpkgs/lshw/patches/
+
+Fix GCC warning "array subscript is above array bounds [-Warray-bounds]"
+
+--- a/src/core/dmi.cc
++++ b/src/core/dmi.cc
+@@ -511,7 +511,7 @@
+ if (num <= 0x0A)
+ return _(memory_array_location[num]);
+ if (num >= 0xA0 && num < 0xA4)
+- return _(jp_memory_array_location[num]);
++ return _(jp_memory_array_location[num - 0xA0]);
+ return "";
+ }
+
diff --git a/utils/lshw/patches/musl-basename.patch b/utils/lshw/patches/musl-basename.patch
new file mode 100644
index 0000000000..07e5788c65
--- /dev/null
+++ b/utils/lshw/patches/musl-basename.patch
@@ -0,0 +1,30 @@
+From: https://github.com/void-linux/void-packages/tree/7bfdb7ab051fbb43309c764ed4613d39ee590679/srcpkgs/lshw/patches/
+
+For musl libc declare a macro version of basename(3).
+
+--- a/src/core/dasd.cc
++++ b/src/core/dasd.cc
+@@ -10,6 +10,10 @@
+ #include <linux/fs.h>
+ #include <map>
+
++#if !defined(__GLIBC__)
++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src)
++#endif
++
+ using namespace std;
+
+ /*Read only block devices, not partitions*/
+--- a/src/core/sysfs.cc
++++ b/src/core/sysfs.cc
+@@ -19,6 +19,10 @@
+
+ __ID("@(#) $Id$");
+
++#if !defined(__GLIBC__)
++#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src)
++#endif
++
+ using namespace sysfs;
+
+ struct sysfs::entry_i
diff --git a/utils/lshw/patches/musl-long_bit.patch b/utils/lshw/patches/musl-long_bit.patch
new file mode 100644
index 0000000000..20a2c8019d
--- /dev/null
+++ b/utils/lshw/patches/musl-long_bit.patch
@@ -0,0 +1,15 @@
+From: ismael@sourcemage.org
+
+musl libc does not implement _SC_LONG_BIT, replace with a portable alternative.
+
+--- a/src/core/abi.cc
++++ b/src/core/abi.cc
+@@ -20,7 +20,7 @@ __ID("@(#) $Id: mem.cc 1352 2006-05-27 23:54:13Z ezix $");
+ bool scan_abi(hwNode & system)
+ {
+ // are we compiled as 32- or 64-bit process ?
+- system.setWidth(sysconf(LONG_BIT));
++ system.setWidth(sizeof(long) * CHAR_BIT);
+
+ pushd(PROC_SYS);
+
diff --git a/utils/lshw/patches/musl-path_max.patch b/utils/lshw/patches/musl-path_max.patch
new file mode 100644
index 0000000000..a6d4ba59bd
--- /dev/null
+++ b/utils/lshw/patches/musl-path_max.patch
@@ -0,0 +1,14 @@
+From: https://github.com/void-linux/void-packages/tree/7bfdb7ab051fbb43309c764ed4613d39ee590679/srcpkgs/lshw/patches/
+
+Need to include limits.h for the definition of PATH_MAX.
+
+--- a/src/core/cpufreq.cc
++++ b/src/core/cpufreq.cc
+@@ -10,6 +10,7 @@
+ #include "version.h"
+ #include "hw.h"
+ #include "osutils.h"
++#include <limits.h>
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>