summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7fd9917abca2018efe74487a290568af086f6fd4 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Maintainer: Gonzalo Exequiel Pedone <hipersayan DOT x AT gmail DOT com>
# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

_android_arch=armv7a-eabi

pkgname=android-${_android_arch}-nss
pkgver=3.106
pkgrel=1
arch=('any')
pkgdesc="Network Security Services (Android ${_android_arch})"
url="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS"
license=('MPL-2.0')
groups=('android-nss')
depends=("android-${_android_arch}-nspr>=4.35"
         "android-${_android_arch}-p11-kit>=0.23.19"
         "android-${_android_arch}-sqlite"
         "android-${_android_arch}-zlib")
makedepends=('clang'
             'gyp'
             'ninja'
             'perl'
             'python'
             'zip')
options=(!strip !buildflags staticlibs !emptydirs)
source=("https://ftp.mozilla.org/pub/security/nss/releases/NSS_${pkgver//./_}_RTM/src/nss-${pkgver}.tar.gz"
        'Linux.mk.patch'
        'FreeblMakefile.patch'
        'mpcpucache.c.patch')
md5sums=('5beed92d43d33b03faf0ec5efd44d1b0'
         'd70d79aa9d8914a9e9d3df1739b63c00'
         'abd61b14e76846b4eb67556211ab8d9d'
         '2cc719ad09173f4eb818ce2badcab283')

prepare() {
    cd "${srcdir}/nss-${pkgver}"

    patch -Np1 -i ../Linux.mk.patch
    patch -Np1 -i ../FreeblMakefile.patch

    # Platform specific patches
    case "${_android_arch}" in
        armv7a-eabi)
            patch -Np1 -i ../mpcpucache.c.patch
            ;;
        *)
            ;;
    esac
}

build() {
    cd "${srcdir}/nss-${pkgver}/nss"
    source android-env ${_android_arch}

    # Platform specific patches
    case "${_android_arch}" in
        aarch64)
            GYP_ARCH="arm64"
            ;;
        armv7a-eabi)
            GYP_ARCH="arm"
            ;;
        x86)
            GYP_ARCH="ia32"
            ;;
        x86-64)
            GYP_ARCH="x64"
            ;;
        *)
            ;;
    esac

    gyp -f ninja-android nss.gyp \
        --depth "${PWD}" \
        --generator-output="${PWD}/build" \
        -DOS=android \
        -Dforce_integrated_as=1 \
        -Dnspr_lib_dir="${ANDROID_PREFIX_LIB}" \
        -Dnspr_include_dir="${ANDROID_PREFIX_INCLUDE}/nspr" \
        -Dnss_dist_dir="${PWD}/build" \
        -Dnss_dist_obj_dir="${PWD}/build" \
        -Dhost_arch="${GYP_ARCH}" \
        -Dtarget_arch="${GYP_ARCH}" \
        -Dstatic_libs=1 \
        -Ddisable_dbm=1 \
        -Dsign_libs=0 \
        -Denable_sslkeylogfile=0 \
        -Ddisable_tests=1 \
        -Duse_system_sqlite=1 \
        -Ddisable_libpkix=1
    ninja -C build/out/Release
}

package() {
    cd "${srcdir}/nss-${pkgver}/nss"
    source android-env ${_android_arch}

    nsprver="$(pkg-config --modversion nspr)"

    sed pkg/pkg-config/nss.pc.in \
        -e "s,%prefix%,${ANDROID_PREFIX},g" \
        -e "s,%exec_prefix%,\${prefix},g" \
        -e "s,%libdir%,${ANDROID_PREFIX_LIB},g" \
        -e "s,%includedir%,${ANDROID_PREFIX_INCLUDE}/nss,g" \
        -e "s,%NSPR_VERSION%,${nsprver},g" \
        -e "s,%NSS_VERSION%,${pkgver},g" |
        install -Dm644 /dev/stdin "${pkgdir}/${ANDROID_PREFIX_LIB}/pkgconfig/nss.pc"

    ln -s nss.pc "${pkgdir}/${ANDROID_PREFIX_LIB}/pkgconfig/mozilla-nss.pc"
    install -v -Dt "${pkgdir}/${ANDROID_PREFIX_LIB}" build/lib/*.so
    install -v -Dt "${pkgdir}/${ANDROID_PREFIX_LIB}" build/lib/*.a

    NSS_VMAJOR=$(grep '#define.*NSS_VMAJOR' lib/nss/nss.h | awk '{print $3}')
    NSS_VMINOR=$(grep '#define.*NSS_VMINOR' lib/nss/nss.h | awk '{print $3}')
    NSS_VPATCH=$(grep '#define.*NSS_VPATCH' lib/nss/nss.h | awk '{print $3}')

    sed pkg/pkg-config/nss-config.in \
        -e "s,@prefix@,${ANDROID_PREFIX},g" \
        -e "s,@exec_prefix@,${ANDROID_PREFIX},g" \
        -e "s,@libdir@,${ANDROID_PREFIX_LIB},g" \
        -e "s,@includedir@,${ANDROID_PREFIX_INCLUDE}/nss,g" \
        -e "s,@MOD_MAJOR_VERSION@,${NSS_VMAJOR},g" \
        -e "s,@MOD_MINOR_VERSION@,${NSS_VMINOR},g" \
        -e "s,@MOD_PATCH_VERSION@,${NSS_VPATCH},g" |
        install -D /dev/stdin "${pkgdir}/${ANDROID_PREFIX_BIN}/nss-config"

    install -v -Dt "${pkgdir}/${ANDROID_PREFIX_INCLUDE}/nss" -m644 build/public/nss/*.h
    install -v -Dt "${pkgdir}/${ANDROID_PREFIX_INCLUDE}/nss/mozpkix" -m644 build/public/nss/mozpkix/*.h

    rm -f "${pkgdir}/${ANDROID_PREFIX_LIB}/libssl.a"
    ${ANDROID_STRIP} -g --strip-unneeded "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.so
    ${ANDROID_STRIP} -g "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.a || true
}