building cntlm from subversion using macports

Why do it the easy way?

Update: I originally wrote this post because of an overflow bug which caused files over 2GB to fail silently, and the fix hadn’t yet been released. Well, the fix has now been released, so it’s probably a better idea to use that version, since this portfile does not work properly with selfupdate.

Instructions

  1. Install and configure macports. Note that selfupdate doesn’t work from svn.

  2. Create a local repository:

    mkdir -p ~/ports/net/cntlm/files
    
  3. Copy the Portfile and patch to the repository (contents below):

    cp /path/to/Portfile ~/ports/net/cntlm
    cp /path/to/patch-trunk-Makefile.diff ~/ports/net/cntlm/files
    
  4. Configure the local repository. Add the following line to /opt/local/etc/macports/sources.conf, then sync the repository:

    file:///Users/localadmin/ports
    
    sudo port -d sync
    
  5. Install cntlm:

    sudo port -v install cntlm
    

Portfile

    # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
    # $Id$
    PortSystem              1.0
    name                    cntlm
    version                 HEAD
    license                 gpl
    categories              net
    platforms               darwin
    maintainers             xs4all.nl:hbruinsma
    homepage                http://cntlm.sourceforge.net/
    description             Cntlm is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy
    svn.url                 https://cntlm.svn.sourceforge.net/svnroot/cntlm/cntlm/trunk
    svn.revision            HEAD
    fetch.type              svn
    worksrcdir              trunk
    patchfiles              patch-trunk-Makefile.diff
    depends_lib             port:coreutils
    build.target            {}
    build.args              SYSCONFDIR=/opt/local/etc BINDIR=/opt/local/sbin \
            MANDIR=/opt/local/man
    destroot.args           SYSCONFDIR=/opt/local/etc BINDIR=/opt/local/sbin \
            MANDIR=/opt/local/man
    
    startupitem.create      yes
    startupitem.name        cntlm
    startupitem.executable  "${prefix}/sbin/cntlm"

patch-trunk-Makefile.diff

    -- Makefile    2011-10-14 19:45:26.000000000 +0800
    +++ Makefile.old        2011-12-06 17:11:08.000000000 +0800
    @@ -44,10 +44,10 @@
                    install -M 644 -f $(MANDIR)/man1 doc/$(NAME).1; \
                    install -M 600 -c $(SYSCONFDIR) doc/$(NAME).conf; \
            else \
    -               install -D -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
    -               install -D -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
    +               install -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
    +               install -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
                    [ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
    -                       || install -D -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
    +                       || install -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
            fi
            @echo; echo "Cntlm will look for configuration in $(SYSCONFDIR)/$(NAME).conf"

Note that macports does not recommend building from subversion, since the results will not be reproducible. However, for testing, it should work fine.