summaryrefslogtreecommitdiff
path: root/opt/nfs-utils/MAKEPKG
blob: 94875e24ff526f8f83d1c379cd48b71dcd076eaa (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
82
83
84
85
86
#!/bin/mkpkg
# description: NFS userspace server and client tools
# url: https://www.kernel.org/pub/linux/utils/nfs-utils/
name=nfs-utils
version=3.1.1
release=2
depends=(libtirpc keyutils libevent libcap2 util-linux sqlite libxml2)
makedeps=(rpcsvc-proto bsd-headers libnl)
source=(https://www.kernel.org/pub/linux/utils/nfs-utils/$version/$name-$version.tar.xz
    musl-rpc-compat.c
    musl-getservbyport.patch
    musl-includes.patch)

sha256sums=(
    "7dbc05eb8b32828b322872b759a62cb3979cb4118f344dd8616813d1390e84e0"
    "82e80caa07bb84e2928f55e47bcb256a794218f19866d493e8002e4b3d539d19"
    "c163225b01417ac8e70ec21bf6c5fb8ceeaecb0e0938f01883d1410f5f776f6b"
    "d8477a6b7f67167dd36176ee2665640eca7f24ae743581ed7098e0e8051f1ac3"
)

patch() {
    cd $name-$version

    patch -p1 < $SRC/musl-getservbyport.patch
    patch -p1 < $SRC/musl-includes.patch

    sed -i '1i #include <string.h>' support/nfs/fh_key_file.c
    sed -i '/#include <sys\/types.h>/a #include <stddef.h>' support/nfs/getport.c

    cp $SRC/musl-rpc-compat.c support/nsm/
}

build() {
    cd $name-$version

    # Build compat stubs so configure finds getrpcbynumber
    cc $CFLAGS -c support/nsm/musl-rpc-compat.c -o musl-rpc-compat.o
    ar rcs libmusl-rpc-compat.a musl-rpc-compat.o

    # lld strictness
    export LDFLAGS="$LDFLAGS -Wl,--undefined-version"
    export LIBS="-L$PWD -lmusl-rpc-compat -lsqlite3 -levent_core"

    ./configure \
        --prefix=/usr \
        --sysconfdir=/etc \
        --sbindir=/usr/sbin \
        --disable-gss \
        --disable-junction \
        --without-systemd \
        --without-tcp-wrappers

    # clang treats K&R empty parens as errors with -Werror=strict-prototypes
    find . -name Makefile -exec sed -i 's/-Werror[^ ]*//g' {} +

    make
    make DESTDIR=$PKG install

    # Guard: only shuffle if something actually landed in /sbin
    if [ -d "$PKG/sbin" ] && [ "$(ls -A $PKG/sbin 2>/dev/null)" ]; then
        mv $PKG/sbin/* $PKG/usr/sbin/
        rmdir $PKG/sbin
    elif [ -d "$PKG/sbin" ]; then
        rmdir $PKG/sbin
    fi

    install -dm755 $PKG/etc/exports.d
    install -dm755 $PKG/var/lib/nfs/rpc_pipefs
    install -dm755 $PKG/var/lib/nfs/v4recovery

    # Default empty exports file
    install -m644 /dev/null $PKG/etc/exports

    # Remove man pages for disabled features
    rm -f $PKG/usr/share/man/man8/rpc.gssd.8
    rm -f $PKG/usr/share/man/man8/rpc.svcgssd.8
    rm -f $PKG/usr/share/man/man8/blkmapd.8

    find $PKG \( -name '*.la' -o -name '*.a' \) -delete
}

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