summaryrefslogtreecommitdiff
path: root/opt/rpcbind/MAKEPKG
blob: 3af179429dfc033e99b0139909e56bcf01e466e6 (plain)
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
#!/bin/mkpkg
# description: RPC program number to address mapper
# url: https://sourceforge.net/projects/rpcbind/
name=rpcbind
version=1.3.1
release=1
depends=(libtirpc)
makedeps=(bsd-headers)
services=(rpcbind)
source=(https://downloads.sourceforge.net/$name/$name-$version.tar.bz2
    musl-sunrpc.patch
    rpcbind-sunrpc.patch
    musl-rpc-compat.c)
sha256sums=(
    "8e551b445f5172f8ef218845af342fb2a2d741b57ce8c777c781a01ea92f92a5"
    "8852c055fa257113d3df3525a5600e6f02f4eacba29cf98a8c0c714e4551cfc9"
    "d0fdffce3e55d1d2170647e1a0949df579d20ff5dbbdcab0df353d7d71a87370"
    "82e80caa07bb84e2928f55e47bcb256a794218f19866d493e8002e4b3d539d19"
)

patch() {
    cd $name-$version

    # musl getaddrinfo does not support service name aliases;
    # use "sunrpc" (canonical /etc/services entry) instead of
    # "rpcbind" and "portmapper"
    patch -p1 < $SRC/rpcbind-sunrpc.patch
    patch -p1 < $SRC/musl-sunrpc.patch

    # musl lacks getrpcbynumber/getrpcbyname (glibc NSS functions)
    # Stub in security.c directly (only used for logging)
    sed -i '1i struct rpcent *getrpcbynumber(int __number) { return 0; }' src/security.c
}

build() {
    cd $name-$version

    # Build compat stubs as static lib and inject
    cc $CFLAGS -c $SRC/musl-rpc-compat.c -o musl-rpc-compat.o
    ar rcs libmusl-rpc-compat.a musl-rpc-compat.o

    ./configure \
        --prefix=/usr \
        --bindir=/usr/sbin \
        --with-rpcuser=root \
        --enable-warmstarts \
        --without-systemdsystemunitdir

    sed -i "s|^LIBS = |LIBS = -L$PWD -lmusl-rpc-compat |" Makefile

    make
    make DESTDIR=$PKG install

    install -dm755 $PKG/var/lib/rpcbind
}

post_build() {
    # runit service
    install -d $PKG/etc/sv/rpcbind/log

    printf '%s\n' \
        '#!/bin/sh' \
        'exec 2>&1' \
        'exec rpcbind -f -w 2>&1' \
        > $PKG/etc/sv/rpcbind/run

    printf '%s\n' \
        '#!/bin/sh' \
        'mkdir -p /var/log/rpcbind' \
        'exec svlogd -tt /var/log/rpcbind' \
        > $PKG/etc/sv/rpcbind/log/run

    chmod 755 $PKG/etc/sv/rpcbind/run
    chmod 755 $PKG/etc/sv/rpcbind/log/run
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}
# vim: filetype=sh