snmp/snmp.patch

Tue, 29 Mar 2011 20:04:34 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 29 Mar 2011 20:04:34 +0200
changeset 334
4a34d7a82eab
child 353
198005e4aad2
permissions
-rw-r--r--

Rework package yet again, correcting and introducing new buildconf logic:
Conditionally disable bootstrap stage comparison correctly, correct
english grammar, better find system as(1) and ld(1), indotruce detailed
optimization option messages, more completely guess cpu types, allow
profiled bootstrapping without a preinstalled GCC because many other
compilers have long since implemented 64-bit arithmetic, instruct make
to build sequentially (not in sparallel) when building a profiled
bootstrap as GCC online documents recommend, and generally improve
comment blocks.

The single most important correction in this changeset relates to the
GCC changed optimization policy since at least GCC 4.5, in which -march
is always passed and not always correctly guessed. In the case of this
package, allowing GCC to guess the architecture leads to wild build
errors at various subcomponents (zlib, libgcc, libiberty...) and
bootstrap stages. It seems quite platform specific, and the safest
approach to correcting this seems to be explicitly always specifying the
-march argument when bootstrapping GCC. Because the best choice 'native'
is not available when bootstrapping using a foreign (non GCC) compiler,
a guess is made according to rpmmacros l_platform in that case.

It is questionable as to whether these recent optimization changes
on the part of GCC or this package are compatible with each other,
or if either are complete or correct at all. At least applying these
corrections allows this package to build again in most cases test.

     1 Index: Makefile.in
     2 --- Makefile.in.orig	2010-09-10 06:23:07.000000000 +0200
     3 +++ Makefile.in	2010-10-09 09:56:09.000000000 +0200
     4 @@ -18,7 +18,7 @@
     5  INCLUDESUBDIR=system
     6  INCLUDESUBDIRHEADERS= aix.h bsd.h bsdi3.h bsdi4.h bsdi.h cygwin.h \
     7  	darwin.h darwin7.h darwin8.h darwin9.h darwin10.h dragonfly.h dynix.h \
     8 -	freebsd2.h freebsd3.h freebsd4.h freebsd5.h freebsd6.h freebsd.h \
     9 +	freebsd2.h freebsd3.h freebsd4.h freebsd5.h freebsd6.h freebsd7.h freebsd8.h freebsd9.h freebsd.h \
    10  	generic.h \
    11  	hpux.h irix.h linux.h mingw32.h mips.h netbsd.h openbsd.h osf5.h \
    12  	solaris2.3.h solaris2.4.h solaris2.5.h solaris2.6.h \
    13 Index: agent/auto_nlist.c
    14 --- agent/auto_nlist.c.orig	2010-07-29 16:58:47.000000000 +0200
    15 +++ agent/auto_nlist.c	2010-10-09 09:08:23.000000000 +0200
    16 @@ -53,6 +53,7 @@
    17      }
    18      if (*ptr == 0) {
    19          *ptr = (struct autonlist *) malloc(sizeof(struct autonlist));
    20 +	memset(*ptr, 0, sizeof(struct autonlist));
    21          it = *ptr;
    22          it->left = 0;
    23          it->right = 0;
    24 Index: agent/mibgroup/mibII/tcp.c
    25 --- agent/mibgroup/mibII/tcp.c.orig	2010-08-13 17:04:33.000000000 +0200
    26 +++ agent/mibgroup/mibII/tcp.c	2010-10-09 09:08:23.000000000 +0200
    27 @@ -87,7 +87,7 @@
    28                   * But only define it under FreeBSD, since it
    29                   *   breaks other systems (notable AIX)
    30                   */
    31 -#ifdef freebsd4
    32 +#if defined (freebsd4) || defined (__NetBSD__)
    33  int  hz = 1000;
    34  #endif
    36 Index: agent/mibgroup/mibII/tcpTable.c
    37 --- agent/mibgroup/mibII/tcpTable.c.orig	2010-06-16 15:13:25.000000000 +0200
    38 +++ agent/mibgroup/mibII/tcpTable.c	2010-10-09 09:08:23.000000000 +0200
    39 @@ -104,6 +104,11 @@
    40  #define	TCPTABLE_REMOTEPORT	pcb.inp_fport
    41  #define	TCPTABLE_IS_LINKED_LIST
    43 +#if defined(__FreeBSD__)
    44 +#undef  INP_NEXT_SYMBOL
    45 +#define INP_NEXT_SYMBOL inp_next
    46 +#endif
    47 +
    48  #endif                          /* linux */
    49  #endif                          /* WIN32 cygwin */
    50  #endif                          /* solaris2 */
    51 @@ -867,12 +872,17 @@
    52          nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
    53          if (!nnew)
    54              break;
    55 +#if defined(__FreeBSD__)
    56 +        memcpy(&(nnew->pcb), &(((struct xinpcb *) xig)->xi_inp),
    57 +                           sizeof(struct inpcb));
    58 +#else
    59          nnew->state = StateMap[((NS_ELEM *) xig)->xt_tp.t_state];
    60          if (nnew->state == 5 /* established */ ||
    61              nnew->state == 8 /*  closeWait  */ )
    62              tcp_estab++;
    63          memcpy(&(nnew->pcb), &(((NS_ELEM *) xig)->xt_inp),
    64                             sizeof(struct inpcb));
    65 +#endif
    67  	nnew->inp_next = tcp_head;
    68  	tcp_head   = nnew;
    69 Index: agent/mibgroup/ucd-snmp/diskio.c
    70 --- agent/mibgroup/ucd-snmp/diskio.c.orig	2010-08-13 17:04:33.000000000 +0200
    71 +++ agent/mibgroup/ucd-snmp/diskio.c	2010-10-09 09:08:23.000000000 +0200
    72 @@ -618,6 +618,20 @@
    73      case DISKIO_DEVICE:
    74          *var_len = strlen(stat->dinfo->devices[indx].device_name);
    75          return (u_char *) stat->dinfo->devices[indx].device_name;
    76 +#if defined(freebsd5) && (__FreeBSD_version >= 500107)
    77 +    case DISKIO_NREAD:
    78 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    79 +        return (u_char *) & long_ret;
    80 +    case DISKIO_NWRITTEN:
    81 +        long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_WRITE];
    82 +        return (u_char *) & long_ret;
    83 +    case DISKIO_READS:
    84 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_READ];
    85 +        return (u_char *) & long_ret;
    86 +    case DISKIO_WRITES:
    87 +        long_ret = (signed long) stat->dinfo->devices[indx].operations[DEVSTAT_WRITE];
    88 +        return (u_char *) & long_ret;
    89 +#else
    90      case DISKIO_NREAD:
    91  #if defined(freebsd5) && __FreeBSD_version >= 500107
    92          long_ret = (signed long) stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
    93 @@ -675,6 +689,7 @@
    94      case DISKIO_LA15:
    95          long_ret = devloads[indx].la15;
    96          return (u_char *) & long_ret;
    97 +#endif
    99      default:
   100          ERROR_MSG("diskio.c: don't know how to handle this request.");
   101 Index: agent/mibgroup/ucd-snmp/memory_solaris2.c
   102 --- agent/mibgroup/ucd-snmp/memory_solaris2.c.orig	2008-10-21 23:10:43.000000000 +0200
   103 +++ agent/mibgroup/ucd-snmp/memory_solaris2.c	2010-10-09 09:08:23.000000000 +0200
   104 @@ -1,3 +1,4 @@
   105 +#undef _FILE_OFFSET_BITS /* swapctl doesn't support 64bit off_t */
   106  #include <net-snmp/net-snmp-config.h>   /* local SNMP configuration details */
   107  #if HAVE_STRING_H
   108  #include <string.h>
   109 Index: agent/mibgroup/ucd-snmp/proc.c
   110 --- agent/mibgroup/ucd-snmp/proc.c.orig	2010-07-29 16:58:47.000000000 +0200
   111 +++ agent/mibgroup/ucd-snmp/proc.c	2010-10-09 09:08:23.000000000 +0200
   112 @@ -1,3 +1,6 @@
   113 +#ifdef solaris2
   114 +#undef _FILE_OFFSET_BITS /* solaris procfs doesn't support 64bit off_t */
   115 +#endif
   116  #include <net-snmp/net-snmp-config.h>
   118  #ifdef solaris2
   119 Index: agent/mibgroup/util_funcs.c
   120 --- agent/mibgroup/util_funcs.c.orig	2010-05-16 20:12:40.000000000 +0200
   121 +++ agent/mibgroup/util_funcs.c	2010-10-09 09:08:23.000000000 +0200
   122 @@ -457,6 +457,9 @@
   123      int             fd[2][2], i, cnt;
   124      char            ctmp[STRMAX], *cptr1, *cptr2, argvs[STRMAX], **argv,
   125          **aptr;
   126 +
   127 +    *pid = -1;  /* open_persist_pipe ignores return code but checks *pid */
   128 +
   129      /*
   130       * Setup our pipes 
   131       */
   132 Index: agent/snmpd.c
   133 --- agent/snmpd.c.orig	2010-08-17 20:31:31.000000000 +0200
   134 +++ agent/snmpd.c	2010-10-09 09:08:23.000000000 +0200
   135 @@ -429,7 +429,7 @@
   136      int             uid = 0, gid = 0;
   137      int             agent_mode = -1;
   138      char           *cptr, **argvptr;
   139 -    char           *pid_file = NULL;
   140 +    char           *pid_file = "@l_prefix@/var/snmp/snmpd.pid";
   141      char            option_compatability[] = "-Le";
   142  #if HAVE_GETPID
   143      int fd;
   144 Index: apps/snmptrapd.c
   145 --- apps/snmptrapd.c.orig	2010-08-13 20:50:07.000000000 +0200
   146 +++ apps/snmptrapd.c	2010-10-09 09:08:23.000000000 +0200
   147 @@ -652,6 +652,7 @@
   148       */
   149  #if HAVE_GETPID
   150      strcat(options, "p:");
   151 +    parse_config_pidFile(NULL, "@l_prefix@/var/snmp/snmptrapd.pid");
   152  #endif
   154  #ifdef WIN32
   155 Index: include/net-snmp/library/system.h
   156 --- include/net-snmp/library/system.h.orig	2010-03-25 16:06:26.000000000 +0100
   157 +++ include/net-snmp/library/system.h	2010-10-09 09:56:40.000000000 +0200
   158 @@ -141,7 +141,8 @@
   159  #endif
   160  #ifndef HAVE_SETENV
   161      NETSNMP_IMPORT
   162 -    int             setenv(const char *, const char *, int);
   163 +    int             __netsnmp_setenv(const char *, const char *, int);
   164 +#   define          setenv(a,b,c) __netsnmp_setenv(a,b,c)
   165  #endif
   167      NETSNMP_IMPORT
   168 Index: include/net-snmp/system/freebsd8.h
   169 --- include/net-snmp/system/freebsd8.h.orig	2010-02-14 20:29:08.000000000 +0100
   170 +++ include/net-snmp/system/freebsd8.h	2010-10-09 09:08:23.000000000 +0200
   171 @@ -1,3 +1,6 @@
   172 +/* freebsd8 is a superset of freebsd7 */
   173 +#include "freebsd7.h"
   174 +#define freebsd7 freebsd7
   175  /* freebsd8 is a superset of freebsd4 */
   176  #include "freebsd4.h"
   177  #define freebsd4 freebsd4
   178 Index: include/net-snmp/system/freebsd9.h
   179 --- include/net-snmp/system/freebsd9.h.orig	2010-10-09 09:08:23.000000000 +0200
   180 +++ include/net-snmp/system/freebsd9.h	2010-10-09 09:08:23.000000000 +0200
   181 @@ -0,0 +1,3 @@
   182 +/* freebsd9 is a superset of freebsd8 */
   183 +#include "freebsd8.h"
   184 +#define freebsd8 freebsd8
   185 Index: snmplib/system.c
   186 --- snmplib/system.c.orig	2010-07-29 16:58:47.000000000 +0200
   187 +++ snmplib/system.c	2010-10-09 09:08:23.000000000 +0200
   188 @@ -837,7 +837,7 @@
   190  #ifndef HAVE_SETENV
   191  int
   192 -setenv(const char *name, const char *value, int overwrite)
   193 +__netsnmp_setenv(const char *name, const char *value, int overwrite)
   194  {
   195      char           *cp;
   196      int             ret;

mercurial