recipes: Adjust 'docsdir' variable to be consistent with the current recipe format
[dragora.git] / recipes / networking / nss / recipe
blob3ec4210403eda75dc7e5fba4de64eecc4759a8ac
1 # Build recipe for nss.
3 # Copyright (c) 2021-2022 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Exit immediately on any error
18 set -e
20 program=nss
21 version=3_74
22 pkgversion=$(echo $version | tr _ .)
23 release=1
25 # Define a category for the output of the package name
26 pkgcategory=networking
28 tarname=${program}-${pkgversion}.tar.gz
30 # Remote source(s)
31 fetch=https://ftp.mozilla.org/pub/security/nss/releases/NSS_${version}_RTM/src/$tarname
33 description="
34 Network security services.
36 Network Security Services (NSS) is a set of libraries designed to
37 support cross-platform development of security-enabled client and
38 server applications.  Applications built with NSS can support
39 SSL v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME,
40 X.509 v3 certificates, and other security standards.
43 homepage=https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS
44 license="MPL v2.0, GPLv2+"
46 # Source documentation
47 docs="COPYING readme.md"
48 docsdir="${docdir}/${program}-${pkgversion}"
50 # Set 'srcdir' using previous 'pkgversion' variable
51 srcdir=${program}-${pkgversion}
53 build()
55     unpack "${tardir}/$tarname"
57     cd "${srcdir}/nss"
59     # Apply a patch for build thanks to "Beyond Linux From Scratch"
60     patch -Np2 -i "${worktree}/patches/nss/nss-3.74-standalone-1.patch"
62     # Set sane permissions
63     chmod -R u+w,go-w,a+rX-s .
65     # Set specific options for the architecture
66     case $arch in
67     amd64 | x32 )
68         arch_options='USE_64=1'
69         ;;
70     i586)
71         arch_options='USE_64=0'
72         ;;
73     esac
75     unset -v CFLAGS CXXFLAGS
77     make -j${jobs} BUILD_OPT=1 \
78      NSS_DISABLE_GTESTS=1 \
79      NSPR_INCLUDE_DIR=/usr/include/nspr \
80      USE_SYSTEM_ZLIB=1 \
81      ZLIB_LIBS=-lz \
82      NSS_ENABLE_WERROR=0 \
83      NSS_USE_SYSTEM_SQLITE=1 \
84      $arch_options
86     unset -v arch_options
88     # Proceed to install the software files
89     cd ../dist
91     mkdir -v -p "${destdir}/usr/lib${libSuffix}" \
92                 "${destdir}/usr/include/nss" \
93                 "${destdir}/usr/bin" \
94                 "${destdir}/usr/lib${libSuffix}/pkgconfig"
96     install -v -p -m755 Linux*/lib/*.so "${destdir}/usr/lib${libSuffix}"
97     install -v -p -m644 Linux*/lib/*.chk "${destdir}/usr/lib${libSuffix}"
98     install -v -p -m644 Linux*/lib/libcrmf.a "${destdir}/usr/lib${libSuffix}"
100     cp -v -pRL public/nss/* "${destdir}/usr/include/nss"
101     cp -v -pRL private/nss/* "${destdir}/usr/include/nss"
102     chmod 644 "${destdir}"/usr/include/nss/*
104     for file in certutil cmsutil crlutil derdump modutil pk12util pp \
105                 signtool signver ssltap vfychain vfyserv nss-config ; \
106     do
107         install -v -p -m755 Linux*/bin/${file} "${destdir}/usr/bin"
108     done
109     unset -v file
111     install -v -p -m644 Linux*/lib/pkgconfig/nss.pc \
112      "${destdir}/usr/lib${libSuffix}/pkgconfig"
114     # Strip remaining binaries and libraries
115     find "$destdir" -type f | xargs file | \
116      awk '/ELF/ && /executable/ || /shared object/' | \
117       cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
118     strip --strip-debug "${destdir}/usr/lib${libSuffix}"/*.a
120     cd ../nss
121     mkdir -v -p "${destdir}/${mandir}/man1"
122     cp -v -p doc/nroff/*.1 "${destdir}/${mandir}/man1"
123     chmod 644 "${destdir}/${mandir}"/man1/*
125     # Compress and link man pages (if needed)
126     if test -d "${destdir}/$mandir"
127     then
128         (
129             cd "${destdir}/$mandir"
130             find . -type f -exec lzip -9 {} +
131             find . -type l | while read -r file
132             do
133                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
134                 rm -- "$file"
135             done
136         )
137     fi
139     # Copy documentation
140     mkdir -v -p "${destdir}/$docsdir"
141     cp -v -p $docs "${destdir}/$docsdir"