summaryrefslogtreecommitdiff
path: root/system/mozilla-nss/mozilla-nss.SlackBuild
blob: fc9c7f7f9446e3ebe470b4b46f72e0843db56247 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
# $Id: mozilla-nss.SlackBuild,v 1.2 2009/09/27 09:56:32 root Exp root $
# Copyright (c) 2005-2009  Eric Hameleers, Eindhoven, NL
# All rights reserved.
#
#   Permission to use, copy, modify, and distribute this software for
#   any purpose with or without fee is hereby granted, provided that
#   the above copyright notice and this permission notice appear in all
#   copies.
#
#   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
#   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
#   IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
#   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
#   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
#   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#   SUCH DAMAGE.
# -----------------------------------------------------------------------------

PRGNAM=mozilla-nss
SRCNAM=nss
VERSION=${VERSION:-3.12.4}
NSPR=${NSPR:-4.8}

BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  SLKLDFLAGS="-lz"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  SLKLDFLAGS="-lz"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  SLKLDFLAGS="-L/usr/lib64 -lz"
  LIBDIRSUFFIX="64"
  export USE_64=1
fi

set -e # Exit on most errors

# Prepare:
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION-with-nspr-$NSPR.tar.gz
cd $SRCNAM-$VERSION-with-nspr-$NSPR
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

# Patch out "No rule to make target -lz.  Stop." error
patch -p1 < $CWD/signtool.zlib.diff

# Build the sources:
export LDFLAGS="$SLKLDFLAGS"
export CFLAGS="$SLKCFLAGS"
export CXXFLAGS="$SLKCFLAGS"
export BUILD_OPT=1
export NSDISTMODE="copy"
export NSS_USE_SYSTEM_SQLITE=1
cd mozilla/security/nss
  make nss_build_all export
cd -

# Manually copy stuff into the package:
mkdir -p $PKG/usr/{bin,lib${LIBDIRSUFFIX},include/{nss,nspr}}
cd mozilla/dist/$(uname -s)*
  cp -pL bin/* $PKG/usr/bin/
  cp -pL lib/* $PKG/usr/lib${LIBDIRSUFFIX}/
  cp -rpL include/* $PKG/usr/include/nspr/
  cp -rpL ../public/nss/*.h $PKG/usr/include/nss/
  rm -f $PKG/usr/bin/*.so
  rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.a
cd -

# Add smime too:
cd mozilla/security/nss/cmd/smimetools
  cp -a smime $PKG/usr/bin/
  chmod 0755 $PKG/usr/bin/smime
  sed -i -e 's#/usr/local/bin#/usr/bin#g' $PKG/usr/bin/smime
cd -

# Provide pkg-config files:
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig
cat <<EOT > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/mozilla-nss.pc
prefix=/usr
exec_prefix=\${prefix}
libdir=/usr/lib${LIBDIRSUFFIX}
includedir=\${prefix}/include/nss

Name: NSS
Description: Network Security Services
Version: $VERSION
Requires: nspr >= $NSPR sqlite3
Libs: -L\${libdir} -lnss3 -lsmime3 -lssl3 -lsoftokn3  -lnssutil3
Cflags: -I\${includedir}
EOT

cat <<EOT > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/mozilla-nspr.pc
prefix=/usr
exec_prefix=\${prefix}
libdir=/usr/lib${LIBDIRSUFFIX}
includedir=\${prefix}/include/nspr

Name: NSPR
Description: The Netscape Portable Runtime
Version: $NSPR
Libs: -L\${libdir} -lplds4 -lplc4 -lnspr4
Cflags: -I\${includedir}
EOT

( cd $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig
  ln -s mozilla-nspr.pc nspr.pc
  ln -s mozilla-nss.pc nss.pc
)

# Add documentation:
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  $CWD/MPL-1.1.txt $CWD/gpl-2.0.txt $CWD/lgpl-2.1.txt $CWD/faq.html \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION

# Strip binaries:
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

# Add a package description:
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Build the package:
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}