[关闭]
@torresdyl 2016-11-17T13:03:08.000000Z 字数 4242 阅读 4041

[NSS/NSPR] How to build NSS 3.27 with NSPR

未分类


(In some environments we have NSS+NSPR installed, such as in my RedHat 7.2, I have:

  1. Installed Packages
  2. nss.x86_64 3.21.0-17.el7 @rhel-7-server-rpms

and:

  1. Installed Packages
  2. nspr.x86_64 4.11.0-1.el7_2 @rhel-7-server-eus-rpms

so we can see that NSS 3.21 + NSPR 4.11 is stable. At least I think so.)

You can check with sudo yum list nss*, and to get more info about every nss-related package, use sudo yum info nss*. NSPR is alike, sudo yum list nspr*.

If you want to upgrade them, use sudo yum upgrade nss*, or check-update. If they are not working, just sudo yum install nss*, sudo yum install nspr*.

0. Download NSS+NSPR source tarballs:

From the main page of NSS, we can enter the Release link to find all versions:

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases

Here we choose NSS 3.27, and the link indicates that NSS 3.27 is working with NSPR 4.13:

https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_27_RTM/src/

So we download them all.

1. Unzip and build

To unzip a .tar.gz file, we use:

  1. tar -xvzf your_zipped_file

If is a .tar file, use:

  1. tar -xvf your_compressed_file

About how to use tar and what these arguments mean, there's a good answer in AskUbuntu:
http://askubuntu.com/questions/25347/what-command-do-i-need-to-unzip-extract-a-tar-gz-file

Type man tar for more information, but this command should do the trick:

  1. tar -xvzf community_images.tar.gz

To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:

  • f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.
  • z: tells tar to decompress the archive using gzip
  • x: tar can collect files or extract them. x does the latter.
  • v: makes tar talk a lot. Verbose output shows you all the files being extracted.

Now, you see two directories, nss and nspr. Enter nss, and with instructions of NSS building in Mozilla.org,

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Sources_Building_Testing

you must build with these command:

  1. gmake nss_build_all

If gmake is not available, try to install build-essential or gcc with g++. If still missing, make can do it.

2. Arguments and errors

As per the previous building instruction, there're two arguments that deserve our attention:

In order to start the build process, use "cd nss" and execute "make nss_build_all". By default this will produce a build in debug mode and for a 32-bit architecture. You may set the environment variable BUILD_OPT=1 to get an optimized build, and/or variable USE_64=1 to get a 64-bit build.

If you have seen this error:

  1. ssl3con.c:36:18: fatal error: zlib.h: No such file or directory
  2. #include "zlib.h"
  3. ^
  4. compilation terminated.

You must add this argument: NSS_SSL_ENABLE_ZLIB=

If you encounter this error:

  1. /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h:No such file or directory

Be sure to add USE_64=1 and try to install glibc-devel.

If you still see a similar but different error, like this:

  1. gcc -o Linux3.10_x86_64_cc_glibc_PTH_64_OPT.OBJ/zip.o -c -O2 -fPIC -DLINUX2_1 -m64 -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR -Wall -Werror -DXP_UNIX -UDEBUG -DNDEBUG -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -I../../../dist/Linux3.10_x86_64_cc_glibc_PTH_64_OPT.OBJ/include -I../../../dist/public/nss -I../../../dist/private/nss -I../../../dist/public/seccmd zip.c
  2. zip.c:7:18: fatal error: zlib.h: No such file or directory
  3. #include "zlib.h"
  4. ^
  5. compilation terminated.

You can solve it like this:
- If you are using Ubuntu x32, try to install zlib1g-dev.
- If you are using Redhat x64, try to install zlib-devel.

And build with all the arguments necessary.

2. Installation

After successful building, you can see no errors are promptted, and you can see a dist directory on the same level of nss and nspr. Like this:

  1. |
  2. - dist
  3. - nss
  4. - nspr

The installation guide of Mozilla is simple but not so clear:

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Reference/Building_and_installing_NSS/Installation_guide

Searching with "install nss" will lead you to this site, where we find more information:

http://www.linuxfromscratch.org/blfs/view/svn/postlfs/nss.html

Note the title of this site is "NSS-3.27.1", meaning that it's updated till now (nov. 2016).

If you have NSS and NSPR installed previously, you may have to check where are they preinstalled. Like in my case, run a locate libnss3.so gives me that it's in /usr/lib64. So try not to cause conflict.

It's always good to check where each and every file are installed. To check them in RPM-based environment, use

  1. rpm -ql some_package

And in dpkg-based system, use

  1. dpkg -L package_name

to list all files owned by this package.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注