Subject: Re: pkg/28543
To: None <darwin-pkg-people@netbsd.org, gnats-admin@netbsd.org,>
From: S <scole@sdf.lonestar.org>
List: pkgsrc-bugs
Date: 06/25/2005 13:21:03
The following reply was made to PR pkg/28543; it has been noted by GNATS.

From: S <scole@sdf.lonestar.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/28543
Date: Sat, 25 Jun 2005 13:20:06 GMT

 My apology if this was received twice; my first attempt at sending
 didn't seem to make it.
 **********************
 >Suggested-Fix:
 There seems to be a namespace collision between darwin lock functions
 and fetchmail's, so I renamed the fetchmail's lock functions to start
 with fm_.  Also, fetchmail needs to link against -lresolv on darwin.
 These changes worked for me but maybe there is another standard way to
 do this with pkgsrc.
 
 I tested these patches against fetchmail-6.2.5nb4 and
 
 Darwin goofy 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17
 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc
 
 -----------------------------------
 pkgsrc/mail/fetchmail/Makefile
 --- Makefile.orig       Fri Jun 17 22:08:55 2005
 +++ Makefile    Fri Jun 17 22:00:56 2005
 @@ -23,6 +23,11 @@
  LDFLAGS+=              ${CFLAGS}
  USE_TOOLS+=            tbl
  
 +.if ${OPSYS} == "Darwin"
 +LDFLAGS+=      -lresolv
 +CFLAGS.Darwin+=  -DBIND_8_COMPAT -DHAVE_RESOLV_H
 +.endif
 +
  .include "options.mk"
  
  DOCDIR=                ${PREFIX}/share/doc/fetchmail
 -----------------------------------
 --- fetchmail.c.orig    Fri Jun 17 22:12:48 2005
 +++ fetchmail.c Fri Jun 17 21:03:23 2005
 @@ -172,7 +172,7 @@
       * call near the beginning of the polling loop for details).  We want
       * to be sure the lock gets nuked on any error exit, basically.
       */
 -    lock_dispose();
 +    fm_lock_dispose();
  
  #ifdef HAVE_GETCWD
      /* save the current directory */
 @@ -268,7 +268,7 @@
         report_init((run.poll_interval == 0 || nodetach) && !run.logfile);
  
      /* construct the lockfile */
 -    lock_setup();
 +    fm_lock_setup();
  
  #ifdef HAVE_SETRLIMIT
      /*
 @@ -349,7 +349,7 @@
      }
  
      /* check for another fetchmail running concurrently */
 -    pid = lock_state();
 +    pid = fm_lock_state();
      bkgd = (pid < 0);
      pid = bkgd ? -pid : pid;
  
 @@ -387,7 +387,7 @@
         {
             fprintf(stderr,GT_("fetchmail: %s fetchmail at %d killed.\n"),
                     bkgd ? GT_("background") : GT_("foreground"), pid);
 -           lock_release();
 +           fm_lock_release();
             if (argc == 2)
                 exit(0);
             else
 @@ -420,7 +420,7 @@
         }
         else if (getpid() == pid)
             /* this test enables re-execing on a changed rcfile */
 -           lock_assert();
 +           fm_lock_assert();
         else if (argc > 1)
         {
             fprintf(stderr,
 @@ -529,7 +529,7 @@
      set_signal_handler(SIGQUIT, terminate_run);
  
      /* here's the exclusion lock */
 -    lock_or_die();
 +    fm_lock_or_die();
  
      /*
       * Query all hosts. If there's only one, the error return will
 @@ -1300,7 +1300,7 @@
           memset(ctl->password, '\0', strlen(ctl->password));
  
  #if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
 -    lock_release();
 +    fm_lock_release();
  #endif
  
      if (activecount == 0)
 -----------------------------------
 --- fetchmail.h.orig    Fri Jun 17 22:12:38 2005
 +++ fetchmail.h Fri Jun 17 21:57:06 2005
 @@ -461,10 +461,10 @@
  extern struct msgblk msgblk;
  
  /* lock.c: concurrency locking */
 -void lock_setup(void), lock_assert(void);
 -void lock_or_die(void), lock_release(void);
 -int lock_state(void);
 -void lock_dispose(void);
 +void fm_lock_setup(void), fm_lock_assert(void);
 +void fm_lock_or_die(void), fm_lock_release(void);
 +int fm_lock_state(void);
 +void fm_lock_dispose(void);
  
  /* use these to track what was happening when the nonresponse timer fired */
  #define GENERAL_WAIT   0       /* unknown wait type */
 -----------------------------------
 --- lock.c.orig Fri Jun 17 22:13:03 2005
 +++ lock.c      Fri Jun 17 21:03:14 2005
 @@ -24,7 +24,7 @@
  static char *lockfile;         /* name of lockfile */
  static int lock_acquired;      /* have we acquired a lock */
  
 -void lock_setup(void)
 +void fm_lock_setup(void)
  /* set up the global lockfile name */
  {
      /* set up to do lock protocol */
 @@ -55,7 +55,7 @@
         unlink(lockfile);
  }
  
 -void lock_dispose(void)
 +void fm_lock_dispose(void)
  /* arrange for a lock to be removed on process exit */
  {
  #ifdef HAVE_ATEXIT
 @@ -66,7 +66,7 @@
  #endif
  }
  
 -int lock_state(void)
 +int fm_lock_state(void)
  {
      int        pid, st;
      FILE       *lockfp;
 @@ -88,13 +88,13 @@
      return(bkgd ? -pid : pid);
  }
  
 -void lock_assert(void)
 +void fm_lock_assert(void)
  /* assert that we already posess a lock */
  {
      lock_acquired = TRUE;
  }
  
 -void lock_or_die(void)
 +void fm_lock_or_die(void)
  /* get a lock on a given host or exit */
  {
      int fd;
 @@ -125,7 +125,7 @@
      }
  }
  
 -void lock_release(void)
 +void fm_lock_release(void)
  /* release a lock on a given host */
  {
      unlink(lockfile);
 -----------------------------------