1 #!/usr/bin/bash
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Load support functions
  28 . ../../lib/functions.sh
  29 
  30 PROG=openssl
  31 VER=1.0.2c
  32 VERHUMAN=$VER
  33 PKG=library/security/openssl # Package name (without prefix)
  34 SUMMARY="$PROG - A toolkit for Secure Sockets Layer (SSL v2/v3) and Transport Layer (TLS v1) protocols and general purpose cryptographic library"
  35 DESC="$SUMMARY"
  36 
  37 DEPENDS_IPS="SUNWcs system/library system/library/gcc-5-runtime library/zlib@1.2.8"
  38 BUILD_DEPENDS_IPS="$DEPENDS_IPS developer/sunstudio12.1"
  39 
  40 NO_PARALLEL_MAKE=1
  41 
  42 make_prog() {
  43     [[ -n $NO_PARALLEL_MAKE ]] && MAKE_JOBS=""
  44     logmsg "--- make"
  45     # This will setup the internal runpath of libssl and libcrypto
  46     logcmd $MAKE $MAKE_JOBS SHARED_LDFLAGS="$SHARED_LDFLAGS" || \
  47         logerr "--- Make failed"
  48     logmsg "--- make test"
  49     logcmd $MAKE test || \
  50         logerr "--- make test failed"
  51 }
  52 
  53 configure32() {
  54     if [ -n "`isalist | grep sparc`" ]; then
  55       SSLPLAT=solaris-sparcv8-cc
  56     else
  57       SSLPLAT=solaris-x86-gcc
  58     fi
  59     logmsg "--- Configure (32-bit) $SSLPLAT"
  60     logcmd ./Configure $SSLPLAT --pk11-libname=/usr/lib/libpkcs11.so.1 shared threads zlib enable-md2 --prefix=$PREFIX ||
  61         logerr "Failed to run configure"
  62     SHARED_LDFLAGS="-shared -Wl,-z,text"
  63 }
  64 configure64() {
  65     if [ -n "`isalist | grep sparc`" ]; then
  66       SSLPLAT=solaris64-sparcv9-cc
  67     else
  68       SSLPLAT=solaris64-x86_64-gcc
  69     fi
  70     logmsg "--- Configure (64-bit) $SSLPLAT"
  71     logcmd ./Configure $SSLPLAT --pk11-libname=/usr/lib/64/libpkcs11.so.1 shared threads zlib enable-md2 \
  72         --prefix=$PREFIX ||
  73         logerr "Failed ot run configure"
  74     SHARED_LDFLAGS="-m64 -shared -Wl,-z,text"
  75 }
  76 
  77 make_install() {
  78     logmsg "--- make install"
  79     logcmd make INSTALL_PREFIX=$DESTDIR install ||
  80         logerr "Failed to make install"
  81 }
  82 
  83 # Move installed libs from /usr/lib to /lib and make symlinks to match upstream package
  84 move_libs() {
  85     logmsg "link up certs"
  86     logcmd rmdir $DESTDIR/usr/ssl/certs ||
  87         logerr "Failed to remove /usr/ssl/certs"
  88     logcmd ln -s /etc/ssl/certs $DESTDIR/usr/ssl/certs ||
  89         logerr "Failed to link up /usr/ssl/certs -> /etc/ssl/certs"
  90     logmsg "Relocating libs from usr/lib to lib"
  91     logcmd mv $DESTDIR/usr/lib/64 $DESTDIR/usr/lib/amd64
  92     logcmd mkdir -p $DESTDIR/lib/amd64
  93     logcmd mv $DESTDIR/usr/lib/lib* $DESTDIR/lib/ ||
  94         logerr "Failed to move libs (32-bit)"
  95     logcmd mv $DESTDIR/usr/lib/amd64/lib* $DESTDIR/lib/amd64/ ||
  96         logerr "Failed to move libs (64-bit)"
  97     logmsg "--- Making usr/lib symlinks"
  98     pushd $DESTDIR/usr/lib > /dev/null
  99     logcmd ln -s /lib/libssl.so.1.0.0 libssl.so
 100     logcmd ln -s /lib/libssl.so.1.0.0 libssl.so.1.0.0
 101     logcmd ln -s /lib/libcrypto.so.1.0.0 libcrypto.so
 102     logcmd ln -s /lib/libcrypto.so.1.0.0 libcrypto.so.1.0.0
 103     popd > /dev/null
 104     pushd $DESTDIR/usr/lib/amd64 > /dev/null
 105     logcmd ln -s /lib/amd64/libssl.so.1.0.0 libssl.so
 106     logcmd ln -s /lib/amd64/libssl.so.1.0.0 libssl.so.1.0.0
 107     logcmd ln -s /lib/amd64/libcrypto.so.1.0.0 libcrypto.so
 108     logcmd ln -s /lib/amd64/libcrypto.so.1.0.0 libcrypto.so.1.0.0
 109     popd > /dev/null
 110 }
 111 
 112 
 113 # Turn the letter component of the version into a number for IPS versioning
 114 ord26() {
 115     local ASCII=$(printf '%d' "'$1")
 116     ASCII=$((ASCII - 64))
 117     [[ $ASCII -gt 32 ]] && ASCII=$((ASCII - 32))
 118     echo $ASCII
 119 }
 120 save_function make_package make_package_orig
 121 make_package() {
 122     if [[ -n "`echo $VER | grep [a-z]`" ]]; then
 123         NUMVER=${VER::$((${#VER} -1))}
 124         ALPHAVER=${VER:$((${#VER} -1))}
 125         VER=${NUMVER}.$(ord26 ${ALPHAVER})
 126     fi
 127 
 128     make_package_orig
 129 }
 130 
 131 init
 132 download_source $PROG $PROG $VER
 133 patch_source
 134 prep_build
 135 build
 136 move_libs
 137 make_lintlibs crypto /lib /usr/include "openssl/!(ssl*|*tls*).h"
 138 make_lintlibs ssl /lib /usr/include "openssl/{ssl,*tls}*.h"
 139 make_isa_stub
 140 make_package
 141 clean_up