[ac00c8f] | 1 | #!/bin/bash |
---|
[c5c522c] | 2 | # Copyright 2005, 2006, 2008, 2009, 2010, 2012 Eric Hameleers, Eindhoven, NL |
---|
[e856512] | 3 | # Copyright 2013, 2014, 2015, 2017, 2018, 2019 Patrick J. Volkerding, Sebeka, MN, USA |
---|
[c5c522c] | 4 | # All rights reserved. |
---|
| 5 | # |
---|
| 6 | # Permission to use, copy, modify, and distribute this software for |
---|
| 7 | # any purpose with or without fee is hereby granted, provided that |
---|
| 8 | # the above copyright notice and this permission notice appear in all |
---|
| 9 | # copies. |
---|
| 10 | # |
---|
| 11 | # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
---|
| 12 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
| 13 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
| 14 | # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
---|
| 15 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
| 17 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
---|
| 18 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
| 19 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
---|
| 20 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
---|
| 21 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
| 22 | # SUCH DAMAGE. |
---|
| 23 | # ----------------------------------------------------------------------------- |
---|
| 24 | |
---|
[ac00c8f] | 25 | cd $(dirname $0) ; CWD=$(pwd) |
---|
| 26 | |
---|
[c5c522c] | 27 | PKGNAM=mozilla-nss |
---|
| 28 | SRCNAM=nss |
---|
[e856512] | 29 | VERSION=${VERSION:-3.50} |
---|
| 30 | NSPR=${NSPR:-4.25} |
---|
[c5c522c] | 31 | BUILD=${BUILD:-1} |
---|
| 32 | |
---|
| 33 | # Automatically determine the architecture we're building on: |
---|
| 34 | MARCH=$( uname -m ) |
---|
| 35 | if [ -z "$ARCH" ]; then |
---|
| 36 | case "$MARCH" in |
---|
| 37 | i?86) export ARCH=i586 ;; |
---|
| 38 | armv7hl) export ARCH=$MARCH ;; |
---|
| 39 | arm*) export ARCH=arm ;; |
---|
| 40 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 41 | *) export ARCH=$MARCH ;; |
---|
| 42 | esac |
---|
| 43 | fi |
---|
| 44 | |
---|
[ac00c8f] | 45 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
| 46 | # the name of the created package would be, and then exit. This information |
---|
| 47 | # could be useful to other scripts. |
---|
| 48 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
| 49 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
| 50 | exit 0 |
---|
| 51 | fi |
---|
| 52 | |
---|
[c5c522c] | 53 | if [ "$ARCH" = "i586" ]; then |
---|
| 54 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
| 55 | LIBDIRSUFFIX="" |
---|
| 56 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 57 | SLKCFLAGS="-O2 -fPIC" |
---|
| 58 | LIBDIRSUFFIX="64" |
---|
| 59 | export USE_64=1 |
---|
| 60 | elif [ "$ARCH" = "armv7hl" ]; then |
---|
| 61 | SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16" |
---|
| 62 | LIBDIRSUFFIX="" |
---|
| 63 | else |
---|
| 64 | SLKCFLAGS="-O2" |
---|
| 65 | LIBDIRSUFFIX="" |
---|
| 66 | fi |
---|
| 67 | |
---|
| 68 | TMP=${TMP:-/tmp} |
---|
| 69 | PKG=$TMP/package-$PKGNAM |
---|
| 70 | |
---|
| 71 | # Seems parallel build does not work with this. |
---|
[ac00c8f] | 72 | #NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
[c5c522c] | 73 | |
---|
| 74 | rm -rf $PKG |
---|
| 75 | mkdir -p $TMP $PKG |
---|
| 76 | |
---|
| 77 | cd $TMP |
---|
| 78 | rm -rf nss-${VERSION} |
---|
| 79 | rm -rf nspr-${NSPR} |
---|
[ac00c8f] | 80 | tar xvf $CWD/nss-$VERSION.tar.?z || exit 1 |
---|
[c5c522c] | 81 | cd nss-$VERSION |
---|
[ac00c8f] | 82 | tar xvf $CWD/nspr-$NSPR.tar.?z || exit 1 |
---|
[c5c522c] | 83 | mv nspr*/nspr . |
---|
| 84 | |
---|
[ac00c8f] | 85 | # -Werror is problematic with gcc7: |
---|
| 86 | sed -i "s|\ -Werror| |" nss/coreconf/Werror.mk || exit 1 |
---|
| 87 | |
---|
[c5c522c] | 88 | # Make sure ownerships and permissions are sane: |
---|
| 89 | chown -R root:root . |
---|
| 90 | find . \ |
---|
| 91 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
[e856512] | 92 | -exec chmod 755 {} \+ -o \ |
---|
[c5c522c] | 93 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
[e856512] | 94 | -exec chmod 644 {} \+ |
---|
[c5c522c] | 95 | |
---|
| 96 | echo Building ... |
---|
| 97 | export LDFLAGS="-lz" |
---|
| 98 | export CFLAGS="$SLKCFLAGS" |
---|
| 99 | export CXXFLAGS="$SLKCFLAGS" |
---|
| 100 | export BUILD_OPT=1 |
---|
| 101 | export NSDISTMODE="copy" |
---|
| 102 | export NSS_USE_SYSTEM_SQLITE=1 |
---|
| 103 | export NSS_ENABLE_ECC=1 |
---|
| 104 | cd nss |
---|
| 105 | # Seems parallel build does not work with this. |
---|
[ac00c8f] | 106 | #make $NUMJOBS nss_build_all export || exit 1 |
---|
| 107 | make nss_build_all export || exit 1 |
---|
[c5c522c] | 108 | cd - |
---|
| 109 | |
---|
| 110 | # Install all the needed stuff to the package dir: |
---|
| 111 | mkdir -p $PKG/usr/{bin,lib${LIBDIRSUFFIX},include/{nss,nspr}} |
---|
| 112 | cd dist/$(uname -s)* |
---|
| 113 | cp -pL bin/{certutil,cmsutil,crlutil,modutil,pk12util,shlibsign,signtool,signver,ssltap} $PKG/usr/bin/ |
---|
| 114 | cp -pL lib/* $PKG/usr/lib${LIBDIRSUFFIX}/ |
---|
| 115 | chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/*.so* |
---|
| 116 | cp -rL include/* $PKG/usr/include/nspr/ |
---|
| 117 | cp -rpL ../public/nss/*.h $PKG/usr/include/nss/ |
---|
| 118 | # Remove some things we do not need: |
---|
| 119 | rm -f $PKG/usr/bin/*.so |
---|
| 120 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.a |
---|
| 121 | rm -rf $PKG/usr/include/nspr/md |
---|
| 122 | cp -L lib/libcrmf.a $PKG/usr/lib${LIBDIRSUFFIX}/ # yes, put this one back |
---|
| 123 | cd - |
---|
| 124 | |
---|
| 125 | cd nss/cmd/smimetools |
---|
| 126 | cp -a smime $PKG/usr/bin/ |
---|
| 127 | chmod 0755 $PKG/usr/bin/smime |
---|
| 128 | sed -i -e 's#/usr/local/bin#/usr/bin#g' $PKG/usr/bin/smime |
---|
| 129 | cd - |
---|
| 130 | |
---|
| 131 | # Install nspr-config: |
---|
| 132 | cat nspr/$(uname -s)*/config/nspr-config | sed -e "s,prefix=/usr/local,prefix=/usr,g" | sed -e "s,libdir=\${exec_prefix}/lib,libdir=\${exec_prefix}/lib${LIBDIRSUFFIX},g" > $PKG/usr/bin/nspr-config |
---|
| 133 | chmod 755 $PKG/usr/bin/nspr-config |
---|
| 134 | |
---|
| 135 | # Install nss-config: |
---|
[e856512] | 136 | #sed -e "s,@prefix@,/usr,g" \ |
---|
| 137 | # -e "s,@MOD_MAJOR_VERSION@,$(printf $VERSION | cut -d. -f1),g" \ |
---|
| 138 | # -e "s,@MOD_MINOR_VERSION@,$(printf $VERSION | cut -d. -f2),g" \ |
---|
| 139 | # -e "s,@MOD_PATCH_VERSION@,$(printf $VERSION | cut -d. -f3),g" \ |
---|
| 140 | # $CWD/nss-config.in > $PKG/usr/bin/nss-config |
---|
| 141 | #chmod 755 $PKG/usr/bin/nss-config |
---|
[c5c522c] | 142 | |
---|
| 143 | # Provide pkg-config files: |
---|
| 144 | mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig |
---|
| 145 | cat <<EOT > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/mozilla-nss.pc |
---|
| 146 | prefix=/usr |
---|
| 147 | exec_prefix=\${prefix} |
---|
| 148 | libdir=/usr/lib${LIBDIRSUFFIX} |
---|
| 149 | includedir=\${prefix}/include/nss |
---|
| 150 | |
---|
| 151 | Name: NSS |
---|
| 152 | Description: Network Security Services |
---|
| 153 | Version: $VERSION |
---|
| 154 | Requires: nspr >= $NSPR sqlite3 |
---|
| 155 | Libs: -L\${libdir} -lnss3 -lsmime3 -lssl3 -lsoftokn3 -lnssutil3 |
---|
| 156 | Cflags: -I\${includedir} |
---|
| 157 | EOT |
---|
| 158 | cat <<EOT > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/mozilla-nspr.pc |
---|
| 159 | prefix=/usr |
---|
| 160 | exec_prefix=\${prefix} |
---|
| 161 | libdir=/usr/lib${LIBDIRSUFFIX} |
---|
| 162 | includedir=\${prefix}/include/nspr |
---|
| 163 | |
---|
| 164 | Name: NSPR |
---|
| 165 | Description: The Netscape Portable Runtime |
---|
| 166 | Version: $NSPR |
---|
| 167 | Libs: -L\${libdir} -lplds4 -lplc4 -lnspr4 |
---|
| 168 | Cflags: -I\${includedir} |
---|
| 169 | EOT |
---|
| 170 | |
---|
| 171 | ( cd $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig |
---|
| 172 | ln -s mozilla-nspr.pc nspr.pc |
---|
| 173 | ln -s mozilla-nss.pc nss.pc |
---|
| 174 | ) |
---|
| 175 | |
---|
| 176 | # Add documentation: |
---|
[e856512] | 177 | #mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
| 178 | #cp -a \ |
---|
| 179 | # $CWD/MPL-1.1.txt $CWD/gpl-2.0.txt $CWD/lgpl-2.1.txt \ |
---|
| 180 | # $CWD/faq.html \ |
---|
| 181 | # $PKG/usr/doc/$PKGNAM-$VERSION |
---|
| 182 | #chown -R root:root $PKG/usr/doc/$PKGNAM-$VERSION |
---|
[c5c522c] | 183 | |
---|
| 184 | # Strip binaries: |
---|
| 185 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
| 186 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 187 | |
---|
| 188 | # Add a package description: |
---|
| 189 | mkdir -p $PKG/install |
---|
| 190 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 191 | |
---|
| 192 | # Build the package: |
---|
| 193 | cd $PKG |
---|
| 194 | /sbin/makepkg -l y -c n $TMP/${PKGNAM}-${VERSION}-${ARCH}-${BUILD}.txz |
---|
| 195 | |
---|