NSS now builds into an RPM.
[fedora-mingw.git] / nss / mingw32-nss.spec
1 %define __strip %{_mingw32_strip}
2 %define __objdump %{_mingw32_objdump}
3 %define _use_internal_dependency_generator 0
4 %define __find_requires %{_mingw32_findrequires}
5 %define __find_provides %{_mingw32_findprovides}
6
7 # Version of NSPR that we depend on.
8 %define nspr_version 4.7
9
10 # Tests cause strange Wine failures ...
11 %define run_tests 0
12
13 Name:           mingw32-nss
14 Version:        3.12.2.0
15 Release:        4%{?dist}
16 Summary:        MinGW Windows port of NSS (Network Security Services)
17
18 License:        MPLv1.1 or GPLv2+ or LGPLv2+
19 Group:          Development/Libraries
20 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
21 BuildArch:      noarch
22
23 URL:            http://www.mozilla.org/projects/security/pki/nss/
24
25 # Extracted from the Fedora native package.  There is no upstream
26 # location for the tarballs.
27 Source0:        nss-%{version}-stripped.tar.bz2
28 Source1:        nss.pc.in
29 Source2:        nss-config.in
30 Source3:        blank-cert8.db
31 Source4:        blank-key3.db
32 Source5:        blank-secmod.db
33 Source8:        nss-prelink.conf
34 Source12:       nss-pem-20080124.tar.bz2
35
36 Source1000:     Cross.mk
37
38 Patch1:         nss-no-rpath.patch
39 Patch2:         nss-nolocalsql.patch
40 Patch5:         nss-pem-bug429175.patch
41 Patch6:         nss-enable-pem.patch
42
43 Patch1000:      nss-cross-compile.patch
44
45 BuildRequires:  mingw32-filesystem >= 33
46 BuildRequires:  mingw32-gcc
47 BuildRequires:  mingw32-binutils
48
49 BuildRequires:  mingw32-nspr >= %{nspr_version}
50 BuildRequires:  mingw32-sqlite
51 BuildRequires:  mingw32-zlib
52
53 BuildRequires:  pkgconfig
54 BuildRequires:  perl
55
56 Requires:       pkgconfig
57
58
59 %description
60 Network Security Services (NSS) is a set of libraries designed to
61 support cross-platform development of security-enabled client and
62 server applications. Applications built with NSS can support SSL v2
63 and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
64 v3 certificates, and other security standards.
65
66
67 %prep
68 %setup -q -n nss-%{version}
69 %setup -q -T -D -n nss-%{version} -a 12
70
71 %patch1 -p0
72 %patch2 -p0
73 %patch5 -p0 -b .429175
74 %patch6 -p0 -b .libpem
75
76 %patch1000 -p0
77
78 # Notes on the naming:
79 # (1) "2.6" is the Linux version number which is appended to the name
80 #     also by NSS Makefiles.
81 # (2) OS_TARGET must be set to the basename (w/o 2.6).
82 cp %{SOURCE1000} mozilla/security/coreconf/FedoraCross2.6.mk
83
84
85 %build
86 # For cross-compilation, make sure pkg-config picks up the cross-compiled
87 # packages only.
88 PKG_CONFIG_LIBDIR="%{_mingw32_libdir}/pkgconfig"
89 export PKG_CONFIG_LIBDIR
90
91 NATIVE_CC=gcc
92 export NATIVE_CC
93 NATIVE_FLAGS="-DLINUX -Dlinux -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR"
94 export NATIVE_FLAGS
95
96 NS_USE_GCC=1
97 export NS_USE_GCC
98
99 OS_TARGET=FedoraCross
100 export OS_TARGET
101
102 # Enable compiler optimizations and disable debugging code
103 BUILD_OPT=1
104 export BUILD_OPT
105
106 # Generate symbolic info for debuggers
107 XCFLAGS="%{_mingw32_cflags}"
108 export XCFLAGS
109
110 export NSPR_INCLUDE_DIR=%{_mingw32_includedir}/nspr
111 export NSPR_LIB_DIR=%{_mingw32_bindir}
112
113 # Target is Win32 (32 bit):
114 #%ifarch x86_64 ppc64 ia64 s390x sparc64
115 #USE_64=1
116 #export USE_64
117 #%endif
118
119 # NSS_ENABLE_ECC=1
120 # export NSS_ENABLE_ECC
121
122 %{__make} -C ./mozilla/security/coreconf
123 %{__make} -C ./mozilla/security/dbm
124 %{__make} -C ./mozilla/security/nss
125
126 # enable the following line to force a test failure
127 # find ./mozilla -name \*.chk | xargs rm -f
128
129 %if %{run_tests}
130 # Run test suite.
131 # In order to support multiple concurrent executions of the test suite
132 # (caused by concurrent RPM builds) on a single host,
133 # we'll use a random port. Also, we want to clean up any stuck
134 # selfserv processes. If process name "selfserv" is used everywhere,
135 # we can't simply do a "killall selfserv", because it could disturb
136 # concurrent builds. Therefore we'll do a search and replace and use
137 # a different process name.
138 # Using xargs doesn't mix well with spaces in filenames, in order to
139 # avoid weird quoting we'll require that no spaces are being used.
140
141 SPACEISBAD=`find ./mozilla/security/nss/tests | grep -c ' '` ||:
142 if [ SPACEISBAD -ne 0 ]; then
143   echo "error: filenames containing space are not supported (xargs)"
144   exit 1
145 fi
146 MYRAND=`perl -e 'print 9000 + int rand 1000'`; echo $MYRAND ||:
147 RANDSERV=selfserv_${MYRAND}; echo $RANDSERV ||:
148 DISTBINDIR=`ls -d ./mozilla/dist/*.OBJ/bin`; echo $DISTBINDIR ||:
149 pushd `pwd`
150 cd $DISTBINDIR
151 ln -s selfserv $RANDSERV
152 popd
153 # man perlrun, man perlrequick
154 # replace word-occurrences of selfserv with selfserv_$MYRAND
155 find ./mozilla/security/nss/tests -type f |\
156   grep -v "\.db$" |grep -v "\.crl$" | grep -v "\.crt$" |\
157   grep -vw CVS  |xargs grep -lw selfserv |\
158   xargs -l perl -pi -e "s/\bselfserv\b/$RANDSERV/g" ||:
159
160 killall $RANDSERV || :
161
162 rm -rf ./mozilla/tests_results
163 cd ./mozilla/security/nss/tests/
164 # all.sh is the test suite script
165 HOST=localhost DOMSUF=localdomain PORT=$MYRAND ./all.sh
166 cd ../../../../
167
168 killall $RANDSERV || :
169
170 TEST_FAILURES=`grep -c FAILED ./mozilla/tests_results/security/localhost.1/output.log` || :
171 if [ $TEST_FAILURES -ne 0 ]; then
172   echo "error: test suite returned failure(s)"
173   exit 1
174 fi
175 echo "test suite completed"
176 %endif
177
178
179 %install
180 rm -rf $RPM_BUILD_ROOT
181
182 # There is no make install target so we'll do it ourselves.
183
184 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_includedir}/nss3
185 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_bindir}
186 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_libdir}
187 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_libdir}/nss/unsupported-tools
188
189 # Set up our package file
190 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_libdir}/pkgconfig
191 %{__cat} %{SOURCE1} | sed -e "s,%%libdir%%,%{_mingw32_libdir},g" \
192                           -e "s,%%prefix%%,%{_mingw32_prefix},g" \
193                           -e "s,%%exec_prefix%%,%{_mingw32_prefix},g" \
194                           -e "s,%%includedir%%,%{_mingw32_includedir}/nss3,g" \
195                           -e "s,%%NSPR_VERSION%%,%{nspr_version},g" \
196                           -e "s,%%NSS_VERSION%%,%{version},g" > \
197                           $RPM_BUILD_ROOT/%{_mingw32_libdir}/pkgconfig/nss.pc
198 NSS_VMAJOR=`cat mozilla/security/nss/lib/nss/nss.h | grep "#define.*NSS_VMAJOR" | awk '{print $3}'`
199 NSS_VMINOR=`cat mozilla/security/nss/lib/nss/nss.h | grep "#define.*NSS_VMINOR" | awk '{print $3}'`
200 NSS_VPATCH=`cat mozilla/security/nss/lib/nss/nss.h | grep "#define.*NSS_VPATCH" | awk '{print $3}'`
201
202 export NSS_VMAJOR 
203 export NSS_VMINOR 
204 export NSS_VPATCH
205
206 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_bindir}
207 %{__cat} %{SOURCE2} | sed -e "s,@libdir@,%{_mingw32_libdir},g" \
208                           -e "s,@prefix@,%{_mingw32_prefix},g" \
209                           -e "s,@exec_prefix@,%{_mingw32_prefix},g" \
210                           -e "s,@includedir@,%{_mingw32_includedir}/nss3,g" \
211                           -e "s,@MOD_MAJOR_VERSION@,$NSS_VMAJOR,g" \
212                           -e "s,@MOD_MINOR_VERSION@,$NSS_VMINOR,g" \
213                           -e "s,@MOD_PATCH_VERSION@,$NSS_VPATCH,g" \
214                           > $RPM_BUILD_ROOT/%{_mingw32_bindir}/nss-config
215
216 chmod 755 $RPM_BUILD_ROOT/%{_mingw32_bindir}/nss-config
217
218 # Copy the binary libraries we want
219 for file in libsoftokn3.dll libfreebl3.dll libnss3.dll libnssutil3.dll \
220             libssl3.dll libsmime3.dll libnssckbi.dll libnsspem.dll libnssdbm3.dll
221 do
222   %{__install} -m 755 mozilla/dist/*.OBJ/lib/$file $RPM_BUILD_ROOT/%{_mingw32_bindir}
223 done
224
225 # These ghost files will be generated in the post step
226 # Make sure chk files can be found in both places
227 #for file in libsoftokn3.chk libfreebl3.chk
228 #do
229 #  touch $RPM_BUILD_ROOT/%{_lib}/$file
230 #  ln -s ../../%{_lib}/$file $RPM_BUILD_ROOT/%{_mingw32_libdir}/$file
231 #done
232
233 # Install the empty NSS db files
234 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/pki/nssdb
235 %{__install} -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/pki/nssdb/cert8.db
236 %{__install} -m 644 %{SOURCE4} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/pki/nssdb/key3.db
237 %{__install} -m 644 %{SOURCE5} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/pki/nssdb/secmod.db
238 %{__mkdir_p} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/prelink.conf.d
239 %{__install} -m 644 %{SOURCE8} $RPM_BUILD_ROOT/%{_mingw32_sysconfdir}/prelink.conf.d/nss-prelink.conf
240
241 # Copy the development libraries we want
242 for file in libcrmf.a libnssb.a libnssckfw.a
243 do
244   %{__install} -m 644 mozilla/dist/*.OBJ/lib/$file $RPM_BUILD_ROOT/%{_mingw32_libdir}
245 done
246
247 # Copy the binaries we want
248 for file in certutil cmsutil crlutil modutil pk12util signtool signver ssltap
249 do
250   %{__install} -m 755 mozilla/dist/*.OBJ/bin/$file $RPM_BUILD_ROOT/%{_mingw32_bindir}
251 done
252
253 # Copy the binaries we ship as unsupported
254 for file in atob btoa derdump ocspclnt pp selfserv shlibsign strsclnt symkeyutil tstclnt vfyserv vfychain
255 do
256   %{__install} -m 755 mozilla/dist/*.OBJ/bin/$file $RPM_BUILD_ROOT/%{_mingw32_libdir}/nss/unsupported-tools
257 done
258
259 # Copy the include files we want
260 for file in mozilla/dist/public/nss/*.h
261 do
262   %{__install} -m 644 $file $RPM_BUILD_ROOT/%{_mingw32_includedir}/nss3
263 done
264
265
266 %clean
267 rm -rf $RPM_BUILD_ROOT
268
269
270 %files
271 %defattr(-,root,root)
272 %{_mingw32_bindir}/nss-config
273 %{_mingw32_bindir}/certutil
274 %{_mingw32_bindir}/cmsutil
275 %{_mingw32_bindir}/crlutil
276 %{_mingw32_bindir}/modutil
277 %{_mingw32_bindir}/pk12util
278 %{_mingw32_bindir}/signtool
279 %{_mingw32_bindir}/signver
280 %{_mingw32_bindir}/ssltap
281 %{_mingw32_bindir}/libsoftokn3.dll
282 %{_mingw32_bindir}/libfreebl3.dll
283 %{_mingw32_bindir}/libnss3.dll
284 %{_mingw32_bindir}/libnssutil3.dll
285 %{_mingw32_bindir}/libssl3.dll
286 %{_mingw32_bindir}/libsmime3.dll
287 %{_mingw32_bindir}/libnssckbi.dll
288 %{_mingw32_bindir}/libnsspem.dll
289 %{_mingw32_bindir}/libnssdbm3.dll
290 %{_mingw32_sysconfdir}/pki/nssdb/cert8.db
291 %{_mingw32_sysconfdir}/pki/nssdb/key3.db
292 %{_mingw32_sysconfdir}/pki/nssdb/secmod.db
293 %{_mingw32_sysconfdir}/prelink.conf.d/nss-prelink.conf
294 %{_mingw32_includedir}/nss3/
295 %{_mingw32_libdir}/libcrmf.a
296 %{_mingw32_libdir}/libnssb.a
297 %{_mingw32_libdir}/libnssckfw.a
298 %{_mingw32_libdir}/nss/unsupported-tools/atob
299 %{_mingw32_libdir}/nss/unsupported-tools/btoa
300 %{_mingw32_libdir}/nss/unsupported-tools/derdump
301 %{_mingw32_libdir}/nss/unsupported-tools/ocspclnt
302 %{_mingw32_libdir}/nss/unsupported-tools/pp
303 %{_mingw32_libdir}/nss/unsupported-tools/selfserv
304 %{_mingw32_libdir}/nss/unsupported-tools/shlibsign
305 %{_mingw32_libdir}/nss/unsupported-tools/strsclnt
306 %{_mingw32_libdir}/nss/unsupported-tools/symkeyutil
307 %{_mingw32_libdir}/nss/unsupported-tools/tstclnt
308 %{_mingw32_libdir}/nss/unsupported-tools/vfychain
309 %{_mingw32_libdir}/nss/unsupported-tools/vfyserv
310 %{_mingw32_libdir}/pkgconfig/nss.pc
311
312
313 %changelog
314 * Tue Feb 17 2009 Richard W.M. Jones <rjones@redhat.com> - 3.12.2.0-4
315 - Now builds.
316
317 * Fri Feb  6 2009 Richard W.M. Jones <rjones@redhat.com> - 3.12.2.0-3
318 - Include license file.
319
320 * Fri Jan 30 2009 Richard W.M. Jones <rjones@redhat.com> - 3.12.2.0-2
321 - Initial RPM release.