aboutsummaryrefslogtreecommitdiffstats
path: root/databases/riak/Makefile
blob: 4e477f7c2984b4db2c2e030f90c8ec875b4c44e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# $FreeBSD$

PORTNAME=   riak
PORTVERSION=    1.4.2
CATEGORIES= databases
MASTER_SITES=   http://s3.amazonaws.com/downloads.basho.com/riak/${PORTVERSION:R}/${PORTVERSION}/ \
        http://downloads.basho.com.s3.amazonaws.com/riak/${PORTVERSION:R}/${PORTVERSION}/

MAINTAINER= ports@robakdesign.com
COMMENT=    Riak is an open source, distributed database

BUILD_DEPENDS=  ${LOCALBASE}/lib/erlang15/bin/erlc:${PORTSDIR}/lang/erlang-runtime15

USES=       gmake
USE_RC_SUBR=    riak

PLIST=      ${WRKDIR}/pkg-plist
PLIST_SUB+= RIAK_LOGDIR=${RIAK_LOGDIR} \
        RIAK_DBDIR=${RIAK_DBDIR} \
        RIAK_CONFDIR=${RIAK_CONFDIR} \
        RIAK_HOMEDIR=${RIAK_HOMEDIR}

USERS=      riak
GROUPS=     riak

RIAK_CONFDIR?=  ${PREFIX}/etc/${PORTNAME}
RIAK_LOGDIR?=   /var/log/${PORTNAME}
RIAK_DBDIR?=    /var/db/${PORTNAME}
RIAK_LIBDIR?=   ${PREFIX}/lib/${PORTNAME}/lib
RIAK_HOMEDIR?=  ${PREFIX}/lib/${PORTNAME}

MAN1=       riak.1 riak-admin.1 riak-debug.1 search-cmd.1
MANCOMPRESSED=  yes

ALL_TARGET= rel
MAKE_JOBS_UNSAFE=yes
MAKE_ENV=   PATH=${LOCALBASE}/lib/erlang15/bin:${PATH}
NO_STAGE=   yes

pre-install:
    ${RM} -f ${PLIST}
    ${CAT} ${PKGDIR}/pkg-plist >> ${PLIST}
    cd ${WRKSRC}/rel/${PORTNAME}; ${FIND} releases -type f \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn | ${SED} -e 's/^/lib\//' \
        | ${AWK} '{print "lib/riak/"$$2 }' >> ${PLIST}
    cd ${WRKSRC}/rel/${PORTNAME}; ${FIND} erts-* -type f \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn  \
        | ${AWK} '{print "lib/riak/"$$2 }' >> ${PLIST}
    cd ${WRKSRC}/rel; ${FIND} ${PORTNAME}/lib -type f \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn | ${SED} -e 's/^/lib\//' \
        | ${AWK} '{print "lib/"$$2 }' >> ${PLIST}
    cd ${WRKSRC}/rel/${PORTNAME}; ${FIND} releases -type d \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn | ${SED} -e 's/^/lib\//' \
        | ${AWK} '{print "lib/riak/"$$2 }' | ${SED} -e "s/^/@dirrm\ /" >> ${PLIST}
    cd ${WRKSRC}/rel/${PORTNAME}; ${FIND} erts-* -type d \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn | ${SED} -e 's/^/lib\//' \
        | ${AWK} '{print "lib/riak/"$$2 }' | ${SED} -e "s/^/@dirrm\ /" >> ${PLIST}
    cd ${WRKSRC}/rel; ${FIND} ${PORTNAME}/lib -type d \
        | ${AWK} '{print length, $$0}' | ${SORT} -rn | ${SED} -e 's/^/lib\//' \
        | ${AWK} '{print "lib/"$$2 }' | ${SED} -e "s/^/@dirrm\ /" >> ${PLIST}
    ${ECHO} "@dirrm lib/riak" >> ${PLIST}
    ${ECHO} "@cwd /" >> ${PLIST}
    ${ECHO} "@dirrmtry %%RIAK_DBDIR%%" >> ${PLIST}
    ${ECHO} "@dirrmtry %%RIAK_LOGDIR%%" >> ${PLIST}

do-install:
.for d in ${RIAK_CONFDIR} ${RIAK_LOGDIR} ${RIAK_DBDIR} ${RIAK_LIBDIR} ${RIAK_HOMEDIR}
    [ -d ${d} ] || ${MKDIR} ${d} && ${CHOWN} ${USERS}:${GROUPS} ${d}
.endfor
    ${INSTALL_DATA} ${WRKSRC}/rel/riak/etc/vm.args ${RIAK_CONFDIR}/vm.args.sample
    ${INSTALL_DATA} ${WRKSRC}/rel/riak/etc/app.config ${RIAK_CONFDIR}/app.config.sample
    ${INSTALL_DATA} ${WRKSRC}/rel/riak/etc/cert.pem ${RIAK_CONFDIR}/cert.pem.sample
    ${INSTALL_DATA} ${WRKSRC}/rel/riak/etc/key.pem ${RIAK_CONFDIR}/key.pem.sample
    (cd ${WRKSRC}/rel/riak/lib/ && ${COPYTREE_BIN} . ${RIAK_LIBDIR})
    (cd ${WRKSRC}/rel/riak/bin/ && ${COPYTREE_BIN} . ${PREFIX}/sbin/)
    (cd ${WRKSRC}/rel/riak/lib/basho-patches && ${COPYTREE_SHARE} . ${RIAK_LIBDIR}/basho-patches)
    (cd ${WRKSRC}/rel/riak/releases && ${COPYTREE_SHARE} . ${RIAK_HOMEDIR}/releases)
    ${CP} -R ${WRKSRC}/rel/riak/erts-* ${RIAK_HOMEDIR}
    ${CHOWN} -R ${USERS}:${GROUPS} ${PREFIX}/lib/${PORTNAME}
    ${INSTALL_MAN} ${WRKSRC}/doc/man/man1/riak.1.gz ${MANPREFIX}/man/man1/
    ${INSTALL_MAN} ${WRKSRC}/doc/man/man1/riak-admin.1.gz ${MANPREFIX}/man/man1/
    ${INSTALL_MAN} ${WRKSRC}/doc/man/man1/riak-debug.1.gz ${MANPREFIX}/man/man1/
    ${INSTALL_MAN} ${WRKSRC}/doc/man/man1/search-cmd.1.gz ${MANPREFIX}/man/man1/

post-install:
    @if [ ! -f ${RIAK_CONFDIR}/vm.args ]; then \
        ${CP} -p ${RIAK_CONFDIR}/vm.args.sample ${RIAK_CONFDIR}/vm.args; \
    fi
    @if [ ! -f ${RIAK_CONFDIR}/app.config ]; then \
        ${CP} -p ${RIAK_CONFDIR}/app.config.sample ${RIAK_CONFDIR}/app.config; \
    fi
    @if [ ! -f ${RIAK_CONFDIR}/cert.pem ]; then \
        ${CP} -p ${RIAK_CONFDIR}/cert.pem.sample ${RIAK_CONFDIR}/cert.pem; \
    fi
    @if [ ! -f ${RIAK_CONFDIR}/key.pem ]; then \
        ${CP} -p ${RIAK_CONFDIR}/key.pem.sample ${RIAK_CONFDIR}/key.pem; \
    fi

.include <bsd.port.mk>