wok rev 694

hardinfo: fix boots & languages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 26 09:24:27 2008 +0000 (2008-04-26)
parents 3989e3ffe4d1
children 3220c33df33d
files hardinfo/receipt hardinfo/stuff/boots.patch hardinfo/stuff/languages.patch
line diff
     1.1 --- a/hardinfo/receipt	Sat Apr 26 07:32:19 2008 +0000
     1.2 +++ b/hardinfo/receipt	Sat Apr 26 09:24:27 2008 +0000
     1.3 @@ -16,6 +16,8 @@
     1.4  	cd $src
     1.5  	patch -p0 < ../stuff/modules.patch  || exit 1
     1.6  	patch -p0 < ../stuff/users.patch  || exit 1
     1.7 +	patch -p0 < ../stuff/languages.patch  || exit 1
     1.8 +	patch -p0 < ../stuff/boots.patch  || exit 1
     1.9  	./configure \
    1.10  		--prefix=/usr \
    1.11  		$CONFIGURE_ARGS
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/hardinfo/stuff/boots.patch	Sat Apr 26 09:24:27 2008 +0000
     2.3 @@ -0,0 +1,65 @@
     2.4 +--- arch/linux/common/boots.h	2008-04-26 10:38:31.000000000 +0200
     2.5 ++++ arch/linux/common/boots.h	2008-04-26 11:15:20.000000000 +0200
     2.6 +@@ -16,11 +16,17 @@
     2.7 +  *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
     2.8 +  */
     2.9 + 
    2.10 ++#include <sys/sysinfo.h>
    2.11 ++#include <sys/utsname.h>
    2.12 ++
    2.13 + void
    2.14 + scan_boots_real(void)
    2.15 + {
    2.16 +-    FILE *last;
    2.17 +-    char buffer[256];
    2.18 ++    struct sysinfo info;
    2.19 ++    struct utsname uname_info;
    2.20 ++    time_t now;
    2.21 ++    char date[40];
    2.22 ++    int i;
    2.23 + 
    2.24 +     scan_os(FALSE);
    2.25 + 
    2.26 +@@ -29,33 +35,13 @@
    2.27 +     else
    2.28 +       return;
    2.29 +     
    2.30 +-    last = popen("last", "r");
    2.31 +-    if (last) {
    2.32 +-      while (fgets(buffer, 256, last)) {
    2.33 +-        if (strstr(buffer, "system boot")) {
    2.34 +-          gchar **tmp, *buf = buffer;
    2.35 +-          
    2.36 +-          strend(buffer, '\n');
    2.37 +-          
    2.38 +-          while (*buf) {
    2.39 +-            if (*buf == ' ' && *(buf + 1) == ' ') {
    2.40 +-              strcpy(buf, buf + 1);
    2.41 +-              
    2.42 +-              buf--;
    2.43 +-            } else {
    2.44 +-              buf++;
    2.45 +-            }
    2.46 +-          }
    2.47 +-
    2.48 +-          tmp = g_strsplit(buffer, " ", 5);
    2.49 +-          computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
    2.50 +-                                                computer->os->boots,
    2.51 +-                                                tmp[4],
    2.52 +-                                                tmp[3]);
    2.53 +-          g_strfreev(tmp);
    2.54 +-        }
    2.55 +-      }
    2.56 +-      
    2.57 +-      pclose(last);
    2.58 +-    }
    2.59 ++    time(&now);
    2.60 ++    sysinfo(&info);
    2.61 ++    uname(&uname_info);
    2.62 ++    now -= info.uptime;
    2.63 ++    strcpy(date,ctime(&now));
    2.64 ++    for (i = 0; date[i] >= ' '; i++);
    2.65 ++    date[i] = 0;
    2.66 ++    computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
    2.67 ++		computer->os->boots, date, uname_info.release);
    2.68 + }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/hardinfo/stuff/languages.patch	Sat Apr 26 09:24:27 2008 +0000
     3.3 @@ -0,0 +1,20 @@
     3.4 +--- arch/common/languages.h	2008-04-26 10:04:42.000000000 +0200
     3.5 ++++ arch/common/languages.h	2008-04-26 10:51:31.000000000 +0200
     3.6 +@@ -21,6 +21,7 @@
     3.7 + {
     3.8 +     FILE *locale;
     3.9 +     gchar buf[512], *retval = NULL;
    3.10 ++    int last = 0;
    3.11 + 
    3.12 +     locale = popen("locale -va", "r");
    3.13 +     if (!locale)
    3.14 +@@ -37,7 +38,8 @@
    3.15 + 	  *date = NULL,
    3.16 + 	  *codeset = NULL;
    3.17 + 
    3.18 +-    while (fgets(buf, 512, locale)) {
    3.19 ++    while (fgets(buf, 512, locale) || last++ == 0) {
    3.20 ++	if (last) buf[0] = 0;
    3.21 + 	if (!strncmp(buf, "locale:", 7)) {
    3.22 + 	    sscanf(buf, "locale: %s", name);
    3.23 + 	    fgets(buf, 128, locale);