[busybox/f15] Fix compilation of uClibc vs Linux-3.0 headers

Daniel Drake dsd at fedoraproject.org
Sat Aug 27 00:59:16 UTC 2011


commit 5e40044852f70ca459877fb72e1497aa6e317ee3
Author: Daniel Drake <dsd at laptop.org>
Date:   Sat Aug 27 01:24:30 2011 +0100

    Fix compilation of uClibc vs Linux-3.0 headers

 busybox-sysinfo-1.patch |   50 +++++++++++++++++++++++++++
 busybox-sysinfo-2.patch |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 busybox.spec            |   10 +++++-
 3 files changed, 144 insertions(+), 1 deletions(-)
---
diff --git a/busybox-sysinfo-1.patch b/busybox-sysinfo-1.patch
new file mode 100644
index 0000000..569db23
--- /dev/null
+++ b/busybox-sysinfo-1.patch
@@ -0,0 +1,50 @@
+From be391e759675b23ccf6e19cb6ea5b819840f3026 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux at googlemail.com>
+Date: Mon, 25 Jul 2011 09:05:43 +0000
+Subject: libbb.h: do not use homegrown struct sysinfo.
+
+Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
+---
+diff --git a/include/libbb.h b/include/libbb.h
+index 1502272..3d31ff2 100644
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -52,6 +52,10 @@
+ #ifdef HAVE_SYS_STATFS_H
+ # include <sys/statfs.h>
+ #endif
++/* struct sysinfo is linux-specific */
++#ifdef __linux__
++# include <sys/sysinfo.h>
++#endif
+ #if ENABLE_SELINUX
+ # include <selinux/selinux.h>
+ # include <selinux/context.h>
+@@ -133,25 +137,6 @@ int klogctl(int type, char *b, int len);
+ #if !defined __FreeBSD__
+ char *dirname(char *path);
+ #endif
+-/* Include our own copy of struct sysinfo to avoid binary compatibility
+- * problems with Linux 2.4, which changed things.  Grumble, grumble. */
+-struct sysinfo {
+-	long uptime;			/* Seconds since boot */
+-	unsigned long loads[3];		/* 1, 5, and 15 minute load averages */
+-	unsigned long totalram;		/* Total usable main memory size */
+-	unsigned long freeram;		/* Available memory size */
+-	unsigned long sharedram;	/* Amount of shared memory */
+-	unsigned long bufferram;	/* Memory used by buffers */
+-	unsigned long totalswap;	/* Total swap space size */
+-	unsigned long freeswap;		/* swap space still available */
+-	unsigned short procs;		/* Number of current processes */
+-	unsigned short pad;			/* Padding needed for m68k */
+-	unsigned long totalhigh;	/* Total high memory size */
+-	unsigned long freehigh;		/* Available high memory size */
+-	unsigned int mem_unit;		/* Memory unit size in bytes */
+-	char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding: libc5 uses this.. */
+-};
+-int sysinfo(struct sysinfo* info);
+ #ifndef PATH_MAX
+ # define PATH_MAX 256
+ #endif
+--
+cgit v0.9.0.1-2-gef13
diff --git a/busybox-sysinfo-2.patch b/busybox-sysinfo-2.patch
new file mode 100644
index 0000000..2faa56a
--- /dev/null
+++ b/busybox-sysinfo-2.patch
@@ -0,0 +1,85 @@
+From 67905e2d7c6ee273b753af22fb22de0ebec918c1 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux at googlemail.com>
+Date: Tue, 26 Jul 2011 11:42:12 +0000
+Subject: *: work around sysinfo.h versus linux/*.h problems
+
+Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
+---
+Index: busybox-1.18.2/include/libbb.h
+===================================================================
+--- busybox-1.18.2.orig/include/libbb.h
++++ busybox-1.18.2/include/libbb.h
+@@ -44,10 +44,12 @@
+ #ifdef HAVE_SYS_STATFS_H
+ # include <sys/statfs.h>
+ #endif
+-/* struct sysinfo is linux-specific */
+-#ifdef __linux__
+-# include <sys/sysinfo.h>
+-#endif
++/* Don't do this here:
++ * #include <sys/sysinfo.h>
++ * Some linux/ includes pull in conflicting definition
++ * of struct sysinfo (only in some toolchanins), which breaks build.
++ * Include sys/sysinfo.h only in those files which need it.
++ */
+ #if ENABLE_SELINUX
+ # include <selinux/selinux.h>
+ # include <selinux/context.h>
+Index: busybox-1.18.2/init/init.c
+===================================================================
+--- busybox-1.18.2.orig/init/init.c
++++ busybox-1.18.2/init/init.c
+@@ -113,7 +113,8 @@
+ #include <paths.h>
+ #include <sys/resource.h>
+ #ifdef __linux__
+-#include <linux/vt.h>
++# include <linux/vt.h>
++# include <sys/sysinfo.h>
+ #endif
+ #if ENABLE_FEATURE_UTMP
+ # include <utmp.h> /* DEAD_PROCESS */
+Index: busybox-1.18.2/procps/free.c
+===================================================================
+--- busybox-1.18.2.orig/procps/free.c
++++ busybox-1.18.2/procps/free.c
+@@ -10,6 +10,9 @@
+ /* getopt not needed */
+ 
+ #include "libbb.h"
++#ifdef __linux__
++# include <sys/sysinfo.h>
++#endif
+ 
+ struct globals {
+ 	unsigned mem_unit;
+Index: busybox-1.18.2/procps/ps.c
+===================================================================
+--- busybox-1.18.2.orig/procps/ps.c
++++ busybox-1.18.2/procps/ps.c
+@@ -16,6 +16,9 @@ enum { MAX_WIDTH = 2*1024 };
+ 
+ #if ENABLE_DESKTOP
+ 
++#ifdef __linux__
++# include <sys/sysinfo.h>
++#endif
+ #include <sys/times.h> /* for times() */
+ #ifndef AT_CLKTCK
+ #define AT_CLKTCK 17
+Index: busybox-1.18.2/procps/uptime.c
+===================================================================
+--- busybox-1.18.2.orig/procps/uptime.c
++++ busybox-1.18.2/procps/uptime.c
+@@ -16,6 +16,10 @@
+ /* getopt not needed */
+ 
+ #include "libbb.h"
++#ifdef __linux__
++# include <sys/sysinfo.h>
++#endif
++
+ 
+ #ifndef FSHIFT
+ # define FSHIFT 16              /* nr of bits of precision */
diff --git a/busybox.spec b/busybox.spec
index 7979fa4..e7d3f27 100644
--- a/busybox.spec
+++ b/busybox.spec
@@ -1,7 +1,7 @@
 Summary: Statically linked binary providing simplified versions of system commands
 Name: busybox
 Version: 1.18.2
-Release: 5%{?dist}
+Release: 6%{?dist}
 Epoch: 1
 License: GPLv2
 Group: System Environment/Shells
@@ -20,6 +20,9 @@ Patch35: http://busybox.net/downloads/fixes-1.18.2/busybox-1.18.2-ping.patch
 Patch36: http://busybox.net/downloads/fixes-1.18.2/busybox-1.18.2-tar.patch
 Patch37: http://busybox.net/downloads/fixes-1.18.2/busybox-1.18.2-udhcp.patch
 Patch38: http://busybox.net/downloads/fixes-1.18.2/busybox-1.18.2-wc.patch
+# Already-upstream fixes for compiling against Linux 3.0 headers
+Patch40: busybox-sysinfo-1.patch
+Patch41: busybox-sysinfo-2.patch
 
 Obsoletes: busybox-anaconda
 URL: http://www.busybox.net
@@ -66,6 +69,8 @@ better suited to normal use.
 %patch36 -p1 -b .tar
 %patch37 -p1 -b .udhcp
 %patch38 -p1 -b .wc
+%patch40 -p1 -b .sysinfo1
+%patch41 -p1 -b .sysinfo2
 
 %build
 # create static busybox - the executable is kept as busybox-static
@@ -134,6 +139,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/busybox.petitboot.1.gz
 
 %changelog
+* Sat Aug 27 2011 Daniel Drake <dsd at laptop.org> - 1:1.18.2-6
+- Fix compilation against uClibc and Linux-3.0 headers
+
 * Fri Aug 26 2011 Daniel Drake <dsd at laptop.org> - 1:1.18.2-5
 - Remove Linux 2.4 support from insmod/modprobe/etc.
 - Fixes build failures on ARM, where such ancient syscalls are not present


More information about the scm-commits mailing list